// JavaScript Document

function inputclear (td,check){
	if(td.id=="login"){
		if(check==true && td.value=='E-mail...'){
			td.value=''	
		}
		else if(check==false && td.value==''){
			td.value='E-mail...'	
		}
	}
	else if(td.id=="password"){
		if(check==true && td.value=='Password...'){
			td.value=''	
		}
		else if(check==false && td.value==''){
			td.value='Password...'	
		}
	}
}

function checkbg(td,arg){
	if(arg==true){
		td.style.background='url(images/login2.jpg) top left no-repeat';	
	}
	else if(arg==false){
		td.style.background='url(images/login.jpg) top left no-repeat';	
	}
}

function word_count(){

	var type=document.order_form.type.value

	var pages=document.order_form.pages.value

		if (pages!=="empty" && type!=="empty" && type!=="powerpoint" && type!=="quantitative_project_accounting" && type!=="quantitative_project_finance" && type!=="quantitative_project_statistics")

		{

			document.getElementById("wordcount").style.fontSize="8pt"

			document.getElementById("wordcount").style.color="#666666"

			document.getElementById("wordcount").style.fontWeight="normal"

			document.getElementById("wordcount").innerHTML="Word Count: approx.&nbsp;"+pages*290+"&nbsp;words (290 words per page)<br>Format: 12 pt Times New Roman font, double spacing, 1 inch margins"

		}

		else{

			document.getElementById("wordcount").innerHTML=""

		}

}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var email=document.order_form.email
	var email2=document.order_form.email2

	if ((email.value==null)||(email.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(email.value)==false){
		email.value=""
		email.focus()
		return false
	}
	if (echeck(email2.value)==false){
		email2.value=""
		email2.focus()
		return false
	}

	return true
 }
