/*
	help.js
*/

//Insert Product To Bin
function addBinItem(product_id, option_id, attribute_id, product_model, reload) {
	$('process').show();
	var url = 'index.php?pid='+product_id+'{'+option_id+'}'+attribute_id+'&action=addBinItem';
	new Ajax.Request(url, {
		method: 'get',

		onSuccess: function(transport) {

			if (200 == transport.status)
				{
					$('process').hide();
					alert('Folgender Artikel: '+product_model+' wurde auf den Merzettel geschrieben');
					if (reload == 'opener') {
						opener.location.reload();
						opener.focus();
					}
					else {
						location.reload();
					}
				}
			else  { alert(transport.status); }

		}
	});
}

//Delete Product From Bin
function removeBinItem(product_id, option_id, attribute_id, product_model) {
	var url = 'index.php?pid='+product_id+'{'+option_id+'}'+attribute_id+'&action=removeBinItem';
	new Ajax.Request(url, {
		method: 'get',

		onSuccess: function(transport) {

			if (200 == transport.status) { alert('Der Artikel: '+product_model+' wurde vom Merzettel gel\u00f6scht'); location.reload();}
			else  { alert(transport.status); }

		}
	});
}

//Insert Product To Basket
function addBasketItem(url, model, reload) {
	$('process').show();
	new Ajax.Request(url, {
		method: 'post',
		 parameters:Form.serialize('cart_quantity'),

		onSuccess: function(transport) {
			$('process').hide();
			if (200 == transport.status)
				{
					alert('Folgender Artikel: '+model+' wurde in den Warenkorb gelegt');
					if (reload == 'opener') {
						opener.location.reload();
						opener.focus();
					}
					else {
						location.reload();
					}
				}
			else  { alert(transport.status); }

		}
	});
return false;
}

//Insert Product To Basket From Bin
function binAddBinItem(url, model, reload, id) {
	new Ajax.Request(url, {
		method: 'post',
		 parameters:Form.serialize('cart_quantity_'+id),

		onSuccess: function(transport) {

			if (200 == transport.status)
				{
					alert('Folgender Artikel: '+model+' wurde in den Warenkorb gelegt');
					if (reload == 'opener') {
						opener.location.reload();
					}
					else {
						location.reload();
					}
					opener.focus();
				}
			else  { alert(transport.status); }

		}
	});
return false;
}

//Checked Function from Collectione and Clip
function checkedRadio(attribute, value) {
	document.getElementById("r"+attribute+value).checked = true;
}

//Checked Function from Bin
function checkedRadioBin(product_id, attribute, value) {
	document.getElementById("r"+product_id+attribute+value).checked = true;
}

//Show Click Pictures
function show_click_picture(picture_name, collection_cat, collection_name) {
	var PictureName = new Image();
	//PictureName.src = "/shop/"+x_template+"buttons/"+x_lang+"/klick.jpg";
	PictureName.src = "/shop/images/product_images/thumbnail_images/"+collection_cat+"/"+collection_name+"/prev/"+picture_name+"_HL.jpg";
	//eval("document['"+picture_name+"'].src = '" + PictureName.src+"'");
	document[picture_name].src = PictureName.src;

}

//Show Listin Click Pictures
/*function show_listing_click_picture(picture_name, collection_cat, collection_name) {
	var PictureName = new Image();
	PictureName.src = "/shop/images/product_images/thumbnail_images/"+collection_cat+"/"+collection_name+"/prev/"+picture_name+"_HL.jpg";
	eval("document['"+picture_name+"'].src = '" + PictureName.src+"'");
}*/

//Show Animatet Pictures
function show_animate_picture(picture_name, collection_cat, collection_name, picture_type) {
	var PictureName = new Image();
	if (picture_type == '1') { PictureName.src = "/shop/images/product_images/thumbnail_images/"+picture_name+".gif"; }
	else { PictureName.src = "/shop/images/product_images/thumbnail_images/"+collection_cat+"/"+collection_name+"/prev/"+picture_name+".jpg"; }
	//eval("document['"+picture_name+"'].src = '" + PictureName.src+"'");
	document[picture_name].src = PictureName.src;

}

//Show Listing Click Pictures
function show_listing_click_picture(picture_name, picture_path) {
	var PictureName = new Image();
	PictureName.src = picture_path+"_HL.jpg";
	//alert(picture_name +' '+picture_path);
	//eval("document['"+picture_name+"'].src = '" + PictureName.src+"'");
	document[picture_name].src = PictureName.src;
}

//Show Listing Animatet Pictures
function show_listing_animate_picture(picture_name, picture_path) {
	var PictureName = new Image();
	PictureName.src = picture_path+".jpg";
	//alert(picture_name +' '+picture_path);
	//eval("document['"+picture_name+"'].src = '" + PictureName.src+"'");
	document[picture_name].src = PictureName.src;
}

//Show Product in Pop-Up
function showProduct(cPath, pid) {
	var newWindow = window.open(cPath+"&show=get_", pid, "width=620,height=840,left=50,top=50,scrollbars=yes,resizable=no");
}

//Show Trailer in Pop-Up cPath, pid
function showTrailer(cPath, pid) {
	//alert(cPath+' '+pid);
	var newWindow = window.open(cPath, pid, "width=800,height=505,toolbar=0,scrollbars=yes,resizable=no");
}

//Show Release
function showReleases(movie_name) {
	var newWindow = window.open("releases_movies.php?mov="+movie_name, "ReleasesWindow", "width=416,height=315,toolbar=0,scrollbars=no,resizable=no");
}

//Load Page in Opener
function loadPageToOpener(cPath) {
	opener.location.href = cPath;
	//opener.focus();
}

// Messag Info
function showMsg(msgid, lng) {
	if (lng == 'german') {
		switch (msgid) {
			case "1" :
				msg = 'Sie muessen sich erst anmelden.\n';
				break;
			default :
				msg = 'Guten Tag';
				break;
		}

	}

	if (lng == 'english') {
		msg = 'englisch';
	}
	alert(msg);
	//window.close();
	//opener.focus();
}

// Naviagtions Steuerung
function showSubCat(id) {
	var linkCat = $$('li.subCat');
	for(var i = 0; i < linkCat.length; i++) {
		if(linkCat[i].id == id) {
			if ($(linkCat[i]).getStyle('display') == 'block') {
				$(linkCat[i]).setStyle({display: 'none'});
			} else {
				$(linkCat[i]).setStyle({display: 'block'});
			}
		} else {
			$(linkCat[i]).setStyle({display: 'none'});
		}
	}
}

//Write Movie
function writeMovie(trailerpath,videoname) {
	detectBrowser();
	if(windowsInternetExplorer) {
		document.write('<object id="QTMov" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="480" height="288"><param name="src" value="http://www.zaxfoot.com/shop/'+trailerpath+'/'+videoname+'" /><param name="controller" value="true" /><param name="autoplay" value="false" /><param name="scale" value="tofit" /><param name="volume" value="50" /><param name="loop" value="false" /></object>');
	}
	else if(isiPhone){
		document.write('<object id="QTMov" type="video/quicktime"><param name="src" value="http://www.zaxfoot.com/shop/'+trailerpath+'/ZaxfootSoon.jpg" width="480" height="270"><param name="target" value="myself" /><param name="href" value="http://www.zaxfoot.com/shop/'+trailerpath+'/'+videoname+'" /><param name="controller" value="true" /><param name="scale" value="tofit" /></object>');
	}
	else {
		document.write('<object id="QTMov" type="video/quicktime" data="http://www.zaxfoot.com/shop/'+trailerpath+'/'+videoname+'" width="480" height="288"><param name="src" value="http://www.zaxfoot.com/shop/'+trailerpath+'/'+videoname+'" /><param name="controller" value="true" /><param name="autoplay" value="false" /><param name="scale" value="tofit" /><param name="volume" value="50" /><param name="loop" value="false" /></object>');
	}
}