// JavaScript Document

// function for checking string
function checkString(str_temp, str_fld)
{
	temp=new String(str_temp);
	if(str_temp=="")
	{
		window.alert("Please enter the " + str_fld);
		return false;
	}

	if(temp.charAt(0)==" ")
	{
		window.alert("The " + str_fld + " cannot start with a space");
		return false;
	}

	str=new String("'\"");

	var flag=1;

	for (c=0; c<temp.length; c++)
	{
		if(str.indexOf(temp.charAt(c))>=0)
		{
			flag=0;
			break;
		}
	}

	if (flag==0)
	{
		window.alert("The " + str_fld + " cannot contain single/double quotes");
		return false;
	}
	return true;
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;

}

function IsZip(sText)
{
   var ValidChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;

}

// function for checking number
function checkNumber(str_temp, str_fld)
{
	temp=new String(str_temp);
	msg="";
	if(str_temp=="")
	{
		//window.alert("Please enter the " + str_fld);
		msg="Please enter the "+ str_fld;
		return msg;
	}

	if(temp.charAt(0)==" ")
	{
		//window.alert("The " + str_fld + " cannot start with a space");
		msg="Please enter the "+ str_fld + " cannot start with a space";
		return msg;
	}

	if (isNaN(str_temp))
	{
		//window.alert("The " + str_fld + " can contain only numbers");
		msg="Please enter the "+ str_fld + " can contain only numbers";
		return msg;
	}
	return msg;
}

// returns the filename(Thumbnail/Blowup name)
function funName(str_temp)
{
	temp=new String(str_temp);

	li=temp.lastIndexOf("\\");
	if(li!=-1)
	{
		li++;
		temp=temp.substr(li);
	}
	if(temp.indexOf(".")==-1)
	{
		return("");
	}
	return(temp);
}
//
function Trim(trimstr)
{
	if(trimstr.length < 1)
	{
		return"";
	}
	trimstr = RTrim(trimstr);
	trimstr = LTrim(trimstr);
	if(trimstr=="")
	{
		return "";
	}
	else
	{
		return trimstr;
	}
} //End Function

function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0)
	{
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} //End While
	return strTemp;
} //End Function

function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1)
	{
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;
	while(iTemp < v_length)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function
function checkspecialcharacter(str)
{
	var iChars = "!@#$%^&*()+=[]\\\';,./{}|\":<>? ";
	for (var i = 0; i < str.length; i++)
	{
		if (iChars.indexOf(str.charAt(i)) != -1)
		{
			return false;
		}
	}
}
function checkspecialcharfirstname(str)
{
	var iChars = "!@#$%^&*()+=[]\\;,./{}|\":<>?";
	for (var i = 0; i < str.length; i++)
	{
		if (iChars.indexOf(str.charAt(i)) != -1)
		{
			return false;
		}
	}
}
function checkspecialcharacterforname(str)
{
	var iChars = "!@#$%^&*()+=[]\\;/{}|\":<>?";
	for (var i = 0; i < str.length; i++)
	{
		if (iChars.indexOf(str.charAt(i)) != -1)
		{
			return false;
		}
	}
}
function checknumericcharacterforname(str)
{
	var iChars = "0123456789";
	for (var i = 0; i < str.length; i++)
	{
		if (iChars.indexOf(str.charAt(i)) != -1)
		{
			return false;
		}
	}
}
function checkspecialcharacterforaddress(str)
{
	var iChars = "!@#$%^&*()+=[]\\\;./{}|\":<>?";
	for (var i = 0; i < str.length; i++)
	{
		if (iChars.indexOf(str.charAt(i)) != -1)
		{
			return false;
		}
	}
}
function checkspecialcharacterfortitle(str)
{
	var iChars = "!@#$%^&*()+=[]\\\;./{}|\"<>?";
	for (var i = 0; i < str.length; i++)
	{
		if (iChars.indexOf(str.charAt(i)) != -1)
		{
			return false;
		}
	}
}

function checkspecialcharacterfordesc(str)
{
	var iChars = "";
	for (var i = 0; i < str.length; i++)
	{
		if (iChars.indexOf(str.charAt(i)) != -1)
		{
			return false;
		}
	}
}
function checkspecialcharacterforimage(str)
{
	var iChars = "!@#$%^&*()+=[]\';,/{}|\"<>?";
	for (var i = 0; i < str.length; i++)
	{
		if (iChars.indexOf(str.charAt(i)) != -1)
		{
			return false;
		}
	}
}
function checkspecialcharacterforUsername(str)
{
	var iChars = "!@^()+=[]\';,/{}|\"<>?";
	for (var i = 0; i < str.length; i++)
	{
		if (iChars.indexOf(str.charAt(i)) != -1)
		{
			return false;
		}
	}
}

function isEmailAddr(email)
{
	var result = false
  	var theStr = new String(email)
  	var index = theStr.indexOf("@");
 	if (index > 0)
  	{
    	var pindex = theStr.indexOf(".",index);
    	if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
 	}
  return result;
}
function emailfield(email)
{
	var msg="";
	if(!isEmailAddr(email))
	{
		msg="Please enter valid Email Address. e.g. name@domain.com";
	}
	else if(Trim(email)=="")
	{
		msg="Please mention your Email Address!";
	}
	return msg;
}
function namefield(name)
{
	var msg="";
	if(checkspecialcharacterforname(name)==false)
	{
		msg="Please do not mention special characters in name!"; //document.getElementById("divname").innerHTML
	}
	else if(Trim(name)=="")
	{
		msg="Please mention your name!";
	}
	else if(checknumericcharacterforname(name)==false)
	{
		msg="Please do not mention numeric characters in name!";
	}
	return msg;
}
function fnamefield(name)
{
	var msg="";
	if(checkspecialcharacterforname(name)==false)
	{
		msg="Please do not mention special characters in First Name!"; //document.getElementById("divname").innerHTML
	}
	else if(Trim(name)=="")
	{
		msg="Please mention First Name!";
	}
	else if(checknumericcharacterforname(name)==false)
	{
		msg="Please do not mention numeric characters in First Name!";
	}
	return msg;
}
function lnamefield(name)
{
	var msg="";
	if(checkspecialcharacterforname(name)==false)
	{
		msg="Please do not mention special characters in Surname!"; //document.getElementById("divname").innerHTML
	}
	else if(Trim(name)=="")
	{
		msg="Please include your Surname!";
	}
	else if(checknumericcharacterforname(name)==false)
	{
		msg="Please do not mention numeric characters in Surname!";
	}
	return msg;
}
function usernamefield(name)
{
	var msg="";
	if(checkspecialcharacterforUsername(name)==false)
	{
		msg="Please do not mention special characters in username!";
	}
	else if(Trim(name)=="")
	{
		msg="Please mention your username!";
	}
	else if(name.length < 5 )
	{
		msg="Username must have at least 5 characters!";
	}
	return msg;
}
function passwordfield(password, confirmpassword)
{
	var msg="";
	if(checkspecialcharacterforUsername(password)==false)
	{
		msg="Please do not mention special characters in Password!";
	}
	else if(Trim(password)=="")
	{
		msg="Please include your Password!";
	}
	else if(password.length < 5 )
	{
		msg="Password must have at least 5 characters!";
	}

	else if(password!=confirmpassword)
	{
		msg="Passwords don't match!";
	}

	return msg;
}

function titledfield(name,str)
{
	var msg="";
	if(checkspecialcharacterfortitle(name)==false)
	{
		msg="Please do not mention special characters in "+str + "!";
	}
	else if(Trim(name)=="")
	{
		msg="Please include your "+str + "!";
	}

	return msg;
}

function addressfield(name)
{
	var msg="";
	if(checkspecialcharacterforaddress(name)==false)
	{
		msg="Please do not mention special characters in Address!";
	}
	else if(Trim(name)=="")
	{
		msg="Please include your Address!";
	}
	return msg;
}
function validateFileExtension(fvalue)
 {
	var msg="";
	if(fvalue!="")
	{
		if(!/(\.jpg|\.jpeg\.JPG|\.JPEG)$/i.test(fvalue))
		 {

			msg="Please select a JPG file only.";

		}
	}
	return msg;
}
function logofilefield(name)
{
	var msg="";
	if(name!="")
	{
		if (name.toUpperCase().indexOf(".JPG") < 0 && name.toUpperCase().indexOf(".JPEG") < 0)
		{
			msg="Please select a JPG file only.";
		}
	}
	return msg;
}
function phonefield(phone, str)
{
	var msg="";
	var temp=phone;
	var stripped = temp.replace(/[\(\)\.\-\ ]/g, '');
	if (phone== "") {
        msg="Please provide "+str + "!";
    }
	else if (!IsNumeric(stripped)) {
        msg="Please enter numbers only!";
    }
	else if(Trim(phone)=="")
	{
		 msg="Please provide " + str + "!";
	}
	return msg;
}

function phonefieldnotcompulsory(phone, str)
{
	var msg="";
	var temp=phone;
	var stripped = temp.replace(/[\(\)\.\-\ ]/g, '');
	if (phone!= "")
	{
      //  msg=str + " can not be blank!";
		if (!IsNumeric(stripped)) {
			 msg="Please enter numbers only!";
		}
		else if(Trim(phone)=="")
		{
			 msg="Please provide " + str + "!";
		}
	 }
	return msg;
}

function zipfield(zip, str)
{
	var msg="";
	var temp=zip;
	var stripped = temp.replace(/[\(\)\.\-\ ]/g, '');
  	if (zip== "") {
        msg="Please include your " + str + "!";
    }
	else if (!IsZip(stripped)) {
        msg="Please do not mention special characters in "+str + "!";
    }
	else if(Trim(zip)=="")
	{
		 msg="Please include your " + str + "!";
	}
	/*else if(zip.length>6)
	{
		 msg=str + " no can contain only 6 digits!";
	}*/

	return msg;
}

function isWebSite(website)
{
	var result = false
  	var theStr = new String(website)
  	var index = theStr.indexOf(".");
 	if (index > 0)
  	{
    	result = true;
 	}

  return result;
}

function websitefield(website)
{
	var msg="";
	if (website== "") {
        msg="Please mention website!";
    }
	return msg;
}
function tocheckblankfield(str, field)
{
	var msg="";
	if (str== "") {
        msg="Please mention " + field + "!";
    }
	return msg;
}
function tocheckblankselection(str, field)
{
	var msg="";
	if (str== "") {
        msg="Please mention " + field + "!";
    }
	return msg;
}
function descriptionfield(website)
{
	var msg="";
	if (website== "") {
        msg="Please mention description!";
    }
	return msg;
}
function tocheckfiletype(filetype,file)
{
	var msg="";
	var temp=filetype.toUpperCase();
	var temp1=file.toUpperCase();
	if ((temp1.indexOf(temp)) < 0 )
	{
		msg="Please select " + filetype + " file";
	}
	return msg;
}


/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   }
   return this
}

function isDate(dtStr){
	dtStr=Trim(dtStr);
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strYear=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strDay=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	var msg="";
	if (pos1==-1 || pos2==-1){
		msg="The date format should be : mm/dd/yyyy";
	}
	if (strMonth.length<1 || month<1 || month>12){
		msg="Please enter a valid month";
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		msg="Please enter a valid day";
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		msg="Please enter a valid 4 digit year between "+ minYear +" and "+ maxYear;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		msg="Please enter a valid date";
	}
	return msg
}

function treatmentover()
	{
		document.getElementById("dropdown").style.display="block";
	}
function treatmentout()
	{
		document.getElementById("dropdown").style.display="none";
	}

function productsover()
{
		document.getElementById("prod_dropdown").style.display="block";
}
function productsout()
{
		document.getElementById("prod_dropdown").style.display="none";
}

function checkvalidation()
{
	if(document.frm_login.u_login.value=="" || document.frm_login.u_login.value=="Email Address")
	{
		//alert("Please provide your login email address!");
		document.getElementById("login_error").innerHTML="Please provide your login email address!";
		document.frm_login.u_login.focus();
		return false;
	}
	else if(!isEmailAddr(document.frm_login.u_login.value))
	{
		//alert("Email must be valid e.g. name@domain.com");
		document.getElementById("login_error").innerHTML="Please provide valid email address. e.g. name@domain.com";
		document.frm_login.u_login.focus();
		return false;
	}
	else if(document.frm_login.password.value=="" || document.frm_login.password.value=="Password")
	{
		//alert("Please check your password!");
		document.getElementById("login_error").innerHTML="Please check your password!";
		document.frm_login.password.focus();
		return false;
	}

	document.frm_login.action="index.php";
	document.frm_login.submit();

}

function checklogin()
{
	if(document.login_form.u_login.value=="" || document.login_form.u_login.value=="Email Address")
	{
		//alert("Please provide your login email address!");
		document.getElementById("divu_login").innerHTML="Please provide your login email address!";
		document.login_form.u_login.focus();
		return false;
	}
	else if(!isEmailAddr(document.login_form.u_login.value))
	{
		//alert("Email must be valid e.g. name@domain.com");
		document.getElementById("divu_login").innerHTML="Please provide valid email address. e.g. name@domain.com";
		document.login_form.u_login.focus();
		return false;
	}
	else if(document.login_form.password.value=="" || document.login_form.password.value=="Password")
	{
		//alert("Please check your password!");
		document.getElementById("divu_password").innerHTML="Please check your password!";
		document.login_form.password.focus();
		return false;
	}

	document.login_form.action="index.php";
	document.login_form.submit();

}

function onblur_login(name, val)
{
	if((name=="u_login") && (val=="Email Address"))
	{
		document.frm_login.u_login.value="";
		document.frm_login.u_login.focus();
		return false;
	}else if((name=="password") && (val=="Password"))
	{
		document.frm_login.password.value="";
		document.frm_login.password.focus();
		return false;
	}
	document.frm_login.action="index.php";
}
function onblurout_login(name, val)
{
	if((name=="u_login") && (val==""))
	{
		document.frm_login.u_login.value="Email Address";
		document.frm_login.u_login.focus();
		return false;
	}else if((name=="password") && (val==""))
	{
		document.frm_login.password.value="Password";
		document.frm_login.password.focus();
		return false;
	}
	document.frm_login.action="index.php";
}

 function logoutover()
  {
	document.getElementById("login").style.display="none";
	document.getElementById("logout").style.display="block";

	//document.frm_login.action="logout.php";
	//document.frm_login.submit();
  }
  function logingo()
  {
	document.getElementById("login").style.display="block";
	document.getElementById("logout").style.display="none";
  }

function validation()
{

	//First Name field validation
	firstname=fnamefield(document.getElementById("fname").value);
	document.getElementById("divfname").innerHTML=firstname;

	//Last Name field validation
	lastname=lnamefield(document.getElementById("lname").value);
	document.getElementById("divlname").innerHTML=lastname;

	//Email field validation
	email=emailfield(document.getElementById("email").value);
	document.getElementById("divemail").innerHTML=email;

	//Phone no field validation
	phone=phonefieldnotcompulsory(document.getElementById("phone").value,"Phone number");
	document.getElementById("divphone").innerHTML=phone;
	//phone=phonefield(document.getElementById("phone").value,"Phone number");
	//document.getElementById("divphone").innerHTML=phone;

	//Mobile no field validation
	mobile=phonefieldnotcompulsory(document.getElementById("mobile").value,"Mobile number");
	document.getElementById("divmobile").innerHTML=mobile;

	//Address field validation
	address=addressfield(document.getElementById("address").value);
	document.getElementById("divaddress").innerHTML=address;

	//Address field validation
	//address2=addressfield(document.getElementById("address2").value);
	//document.getElementById("divaddress2").innerHTML=address2;

	//City field validation
	city=titledfield(document.getElementById("city").value,"Town");
	document.getElementById("divcity").innerHTML=city;

	//Zip code field validation
	//zipx=zipfield(document.getElementById("zip").value,"Post Code");
	//alert(zipx);

	zipx=checkPostCode(document.getElementById("zip").value);

	if(zipx=='')
	{
		//document.getElementById("divzip").innerHTML="Please enter a valid UK Post Code!";
		//return false;
		zipx="";
	}
	else
	{
		//
		document.getElementById("zip").value=zipx;
		document.getElementById("divzip").innerHTML="";
		zipx="";
		//alert(zipx);
	}

	//Password field validation	//password, confirmpassword
	passwordx=passwordfield((document.getElementById("mypassword").value),(document.getElementById("confirm").value));
	document.getElementById("divpassword").innerHTML=passwordx;

	/*//Phone no field validation
	fax=phonefieldnotcompulsory(document.getElementById("fax").value,"Fax number");
	document.getElementById("divfax").innerHTML=fax;
	var securitycode;
	if(document.getElementById("security_code").value=="")
	{
		document.getElementById("divsecuritycode").innerHTML="Please enter security code.";
		securitycode=="false"
	}
	else
	{
		securitycode="";
	}
*/

	if( firstname=="" && lastname=="" && email=="" && phone=="" && mobile=="" && address=="" && city=="" && zipx=="" && passwordx=="")
	{
		return true;
	}
	else
	{
		return false;
	}
}


function editvalidation()
{

	//First Name field validation
	firstname=fnamefield(document.getElementById("fname").value);
	document.getElementById("divfname").innerHTML=firstname;

	//Last Name field validation
	lastname=lnamefield(document.getElementById("lname").value);
	document.getElementById("divlname").innerHTML=lastname;

	//Email field validation
	email=emailfield(document.getElementById("email").value);
	document.getElementById("divemail").innerHTML=email;

	//Phone no field validation
	phone=phonefieldnotcompulsory(document.getElementById("phone").value,"Phone number");
	document.getElementById("divphone").innerHTML=phone;
	//phone=phonefield(document.getElementById("phone").value,"Phone number");
	//document.getElementById("divphone").innerHTML=phone;

	//Mobile no field validation
	mobile=phonefieldnotcompulsory(document.getElementById("mobile").value,"Mobile number");
	document.getElementById("divmobile").innerHTML=mobile;

	//Address field validation
	address=addressfield(document.getElementById("address").value);
	document.getElementById("divaddress").innerHTML=address;

	//Address field validation
	//address2=addressfield(document.getElementById("address2").value);
	//document.getElementById("divaddress2").innerHTML=address2;

	//City field validation
	city=titledfield(document.getElementById("city").value,"Town");
	document.getElementById("divcity").innerHTML=city;

	//Zip code field validation
	zipx=checkPostCode(document.getElementById("zip").value);

	if(zipx==false)
	{
		document.getElementById("divzip").innerHTML="Please enter a valid UK postcode!";
		return false;
	}
	else
	{
		document.getElementById("zip").value=zipx;
		document.getElementById("divzip").innerHTML="";
		zipx="";
	}

	if( firstname=="" && lastname=="" && email=="" && phone=="" && mobile=="" && address=="" && city=="" && zipx=="")
	{
		return true;
	}
	else
	{
		return false;
	}
}



function validationpass()
{

	//Password field validation
	oldpass=titledfield(document.getElementById("oldpass").value,"Existing Password");
	document.getElementById("divoldpass").innerHTML=oldpass;

	//Password field validation	//password, confirmpassword
	newpass=passwordfield((document.getElementById("newpass").value),(document.getElementById("confirmpass").value));
	document.getElementById("divpassword").innerHTML=newpass;

	if(oldpass=="" && newpass=="")
	{
		return true;
	}
	else
	{
		return false;
	}
}
 function editmyaccount()
  {
	document.getElementById("displayfirst").style.display="none";
	document.getElementById("displaysecond").style.display="block";
	document.getElementById("displaythird").style.display="none";
  }

  function editpassword()
  {
	document.getElementById("displayfirst").style.display="none";
	document.getElementById("displaysecond").style.display="none";
	document.getElementById("displaythird").style.display="block";
  }

 function validationcontact()
{

	//Name field validation
	firstname=namefield(document.getElementById("name").value);
	document.getElementById("divname").innerHTML=firstname;


	//Email field validation
	email=emailfield(document.getElementById("email").value);
	document.getElementById("divemail").innerHTML=email;

	//Phone no field validation
	phone=phonefieldnotcompulsory(document.getElementById("phone").value,"Phone number");
	document.getElementById("divphone").innerHTML=phone;
	//phone=phonefield(document.getElementById("phone").value,"Phone number");
	//document.getElementById("divphone").innerHTML=phone;

	//City field validation
	city=titledfield(document.getElementById("city").value,"Town");
	document.getElementById("divcity").innerHTML=city;


	if( name=="" && email=="" && phone=="" && city=="")
	{
		return true;
	}
	else
	{
		return false;
	}
}


function validationnewsletter()
{

	//Name field validation
	newsname=namefield(document.getElementById("newsname").value);
	document.getElementById("divnewsname").innerHTML=newsname;

	//Email field validation
	newsemail=emailfield(document.getElementById("newsemail").value);
	document.getElementById("divnewsemail").innerHTML=newsemail;


	if( newsname=="" && newsemail=="")
	{
		return true;
	}
	else
	{
		return false;
	}
}

function confirmdelete(productid)
{

	var agree=confirm("Are you sure, you want to remove the item from the basket?");
	if(agree)
	{
		document.location.href='index.php?action=delete&id='+productid;
		return true ;
	}
	else
	{
		return false ;
	}


}


//Application:   Utility Function
//Author:        John Gardner

function checkPostCode (toCheck) {

  // Permitted letters depend upon their position in the postcode.
  var alpha1 = "[abcdefghijklmnoprstuwyz]";                       // Character 1
  var alpha2 = "[abcdefghklmnopqrstuvwxy]";                       // Character 2
  var alpha3 = "[abcdefghjkstuw]";                                // Character 3
  var alpha4 = "[abehmnprvwxy]";                                  // Character 4
  var alpha5 = "[abdefghjlnpqrstuwxyz]";                          // Character 5

  // Array holds the regular expressions for the valid postcodes
  var pcexp = new Array ();

  // Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA
  pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1,2})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));

  // Expression for postcodes: ANA NAA
  pcexp.push (new RegExp ("^(" + alpha1 + "{1}[0-9]{1}" + alpha3 + "{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));

  // Expression for postcodes: AANA  NAA
  pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1}" + alpha4 +"{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));

  // Exception for the special postcode GIR 0AA
  pcexp.push (/^(GIR)(\s*)(0AA)$/i);

  // Standard BFPO numbers
  pcexp.push (/^(bfpo)(\s*)([0-9]{1,4})$/i);

  // c/o BFPO numbers
  pcexp.push (/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i);

  // Overseas Territories
  pcexp.push (/^([A-Z]{4})(\s*)(1ZZ)$/i);

  // Load up the string to check
  var postCode = toCheck;

  // Assume we're not going to find a valid postcode
  var valid = false;

  // Check the string against the types of post codes
  for ( var i=0; i<pcexp.length; i++) {
    if (pcexp[i].test(postCode)) {

      // The post code is valid - split the post code into component parts
      pcexp[i].exec(postCode);

      // Copy it back into the original string, converting it to uppercase and
      // inserting a space between the inward and outward codes
      postCode = RegExp.$1.toUpperCase() + " " + RegExp.$3.toUpperCase();

      // If it is a BFPO c/o type postcode, tidy up the "c/o" part
      postCode = postCode.replace (/C\/O\s*/,"c/o ");

      // Load new postcode back into the form element
      valid = true;

      // Remember that we have found that the code is valid and break from loop
      break;
    }
  }

  // Return with either the reformatted valid postcode or the original invalid
  // postcode
  if (valid) {return postCode;} else return false;
}

function paginate(start,nval,num)
{
	if(nval==1)
	{
		start=start+num;
		document.frm.start.value=start;
		document.frm.action="press-detail.php";
		document.frm.submit();
	}
	else if(nval==2)
	{
		start=start-num;
		document.frm.start.value=start;
		document.frm.action="press-detail.php";
		document.frm.submit();
	}
}

function paginate1(start,nval,num)
{
	if(nval==1)
	{
		start=start+num;
		document.frmlife.start.value=start;
		document.frmlife.action="your-lifestyle-detailed.php";
		document.frmlife.submit();
	}
	else if(nval==2)
	{
		start=start-num;
		document.frmlife.start.value=start;
		document.frmlife.action="your-lifestyle-detailed.php";
		document.frmlife.submit();
	}
}

/*function paginate(start,nval,num,pagename)
{
	if(nval==1)
	{
		start=start+num;
		document.frm.start.value=start;
		document.frm.action=pagename;
		document.frm.submit();
	}
	else if(nval==2)
	{
		start=start-num;
		document.frm.start.value=start;
		document.frm.action=pagename;
		document.frm.submit();
	}
}
*/
function update_delivery_cost(){
	var str;
	var position;
	var del_type;
	str = document.getElementById("delivery_option").value;
	position = str.indexOf(":");
	del_price = str.substring(0,position)
	document.getElementById("del_price").value = del_price;
	document.getElementById("del_date").value = '';
}
/**
 *
 * @access public
 * @return void
 **/