//USE THIS FUNCTION FOR CHECKING THE EMAIL IS VALIDATED OR NOT

function isEmail(strEMail) //validations for email

{

	var strInvalidChars,blnTemp,i,strTemp,intdot,IsMail,strEMailRev,intAtTheRate;

    intdot = strEMail.lastIndexOf(".");

	if (intdot == -1 )

		return false;

    

	intdot=strEMail.length-intdot-1;

	if (intdot < 2 )

		return false;

    
    // Disallowed characters
    strInvalidChars = "!#$%^&*()=+{}[]|\;:'/?>,< ";

	intAtTheRate = strEMail.indexOf("@") ;

    // Check that there is at least one '@' and a character before @
    if (intAtTheRate < 1)
		blnTemp=true;
	else
		blnTemp=false;

    if (blnTemp)
		return !blnTemp;
	
	// Check that there is at least one '.' in the form a@a.com
    blnTemp = (strEMail.indexOf(".") < 3);
   if (blnTemp)
		return !blnTemp;

	//   Check that there is at least one char between '.' and @ after @
	intdot= strEMail.indexOf(intAtTheRate+1,".");
	blnTemp = (intdot==2);
     if (blnTemp)
		return !blnTemp;

	//   Check that there is at least one char between '.' and @ before @
    blnTemp = (strEMail.substring(intAtTheRate - 1, intAtTheRate) == ".");
    if (blnTemp)
		return !blnTemp;

	//  and that the length is at least six (a@a.co)
    blnTemp = (strEMail.length < 6);
   if (blnTemp) 
		return !blnTemp;
	//  Check that there is only one '@'
    blnTemp = (intAtTheRate != strEMail.lastIndexOf("@"));
    
   if (blnTemp)
	return !blnTemp;
   //    extra checks
  //     AFTER '@' space is not allowed
	strTemp=strEMail.substring(intAtTheRate+1);
	blnTemp = (strTemp.indexOf(" ") > 0);
   if (blnTemp) 
		return !blnTemp;


  //   Check that there is one dot AFTER '@'

    blnTemp = (strTemp.indexOf(".") == 0);

   if (blnTemp)

		return !blnTemp;

    

	//    Check if there's a quote (")

    blnTemp = strEMail.indexOf("\"") > 0;

     if (blnTemp )

		return !blnTemp;

    

	//     Check if there's any other disallowed chars

	//     optimize a little if strEMail longer than strInvalidChars

	//     check the other way around

    if (strEMail.length > strInvalidChars.length)

	{

        for(var i = 0; i< strInvalidChars.length;i++)

		{

            if (strEMail.indexOf(strInvalidChars.substring(i,i+1)) > 0 )

                  blnTemp = true;

            if (blnTemp )

				break;

        } //end for

    } //end if

	else

	{

        for(var i = 0 ;i< strEMail.length;i++)

		{

            if (strInvalidChars.indexOf(strEMail.substring(i,i+1)) > 0) 

                  blnTemp = true;

            if (blnTemp )

				break;

        } //end for

    } //end else

    if (blnTemp)

		return !blnTemp;

    

	//     extra check

	 //    no two consecutive dots

    blnTemp = strEMail.indexOf("..") > 0;

    if (blnTemp)

		return !blnTemp;

    

	//    if any of the above are true, invalid e-mail

    return !blnTemp;



}

//USE THIS FUNTION TO CHECK WHETHER THE INPUT IS NUMERIC OR NOT

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;

   

   }



//USE THIS FUNTION TO REPLICATE THE VALUES FROM BILLING DETAILS TO DELIVERY DETAILS

function replicate(obj1,obj2){

obj2.value = obj1.value;

}

//USE THIS FUNCTION TO REPLICATE THE COUNTRY SELECTED FROM BILLING COUNTRY TO DELIVERY COUNTRY

function replicateCountry(obj1,obj2){

obj2.options.selectedIndex= obj1.options.selectedIndex;

}

//USE THIS FUNCTION TO DISABLE THE OTHER OPTION SELECTED WILE SELECTING THE SUBSCRIPTION OFFERS

function disab(val, frm, u){

//alert(val);	

if(u != 1){

	if(val == 1){

		frm.Offer2.selectedIndex="0";

		frm.Offer3.selectedIndex="0";

		frm.Offer1.disabled=false;

		frm.Offer2.disabled=true;

		frm.Offer3.disabled=true;

	}

	if(val == 2){

		frm.Offer1.selectedIndex="0";

		frm.Offer3.selectedIndex="0";

		frm.Offer1.disabled=true;

		frm.Offer2.disabled=false;

		frm.Offer3.disabled=true;

	}

	if(val == 3){

		frm.Offer1.selectedIndex="0";

		frm.Offer2.selectedIndex="0";

		frm.Offer2.disabled=true;

		frm.Offer1.disabled=true;

		frm.Offer3.disabled=false;		

	}

}	

}

//USE THIS FUNCTION TO CHECK OR UNCHECK THE VALUES FROM DELIVERY ADDRESS TO BILLING ADDRESS
function ValidateDetails(formnm,obj)	{

if (obj.checked == false)	{

	formnm.name.value = "";

	formnm.designation.value = "";

	formnm.company.value = "";

	formnm.dob.value = "";

	formnm.address_1.value = "";

	formnm.address_2.value = "";

	formnm.address_3.value = "";

	formnm.city.value = "";

	formnm.cmb_country.options.selectedIndex= "0";

	formnm.pincode.value = "";

	formnm.phone_1.value = "";

	formnm.phone_2.value = "";

	formnm.isdcode_1.value = "";

	formnm.isdcode_2.value = "";

	formnm.stdcode_1.value = "";

	formnm.stdcode_2.value = "";

	formnm.faxisdcode.value = "";

	formnm.faxcode.value = "";

	formnm.fax.value = "";

	formnm.state.value = "";

}	else {

	formnm.name.value = formnm.pay_name.value;

	formnm.designation.value =formnm.pay_designation.value;

	formnm.company.value =formnm.pay_company.value;

	formnm.dob.value =formnm.pay_dob.value;

	formnm.address_1.value =formnm.pay_address_1.value;

	formnm.address_2.value =formnm.pay_address_2.value;

	formnm.address_3.value =formnm.pay_address_3.value;

	formnm.city.value =formnm.pay_city.value;

	formnm.state.value =formnm.pay_state.value;

	//formnm.cmb_country.value =formnm.pay_cmb_country.value;

	formnm.pincode.value =formnm.pay_pincode.value;

	formnm.phone_1.value =formnm.pay_phone_1.value;

	formnm.phone_2.value =formnm.pay_phone_2.value;

	formnm.isdcode_1.value =formnm.pay_isdcode_1.value;

	formnm.isdcode_2.value =formnm.pay_isdcode_2.value;

	formnm.stdcode_1.value =formnm.pay_stdcode_1.value;

	formnm.stdcode_2.value =formnm.pay_stdcode_2.value;

	formnm.faxisdcode.value =formnm.pay_faxisdcode.value;

	formnm.faxcode.value =formnm.pay_faxcode.value;

	formnm.fax.value =formnm.pay_fax.value;

	formnm.state.value =formnm.pay_state.value;

}

}

//USE THIS FUNTION TO RESET ALL THE VALUES FROM BILLING ADDRESS

function ClearSubForm(formnm)	{

	formnm.name.value = "";

	formnm.designation.value = "";

	formnm.company.value = "";

	formnm.dob.value = "";

	formnm.address_1.value = "";

	formnm.address_2.value = "";

	formnm.address_3.value = "";

	formnm.city.value = "";

	formnm.state.value = "";

	formnm.cmb_country.options.selectedIndex= "0";

	formnm.pincode.value = "";

	formnm.phone_1.value = "";

	formnm.phone_2.value = "";

	formnm.stdcode_1.value = "";

	formnm.stdcode_2.value = "";

	formnm.faxcode.value = "";

	formnm.fax.value = "";

	formnm.pay_name.value = "";

	formnm.pay_designation.value = "";

	formnm.pay_company.value = "";

	formnm.pay_dob.value = "";

	formnm.pay_address_1.value = "";

	formnm.pay_address_2.value = "";

	formnm.pay_address_3.value = "";

	formnm.pay_city.value = "";

	formnm.pay_state.value = "";

	formnm.pay_cmb_country.options.selectedIndex= "0";

	formnm.pay_pincode.value = "";

	formnm.pay_phone_1.value = "";

	formnm.pay_phone_2.value = "";

	formnm.pay_stdcode_1.value = "";

	formnm.pay_stdcode_2.value = "";

	formnm.pay_faxcode.value = "";

	formnm.pay_fax.value = "";

}

//USE THIS FUNCTION TO CHECK THE VALIDATION OF THE DATA BEING PROVIDED

function subformsubcheck(){

var errmsg="";

ltrim = /^\s+/ ;

rtrim = /\s+$/ ;

txt = /^[a-zA-Z\s]+$/i;

digit = /^[0-9]+$/i;



var selected;

var optcnt = 0;

var selradio = 0;

for (var i=0;i < document.subscribesubmit.elements.length;i++)	{

	if (document.subscribesubmit.elements[i].type== "radio")		{

		if (document.subscribesubmit.elements[i].checked == true)	{

			optcnt++;

			selradio=i;

	
		}

	}

}

if (optcnt == 0) errmsg+="- Subscription Period\n";



if(selradio==0 || selradio==2 || selradio==4)

{

	if(selradio==0)

	{

	 if(document.subscribesubmit.Offer1.value==0)

		{

		 errmsg+="- You have not chosen Special Offer\n";

		}

	}

	else if(selradio==2)

	{

	 if(document.subscribesubmit.Offer2.value==0)

		{

		 errmsg+="- You have not chosen Special Offer\n";

		}

	}

	else if(selradio==4)

	{

		if(document.subscribesubmit.Offer3.value==0)

		{

			 errmsg+="- You have not chosen Special Offer\n";

		}

	}

}

// checkMail()

var x = document.subscribesubmit.email.value;

if(document.subscribesubmit.email.value == "")

{

	errmsg += "- Enter Email\n";

}

else if(!(isEmail(document.subscribesubmit.email.value)))

{

	errmsg += "- Enter Valid Email\n";

}



	name = document.subscribesubmit.pay_name.value;

	name = name.replace(rtrim,'');

	name = name.replace(ltrim,'');

	if (name=="") errmsg+="- Delivery Name\n";

	else if( !name.match( txt ) ) errmsg+="- Invalid Delivery Name\n";



	dob = document.subscribesubmit.pay_dob.value;

	dob = dob.replace(rtrim,'');

	dob = dob.replace(ltrim,'');

	if(dob == "")

	{

		errmsg += "- Date of Birth\n";

	}

	else if (!isDate(dob))

	{

		errmsg+="- Invalid Date Of Birth\n";

	}



	address_1 = document.subscribesubmit.pay_address_1.value;

	address_1 = address_1.replace(rtrim,'');

	address_1 = address_1.replace(ltrim,'');

	if (address_1=="") errmsg+="- Address\n";



	city = document.subscribesubmit.pay_city.value;

	city = city.replace(rtrim,'');

	city = city.replace(ltrim,'');

	if (city=="") errmsg+="- City\n"; 

	else if( !city.match( txt ) ) errmsg+="- Invalid  City\n";



	state = document.subscribesubmit.pay_state.value;

	state = state.replace(rtrim,'');

	state = state.replace(ltrim,'');

	if (state=="") errmsg+="- State\n";

	else if( !state.match( txt ) )  errmsg+="- Invalid  State\n";



	pincode = document.subscribesubmit.pay_pincode.value;

	pincode = pincode.replace(rtrim,'');

	pincode = pincode.replace(ltrim,'');

	if (pincode=="") errmsg+="- Pincode\n";

	else 
	{

		if(document.subscribesubmit.u.value != "1")
		{
			if( !pincode.match( digit ) ) errmsg+="- Invalid Pincode\n";
		}
	}

	country = document.subscribesubmit.pay_cmb_country.value;

	country = country.replace(rtrim,'');

	country = country.replace(ltrim,'');

	if (country =="") errmsg+="-  Country\n";



	isdcode_1 = document.subscribesubmit.pay_isdcode_1.value;

	isdcode_1 = isdcode_1.replace(rtrim,'');

	isdcode_1 = isdcode_1.replace(ltrim,'');

	if (isdcode_1=="") errmsg+="- ISD Code\n";

	else if (isdcode_1.length > 5) errmsg+="- ISD Code for phone 1 should be less than 6 digits\n";

//	else if( !isdcode_1.match( digit ) )  errmsg+="- Enter valid Delivery ISD Code\n";



	stdcode_1 = document.subscribesubmit.pay_stdcode_1.value;

	stdcode_1 = stdcode_1.replace(rtrim,'');

	stdcode_1 = stdcode_1.replace(ltrim,'');

	if (stdcode_1=="")	errmsg+="-  STD Code\n";

	else if (stdcode_1.length > 5) errmsg+="- STD Code for phone 1 should be less than 6 digits\n"

//	if( !stdcode_1.match( digit ) ) errmsg+="- Invalid Delivery STD Code for Phone number 1\n";



	phone_1 = document.subscribesubmit.pay_phone_1.value;

	phone_1 = phone_1.replace(rtrim,'');

	phone_1 = phone_1.replace(ltrim,'');

	if (phone_1=="") errmsg+="- Phone number\n";

	else if (phone_1.length < 6 ) errmsg+="- Phone number 1 should be more than 6 digits\n";



	//else if( !phone_1.match( digit ) || phone_1.length < 6 ) errmsg+="- Invalid Phone number 1\n";



	isdcode_2 = document.subscribesubmit.pay_isdcode_2.value;

	stdcode_2 = document.subscribesubmit.pay_stdcode_2.value;

	phone_2 = document.subscribesubmit.pay_phone_2.value;



	if(isdcode_2 != '' && stdcode_2 != '' && phone_2 != ''){

		isdcode_2 = isdcode_2.replace(rtrim,'');

		isdcode_2 = isdcode_2.replace(ltrim,'');

		if (isdcode_2=="") errmsg+="-  ISD Code for Phone 2\n";

		else if (isdcode_2.length > 5) errmsg+="- ISD Code for phone 2 should be less than 6 digits\n";

		//if( !isdcode_2.match( digit ) )  errmsg+="- Enter valid Delivery ISD Code\n";



		stdcode_2 = stdcode_2.replace(rtrim,'');

		stdcode_2 = stdcode_2.replace(ltrim,'');

		if (stdcode_2=="")	errmsg+="- STD Code for Phone 2\n";

		if (stdcode_2.length > 5) errmsg+="- STD Code for phone 2 should be less than 6 digits\n"

		//if( !stdcode_2.match( digit ) ) errmsg+="- Invalid Delivery STD Code for Phone number 2\n";



		phone_2 = phone_2.replace(rtrim,'');

		phone_2 = phone_2.replace(ltrim,'');

		if (phone_2=="") errmsg+="- Phone number 2\n";

		else if (phone_2.length < 6 ) errmsg+="- Phone number 2 cannot be less than 6 digits\n";



		//if( !phone_2.match( digit ) ) errmsg+="- Invalid Delivery Phone number 2\n";

	}



	pay_faxisdcode = document.subscribesubmit.pay_faxisdcode.value;

	pay_faxcode = document.subscribesubmit.pay_faxcode.value;

	pay_fax = document.subscribesubmit.pay_fax.value;

	if(pay_faxisdcode != '' && pay_faxcode != '' && pay_fax != '')

	{

		pay_faxisdcode = pay_faxisdcode.replace(rtrim,'');

		pay_faxisdcode = pay_faxisdcode.replace(ltrim,'');

		if (pay_faxisdcode =="")	errmsg+="- STD Code\n";

		else if (pay_faxisdcode .length > 5) errmsg+="- ISD Code for Fax Number should less than 6 digits\n"

		//if( !pay_faxisdcode .match( digit ) ) errmsg+="- Invalid Delivery ISD Code for pay fax number 1\n";



		pay_faxcode = pay_faxcode.replace(rtrim,'');

		pay_faxcode = pay_faxcode.replace(ltrim,'');

		if (pay_faxcode =="")	errmsg+="- STD Code\n";

		else if (pay_faxcode .length > 5) errmsg+="- STD Code for Fax Number should be less than 6 digits \n"

		//if( !pay_faxcode .match( digit ) ) errmsg+="- Invalid Delivery STD Code for pay fax number \n";



		pay_fax = pay_fax.replace(rtrim,'');

		pay_fax = pay_fax.replace(ltrim,'');

		if (pay_fax=="") errmsg+="- Fax number\n";

		else if (pay_fax.length < 6 ) errmsg+="- Fax number cannot be less than 6 digits\n";

		//if( !pay_fax.match( digit ) ) errmsg+="- Invalid Delivery pay fax number 2\n";

	}





if(document.subscribesubmit.ch_same_det.checked == false)

{

	errmsg+="\n";

	name = document.subscribesubmit.name.value;

	name = name.replace(rtrim,'');

	name = name.replace(ltrim,'');

	if (name=="") errmsg+="- Delivery Name\n";

	else if( !name.match( txt ) ) errmsg+="- Invalid Delivery Name\n";



	dob = document.subscribesubmit.dob.value;

	dob = dob.replace(rtrim,'');

	dob = dob.replace(ltrim,'');

	if(dob == "")

	{

		errmsg += "- Date of Birth\n";

	}

	else if (!isDate(dob))

	{

		errmsg+="- Invalid Date Of Birth\n";

	}	



	address_1 = document.subscribesubmit.address_1.value;

	address_1 = address_1.replace(rtrim,'');

	address_1 = address_1.replace(ltrim,'');

	if (address_1=="") errmsg+="- Delivery Address\n";



	

	city = document.subscribesubmit.city.value;

	city = city.replace(rtrim,'');

	city = city.replace(ltrim,'');

	if (city=="") errmsg+="- Delivery City\n"; 

	else if( !city.match( txt ) ) errmsg+="- Invalid Delivery City\n";



	state = document.subscribesubmit.state.value;

	state = state.replace(rtrim,'');

	state = state.replace(ltrim,'');

	if (state=="") errmsg+="- Delivery State\n";

	else if( !state.match( txt ) )  errmsg+="- Invalid Delivery State\n";

	

	pincode = document.subscribesubmit.pincode.value;

	pincode = pincode.replace(rtrim,'');

	pincode = pincode.replace(ltrim,'');

	if (pincode=="") errmsg+="- Delivery Pincode\n";

	else

	{

		if(document.subscribesubmit.u.value != "1")

		{

			if( !pincode.match( digit ) ) errmsg+="- Invalid Pincode\n";

		}

	}

	

	

	country = document.subscribesubmit.cmb_country.value;

	country = country.replace(rtrim,'');

	country = country.replace(ltrim,'');

	if (country =="") errmsg+="- Delivery Country\n";

	

	isdcode_1 = document.subscribesubmit.isdcode_1.value;

	isdcode_1 = isdcode_1.replace(rtrim,'');

	isdcode_1 = isdcode_1.replace(ltrim,'');

	if (isdcode_1=="") errmsg+="- Delivery ISD Code\n";

	else if (isdcode_1.length > 5)  errmsg+="- Delivery ISD Code for phone 1 should be less than 6 digits\n";

	//if( !isdcode_1.match( digit ) )  errmsg+="- Enter valid ISD Code\n";

	

	stdcode_1 = document.subscribesubmit.stdcode_1.value;

	stdcode_1 = stdcode_1.replace(rtrim,'');

	stdcode_1 = stdcode_1.replace(ltrim,'');

	if (stdcode_1=="")	errmsg+="- Delivery STD Code for Phone 1\n";

	else if (stdcode_1.length > 5) errmsg+="- Delivery STD Code for Phone 1 should be less than 6 digits \n"

	//if( !stdcode_1.match( digit ) ) errmsg+="- Invalid STD Code for Phone number 1\n";





	phone_1 = document.subscribesubmit.phone_1.value;

	phone_1 = phone_1.replace(rtrim,'');

	phone_1 = phone_1.replace(ltrim,'');

	if (phone_1=="") errmsg+="- Delivery Phone number 1\n";

	else if (phone_1.length < 6 ) errmsg+="- Delivery Phone 1 cannot be less than 6 digits\n";

	//else if( !phone_1.match( digit ) || phone_1.length < 6 ) errmsg+="- Invalid Delivery Phone number 1\n";

	

	isdcode_2 = document.subscribesubmit.isdcode_2.value;

	stdcode_2 = document.subscribesubmit.stdcode_2.value;

	phone_2 = document.subscribesubmit.phone_2.value;



	if(isdcode_2 != '' && stdcode_2 != '' && phone_2 != '')

	{

		isdcode_2 = isdcode_2.replace(rtrim,'');

		isdcode_2 = isdcode_2.replace(ltrim,'');

		if (isdcode_2=="") errmsg+="- Delivery ISD Code\n";

		else if( isdcode_2.length > 5)  errmsg+="- Delivery  ISD Code for phone 2 should be less than 6 digits\n";



		stdcode_2 = stdcode_2.replace(rtrim,'');

		stdcode_2 = stdcode_2.replace(ltrim,'');

		if (stdcode_2=="")	errmsg+="- Delivery STD Code\n";

		else if(stdcode_2.length > 5 ) errmsg+="- Delivery STD Code for Phone 2 should be less than 6 digits \n";



		phone_2 = phone_2.replace(rtrim,'');

		phone_2 = phone_2.replace(ltrim,'');

		if (phone_2=="") errmsg+="- Delivery Phone number\n";	

		else if (phone_2.length < 6) errmsg+="- Delivery Phone 2 cannot be less than 6 digits\n";

	}



	faxisdcode = document.subscribesubmit.faxisdcode.value;

faxcode = document.subscribesubmit.faxcode.value;

fax = document.subscribesubmit.fax.value;

if(faxisdcode != '' && faxcode != '' && fax != ''){

	faxisdcode = faxisdcode.replace(rtrim,'');

	faxisdcode = faxisdcode.replace(ltrim,'');

	if (faxisdcode =="")	errmsg+="- Delivery STD Code\n";

	else if (faxisdcode .length > 5) errmsg+="- Delivery ISD Code for Fax should be less than 6 digits\n"

	//if( !faxisdcode .match( digit ) ) errmsg+="- ISDD Code for fax number 1\n";



	faxcode = faxcode.replace(rtrim,'');

	faxcode = faxcode.replace(ltrim,'');

	if (faxcode =="")	errmsg+="- Delivery STD Code\n";

	else if (faxcode .length > 5) errmsg+="- Delivery STD Code for Fax Number should be less than 6 digits \n"

	//if( !faxcode .match( digit ) ) errmsg+="- STD Code for Faxnumber 2\n";



	fax = fax.replace(rtrim,'');

	fax = fax.replace(ltrim,'');

	if (fax=="") errmsg+="- Delivery Fax number\n";

	else if (fax.length < 6 ) errmsg+="- Delivery Fax number cannot be less than 6 digits\n";

	

}



	





	

	pay_designation = document.subscribesubmit.pay_designation.value;

	//if (pay_designation=="") errmsg+="- pay_designation\n";

	if (pay_designation!=""){

		pay_designation = pay_designation.replace(rtrim,'');

		pay_designation = pay_designation.replace(ltrim,'');

		if( !pay_designation.match( txt ) )  errmsg+="- pay designation\n";

	}	

}



	

if (errmsg!="") {

	alert("Please make the following corrections before subscription can be complete \n"+errmsg);

	return false;

}

}



	

function isDate(dateStr) {



var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;

var matchArray = dateStr.match(datePat); // is the format ok?



if (matchArray == null) {

//alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");

return false;

}



day = matchArray[1]; // p@rse date into variables

month = matchArray[3];

year = matchArray[5];

/*alert(day);

alert(month);

alert(year);*/



if (month < 1 || month > 12) { // check month range

//alert("Month must be between 1 and 12.");

return false;

}



if (day < 1 || day > 31) {

//alert("Day must be between 1 and 31.");

return false;

}



if ((month==4 || month==6 || month==9 || month==11) && day==31) {

//alert("Month "+month+" doesn`t have 31 days!")

return false;

}



if (month == 2) { // check for february 29th

var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));

if (day > 29 || (day==29 && !isleap)) {

//alert("February " + year + " doesn`t have " + day + " days!");

return false;

}

}

return true; // date is valid

}

//following functions are used in feedback_middle.inc.php

	function sub_other()
	{
		if(document.frm1.subject.value != "Other")
		{
			document.frm1.other_subject.value="";
			document.frm1.other_subject.disabled = true;
			
		}
		else
		{
			document.frm1.other_subject.disabled = false;
			document.frm1.other_subject.value="";
			
		}
	}

	function disable()
	{
		if((document.frm1.subject.value == "1") ||(document.frm1.subject.value == "2") ||(document.frm1.subject.value == "3") ||(document.frm1.subject.value == "4") ||(document.frm1.subject.value == "5") ||(document.frm1.subject.value == "6"))
		{
			document.frm1.other.disabled=true;
		}
		else
		{
			document.frm1.other.disabled=false;
		}
	}
	function subject()
	{
		if(document.frm1.subject.value == "0")
		{
			alert("Select Subject");
			return false
		}
		else if(document.frm1.subject.value == "7")
		{
			str = document.frm1.other.value
			if(str == "")
			{
				alert("Enter Subject");
				document.frm1.other.focus();
				return false
			}
		}
		return true
	}
	function isvalid_email()
	{
		//str = document.frm1.em1.value
		str = document.frm1.email.value;
				if(str != "")
				{
					len = str.length
					for(i=1;i<=len;i++)
					{
						if (str.charAt(i) == "@" )
						{
							for(j=1; j<(len-2); j++)
							{
								if (str.charAt(j) == ".")
								{
									return true
								}
							}
						}
					}
					alert("Enter Valid Email Address");
					return false
				}
				else
				{
					alert("Enter Email Address");
					return false
				}
			}
	function isvalid_name()
	{
		str = document.frm1.name.value
		if(str == "")
		{
			alert("Enter your Name");
			return false
		}
			return true
	}
	function isvalid_msg()
	{
		str = document.frm1.message.value
		if(str == "")
		{
			alert("Enter Message");
			return false
		}
			return true
	}
	function quoteChk2()
	{	
		event.keyCode=quoteDisallow22(event.keyCode)	
	}
	function quoteDisallow22(keyPressed)
	{
		if((keyPressed < 48) || (keyPressed > 57))
		{
			keyPressed = 0
		}
		else
		{
			return keyPressed
		}
	}
	function isvalid_telephone()
	{
		if((document.frm1.std1.value == "") || (document.frm1.phone1.value == ""))
		{
			alert("Enter Phone Nmber");
			return false
		}
			return true
	}

//************** function for validation Phone numbers *****************
function isTelNo()
{
  // Name      : isPhoneNo
  // Purpose   : allow user to enter value in phone numbers with only "-" and "." .
  // Inputs    : tmp_str -> string for validation.
  // Outputs   : return 1 -> if form field is as phone no format.
  //		 return -1 -> if form field is not as phone no format.
var tmp_str = document.frm1.phone.value;
var Chars = "0123456789+-.";
 var flag=0;

      for (var i = 0; i < tmp_str.length; i++)
      {
          // Check that current character is number.
          var c = tmp_str.charAt(i);

          if (Chars.indexOf(c) == -1)
          	flag = 1;
      }  
	 
      if(flag)
      {
		alert("Enter valid Phone Number");
		return false;
		
      }	  
	  else
	  {
		//alert("TEST");
		return true;
		
	  }
}
function processform()
{
		
		if (!isvalid_name(document.frm1.name.value)) return false;
		
		 if(document.frm1.phone.value=='')
			{
				alert("Enter Phone Number");
				return false;

			}
		
		if (!isTelNo(document.frm1.phone.value)) return false;
		
		if (!isvalid_email(document.frm1.email.value)) return false;
		
		if (!isvalid_msg(document.frm1.message.value)) return false;
	}
		function sendmail()
{
	
	if (document.frmsendmail.rname.value=="")
	{
		alert("Please enter Receiver Name");
		document.frmsendmail.rname.focus();
		return false;
	}

	if (document.frmsendmail.recemail.value=="")
	{
		alert("Please enter Email Address");
		document.frmsendmail.recemail.focus();
		return false;
	}
	// Email validation !
	var i = 1;
	var s=document.frmsendmail.recemail.value;
	var valid_chars = '%&*()\'\";:/';
	for (i=0;i<s.length;i++){
		if (valid_chars.indexOf(s.charAt(i)) != -1){
			 alert('Please enter a valid Email address');
			 return false;
		 }
	}
	var sLength = document.frmsendmail.recemail.value.length;
	i=1;
	while ((i < sLength) && (s.charAt(i) != "@")){
	   i++;
	}
	if ((i >= sLength) || (s.charAt(i) != "@")){
	   alert('Please enter valid Email address');
	   document.frmsendmail.recemail.focus();
	   return false;
	}
	else i += 2;
	while ((i < sLength) && (s.charAt(i) != ".")){
		i++;
	}
	if ((i >= sLength - 1) || (s.charAt(i) != ".")){
		alert('Please enter valid Email address');
		document.frmsendmail.recemail.focus();
		return false;
	}
	
	if (document.frmsendmail.name.value=="")
	{
		alert("Please enter Your Name ");
		 document.frmsendmail.name.focus();
		return false;
	}
	if (document.frmsendmail.mail.value=="")
	{
		alert("Please enter Your Email ");
		document.frmsendmail.mail.focus();
		return false;
	}

var i = 1;
	var s=document.frmsendmail.mail.value;
	var valid_chars = '%&*()\'\";:/';
	for (i=0;i<s.length;i++){
		if (valid_chars.indexOf(s.charAt(i)) != -1){
			 alert('Please enter a valid Email address');
			 return false;
		 }
	}
	var sLength = document.frmsendmail.mail.value.length;
	i=1;
	while ((i < sLength) && (s.charAt(i) != "@")){
	   i++;
	}
	if ((i >= sLength) || (s.charAt(i) != "@")){
	   alert('Please enter valid Email address');
	   document.frmsendmail.mail.focus();
	   return false;
	}
	else i += 2;
	while ((i < sLength) && (s.charAt(i) != ".")){
		i++;
	}
	if ((i >= sLength - 1) || (s.charAt(i) != ".")){
		alert('Please enter valid Email address');
		document.frmsendmail.mail.focus();
		return false;
	}
	return true;
}

function pollsubmit(pollid)
{
	if (document.frmpoll.opts.value=="")
	{
		alert("You have not selected an option, please select an option and then click the 'Vote' button");
		return false;
	}
	else
	{
		opts=document.frmpoll.opts.value;
		window.open("pollresult.php?insert=y&pollid="+pollid+"&opt="+opts,"viewgiftproducts","top=0,left=0,width=400,height=420,resizable=no,scrollbars=no");
	}
}
function pollresult(pollid)
{
	window.open("pollresult.php?pollid="+pollid,"viewgiftproducts","top=0,left=0,width=400	,height=420,resizable=no,scrollbars=no");
}
function insertval(val)
{
	
	document.frmpoll.opts.value=val;
}

  	function opennew1(img)
			{
			
					window.open("displaycover.php?imagename="+img,"viewgiftproducts","top=0,left=0,width=350,height=473,resizable=no,scrollbars=no");
			}
	
  	function openpopup(img)
			{
			
					window.open("displayimage.php?img="+img,"viewgiftproducts","top=0,left=0,width=350,height=473,resizable=no,scrollbars=no");
			}
			