function pokeServerForInvitations() {
	send("!!!-asking","mir_invitations.php");
	setTimeout("pokeServerForInvitations()",3000);
	}
function showInvitation(ftext) {
	document.getElementById("textforinvitation").innerHTML = ftext;
	moveItAcross();
	}
function moveItAcross() {
	if (removePX(document.getElementById("myinvite").style.left)<200)
		{
		newValue = removePX(document.getElementById("myinvite").style.left) - 0 + 10;
		document.getElementById("myinvite").style.left = newValue + "px";
		document.getElementById("myinvite").style.top = newValue + "px";
		}
	if (removePX(document.getElementById("myinvite").style.left)<200)
		setTimeout("moveItAcross()",50);
	}
function closeInvitation() {
	document.getElementById("myinvite").style.left = "-180px";
	document.getElementById("myinvite").style.top = "-180px";
	}
function acceptInvitation() {
	closeInvitation();
	loadlivehelp()
	}
function valideSubmitSite() {
	if (globalform.siteTitle.value=="")
		{
		flickerwarning('a','#FF0000','Please fill-in the \"Title of your web site\" field!');
		return ("non");
		}
	if (globalform.siteUrl.value=="")
		{
		flickerwarning('a','#FF0000','Please fill-in the \"URL of your web site\" field!');
		return ("non");
		}
	if (globalform.siteCategory.selectedIndex==0)
		{
		flickerwarning('a','#FF0000','Please select the \"Category you wish to appear in\"');
		return ("non");
		}
	if (globalform.siteDescription.value=="")
		{
		flickerwarning('a','#FF0000','Please provide a brief paragraph describing your website!');
		return ("non");
		}
	if (globalform.siteContactName.value=="")
		{
		flickerwarning('a','#FF0000','Please fill-in the \"Contact name\" field!');
		return ("non");
		}
	if ((globalform.siteContactEmail.value=="")||(globalform.siteContactEmail.value.indexOf("@")<1))
		{
		flickerwarning('a','#FF0000','The E-mail address is not valid!');
		return ("non");
		}
	if (globalform.siteCosyposyUrl.value=="")
		{
		flickerwarning('a','#FF0000','Please fill-in the \"URL where the link to cosyposy is visible\" field!');
		return ("non");
		}	
	return("ok");
	}
function valideNewcheckout(xcartvalue) {
	if (globalform.modify_firstname.value=="")
		{
		flickerwarning('a','#FF0000','Please fill-in the \"First Name\" field!');
		return ("non");
		}
	if (globalform.modify_name.value=="")
		{
		flickerwarning('a','#FF0000','Please fill-in the \"Last Name\" field!');
		return ("non");
		}
	if (globalform.modify_addr1.value=="")
		{
		flickerwarning('a','#FF0000','Please fill-in the \"Address\" field!');
		return ("non");
		}
	if (globalform.modify_addr3.value=="")
		{
		flickerwarning('a','#FF0000','Please fill-in the \"Town/City\" field!');
		return ("non");
		}
	if (globalform.modify_addrzip.value=="")
		{
		flickerwarning('a','#FF0000','Please fill-in the \"Post/zip code\" field!');
		return ("non");
		}
	if(nonUK(globalform.modify_country.value))
		{
		if (globalform.deliveryoptions[0].checked==false)
			{
			flickerwarning('a','#FF0000','The Delivery option should be \"International Signed\".');
			return ("non");
			}
		else
			return ("ok");
		}
	else
		{
		if (globalform.deliveryoptions[0].checked==true)
			{
			flickerwarning('a','#FF0000','You should not select \"International signed\" for shipping in the UK.');
			return ("non");
			}
		return ("ok");
		}
	}
function valideNewcheckout2() {
	if ((globalform.modify_email.value=="")||(globalform.modify_email.value.indexOf("@")<1))
		{
		flickerwarning('a','#FF0000','The E-mail address is not valid.');
		return ("non");
		}
	else
		{
		if (globalform.modify_phone.value=="")
			{
			flickerwarning('a','#FF0000','Please enter a phone number.');
			return ("non");
			}
		else
			return ("ok");
		}
	}
function valideNewcheckout3() {
	if (globalform.sameforbilling[0].checked)
		return ("ok");
	else
		{
		if (globalform.billing_modify_firstname.value=="")
			{
			flickerwarning('a','#FF0000','Please fill-in the \"First Name\" field!');
			return ("non");
			}
		if (globalform.billing_modify_name.value=="")
			{
			flickerwarning('a','#FF0000','Please fill-in the \"Last Name\" field!');
			return ("non");
			}
		if (globalform.billing_modify_addr1.value=="")
			{
			flickerwarning('a','#FF0000','Please fill-in the \"Address\" field!');
			return ("non");
			}
		if (globalform.billing_modify_addr3.value=="")
			{
			flickerwarning('a','#FF0000','Please fill-in the \"Town/City\" field!');
			return ("non");
			}
		if (globalform.billing_modify_addrzip.value=="")
			{
			flickerwarning('a','#FF0000','Please fill-in the \"Post/zip code\" field!');
			return ("non");
			}
		else
			return ("ok");
		}
	}
function valideNewcheckout4() {
	if (globalform.ccn1.value=="")
			{
			flickerwarning('a','#FF0000','Please double-check the Card number');
			return ("non");
			}
	if ((globalform.ccexpy.value=="")||(globalform.ccexpy.value=="yyyy")||(globalform.ccexpm.value=="")||(globalform.ccexpm.value=="mm"))
			{
			flickerwarning('a','#FF0000','Please double-check the Expiration date');
			return ("non");
			}
	if (((globalform.ccexpyissue.value=="yyyy")||(globalform.ccexpmissue.value=="mm"))&&(globalform.xxn1.value==""))
			{
			flickerwarning('a','#FF0000','Please double-check the card security number');
			return ("non");
			}
	document.getElementById('shopbutton').style.visibility='hidden';
	flickerwarning('c','#5885C0','Please wait...');
	return ("ok");
	}
function xgotonewcheckout2(xcurIndex) {
	globalform.action = "newcheckout2.php?viewcurrency=" + xcurIndex;
	globalform.submit();
	}
function xgotonewcheckout3(xcurIndex) {
	globalform.action = "newcheckout3.php?viewcurrency=" + xcurIndex;
	globalform.submit();
	}
function xgotonewcheckout4(xcurIndex) {
	globalform.action = "newcheckout4.php?viewcurrency=" + xcurIndex;
	globalform.submit();
	}
function xgotonewcheckout5(xcurIndex) {
	globalform.action = "newcheckout5.php?viewcurrency=" + xcurIndex;
	globalform.submit();
	}
function loadlivehelp() {
	window.open('livehelp.php','mywindow3','width=544,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
	}
function loadcomments() {
	window.open('comments.php','mywindow2','width=544,height=800,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
	}
function xgoto(forsecurelink,forsearchedtype,fordisplaycategory,forrunfilter,forcodetoshow,forshopbysize,foraddcatfilter,targetto,linktogo) {
	document.getElementById('iddisplaycategory').value=fordisplaycategory;
	document.getElementById('idrunfilter').value=forrunfilter;
	document.getElementById('idcodetoshow').value=forcodetoshow;
	document.getElementById('idshopbysize').value=forshopbysize;
	document.getElementById("idaddcatfilter").value=foraddcatfilter;
	document.getElementById("idsearchedtype").value=forsearchedtype;
	altkeyevent = "non";
	try	{
		if (event.altKey == true)
			altkeyevent = "oui";
		else
			altkeyevent = "non";
		}
	catch(err) { altkeyevent = "non"; }
	if (altkeyevent == "oui")
		{
		window.open(forsecurelink+"secure/one_prod.php?prodcode="+document.getElementById('idcodetoshow').value,"mywin","width=900,height=720,resizable=yes,scrollbars=yes");
		}
	else
		{
		if (linktogo.indexOf("?") > 1)
			newLocation = forsecurelink + linktogo + "&addcatfilter=" + document.getElementById("idaddcatfilter").value + "&viewcurrency=" + document.getElementById("idcurrency").value + "&viewcategory=" + document.getElementById("iddisplaycategory").value + "&viewfilter=" + document.getElementById("idrunfilter").value + "&viewcode=" + document.getElementById("idcodetoshow").value + "&shopsize=" + document.getElementById("idshopbysize").value + "&searchedtype=" + forsearchedtype;
		else
			newLocation = forsecurelink + linktogo + "?addcatfilter=" + document.getElementById("idaddcatfilter").value + "&viewcurrency=" + document.getElementById("idcurrency").value + "&viewcategory=" + document.getElementById("iddisplaycategory").value + "&viewfilter=" + document.getElementById("idrunfilter").value + "&viewcode=" + document.getElementById("idcodetoshow").value + "&shopsize=" + document.getElementById("idshopbysize").value + "&searchedtype=" + forsearchedtype;
		if (targetto=="")
			document.location = newLocation;
		else
			{
			if (targetto=="sizing_guide")
				window.open(newLocation,'mywindow2','width=544,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
			else
				window.open(newLocation,'mywindow','width=544,height=810,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
			}
		}
	}
function rightOf(what,howmanychar) {
	return what.substr(what.length-howmanychar,howmanychar)
	}
function saveView() {
	window.location.reload( true );
	}
function searchnow() {
	newLocation = "search_result.php?viewcurrency=" + document.getElementById("idcurrency").value + "&viewcategory=" + document.getElementById("iddisplaycategory").value + "&viewfilter=Textual%20search&viewcode=&shopsize=&searchstring=" + document.getElementById("xsearchstring").value;
	document.location = newLocation;
	}
function removePX(what) {
	return what.substr(0,what.length-2)
	}
function writeCookie(xname,xvalue) { 
	var today = new Date(); 
	var the_date = new Date("December 31, 2023"); 
	var the_cookie_date = the_date.toGMTString(); 
	var the_cookie = xname+"="+xvalue; 
	var the_cookie = the_cookie + ";expires=" + the_cookie_date; 
	document.cookie=the_cookie;
	} 
function delete_cookie() {
	cookie_name = "cosyposy";
	var cookie_date = new Date ( );
	cookie_date.setTime ( cookie_date.getTime() - 1 );
	document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
	}
function flickerwarning(fstate,fcolor,fmessage) {
	switch (fstate) {
		case 'a':
			document.getElementById("forthewarning").innerHTML = "<div id='myuserwarning' style='background-color:" + fcolor + ";color:#FFFFFF;position:absolute;left:100px;top:200px;height:150px;width:600px;padding:10px;z-index:2000;'><div style='border:solid #FFFFFF 1px;background-color:" + fcolor + ";color:#FFFFFF;font-size:15px;position:absolute;left:10px;top:10px;height:130px;width:580px;padding:10px;'>" + fmessage + "<div onclick='document.getElementById(\"myuserwarning\").style.visibility = \"hidden\";' style='cursor:pointer;border: solid #FFFFFF 1px;background-color:" + fcolor + ";color:#FFFFFF;font-size:15px;position:absolute;left:500px;top:103px;height:20px;width:50px;'>&nbsp;Close&nbsp;</div></div></div>";
			setTimeout("flickerwarning('b','','')",10000);
			break;
		case 'b':
			document.getElementById("forthewarning").innerHTML = "";
			break;
		case 'c':
			document.getElementById("forthewarning").innerHTML = "<div id='myuserwarning' style='background-color:" + fcolor + ";color:#FFFFFF;position:absolute;left:100px;top:200px;height:150px;width:600px;padding:10px;z-index:2000;'><div style='border:solid #FFFFFF 1px;background-color:" + fcolor + ";color:#FFFFFF;font-size:15px;position:absolute;left:10px;top:10px;height:130px;width:580px;padding:10px;'>" + fmessage + "</div></div>";
			break;
		}
	}

function cent2(amount) {
	amount -= 0;
	amount = (Math.round(amount*100))/100;
	return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
	}
function cent(amount) {
	amount -= 0;
	amount = 100*amount;
	return (amount);
	}
function showhidebilling() {
	if (globalform.billingaddress.checked==true)
		{
		document.getElementById("paymentbutton1").style.visibility="visible";
		document.getElementById("billingblog").style.visibility="hidden";
		document.getElementById('overallcontainer0').style.height=removePX(document.getElementById("overallcontainer0").style.height)-0-330;
		document.getElementById('overallcontainer1').style.height=removePX(document.getElementById("overallcontainer1").style.height)-0-330;
		}
	else
		{
		document.getElementById("paymentbutton1").style.visibility="hidden";
		document.getElementById("billingblog").style.visibility="visible";
		document.getElementById('overallcontainer0').style.height=removePX(document.getElementById("overallcontainer0").style.height)-0+330;
		document.getElementById('overallcontainer1').style.height=removePX(document.getElementById("overallcontainer1").style.height)-0+330;
		}
	}
function nonEU($whatcountry) {
	switch ($whatcountry) {
		case "Germany":
			return false;
			break;
		case "Austria":
			return false;
			break;
		case "Belgium":
			return false;
			break;
		case "Denmark":
			return false;
			break;
		case "Spain":
			return false;
			break;
		case "France":
			return false;
			break;
		case "Greece":
			return false;
			break;
		case "Finland":
			return false;
			break;
		case "Ireland":
			return false;
			break;
		case "Italy":
			return false;
			break;
		case "Luxembourg":
			return false;
			break;
		case "Portugal":
			return false;
			break;
		case "Sweden":
			return false;
			break;
		case "Cyprus":
			return false;
			break;
		case "Hungary":
			return false;
			break;
		case "Estonia":
			return false;
			break;
		case "Poland":
			return false;
			break;
		case "Czech Republic":
			return false;
			break;
		case "Slovenia":
			return false;
			break;
		case "Latvia":
			return false;
			break;
		case "Lithuania":
			return false;
			break;
		case "Slovakia":
			return false;
			break;
		case "Malta":
			return false;
			break;
		case "United Kingdom":
			return false;
			break;
		case "Netherlands":
			return false;
			break;
		default:
			return true;
			break;
		}
	}
function nonUK($whatcountry) {
	switch ($whatcountry) {
		case "United Kingdom":
			return false;
			break;
		default:
			return true;
			break;
		}
	}
function add_price(sAmout1,sAmout2) {
	return cent2((cent(sAmout1)-0+cent(sAmout2))/100);
	}
function remove_price(sAmout1,sAmout2) {
	return cent2((cent(sAmout1)-0-cent(sAmout2))/100);
	}
function returnDisplayPrice(xxprice,currencyIndex,xpound2euro,xpound2dollar,xpound2dollarCA) {
	if (currencyIndex==0)
		return "&pound;"+cent2(xxprice).toString();
	if (currencyIndex==1)
		return "&euro;"+cent2(xxprice*xpound2euro).toString();
	if (currencyIndex==2)
		return "$"+cent2(xxprice*xpound2dollar).toString();
	if (currencyIndex==3)
		return "$"+cent2(xxprice*xpound2dollarCA).toString();
	}
function recalculateAll(currencyIndex,xpound2euro,xpound2dollar,xpound2dollarCA) {
	xproblem='no';
	//additional line in Shopping bag
	if (shippingcharges=='yes')
		{
		if(nonEU(globalform.modify_country.value))
			{
			document.getElementById("subtotalgoodsnonEU").style.visibility="visible";
			priceOfGoodsNonEU = priceOfgoods-vatOnGoods;
			document.getElementById("sSubTotalgoodsNonEU").innerHTML=returnDisplayPrice(priceOfGoodsNonEU,currencyIndex,xpound2euro,xpound2dollar,xpound2dollarCA);
			}
		}
	//Voucher
	if (shippingcharges=='yes')
		{
		if(nonEU(globalform.modify_country.value))
			{
			sTemp = priceOfGoodsNonEU*promotionalDiscount/100;
			sTemp2 = priceOfGoodsNonEU-sTemp;
			}
		else
			{
			sTemp = priceOfgoods*promotionalDiscount/100;
			sTemp2 = priceOfgoods-sTemp;
			}
		}
	else
		{
		sTemp = priceOfgoods*promotionalDiscount/100;
		sTemp2 = priceOfgoods-sTemp;
		}
	document.getElementById("sPriceDiscount").innerHTML = returnDisplayPrice(sTemp,currencyIndex,xpound2euro,xpound2dollar,xpound2dollarCA);
	document.getElementById("sSubTotal1").innerHTML = returnDisplayPrice(sTemp2,currencyIndex,xpound2euro,xpound2dollar,xpound2dollarCA);
	//delivery
	if (shippingcharges=='yes')
		{
		if(nonUK(globalform.modify_country.value))
			{
			if (globalform.deliveryoptions[0].checked==false)
				globalform.deliveryoptions[0].checked=true;
			}
		else
			{
			if (globalform.deliveryoptions[0].checked==true)
				xproblem="You must not select \"International signed\" for shipping in the UK";
			if ((globalform.deliveryoptions[1].checked==true)&&(sTemp2<15))
				xproblem="You must not select \"Free shipping\" for orders below 15 Pounds";
			}
		
		if (globalform.deliveryoptions[0].checked) { sTemp = globalform.deliveryoptions[0].value; globalform.deliverydisplay.value="International signed"; }
		if (globalform.deliveryoptions[1].checked) { sTemp = globalform.deliveryoptions[1].value; globalform.deliverydisplay.value="Free shipping within the UK"; }
		//if (globalform.deliveryoptions[2].checked) { sTemp = globalform.deliveryoptions[2].value; globalform.deliverydisplay.value="UK next day delivery"; }
		if (globalform.deliveryoptions[2].checked) { sTemp = globalform.deliveryoptions[2].value; globalform.deliverydisplay.value="UK signed"; }
		if (globalform.deliveryoptions[3].checked) { sTemp = globalform.deliveryoptions[3].value; globalform.deliverydisplay.value="UK next day delivery"; }
		sTemp = add_price(sTemp2,sTemp);
		document.getElementById("sSubTotal2").innerHTML = returnDisplayPrice(sTemp,currencyIndex,xpound2euro,xpound2dollar,xpound2dollarCA);
		}
	else
		sTemp = sTemp2
	//gift wrapping
	if (shippingcharges=='yes')
		{
		if (globalform.wrap_as_gift.checked)
			{ 
			sTemp = sTemp - 0 + 3.00; 
			globalform.wrap_message.disabled=false;
			globalform.wrap_message.style.backgroundColor="#FFFFFF";
			}
		else
			{
			globalform.wrap_message.style.backgroundColor="#EFEFEF";
			globalform.wrap_message.disabled=true;
			}
		document.getElementById("sSubTotal3").innerHTML = returnDisplayPrice(sTemp,currencyIndex,xpound2euro,xpound2dollar,xpound2dollarCA);
		}
	document.getElementById("sGrandTotal").innerHTML = returnDisplayPrice(sTemp,currencyIndex,xpound2euro,xpound2dollar,xpound2dollarCA);
	globalform.chargeGrandTotal.value=cent2(sTemp);
	if (shippingcharges=='no')
		{
		globalform.modify_firstname.value = globalform.modify_firstname_billing.value;
		globalform.modify_name.value = globalform.modify_name_billing.value;
		globalform.modify_addr1.value = globalform.modify_addr1_billing.value;
		globalform.modify_addr2.value = globalform.modify_addr2_billing.value;
		globalform.modify_addr3.value = globalform.modify_addr3_billing.value;
		globalform.modify_addrzip.value = globalform.modify_addrzip_billing.value;
		globalform.modify_addrstate.value = globalform.modify_addrstate_billing.value;
		globalform.modify_country.selectedIndex = globalform.modify_country_billing.selectedIndex;
		}
	if ((shippingcharges!='no')&&(globalform.sameforbilling.checked==true))
		{
		globalform.modify_firstname_billing.value = globalform.modify_firstname.value;
		globalform.modify_name_billing.value = globalform.modify_name.value;
		globalform.modify_addr1_billing.value = globalform.modify_addr1.value;
		globalform.modify_addr2_billing.value = globalform.modify_addr2.value;
		globalform.modify_addr3_billing.value = globalform.modify_addr3.value;
		globalform.modify_addrzip_billing.value = globalform.modify_addrzip.value;
		globalform.modify_addrstate_billing.value = globalform.modify_addrstate.value;
		globalform.modify_country_billing.selectedIndex = globalform.modify_country.selectedIndex;
		}
	}
function savalidate() {
	xproblem = "no";
	if (globalform.yyname.value=="")
		xproblem="You must fill-in the \"Your name\" field!";
	if (globalform.yyname2.value=="")
		xproblem="You must fill-in the \"Name\" field!";
	if ((globalform.yyemail.value=="")||(globalform.yyemail.value.indexOf("@")<1))
		xproblem="The \"E-mail address\" field must be a valid email address";
	if (globalform.yymessage.value=="")
		xproblem="You must fill-in the \"personal message\" field!";
	}
function xvalidateform() {
	if (shippingcharges=='no')
		{
		if (globalform.modify_firstname_billing.value=="")
			xproblem="You must fill-in the \"Billing First Name\" field!";
		if (globalform.modify_name_billing.value=="")
			xproblem="You must fill-in the \"Billing Name\" field!";
		if (globalform.modify_addr1_billing.value=="")
			xproblem="You must fill-in the \"Billing Address\" field!";
		if (globalform.modify_addr3_billing.value=="")
			xproblem="You must fill-in the \"Billing Town/City\" field!";
		if (globalform.modify_addrzip_billing.value=="")
			xproblem="You must fill-in the \"Billing Post/zip code\" field!";
		}
	if ((shippingcharges!='no')&&(globalform.sameforbilling.checked==true))
		{
		if (globalform.modify_firstname.value=="")
			xproblem="You must fill-in the \"Shipping First Name\" field!";
		if (globalform.modify_name.value=="")
			xproblem="You must fill-in the \"Shipping Name\" field!";
		if (globalform.modify_addr1.value=="")
			xproblem="You must fill-in the \"Shipping Address\" field!";
		if (globalform.modify_addr3.value=="")
			xproblem="You must fill-in the \"Shipping Town/City\" field!";
		if (globalform.modify_addrzip.value=="")
			xproblem="You must fill-in the \"Shipping Post/zip code\" field!";
		}
	if ((globalform.modify_email.value=="")||(globalform.modify_email.value.indexOf("@")<1))
		xproblem="The \"E-mail address\" field must be a valid email address";
	}
function CreateBookmarkLink() { 
	//send("Cosyposy bookmarked!","mir_log.php");
	title = "Cosyposy childrenswear";   
	// Blogger - Replace with <$BlogItemTitle$>   
	// MovableType - Replace with <$MTEntryTitle$> 
	url = "http://www.cosyposy.co.uk";  
	// Blogger - Replace with <$BlogItemPermalinkURL$>   
	// MovableType - Replace with <$MTEntryPermalink$>  
	// WordPress - <?php bloginfo('url'); ?>	
	if (window.sidebar) 
		{ 
		// Mozilla Firefox Bookmark		
		window.sidebar.addPanel(title, url,"");	
		} 
	else if( window.external ) 
		{ 
		// IE Favorite		
		window.external.AddFavorite( url, title); 
		}
	else if(window.opera && window.print) 
		{ 
		// Opera Hotlist		
		return true; 
		} 
	} 
