// JavaScript Document


function VerifyFrmbcdes() {
	
	var txt = "";

	if (document.frmbcdes.company_name.value=="Company Name") {
		txt = txt + "\n * Change or Delete Company Name";
	}
	if (document.frmbcdes.company_slogan.value=="Company Slogan") {
		txt = txt + "\n * Change or Delete Company Slogan";
	}

	if (document.frmbcdes.name.value=="Name Surname") {
		txt = txt + "\n * Change or Delete Name";
	}
	
	if (document.frmbcdes.position.value=="position") {
		txt = txt + "\n * Chaneg or Delete Position";
	}
	if (document.frmbcdes.tel.value=="Tel: 0208 123 4567") {
		txt = txt + "\n * Change or Delete Tel: 0208 123 4567";
	}
	
	if (document.frmbcdes.fax.value=="Fax: 0208 123 4568") {
		txt = txt + "\n * Change or Delete Fax: 0208 123 4568";
	}
	if (document.frmbcdes.email.value=="E-mail: info@oxagon.co.uk") {
		txt = txt + "\n * Change or Delete E-mail: info@oxagon.co.uk";
	}
	if (document.frmbcdes.web.value=="Web: www.oxagon.co.uk") {
		txt = txt + "\n * Change or Delete Web: www.oxagon.co.uk";
	}
	
	if (document.frmbcdes.address_1.value=="House Name") {
		txt = txt + "\n * Change or Delete House Name";
	}
	if (document.frmbcdes.address_2.value=="125 Cherry Orchard Road") {
		txt = txt + "\n * Change or Delete 125 Cherry Orchard Road";
	}
	if (document.frmbcdes.address_3.value=="Croydon, Surrey") {
		txt = txt + "\n * Change or Delete Croydon, Surrey";
	}
	if (document.frmbcdes.postcode.value=="CR0 6BE") {
		txt = txt + "\n * Change or Delete CR0 6BE";
	}

	if (txt) {
		alert ("The folowing fields are required:\n" + txt);
		return false;
	}
}

function randomnumber()
{
    var randomnumber=Math.floor(Math.random()*9999999999)
    var y=new String(randomnumber).length;
    if (y!=10)
    {
        x();
    }
    else
    {
        return randomnumber;
    }
}



function VerifyCheckout() {
	
	var txt = "";

	var str=document.checkout.cust_email.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i 
	if (!filter.test(str)) {
	 txt = txt + "\n * Email is not Valid";
	}
	if (document.checkout.cust_name.value=="") {
		txt = txt + "\n * First Name";
	}
	
	if (document.checkout.cust_surname.value=="") {
		txt = txt + "\n * Last Name";
	}
	
	if (document.checkout.cust_telephone.value=="") {
		txt = txt + "\n * Telephone";
	}
	
	if (document.checkout.cust_address.value=="") {
		txt = txt + "\n * Billing Address 1";
	}
	/*
	if ( (document.checkout.cust_address_2.value=="") && (!document.checkout.samedeliveryaddress.checked) ){
		txt = txt + "\n * Delivery Address";
	}
	*/

	if (document.checkout.cust_city.value=="") {
		txt = txt + "\n * City / Town";
	}
	
	if (document.checkout.cust_postcode.value=="") {
		txt = txt + "\n * Post Code";
	}
	
	if (!document.checkout.termsagree.checked) {
	 txt = txt + "\n * You have to agree with our Terms & Conditions";
	}

	if (txt) {
		alert ("The folowing fields are required:\n" + txt);
		return false;
	}
}



function getpos(overlay, offtype) {
	
	var totaloff=(offtype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	
	while (parentEl!=null) {
		totaloff=(offtype=="left")? totaloff+parentEl.offsetLeft : totaloff+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	
	return totaloff;
	
}

function overlay(curobj, subobjstr, opt_position) {
	
	if (document.getElementById) {
		
		var subobj=document.getElementById(subobjstr);
		subobj.style.display=(subobj.style.display!="block")? "block" : "block";
		var xpos=getpos(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0);
		var ypos=getpos(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0);
		subobj.style.left=xpos+"px";
		subobj.style.top=ypos+"px";
		//return false
		
	}
	else
	return true
	
}

function overlayclose(subobj) {
	
	document.getElementById(subobj).style.display="none";
	
}


function DisplayEmail() {
var name = 'printing';
var at = '&#64;';
var domain = 'oxagon';
var ext = '.co.uk';
document.write('<a href=\"mailto:'+name+at+domain+ext+'\">'+name+at+domain+ext+'</a>');
}