function change_arrow(td,file){

	td.firstChild.style.background="url(../image/"+file+") no-repeat 4px 3px"

	



}



function button_roll(id,color,colorfont){

	id.style.backgroundColor=color

	id.style.color=colorfont

}

function price() 

{

	var level=document.level.level.value

	


	if(document.getElementById("highschool").style.display=="block") 

	{

		document.getElementById("highschool").style.display="none"; 

	}

	if(document.getElementById("collegeyear1").style.display=="block") 

	{

		document.getElementById("collegeyear1").style.display="none"; 

	}

	if(document.getElementById("collegeyear2").style.display=="block") 

	{

		document.getElementById("collegeyear2").style.display="none"; 

	}

	if(document.getElementById("collegeyear3").style.display=="block") 

	{

		document.getElementById("collegeyear3").style.display="none"; 

	}

	if(document.getElementById("collegeyear4").style.display=="block") 

	{

		document.getElementById("collegeyear4").style.display="none"; 

	}

	

	if(document.getElementById("graduate").style.display=="block") 

	{

		document.getElementById("graduate").style.display="none"; 

	}

	if(document.getElementById("phd").style.display=="block") 

	{

		document.getElementById("phd").style.display="none"; 

	}

	if(document.getElementById("phd").style.display=="block") 

	{

		document.getElementById("phd").style.display="none"; 

	}

	if(document.getElementById("professional").style.display=="block") 

	{

		document.getElementById("professional").style.display="none"; 

	}



	if(level!==""){

	document.getElementById(level).style.display="block"

	}



}



function project_type()

{

	if(document.getElementById("powerpoint").selected)

	{

	document.getElementById("pages").innerHTML="Number of slides"

	} 



	if(document.getElementById("quantitative_project_accounting").selected)

	{

	document.getElementById("pages").innerHTML="Number of problems:"

	} 

	

	if(document.getElementById("quantitative_project_finance").selected)

	{

	document.getElementById("pages").innerHTML="Number of problems:"

	} 



	if(document.getElementById("quantitative_project_statistics").selected)

	{

	document.getElementById("pages").innerHTML="Number of problems:"

	} 





	if(!document.getElementById("quantitative_project_statistics").selected && !document.getElementById("quantitative_project_finance").selected && !document.getElementById("quantitative_project_accounting").selected && !document.getElementById("powerpoint").selected)

	{

	document.getElementById("pages").innerHTML="Number of pages:"

	} 

}

function rate_quote()

{

	

	var level=document.order_form.academiclevel.value

	var month=document.order_form.month.value

	var day=document.order_form.day.value

	var year=document.order_form.year.value

	var hours=document.order_form.hours.value

	var minutes=document.order_form.minutes.value



	if(level=="empty"){

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

	}

	if(level=="secondaryschool"){

		document.getElementById("rate_quote").innerHTML="from $11.95 per page"

	}

	if(level=="highschool"){

		document.getElementById("rate_quote").innerHTML="from $11.95 per page"

	}

		if(level=="2yearcollege"){

		document.getElementById("rate_quote").innerHTML="from $13.95 per page"

	}

	if(level=="4yearcollege"){

		document.getElementById("rate_quote").innerHTML="from $14.95 per page"

	}

	if(level=="graduate"){

		document.getElementById("rate_quote").innerHTML="from $16.95 per page"

	}

	if(level=="phd"){

		document.getElementById("rate_quote").innerHTML="from $19.95 per page"

	}

}

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="<br><br>Word Count: approx.&nbsp;"+pages*330+"&nbsp;words (330 words per page)<br>Format: 12 pt Times New Roman font, double spacing, 1 inch margins"

		}

		else{

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

		}

}

function change_backgroundmenu(td)

{

	td.style.backgroundColor="#d6f1ad"

	td.previousSibling.previousSibling.style.background="url(http://www.customessaymeister.com/images/menumaincorneract.gif) bottom right no-repeat"

	td.previousSibling.style.background="#d6f1ad url(http://www.customessaymeister.com/images/menumainact.gif) top right no-repeat"

	td.nextSibling.style.background="#d6f1ad url(http://www.customessaymeister.com/images/menumainactr.gif) top left no-repeat"

	td.nextSibling.nextSibling.style.background="url(http://www.customessaymeister.com/images/menumaincorneractr.gif) bottom left no-repeat"

}

function return_backgroundmenu(td)

{

	td.style.backgroundColor="#b6e76d"

	td.previousSibling.previousSibling.style.background="url(http://www.customessaymeister.com/images/menumaincornerpas.gif) bottom right no-repeat"

	td.previousSibling.style.background="#b6e76d url(http://www.customessaymeister.com/images/menumainpas.gif) top right no-repeat"

	td.nextSibling.style.background="#b6e76d url(http://www.customessaymeister.com/images/menumainpasr.gif) top left no-repeat"

	td.nextSibling.nextSibling.style.background="url(http://www.customessaymeister.com/images/menumaincornerpasr.gif) bottom left no-repeat"

}

function change_backgroundmenu_sec(td,color)

{

	td.firstChild.style.color=color

	td.style.background="#EAEAEA"

	td.previousSibling.style.background="#EAEAEA url(http://www.customessaymeister.com/images/menucornersecpas_roll.gif) no-repeat top left"

	td.nextSibling.style.background="#EAEAEA url(http://www.customessaymeister.com/images/menucornersecpasr_roll.gif) no-repeat top right"

}

function return_backgroundmenu_sec(td,color)

{

	td.firstChild.style.color=color

	td.style.backgroundColor="#CCCCCC"

	td.previousSibling.style.background="#CCCCCC url(http://www.customessaymeister.com/images/menucornersecpas.gif) no-repeat top left"

	td.nextSibling.style.background="#CCCCCC url(http://www.customessaymeister.com/images/menucornersecpasr.gif) no-repeat top right"

}



function change_background(field,color)

{

	field.style.backgroundColor=color

}

function showfaq(id)

{

	if(document.getElementById(id).style.display=='none')

	{

		document.getElementById(id).style.display='block'


	}

	else

	{	

		document.getElementById(id).style.display='none'


	}

}

function showcategory(id)

{

	if(document.getElementById(id).style.display=='none')

	{

		document.getElementById(id).style.display='block'


	}

	else

	{	

		document.getElementById(id).style.display='none'


	}

}



function preload_img_sec()

{

var a=new Image(8,8)

	 a.src="http://www.customessaymeister.com/images/menucornersecpas.gif"

var b=new Image(8,8)

	 b.src="http://www.customessaymeister.com/images/menucornersecpasr.gif"

var c=new Image(8,8)

	 c.src="http://www.customessaymeister.com/images/menucornersecpas_roll.gif"

var d=new Image(8,8)

	 d.src="http://www.customessaymeister.com/images/menucornersecpasr_roll.gif"

}



function preload_img_main()

{ 

 var menumainact=new Image(8,8)

	 menumainact.src="http://www.customessaymeister.com/images/menumainact.gif"

 var menumainactr=new Image(8,8)

	 menumainactr.src="http://www.customessaymeister.com/images/menumainactr.gif"

 var menumaincorneractr=new Image(8,8)

	 menumaincorneractr.src="http://www.customessaymeister.com/images/menumaincorneractr.gif"

 var menumaincorneract=new Image(8,8)

	 menumaincorneract.src="http://www.customessaymeister.com/images/menumaincorneract.gif"

}

function ga(o,e)

	{

	var a,f,g,h,p,r,t; 

	if (document.getElementById)

	{

		a="u"+o.id; 

		p = "";

		r = "";

		g = e.target;

		if (g) { 

			t = g.id;

			f = g.parentNode;

			if (f) {

			p = f.id;h = f.parentNode;

				if (h) r = h.id;

			}

	} 

		else{

			h = e.srcElement;

			f = h.parentNode;

			if (f) p = f.id;

			t = h.id;}

			if (t==a || p==a || r==a) return true;

			location.href=document.getElementById(a).href

		}

}

function td_url(o,e,index)

{	

		location.href=o.childNodes[index]

}

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
}
 
function fetch_client_data(url){
	var login=document.getElementById('client_login').value;
	var password=document.getElementById('client_password').value;
   	
	var passData="login="+login+"&password="+password;
	var http_request = false;
	
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	    http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
	        http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Error: Unable to initialize class');
        return false;
    }

	http_request.onreadystatechange = function() { fetchContents(http_request); };
    http_request.open('POST', url, true);
  	http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');  
	http_request.send(passData);
}

 
function fetchContents(http_request) {
	if (http_request.readyState == 4) {
        if (http_request.status == 200) {
			if(http_request.responseText=='false'){
			   document.getElementById('fetch_client_message').innerHTML="Incorrect login or password";
			}
			else{
				var text=http_request.responseText;
				text=text.split("|");
				document.getElementById('firstname').value=text[0];
				document.getElementById('lastname').value=text[1];
				document.getElementById('email').value=text[2];
				document.getElementById('email2').value=text[3];
				document.getElementById('phone').value=text[4];
				document.getElementById('address').value=text[5];
				document.getElementById('city').value=text[6];
				document.getElementById('state').value=text[7];
				document.getElementById('zip').value=text[8];
				document.getElementById('country').value=text[9];

				document.getElementById('fetch_client_message').innerHTML="Welcome "+text[0];
			}
		} 
		else {
		    alert('Request has failed');
		}
    }
}

function checkformextrapages(obj){
	var pages=document.formextrapages.pages.value;
	var paymethod=document.formextrapages.payment_method.value
	if(pages=='empty' || paymethod=='empty'){
		alert('Please select the number of pages and checkout method');	
	}
	else{
		document.formextrapages.submit();	
	}
}

function fetch_forex(url,cur_from,cur_to){
	//var amount=document.getElementById('dynaquote').innerHTML;
	var amount=document.getElementById('dynaquote').innerHTML;
	if(cur_to!='empty'){
		document.getElementById('forex').innerHTML='<img src=\'https://www.customessaymeister.com/images/loading.gif\'>';
	}
	var passData="amount="+amount+"&cur_from="+cur_from+"&cur_to="+cur_to;
	var http_request = false;
	
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	    http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
	        http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Error: Unable to initialize class');
        return false;
    }

	http_request.onreadystatechange = function() { alert_forex(http_request,cur_to); };
    http_request.open('POST', url, true);
  	http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');  
	http_request.send(passData);
}



function alert_forex(http_request,cur_to) {
	if (http_request.readyState == 4) {
        if (http_request.status == 200) {
			if(cur_to!='empty'){
				//alert(http_request.responseText);
				document.getElementById('forex').innerHTML='&nbsp;=&nbsp;'+http_request.responseText;
			}
		} 
		else {
		    alert('Request has failed');
		}
    }
}

function country_cc(url,country){
	document.getElementById('country_cc').innerHTML='<img src=\'https://www.customessaymeister.com/images/loading.gif\'>';
	var passData="country="+country;
	var http_request = false;
	
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	    http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
	        http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Error: Unable to initialize class');
        return false;
    }

	http_request.onreadystatechange = function() { alert_country_cc(http_request); };
    http_request.open('POST', url, true);
  	http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');  
	http_request.send(passData);
}



function alert_country_cc(http_request) {
	if (http_request.readyState == 4) {
        if (http_request.status == 200) {
			//alert(http_request.responseText);
			document.getElementById('country_cc').innerHTML=http_request.responseText;
		} 
		else {
		    alert('Request has failed');
		}
    }
}
function quote(url) {
	var type=document.order_form.type.value;
	var level=document.order_form.academiclevel.value;
		
	var day=document.order_form.day.value;
	var month=document.order_form.month.value;
	var year=document.order_form.year.value;
	var hours=document.order_form.hours.value;
	var minutes=document.order_form.minutes.value;
	var noon=document.order_form.noon.value;

	if(type=="quantitative_project_accounting" || type=="quantitative_project_finance" || type=="quantitative_project_statistics"){
		document.getElementById('pagestitle').innerHTML='Number of problems/questions';
	}
	else if(type=="powerpoint"){
		document.getElementById('pagestitle').innerHTML='Number of slides';
	}
	else{
		document.getElementById('pagestitle').innerHTML='Number of pages';
	}
		
	var pages=document.order_form.pages.value;
	if(type!=="empty" && level!=="empty" && pages!=="empty"){
		document.getElementById('dynaquoteproc').innerHTML='<img src=\'https://www.customessaymeister.com/images/ajax-loader.gif\'>';
		document.getElementById('dynaquotetab').style.display='none';
	}
	var datasend="type="+type+"&level="+level+"&day="+day+"&month="+month+"&year="+year+"&hours="+hours+"&minutes="+minutes+"&noon="+noon+"&pages="+pages;
	var http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
    	http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
               http_request.overrideMimeType('text/xml');
            }
       } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Error: Unable to initialize class');
            return false;
        }
        http_request.onreadystatechange = function() { quoteback(http_request,type,pages); };
        http_request.open('POST', url, true);
       	http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');  
		http_request.send(datasend);
}

function quoteback(http_request,type,pages) {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
				document.getElementById('dynaquoteproc').innerHTML='';
				if(http_request.responseText!='failed' && http_request.responseText!='3'){
					var array=http_request.responseText.split("|");
				  	
					var rate = array[0];
				  	var total = array[1];
				  	var timespan = array[2];
					var wcmin = array[3];
					var wcmax = array[4];

					document.getElementById('dynaquotetab').style.display='block';
					
					if(type=="quantitative_project_accounting" || type=="quantitative_project_finance" || type=="quantitative_project_statistics"){
						document.getElementById('dynaquotewordcount').innerHTML='<small>Project length:&nbsp;</small>'+pages+' problems/questions';
						document.getElementById('dynaquoterate').innerHTML='<small>Rate per problem:&nbsp;</small>$'+rate;
					}
					else if(type=="powerpoint"){
						document.getElementById('dynaquotewordcount').innerHTML='<small>Project length:&nbsp;</small>'+pages+' slides';
						document.getElementById('dynaquoterate').innerHTML='<small>Rate per slide:&nbsp;</small>$'+rate;
					}
					else{
						document.getElementById('dynaquotewordcount').innerHTML='<small>Total wordcount:&nbsp;</small>'+wcmin+' - '+wcmax+' words';
						document.getElementById('dynaquoterate').innerHTML='<small>Rate per page:&nbsp;</small>$'+rate;
					}

					document.getElementById('dynaquote').innerHTML=total;
					document.getElementById('dynaquotetime').innerHTML='<small>Time span:&nbsp;</small>'+timespan;

					
					
					document.getElementById('forex').innerHTML='';
					document.order_form.forexname.value='empty'
				}
				if(http_request.responseText=='3'){
					alert('Error: Wrong deadline! Our minimum turnaround is 3 hours and it is applicable to short and relatively easy projects that are less than 5 pages in length. Please edit the deadline accordingly.');
					document.getElementById('dynaquotetab').style.display='none';
				}

			} else {
                alert('Request has failed');
            }
        }
    }
