function selectCountry()
{
   document.forms.mainForm.submit();
}

function selectMobile()
{
   document.forms.mainForm.submit();
}


function launch(newURL, newName, newFeatures, orgName) {
        var remote = open(newURL, newName, newFeatures);

        if (remote.opener == null)
            remote.opener = window;
        remote.opener.name = orgName;

        return remote;
}

function sendTryBuy()
{
	if((document.forms.mainForm.sendtophonenumber.value.length < 4) && (micropayment == false))
	{
		alert(unescape(enterphonenumber));
	}
	else
	{
		// get phonenumber from form
		phonenumber = document.forms.mainForm.sendtophonenumber.value;

		// strip all non numeric chars from phonenumber
		phonenumber = stripAlphaChars(phonenumber);

		// make sure phonenumber is correct
		if(phonenumber.substr(0, 2) == "00") // this customer already entered the international phonenumber
		{
			// do nothing, use phonenumber as it is..
		}
		else if(phonenumber.substr(0, 1) == "0") // this user entered his 'national' phonenumber
		{
			phonenumber = "00"+document.forms.mainForm.cpc.value+phonenumber.substr(1, phonenumber.length);
		}
		else if((phonenumber.substr(0, 1) == "1") && (document.forms.mainForm.cpc.value == 1))// user from the US, 'national' phonenumber
		{
			phonenumber = "001"+phonenumber.substr(1, phonenumber.length);
		}
		else if(document.forms.mainForm.cpc.value == 1) // user from US, 'local' phonenumber
		{
			phonenumber = "001"+phonenumber;
		}
		else // other, just copy 00+countrycode+phonenumber
		{
			phonenumber = "00"+document.forms.mainForm.cpc.value+phonenumber;
		}

        this.document.location.href="buy.php?sendtrybuy=1&product="+document.forms.mainForm.product.value+"&phone="+phonenumber;
	}
}

function doPayment(paymentmethod)
{
	
	if(subscription == false && (document.forms.mainForm.sendtophonenumber.value.length < 4) && (micropayment == false))
	{
		alert(unescape(enterphonenumber));
	}
	else
	{	
		if(!subscription)
		{
			// get phonenumber from form unless dev is HUSTLER
			if(document.forms.ccForm.dev.value != "2430")
			{
				phonenumber = document.forms.mainForm.sendtophonenumber.value;
				
				// strip all non numeric chars from phonenumber
				phonenumber = stripAlphaChars(phonenumber);

				// make sure phonenumber is correct
				if(phonenumber.substr(0, 2) == "00") // this customer already entered the international phonenumber
				{
					// do nothing, use phonenumber as it is..
				}
				else if(phonenumber.substr(0, 1) == "0") // this user entered his 'national' phonenumber
				{
					phonenumber = "00"+document.forms.mainForm.cpc.value+phonenumber.substr(1, phonenumber.length);
				}
				else if((phonenumber.substr(0, 1) == "1") && (document.forms.mainForm.cpc.value == 1))// user from the US, 'national' phonenumber
				{
					phonenumber = "001"+phonenumber.substr(1, phonenumber.length);
				}
				else if(document.forms.mainForm.cpc.value == 1) // user from US, 'local' phonenumber
				{
					phonenumber = "001"+phonenumber;
				}
				else // other, just copy 00+countrycode+phonenumber
				{
					phonenumber = "00"+document.forms.mainForm.cpc.value+phonenumber;
				}
			}
			else
			{
				phonenumber = "empty";
				document.forms.ccForm.target = "_self";
			}
		}

		rc = document.forms.mainForm.retrievecode.value;

		pid = document.forms.mainForm.product.value;
		aid = document.forms.mainForm.affiliate.value;
		if(aid == '')
			aid = '0';
		cus = document.forms.mainForm.customparameter.value;

		if(subscription || (((rc != '') || (rc != "0")) && ((phonenumber != '') && (phonenumber != "0"))))
		{
			if(paymentmethod == 'paypal')
			{
				alert('Sorry, PayPal not accepted at this moment. Please use credit card or SMS.');
				//document.forms.ppForm.item_number.value = rc+"-"+phonenumber;
				//document.forms.ppForm.submit();
			}
			else if(paymentmethod == 'creditcard')
			{
				//document.forms.ccForm.cartId.value = rc+"-"+phonenumber;
//				document.forms.ccForm.cartId.value = pid+"-"+aid+"-"+phonenumber+"-"+cus;
				if(!subscription)
				{
					document.forms.ccForm.cartId.value = rc+"::"+phonenumber+"::"+aid+"::"+pid+"::"+cus;
					document.forms.ccForm.phonenumber.value = phonenumber;
				}
//alert(document.forms.ccForm.cartId.value);
//alert(document.forms.ccForm.currency.value);
				if(document.forms.ccForm.currency.value == "SEK")
					document.forms.ccForm.currency.value = "EUR";
				if(document.forms.ccForm.currency.value == "DKK")
					document.forms.ccForm.currency.value = "EUR";
				if(document.forms.ccForm.currency.value == "NOK")
					document.forms.ccForm.currency.value = "EUR";

				document.forms.ccForm.submit();
			}
			else
			{
				alert("Something went wrong here, please mail support@sharewire.net");
			}

		}
		else
		{
			alert("Something went wrong here, please mail support@sharewire.net");
		}
	}
}

function doPaypalPayment()
{
	if(document.forms.mainForm.sendtophonenumber.value.length < 1)
	{
		alert(unescape(enterphonenumber));
	}
	else
	{
		// first, make sure phonenumber is correct
		phonenumber = document.forms.mainForm.sendtophonenumber.value;
		if(phonenumber.substr(0, 1) == "0")
		{
			phonenumber = "00"+document.forms.mainForm.cpc.value+phonenumber.substr(1, phonenumber.length);
			rc = document.forms.mainForm.retrievecode.value;
			document.forms.ppForm.item_number.value = rc+"-"+phonenumber;
		}
		else if(phonenumber.substr(0, 1) == "+")
		{
			phonenumber = "00"+phonenumber.substr(1, phonenumber.length);
			rc = document.forms.mainForm.retrievecode.value;
			document.forms.ppForm.item_number.value = rc+"-"+phonenumber;
		}
		else if(phonenumber.substr(0, 1) == "1")
		{
			phonenumber = "001"+phonenumber.substr(1, phonenumber.length);
			rc = document.forms.mainForm.retrievecode.value;
			document.forms.ppForm.item_number.value = rc+"-"+phonenumber;
		}
		else
		{
			rc = document.forms.mainForm.retrievecode.value;
			document.forms.ppForm.item_number.value = rc+"-"+phonenumber;
		}
alert(document.forms.ppForm.item_number.value);
		if(((rc != '') || (rc != "0")) && ((phonenumber != '') || (phonenumber != "0")))
		{
			// if phonenumber is not empty or 0
//			document.forms.ppForm.submit();
		}
		else
		{
			alert("Something went wrong here, please mail support.");
		}
	}
}

function showDiv(divid, dowhat)
{
	divje = document.getElementById(divid)

	if(dowhat == "show")
	{
		divje.style.visibility = "visible";
	}
	else
	{
		divje.style.visibility = "hidden";
	}
}

function stripAlphaChars(pstrSource) 
{ 
	var m_strOut = new String(pstrSource); 
    m_sOut = m_strOut.replace(/[^0-9]/g, ''); 

    return m_sOut; 
}

/* disable right click functionality */

////////////////////////////////
// Please leave this notice.
// Disable Right Click version 1.0
// By Essam Gamal .. Migoicons as a web user name
// Website: http://migoicons.tripod.com
// Email: migoicons@hotmail.com
// Friday, June 13, 2003
/////////////////////////////

/*

var message = "" // leave this empty for no alter message.

var nIsIE4 = (document.all&&!document.getElementById)? 1:0
var nIsNS6 = (navigator.productSub<20011019)? 1:0 
var nIsNS4 = (navigator.appName.toLowerCase()=="netscape"&&parseInt(navigator.appVersion)==4)? 1:0

function DisableRightClick(e){
 if((nIsIE4&&event.button==2)||((nIsNS4||nIsNS6)&&(e.which==2||e.which==3))){
	if(nIsIE4&&!message) message="Function Disabled"
	if(message) alert(message)
	return false
 }
}

if(nIsIE4||nIsNS4){
	if(nIsNS4) document.captureEvents(Event.MOUSEDOWN)
	document.onmousedown = DisableRightClick
} 
else if(nIsNS6) document.onmouseup = DisableRightClick
document.oncontextmenu = new Function("if(message)alert(message);return false")
*/