function msg(n_msg,x){
var msg="The following fields were found to be blank or incorrect.\nKindly check and correct it before submiting the form \n"
msg=msg+"------------------------------------------------------------------\n\n"
msg=msg+n_msg+"\n\n"
if(x==1){alert(msg); return false;}
}

//for email addresses
var regexp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;

//illegal characters in fields
var illegalCharStr = '~!@#$%^*()<>{}[]=?/\\\":;';

var illegalCharStrWeb = '~!@#$%^*()<>{}[]=?";';
 	
// Removes all characters which appear in string bag from string s.
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++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

//check for illegal characters
function checkIlleg(va)
{
	var stripped = stripCharsInBag (va, illegalCharStr);
	if(va != '' && stripped.length < va.length)
	{
		return false;
	}
	return true;
}

//check illegal characters for url
function checkIllegweb(va)
{
	var stripped = stripCharsInBag (va, illegalCharStrWeb);
	if(va != '' && stripped.length < va.length)
	{
		return false;
	}
	return true;
}

//check for tel number
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

//Verify TEXTAREA field - general
function VerifyMsg(f_ld,c_nt,cnt_fld) {

	var len = f_ld.value.length
	var cl

	if ((len == 1) && (f_ld.value.substring(0, 1) == " ")) {
		f_ld.value = ""
		len = 0
	}
	if (len > (c_nt-10)) {
		f_ld.value = f_ld.value.substring(0, c_nt)
		cl = 0
	}
	else {
		cl = c_nt - len
	}
	eval(cnt_fld).value = cl
}


//order form validate
function OrdrVal(){
//alert("5")
	var x=0;
	var err_msg=""		
	if (!document.invoice.card_type.options[document.invoice.card_type.selectedIndex].value) {
		err_msg=err_msg+"Enter Credit Card Information\n"; x=1;
		}	
	else { 
	if(!document.invoice.card_holder_name.value){
			err_msg=err_msg+"Card Holder's Name\n"; x=1;
		}
	else {
	if(!checkIlleg(document.invoice.card_holder_name.value)){
			err_msg=err_msg+"Card Holder's Name - Invalid Characters\n"; x=1;
			}
		 }	
	if (!checkCreditCard(document.invoice.card_type, document.invoice.card_no)){
			err_msg=err_msg+"Invalid Credit Card number\n"; x=1;
		}
	if (!checkCardDate(document.invoice.card_expiry_month, document.invoice.card_expiry_year)){
			err_msg=err_msg+"Credit Card Expiry Date is not valid\n"; x=1;
			}	
		}
	if (!document.invoice.Country[document.invoice.Country.selectedIndex].value)
		{
		err_msg=err_msg+"Country\n"; x=1;	
		}		
	if(document.invoice.email.value=="")
        {
       err_msg=err_msg+"Email\n"; x=1;					
        }							
			else {
					email = document.invoice.email.value;
					if(email.search(regexp) == -1){
		  			  err_msg=err_msg+"Email - Invalid Characters\n"; x=1;		
						}
				}		
	if(document.invoice.Total_Amount_US$.value=="")
        {
     err_msg=err_msg+"Total Amount\n"; x=1;	
        }																			
	return msg(err_msg,x);		
	}	

//Esteshari order form validate
function EhariOrdrVal(){
//alert("5")
	var x=0;
	var err_msg=""		
	if (!document.SubmitForm.card_type.options[document.SubmitForm.card_type.selectedIndex].value) {
		err_msg=err_msg+"Enter Credit Card Information\n"; x=1;
		}	
	else { 
	if(!document.SubmitForm.card_holder_name.value){
			err_msg=err_msg+"Card Holder's Name\n"; x=1;
		}
	else {
	if(!checkIlleg(document.SubmitForm.card_holder_name.value)){
			err_msg=err_msg+"Card Holder's Name - Invalid Characters\n"; x=1;
			}
		 }	
	if (!checkCreditCard(document.SubmitForm.card_type, document.SubmitForm.card_no)){
			err_msg=err_msg+"Invalid Credit Card number\n"; x=1;
		}
	if (!checkCardDate(document.SubmitForm.card_expiry_month, document.SubmitForm.card_expiry_year)){
			err_msg=err_msg+"Credit Card Expiry Date is not valid\n"; x=1;
			}	
		}
	if (!document.SubmitForm.Country[document.SubmitForm.Country.selectedIndex].value)
		{
		err_msg=err_msg+"Country\n"; x=1;	
		}	
	if(document.SubmitForm.Shipping_Address.value=="")
        {
     err_msg=err_msg+"Shipping Address\n"; x=1;	
        }	
	if(document.SubmitForm.No_Of_Copies.value=="")
        {
     err_msg=err_msg+"Number of Copies\n"; x=1;	
        }		
	if(document.SubmitForm.email.value=="")
        {
       err_msg=err_msg+"Email\n"; x=1;					
        }							
			else {
					email = document.SubmitForm.email.value;
					if(email.search(regexp) == -1){
		  			  err_msg=err_msg+"Email - Invalid Characters\n"; x=1;		
						}
				}		
	if(document.SubmitForm.Total_Amount_US$.value=="")
        {
     err_msg=err_msg+"Total Amount\n"; x=1;	
        }
		
	
		
																					
	return msg(err_msg,x);		
	}	
	
//Sponsored order form validate
function SpOrdrVal(){


	var x=0;
	err_msg = '';
	
	
//	var err_msg=""		
//	if (!document.Sponsored.card_type.options[document.Sponsored.card_type.selectedIndex].value) {
//		err_msg=err_msg+"Enter Credit Card Information\n"; x=1;
//		}	
//	else { 
	if(!document.Sponsored.card_holder_name.value){
			err_msg=err_msg+"Name\n"; x=1;
		}
	else {
	if(!checkIlleg(document.Sponsored.card_holder_name.value)){
			err_msg=err_msg+"Name - Invalid Characters\n"; x=1;
			}
		 }	
		
		

//	if (!checkCreditCard(document.Sponsored.card_type, document.Sponsored.card_no)){
//			err_msg=err_msg+"Invalid Credit Card number\n"; x=1;
//		}
//	if (!checkCardDate(document.Sponsored.card_expiry_month, document.Sponsored.card_expiry_year)){
//			err_msg=err_msg+"Credit Card Expiry Date is not valid\n"; x=1;
//			}	
//		}
	if (!document.Sponsored.Country[document.Sponsored.Country.selectedIndex].value)
		{
		err_msg=err_msg+"Country\n"; x=1;	
		}		
	if(document.Sponsored.email.value=="")
        {
       err_msg=err_msg+"Email\n"; x=1;					
        }							
			else {
					email = document.Sponsored.email.value;
					if(email.search(regexp) == -1){
		  			  err_msg=err_msg+"Email - Invalid Characters\n"; x=1;		
						}
				}	

	if(document.Sponsored.Site_Name.value=="")
        {
     err_msg=err_msg+"Site Name\n"; x=1;	
        }
	if(document.Sponsored.URL.value=="")
        {
     err_msg=err_msg+"URL\n"; x=1;	
        }
	if(document.Sponsored.Authorization.value!="I AGREE")
        {
		    err_msg=err_msg+"Please write I AGREE for Authorization\n"; x=1;	 		
        }
	
	if(document.Sponsored.captcha_code.value =="")
	{
		     err_msg=err_msg+"Verification Code\n"; x=1;	
	}
	if(document.Sponsored.total_amount.value =="" || document.Sponsored.total_amount.value =="0" )
	{
		     err_msg=err_msg+"Package\n"; x=1;	
	}
	return msg(err_msg,x);		
	}