// JavaScript Document
function funClear()
{
	if(document.frm.p_name.value == "Your Name")
	{
		document.frm.p_name.value = "";
	}
}
function emailCheck(emailStr) 
{
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null)
	 {	
		alert("Email address seems incorrect (check @ and .'s)");
		return false;
	 }
	var user=matchArray[1];
	var domain=matchArray[2];
	
	for (i=0; i<user.length; i++) 
	{
		if (user.charCodeAt(i)>127) 
		{
			alert("Ths username contains invalid characters in Email address");
			return false;
	    }
	}
	for (i=0; i<domain.length; i++) 
	{
		if (domain.charCodeAt(i)>127) 
		{
			alert("Ths domain name contains invalid characters in Email address");
			return false;
	   }
	}
	
	if (user.match(userPat)==null) 
	{	
		alert("The username doesn't seem to be valid in Email Address");
		return false;
	}
	
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) 
	{	
		for (var i=1;i<=4;i++) 
		{
			if (IPArray[i]>255) 
			{
				alert("Destination IP address is invalid! in email address");
				return false;
		   }
		}	
		return true;
		}
	
	// Domain is symbolic name.  Check if it's valid.
	 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
	alert("The domain name does not seem to be valid in email address");
	return false;
	   }
	}
	
	if (checkTLD && domArr[domArr.length-1].length!=2 && 
	domArr[domArr.length-1].search(knownDomsPat)==-1) {
	alert("The address must end in a well-known domain or two letter " + "country in email address");
	return false;
	}
	
	if (len<2) {
	alert("This address is missing a hostname! in email address");
	return false;
	}	
	return true;
}
function IsNumeric(strString)
 {
   var strValidChars = "0123456789.()- ";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return true;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}
function IsNumericDot(strString)
 {
   var strValidChars = "0123456789. ";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return true;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}
function IsValidIDSpace(strString)
 {
   var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.@_- ";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}


function validateFrmCanvisOnly()
{
//	alert("day=["+document.frm.p_day.value+"] - month=["+document.frm.p_month.value+"] - year=["+document.frm.p_year.value+"]");
	
	var size = "";
	for(i=0;i<document.frm.radiobutton.length;i++)
	{
		if(document.frm.radiobutton[i].checked)
		{
	//		alert(document.frm.radiobutton[i].value);
			size = document.frm.radiobutton[i].value;
		}
	}
	// place value in hidden fields in form ... 
	 document.frm.hsize.value = size;

/**************************************************/
/* CODE BY RAFIQ FROM PAKISTAN INTERACTIVES		 */
/*************************************************/
// parameters going on submitting this form are ..
// 1 - p_name      - for name of child
// 2 - p_day		- for day of dob
// 3 - p_month		- month of dob
// 4 - p_year		- year of dob
// 5 - hsize		- selected size of canvas
// 6 - ha			- canvas Color dispaly
// 7 - hb			- canvas Corners motif
// 8 - hc			- canvas prod - picture
// 9 - display		- new page display  = preview
/*************************************************/
/**************************************************/
		document.frm.method = "POST";
//		document.frm.action = "index2.php?display=preview&canvas=only";
		document.frm.action = "cart.php?cart_action=add&canvas=only";
		document.frm.submit();
		return true;
}

function validateFrmJunior()
{
//	alert("day=["+document.frm.p_day.value+"] - month=["+document.frm.p_month.value+"] - year=["+document.frm.p_year.value+"]");
	if(document.frm.p_name.value == "")
	{
		alert("Name Field missing ! ");
		document.frm.p_name.select();
		return false;		
	}
	if(document.frm.p_name.value == "Your Name")
	{
		alert("Name Field missing ! ");
		document.frm.p_name.select();
		return false;		
	}
	if(IsValidIDSpace(document.frm.p_name.value) == false)
	{
		alert("Invalid characters in Name Field! Only [a-z],[A-Z],[0-9],_,@,space allowed");
		document.frm.p_name.select();
		return false;		
	}
	if(document.frm.p_day.value == "")
	{
		alert("Day Field of DOB missing ! ");
		return false;		
	}
	if(document.frm.p_month.value == "")
	{
		alert("Month Field of DOB missing ! ");
		return false;		
	}
	if(document.frm.p_year.value == "")
	{
		alert("Year Field of DOB missing ! ");
		return false;		
	}
	
	var size = "";
	for(i=0;i<document.frm.radiobutton.length;i++)
	{
		if(document.frm.radiobutton[i].checked)
		{
	//		alert(document.frm.radiobutton[i].value);
			size = document.frm.radiobutton[i].value;
		}
	}
	
	var del = "";
	for(i=0;i<document.frm.deliverbutton.length;i++)
	{
		if(document.frm.deliverbutton[i].checked)
		{
	//		alert(document.frm.radiobutton[i].value);
			del = document.frm.deliverbutton[i].value;
		}
	}
	// place value in hidden fields in form ... 
	 document.frm.deliver.value = del;
	 document.frm.hsize.value = size;

/**************************************************/
/* CODE BY RAFIQ FROM PAKISTAN INTERACTIVES		 */
/*************************************************/
// parameters going on submitting this form are ..
// 1 - p_name      - for name of child
// 2 - p_day		- for day of dob
// 3 - p_month		- month of dob
// 4 - p_year		- year of dob
// 5 - hsize		- selected size of canvas
// 6 - ha			- canvas Color dispaly
// 7 - hb			- canvas Corners motif
// 8 - hc			- canvas prod - picture
// 9 - display		- new page display  = preview
/*************************************************/
/**************************************************/
		document.frm.method = "POST";
		//document.frm.action = "index2.php?display=juniorpreview&p_month="+document.frm.p_month.value;
    document.frm.action = "cart.php?type=junior&cart_action=add";
		document.frm.submit();
		return true;
}


function validateFrm()
{
//	alert("day=["+document.frm.p_day.value+"] - month=["+document.frm.p_month.value+"] - year=["+document.frm.p_year.value+"]");
	if(document.frm.p_name.value == "")
	{
		alert("Name Field missing ! ");
		document.frm.p_name.select();
		return false;		
	}
	if(document.frm.p_name.value == "Your Name")
	{
		alert("Name Field missing ! ");
		document.frm.p_name.select();
		return false;		
	}
	if(IsValidIDSpace(document.frm.p_name.value) == false)
	{
		alert("Invalid characters in Name Field! Only [a-z],[A-Z],[0-9],_,@,space allowed");
		document.frm.p_name.select();
		return false;		
	}
	if(document.frm.p_day.value == "")
	{
		alert("Day Field of DOB missing ! ");
		return false;		
	}
	if(document.frm.p_month.value == "")
	{
		alert("Month Field of DOB missing ! ");
		return false;		
	}
	if(document.frm.p_year.value == "")
	{
		alert("Year Field of DOB missing ! ");
		return false;		
	}
	
	var size = "";
	for(i=0;i<document.frm.radiobutton.length;i++)
	{
		if(document.frm.radiobutton[i].checked)
		{
	//		alert(document.frm.radiobutton[i].value);
			size = document.frm.radiobutton[i].value;
		}
	}
	// place value in hidden fields in form ... 
	 document.frm.hsize.value = size;

/**************************************************/
/* CODE BY RAFIQ FROM PAKISTAN INTERACTIVES		 */
/*************************************************/
// parameters going on submitting this form are ..
// 1 - p_name      - for name of child
// 2 - p_day		- for day of dob
// 3 - p_month		- month of dob
// 4 - p_year		- year of dob
// 5 - hsize		- selected size of canvas
// 6 - ha			- canvas Color dispaly
// 7 - hb			- canvas Corners motif
// 8 - hc			- canvas prod - picture
// 9 - display		- new page display  = preview
/*************************************************/
/**************************************************/
		document.frm.method = "POST";
//		document.frm.action = "index2.php?display=add2cart&p_month="+document.frm.p_month.value;
		document.frm.action = "cart.php?cart_action=add";
		document.frm.submit();
		return true;
}

function validatePreview()
{

// sender / customer validation ...

	if (document.frm.txtCusName.value == "")
	{
		alert("Your Name field is missing!");
		document.frm.txtCusName.select();
		return false;
	}
	if (document.frm.txtCusName.value.length < 4)
	{
		alert("Your Name field Length must be greater than 4 characters!");
		document.frm.txtCusName.select();
		return false;		
	}	
	if(IsValidIDSpace(document.frm.txtCusName.value)== false)
	{
		alert("Must be Valid Characters ie [a..z],[A..Z],[0..9],[.],[@],[_],[-], Spaces ");
		document.frm.txtCusName.select();
		return false;		
	}
	if(document.frm.txtCusAddress.value == "")
	{
		alert("Your Address Field is Missing ...");
		document.frm.txtCusAddress.select();
		return false;
	}
	if (document.frm.txtCusCity.value == "")
	{
		alert("Your City field is missing!");
		document.frm.txtCusCity.select();
		return false;
	}
	
	if (document.frm.txtord_hearabout.value == "")
	{
		alert("How did you hear about us field is missing!");
		document.frm.txtord_hearabout.select();
		return false;
	}
	
	if (document.frm.txtCusCity.value.length < 3)
	{
		alert("Your City field Length must be greater than 3 characters!");
		document.frm.txtCusCity.select();
		return false;		
	}	
	if(IsValidIDSpace(document.frm.txtCusCity.value)== false)
	{
		alert("Must be Valid Characters ie [a..z],[A..Z],[0..9],[.],[@],[_],[-], Spaces ");
		document.frm.txtCusCity.select();
		return false;		
	}
	if(document.frm.txtCusPcode.value == "")
	{
		alert("Your Postal Code Field is Missing ...");
		document.frm.txtCusPcode.select();
		return false;
	}	
	else if(IsValidIDSpace(document.frm.txtCusPcode.value) == false)
	{
		alert("Invalid Postal Code Number Field ...");
		document.frm.txtCusPcode.select();
		return false;
	}	
	if(document.frm.txtCusPhone.value == "")
	{
		alert("Your Phone Number Field is Missing ...");
		document.frm.txtCusPhone.select();
		return false;
	}	
	else if(IsNumeric(document.frm.txtCusPhone.value) == false)
	{
		alert("Invalid Phone Number Field, Only Numeric Allowed ...");
		document.frm.txtCusPhone.select();
		return false;
	}	
	else if(document.frm.txtCusMobile.value != "" && IsNumeric(document.frm.txtCusMobile.value) == false)
	{
		alert("Invalid Mobile Number Field, Only Numeric Allowed ...");
		document.frm.txtCusMobile.select();
		return false;
	}	
 	else if(document.frm.txtCusEmail.value == "")
	{
		alert("Your Email Field is Missing ...");
		document.frm.txtCusEmail.select();
		return false;
	}
	else if (emailCheck(document.frm.txtCusEmail.value)== false)
	{
		document.frm.txtCusEmail.select();
		return false;		
	}	
	else if(document.frm.txtLS.value != "" && IsValidIDSpace(document.frm.txtLS.value) == false)
	{
		alert("Invalid Local Stockist ID ...");
		document.frm.txtLS.select();
		return false;
	}	

// shipping / receiving validation 

	if (document.frm.txtRecName.value == "")
	{
		alert("Shipping Name field is missing!");
		document.frm.txtRecName.select();
		return false;
	}
	if (document.frm.txtRecName.value.length < 4)
	{
		alert("Shipping Name field Length must be greater than 4 characters!");
		document.frm.txtRecName.select();
		return false;		
	}	
	if(IsValidIDSpace(document.frm.txtRecName.value)== false)
	{
		alert("Must be Valid Characters ie [a..z],[A..Z],[0..9],[.],[@],[_],[-], Spaces ");
		document.frm.txtRecName.select();
		return false;		
	}
	if(document.frm.txtRecAddress.value == "")
	{
		alert("Shipping Address Field is Missing ...");
		document.frm.txtRecAddress.select();
		return false;
	}
	if (document.frm.txtRecCity.value == "")
	{
		alert("Shipping City field is missing!");
		document.frm.txtRecCity.select();
		return false;
	}
	if (document.frm.txtRecCity.value.length < 3)
	{
		alert("Shipping City field Length must be greater than 3 characters!");
		document.frm.txtRecCity.select();
		return false;		
	}	
	if(IsValidIDSpace(document.frm.txtRecCity.value)== false)
	{
		alert("Must be Valid Characters ie [a..z],[A..Z],[0..9],[.],[@],[_],[-], Spaces ");
		document.frm.txtRecCity.select();
		return false;		
	}
	if(document.frm.txtRecPcode.value == "")
	{
		alert("Shipping Postal Code Field is Missing ...");
		document.frm.txtRecPcode.select();
		return false;
	}	
	else if(IsValidIDSpace(document.frm.txtRecPcode.value) == false)
	{
		alert("Invalid Postal Code Number Field, Only Numeric Allowed ...");
		document.frm.txtRecPcode.select();
		return false;
	}	

	if(document.frm.txtRecPhone.value == "")
	{
		alert("Shipping Phone Number Field is Missing ...");
		document.frm.txtRecPhone.select();
		return false;
	}	
	else if(IsNumeric(document.frm.txtRecPhone.value) == false)
	{
		alert("Invalid Phone Number Field, Only Numeric Allowed ...");
		document.frm.txtRecPhone.select();
		return false;
	}	

document.frm.method = "POST";
document.frm.action = "index2.php?display=vcard&canvas="+document.frm.canvas.value;
document.frm.submit();
return true;
}

function validatePreview2()
{

// sender / customer validation ...

	if (document.frm.txtCusName.value == "")
	{
		alert("Your Name field is missing!");
		document.frm.txtCusName.select();
		return false;
	}
	if (document.frm.txtCusName.value.length < 4)
	{
		alert("Your Name field Length must be greater than 4 characters!");
		document.frm.txtCusName.select();
		return false;		
	}	
	if(IsValidIDSpace(document.frm.txtCusName.value)== false)
	{
		alert("Must be Valid Characters ie [a..z],[A..Z],[0..9],[.],[@],[_],[-], Spaces ");
		document.frm.txtCusName.select();
		return false;		
	}
	if(document.frm.txtCusAddress.value == "")
	{
		alert("Your Address Field is Missing ...");
		document.frm.txtCusAddress.select();
		return false;
	}
	if (document.frm.txtCusCity.value == "")
	{
		alert("Your City field is missing!");
		document.frm.txtCusCity.select();
		return false;
	}
	
	if (document.frm.txtord_hearabout.value == "")
	{
		alert("How did you hear about us field is missing!");
		document.frm.txtord_hearabout.select();
		return false;
	}
	
	if (document.frm.txtCusCity.value.length < 3)
	{
		alert("Your City field Length must be greater than 3 characters!");
		document.frm.txtCusCity.select();
		return false;		
	}	
	if(IsValidIDSpace(document.frm.txtCusCity.value)== false)
	{
		alert("Must be Valid Characters ie [a..z],[A..Z],[0..9],[.],[@],[_],[-], Spaces ");
		document.frm.txtCusCity.select();
		return false;		
	}
	if(document.frm.txtCusPcode.value == "")
	{
		alert("Your Postal Code Field is Missing ...");
		document.frm.txtCusPcode.select();
		return false;
	}	
	else if(IsValidIDSpace(document.frm.txtCusPcode.value) == false)
	{
		alert("Invalid Postal Code Number Field ...");
		document.frm.txtCusPcode.select();
		return false;
	}	
	if(document.frm.txtCusPhone.value == "")
	{
		alert("Your Phone Number Field is Missing ...");
		document.frm.txtCusPhone.select();
		return false;
	}	
	else if(IsNumeric(document.frm.txtCusPhone.value) == false)
	{
		alert("Invalid Phone Number Field, Only Numeric Allowed ...");
		document.frm.txtCusPhone.select();
		return false;
	}	
	else if(document.frm.txtCusMobile.value != "" && IsNumeric(document.frm.txtCusMobile.value) == false)
	{
		alert("Invalid Mobile Number Field, Only Numeric Allowed ...");
		document.frm.txtCusMobile.select();
		return false;
	}	
 	else if(document.frm.txtCusEmail.value == "")
	{
		alert("Your Email Field is Missing ...");
		document.frm.txtCusEmail.select();
		return false;
	}
	else if (emailCheck(document.frm.txtCusEmail.value)== false)
	{
		document.frm.txtCusEmail.select();
		return false;		
	}	
	else if(document.frm.txtLS.value != "" && IsValidIDSpace(document.frm.txtLS.value) == false)
	{
		alert("Invalid Local Stockist ID ...");
		document.frm.txtLS.select();
		return false;
	}	

// shipping / receiving validation 

	if (document.frm.txtRecName.value == "")
	{
		alert("Shipping Name field is missing!");
		document.frm.txtRecName.select();
		return false;
	}
	if (document.frm.txtRecName.value.length < 4)
	{
		alert("Shipping Name field Length must be greater than 4 characters!");
		document.frm.txtRecName.select();
		return false;		
	}	
	if(IsValidIDSpace(document.frm.txtRecName.value)== false)
	{
		alert("Must be Valid Characters ie [a..z],[A..Z],[0..9],[.],[@],[_],[-], Spaces ");
		document.frm.txtRecName.select();
		return false;		
	}
	if(document.frm.txtRecAddress.value == "")
	{
		alert("Shipping Address Field is Missing ...");
		document.frm.txtRecAddress.select();
		return false;
	}
	if (document.frm.txtRecCity.value == "")
	{
		alert("Shipping City field is missing!");
		document.frm.txtRecCity.select();
		return false;
	}
	if (document.frm.txtRecCity.value.length < 3)
	{
		alert("Shipping City field Length must be greater than 3 characters!");
		document.frm.txtRecCity.select();
		return false;		
	}	
	if(IsValidIDSpace(document.frm.txtRecCity.value)== false)
	{
		alert("Must be Valid Characters ie [a..z],[A..Z],[0..9],[.],[@],[_],[-], Spaces ");
		document.frm.txtRecCity.select();
		return false;		
	}
	if(document.frm.txtRecPcode.value == "")
	{
		alert("Shipping Postal Code Field is Missing ...");
		document.frm.txtRecPcode.select();
		return false;
	}	
	else if(IsValidIDSpace(document.frm.txtRecPcode.value) == false)
	{
		alert("Invalid Postal Code Number Field, Only Numeric Allowed ...");
		document.frm.txtRecPcode.select();
		return false;
	}	

	if(document.frm.txtRecPhone.value == "")
	{
		alert("Shipping Phone Number Field is Missing ...");
		document.frm.txtRecPhone.select();
		return false;
	}	
	else if(IsNumeric(document.frm.txtRecPhone.value) == false)
	{
		alert("Invalid Phone Number Field, Only Numeric Allowed ...");
		document.frm.txtRecPhone.select();
		return false;
	}	

document.frm.method = "POST";
document.frm.action = "index2.php?display=vcard2&canvas="+document.frm.canvas.value;
document.frm.submit();
return true;
}
/*************************************************************/
/*************************************************************/
/* CODE BY MUHAMMAD RAFIQ FROM WWW.PAKISTANINTERACTIVES.COM **/
/* SATURDAY 21 JULY 2008 - ALL RIGHTS RESERVED BY PAK INTER **/
/*************************************************************/
/*....R..R...........R...........R.R.R.R.R....R.....R.R.R....*/
/*....R....R........R.R..........R............R...R........R.*/
/*....R...R........R...R.........R............R...R........R.*/
/*....R.R.........R.R.R.R........R.R.R.R.R....R...R........R.*/
/*....R.R........R.......R.......R............R...R....R...R.*/
/*....R...R.....R.........R......R............R...R......R.R.*/
/*....R....R...R...........R.....R............R....R.R.R.R.RR*/
/*************************************************************/
/* CODE BY MUHAMMAD RAFIQ FROM WWW.PAKISTANINTERACTIVES.COM */
/* SATURDAY 21 JULY 2008 - ALL RIGHTS RESERVED BY PAK INTER */
/************************************************************/
/************************************************************/

function validatePreviewBack()
{
	document.frm.method = "POST";
	document.frm.action = "index2.php?display=preview";
	document.frm.submit();
	return true;
}

function validatePreviewBack2()
{
	document.frm.method = "POST";
	document.frm.action = "index2.php?display=juniorpreview";
	document.frm.submit();
	return true;
}

function validatePreviewBack3()
{
	document.frm.method = "POST";
	document.frm.action = "index2.php?display=shipping";
	document.frm.submit();
	return true;
}

function doCheckOut(id)
{	
	document.frm.method = "POST";
	document.frm.action = "index2.php?display=checkout&vid="+id;
	document.frm.submit();
	return true;
}
function doCheckOutbyCheque(id)
{	
	document.frm.method = "POST";
	document.frm.action = "index2.php?display=bycheque&vid="+id;
	document.frm.submit();
	return true;
}

/////////////////////////// specials ////////////////////////////////////////
function validateFrmSpec()
{
//	alert("day=["+document.frm.p_day.value+"] - month=["+document.frm.p_month.value+"] - year=["+document.frm.p_year.value+"]");
	if(document.frm.p_name.value == "")
	{
		alert("Name Field missing ! ");
		document.frm.p_name.select();
		return false;		
	}
	if(document.frm.p_name.value == "Your Name")
	{
		alert("Name Field missing ! ");
		document.frm.p_name.select();
		return false;		
	}
	if(IsValidIDSpace(document.frm.p_name.value) == false)
	{
		alert("Invalid characters in Name Field! Only [a-z],[A-Z],[0-9],_,@,space allowed");
		document.frm.p_name.select();
		return false;		
	}
	if(document.frm.p_day.value == "")
	{
		alert("Day Field of DOB missing ! ");
		return false;		
	}
	if(document.frm.p_month.value == "")
	{
		alert("Month Field of DOB missing ! ");
		return false;		
	}
	if(document.frm.p_year.value == "")
	{
		alert("Year Field of DOB missing ! ");
		return false;		
	}
	
var tempid = 0;
	for(i=0;i<document.frm.rdSelect.length;i++)
	{
		if(document.frm.rdSelect[i].checked)
		{
		 	tempid = document.frm.rdSelect[i].value;
//			alert(tempid);
		}
	}
// place value in hidden fields in form ... 


/**************************************************/
/* CODE BY RAFIQ FROM PAKISTAN INTERACTIVES		 */
/*************************************************/
// parameters going on submitting this form are ..
// 1 - p_name      - for name of child
// 2 - p_day		- for day of dob
// 3 - p_month		- month of dob
// 4 - p_year		- year of dob
// 5 - hsize		- selected size of canvas
// 6 - ha			- canvas Color dispaly
// 7 - hb			- canvas Corners motif
// 8 - hc			- canvas prod - picture
// 9 - display		- new page display  = preview
/*************************************************/
/**************************************************/
//alert(document.frm.ha.value+" - "+document.frm.hb.value+" - "+document.frm.hc.value);

		document.frm.method = "POST";
		document.frm.action = "index2.php?display=preview&p_month="+document.frm.p_month.value+"&dv="+tempid;
		document.frm.submit();
		return true;
}
/////////////////////////// Favourite ////////////////////////////////////////
function validateFrmFav()
{
//	alert("day=["+document.frm.p_day.value+"] - month=["+document.frm.p_month.value+"] - year=["+document.frm.p_year.value+"]");
	
var tempid = 0;
	//	alert("day=["+document.frm.p_day.value+"] - month=["+document.frm.p_month.value+"] - year=["+document.frm.p_year.value+"]");
	if(document.frm.p_name.value == "")
	{
		alert("Name Field missing ! ");
		document.frm.p_name.select();
		return false;		
	}
	if(document.frm.p_name.value == "Your Name")
	{
		alert("Name Field missing ! ");
		document.frm.p_name.select();
		return false;		
	}
	if(IsValidIDSpace(document.frm.p_name.value) == false)
	{
		alert("Invalid characters in Name Field! Only [a-z],[A-Z],[0-9],_,@,space allowed");
		document.frm.p_name.select();
		return false;		
	}
	if(document.frm.p_day.value == "")
	{
		alert("Day Field of DOB missing ! ");
		return false;		
	}
	if(document.frm.p_month.value == "")
	{
		alert("Month Field of DOB missing ! ");
		return false;		
	}
	if(document.frm.p_year.value == "")
	{
		alert("Year Field of DOB missing ! ");
		return false;		
	}
	
	for(i=0;i<document.frm.rdSelect.length;i++)
	{
		if(document.frm.rdSelect[i].checked)
		{
			tempid = document.frm.rdSelect[i].value;
//			alert(tempid);			
		}
	}
	var size = "";
	for(i=0;i<document.frm.radiobutton.length;i++)
	{
		if(document.frm.radiobutton[i].checked)
		{
	//		alert(document.frm.radiobutton[i].value);
			size = document.frm.radiobutton[i].value;
		}
	}
	// place value in hidden fields in form ... 
	 document.frm.hsize.value = size;	
// place value in hidden fields in form ... 


		document.frm.method = "POST";
		document.frm.action = "cart.php?cart_action=add&canvas=favourite&dv=" + tempid;
		document.frm.submit();
		return true;
}
function toggleBillingInfo(trgForm)
{
	
	if (trgForm.SubmitBilling.checked == true)
    {		
        trgForm.txtRecName.value = trgForm.txtCusName.value;
        trgForm.txtRecAddress.value = trgForm.txtCusAddress.value;
        trgForm.txtRecCity.value = trgForm.txtCusCity.value;
        trgForm.cmbRecCountry.value = trgForm.cmbCusCountry.value;
        trgForm.txtRecPcode.value = trgForm.txtCusPcode.value;
        trgForm.txtRecPhone.value = trgForm.txtCusPhone.value;
    }
    else
    {
        trgForm.txtRecName.value = "";
        trgForm.txtRecAddress.value = "";
        trgForm.txtRecCity.value = "";
        trgForm.cmbRecCountry.value = "England";
        trgForm.txtRecPcode.value = "";
        trgForm.txtRecPhone.value = "";
    }
}

function deleteItem(number) {
  if (confirm('Are you sure?')) {
    url = "cart.php?cart_action=delete&number=" + number;
    window.location = url;
  } else {
  }
}