// JavaScript Document
function add_to_basket(it,cu){
	url = "/ajax/add_to_basket.php?item=" + it + "&custom=" + cu;
	siylc_ajax(url,"basket",'<p class="double">Adding to basket...</p>');
}
function update_basket(it,cust,qty){
	url = "/ajax/update_basket.php?item=" + it + "&custom=" + cust + "&qty=" + qty;
	siylc_ajax(url,"viewbasket",'<table><tr><td class="title">Updating, Please Wait...</td></tr></table>');
	return false;
}
function update_country(country){
	url = "/ajax/update_country.php?country=" + country;
	siylc_ajax(url,"viewbasket",'<table><tr><td class="title">Updating, Please Wait...</td></tr></table>');
	return false;
}
function update_pnp(pnp){
	url = "/ajax/update_pnp.php?pnp=" + pnp;
	siylc_ajax(url,"viewbasket",'<table><tr><td class="title">Updating, Please Wait...</td></tr></table>');
	return false;
}
function update_voucher(id,text){
	url = "/ajax/update_voucher.php?id=" + id + "&text=" + encodeURIComponent(text);
	siylc_ajax(url,"viewbasket",'<table><tr><td class="title">Updating, Please Wait...</td></tr></table>');
	return false;
}
function qsearch(q){
	url = "/ajax/qsearch.php?q=" + q;
	siylc_ajax(url,"history");	
}
function suggest(q){
	url = "/ajax/suggest.php?q=" + q;
	siylc_ajax(url,"homesuggest");	
}

function editor(page,type){
	url = "/ajax/editor.php?page=" + page + "&type=" + type + "&id=" + custom_id;
	siylc_ajax(url,"editor",'<ul><li><a href="#"><span class="no">Loading...</span></a></li></ul><h2>Loading, Please Wait...</h2>');
	window.scroll(0,150); 
}

function editor_select_save(what,newvalue,side){
	if(what=="font"){
		myimg = "/img/editor/font.php?font=" + newvalue;
	}else{
		myimg = "/img/editor/" + what + "/" + newvalue;
	}	
	document.getElementById("img_" + what).src = myimg;
	document.getElementById("selector").style.display = "none";
	document.getElementById("selector").innerHTML = "Loading...";
	
	editor_update(what,newvalue,side);
}
function editor_select(what, side){
	if(document.getElementById("selector").style.display=="block"){
		document.getElementById("selector").style.display = "none";
	}else{
		url = "/ajax/selector.php?page=" + what + "&id=" + custom_id + "&side=" + side;
		siylc_ajax(url,"selector","<h3>Loading, Please Wait...</h3>");
	}
}

function editor_update(what,newvalue,side){
	url = "/ajax/editor_update.php?id=" + custom_id + "&what=" + what + "&value=" + encodeURIComponent(newvalue) + "&side=" + side;
	siylc_ajax(url,"preview");
}

function editor_selectdefault(){
	if(document.getElementById("text").value=="Type your text here..."){
		document.getElementById("text").value = "";
	}	
}

function editor_upload(){
	document.eform.submit()
	document.getElementById("preview").innerHTML = '<img src="/img/loadingblade.jpg" width="430" height="103" />';
}

function show_popup(page){
	document.getElementById("basket").style.display = "none";
	document.getElementById("popup").style.display = "block";
	siylc_ajax("/ajax/photo.php?src=" + page,"popup","<h3>Loading, Please Wait...</h3>");
	return false;
}

function show_popupnew(page){
	document.getElementById("basket").style.display = "none";
	document.getElementById("popup").style.display = "block";
	siylc_ajax("/ajax/photo.php?src=" + page,"popup","<h3>Loading, Please Wait...</h3>");
	return false;
}

function show_preview(page){
	document.getElementById("basket").style.display = "none";
	document.getElementById("popup").style.display = "block";
	siylc_ajax("/ajax/bigblade.php?id=" + page,"popup","<h3>Loading, Please Wait...</h3>");
	return false;
}

function hide_popup(){
	document.getElementById("popup").style.display = "none";
	if(document.getElementById("basket").innerHTML!=""){
		document.getElementById("basket").style.display = "block";
	}
}
function show_gallery(urlid){
	var url = photos[urlid];
	if(urlid<photos.length){
		if(urlid<0){
			hide_popup();
		}else{
			document.getElementById("basket").style.display = "none";
			document.getElementById("popup").style.display = "block";
			siylc_ajax("/ajax/gallery.php?src=" + url + "&id=" + urlid,"popup","<h3>Loading, Please Wait...</h3>");
			
		}
	}else{
		hide_popup();
	}	
	return false;
}
