// JavaScript Document

function LoadFunctions() {

	SetVariables();

	var getCurrentDate = new Date();
	
	idOrderMonth.selectedIndex	= getCurrentDate.getMonth()+1;
	idOrderDate.selectedIndex	= getCurrentDate.getDate()+1;
	
	if (varOrderYear == "2010"){
		idOrderYear.selectedIndex = 1;
		CurrentYear = 1;
	}
	
	if (varOrderYear == "2011"){
		idOrderYear.selectedIndex = 2;
		CurrentYear = 2;
	}
	
	if (varOrderYear == "2012"){
		idOrderYear.selectedIndex = 3;
		CurrentYear = 3;
	}
	
	SetDeadline();

CalculateAmount();
	//CalculateAmount2();
saveSchoolCollegeLevel();
savePaperType();
saveCitationStyle();
saveNumSourceRef();

}

function SetVariables() {
	
	var getCurrentDate = new Date();
	
	idOrderMonth 	= document.getElementById("OrderMonth");
	idOrderDate 	= document.getElementById("OrderDate");
	idOrderYear 	= document.getElementById("OrderYear");
	
	idReqDays		= document.getElementById("ReqDays");
	idReqDays2		= document.getElementById("ReqDays2");
	
	idNumWords		= document.getElementById("NumWords");
	isNumWords2		= document.getElementById("NumWords2");

	varChkOldDate	= getCurrentDate.getDate();
	
	varOrderYear	= getCurrentDate.getFullYear();
	
	CurrentMonth	= getCurrentDate.getMonth()+1;
	CurrentDate		= getCurrentDate.getDate();
	
	YearSI	= idOrderYear.selectedIndex;
	DateSI 	= idOrderDate.selectedIndex;
	MonthSI = idOrderMonth.selectedIndex;
	
}

function setCurrentDate(){

	SetVariables();

	idOrderMonth.selectedIndex	= CurrentMonth;
	idOrderDate.selectedIndex	= CurrentDate;
	idOrderYear.selectedIndex	= CurrentYear;
		
}

function AddDays(Cnt) {
	
	if (varOrderYear == "2010"){
		idOrderYear.selectedIndex = 1;
		CurrentYear = 1;
	}
	
	if (varOrderYear == "2011"){
		idOrderYear.selectedIndex = 2;
		CurrentYear = 2;
	}
	
	if (varOrderYear == "2012"){
		idOrderYear.selectedIndex = 3;
		CurrentYear = 3;
	}
	
	var getCurrentDate = new Date();

	ChkCurrentMonth	= getCurrentDate.getMonth();
	ChkCurrentDate	= getCurrentDate.getDate();
	ChkLeapYear		= getCurrentDate.getFullYear();
	
	FindCurrentMonth = ChkCurrentMonth+1
	
	if (FindCurrentMonth == 1 || FindCurrentMonth == 3 || FindCurrentMonth == 5 || FindCurrentMonth == 7 || FindCurrentMonth == 9 || FindCurrentMonth == 11) {
	
		varTotalDates 	= 31;
	
	} else if (FindCurrentMonth == 4 || FindCurrentMonth == 6 || FindCurrentMonth == 8 || FindCurrentMonth == 10 || FindCurrentMonth == 12) {
	
		varTotalDates 	= 30;
	
	} else {
		
		varTotalDates 	= 28;
		
		if (ChkLeapYear == "2012") {
		
			varTotalDates 	= 29;
		
		}
		
	}
	
	varTotalMonths 	= 12;
	varSI			= 1;
	
	setOrderDateDeadline 	= ChkCurrentDate+Cnt;
	setOrderMonthDeadline	= CurrentMonth+1;
	
	varAddTenDays	= setOrderDateDeadline - varTotalDates;
	
	idOrderMonth.selectedIndex	= getCurrentDate.getMonth()+1;
	idOrderDate.selectedIndex	= setOrderDateDeadline;
	idOrderYear.selectedIndex	= CurrentYear;
	
	document.getElementById("valOrderMonth").value	= idOrderMonth.selectedIndex;
	document.getElementById("valOrderDate").value	= idOrderDate.selectedIndex;
	document.getElementById("valOrderYear").value	= idOrderYear.selectedIndex;
	
	//document.getElementById("DeadlineHID").value	= idOrderMonth.selectedIndex + "/" + setOrderDateDeadline + "/" + varOrderYear;
	
	if ( setOrderDateDeadline > varTotalDates ) {	
		
		idOrderDate.selectedIndex	= setOrderDateDeadline - varTotalDates;
		ChkCurrentMonth		= ChkCurrentMonth+1+varSI
		document.getElementById("valOrderDate").value	= idOrderDate.selectedIndex;
		
		if (ChkCurrentMonth > varTotalMonths) {
			
			idOrderMonth.selectedIndex	= ChkCurrentMonth - varTotalMonths;
			document.getElementById("valOrderMonth").value	= idOrderMonth.selectedIndex;
			ChkCurrentYear	= CurrentYear+1
			
			if (ChkCurrentYear > CurrentYear) {
				
				idOrderYear.selectedIndex	= ChkCurrentYear;
				varOrderYear				= "2011";
				document.getElementById("valOrderYear").value	= idOrderYear.selectedIndex;
				
			}
			
		} else {
			
			if (ChkCurrentMonth < varTotalMonths) {
				
				idOrderMonth.selectedIndex	= ChkCurrentMonth;
				document.getElementById("valOrderMonth").value	= idOrderMonth.selectedIndex;
				
			}
		
		}	
	
		//document.getElementById("DeadlineHID").value	= idOrderMonth.selectedIndex + "/" + idOrderDate.selectedIndex + "/" + varOrderYear;
	
	}

}

function ChkOldDate(){

	SetVariables();
	
	if ( YearSI == 0 ) { ShowAlertAddDays(); }
	
	if ( MonthSI == 0 ) { ShowAlertAddDays(); }
	
	if ( DateSI == 0 ) { ShowAlertAddDays(); }
	
	
	if ( MonthSI == CurrentMonth && DateSI < CurrentDate && YearSI == CurrentYear ) { ShowAlertAddDays(); }
	
	if ( MonthSI < CurrentMonth && DateSI == CurrentDate && YearSI == CurrentYear ) { ShowAlertAddDays(); }
	
	if ( MonthSI == CurrentMonth && DateSI == CurrentDate && YearSI < CurrentYear ) { ShowAlertAddDays(); }
	
	
	if ( MonthSI < CurrentMonth && DateSI > CurrentDate && YearSI == CurrentYear ) { ShowAlertAddDays(); }
	
	if ( MonthSI < CurrentMonth && DateSI < CurrentDate && YearSI == CurrentYear ) { ShowAlertAddDays(); }
	
	if ( MonthSI > CurrentMonth && DateSI > CurrentDate && YearSI < CurrentYear ) { ShowAlertAddDays(); }
	
	if ( MonthSI == CurrentMonth && DateSI > CurrentDate && YearSI < CurrentYear ) { ShowAlertAddDays(); }
	
	if ( MonthSI > CurrentMonth && DateSI == CurrentDate && YearSI < CurrentYear ) { ShowAlertAddDays(); }
	
	if ( MonthSI < CurrentMonth && DateSI < CurrentDate && YearSI < CurrentYear ) { ShowAlertAddDays(); }
	
	if ( MonthSI == CurrentMonth+1 && DateSI < CurrentDate && YearSI == CurrentYear ) { ShowAlertAddDays(); }
	
	SetDeadline();
	
}

function ShowAlertAddDays() {
	strAlert = "Sorry! Your Cannot Select Old Date!";
	alert(strAlert);
	AddDays(6);
}

function SetDeadline() {	


	if ( idOrderYear.selectedIndex == 1 ) {
		varOrderYear = "2010";
	}
	
	if ( idOrderYear.selectedIndex == 2 ) {
		varOrderYear = "2011";
	}
	
	if ( idOrderYear.selectedIndex == 3 ) {
		varOrderYear = "2012";
	}
	
	document.getElementById("valOrderMonth").value	= idOrderMonth.selectedIndex;
	document.getElementById("valOrderDate").value	= idOrderDate.selectedIndex;
	document.getElementById("valOrderYear").value	= idOrderYear.selectedIndex;

	//document.getElementById("DeadlineHID").value	= idOrderMonth.selectedIndex + "/" + idOrderDate.selectedIndex + "/" + varOrderYear;

}

function CalculateAmount() {

SetVariables();

var RQlen = document.orderform.ReqDays.length;

for (a=0; a<RQlen; a++) {
	if (document.orderform.ReqDays[a].selected) {
		ReqDays = document.orderform.ReqDays[a].value;
	}
}

var NWlen = document.orderform.NumWords.length;

for (b=0; b<NWlen; b++) {
	if (document.orderform.NumWords[b].selected) {
		varNumWords = document.orderform.NumWords[b].value;
	}
}

varPageCount = varNumWords/250;

varTotalValue = varPageCount*ReqDays;

document.getElementById("TotalAmountErr").firstChild.data = varTotalValue;
document.getElementById("TotalAmountHID").value = document.getElementById("TotalAmountErr").firstChild.data;

theValue = document.getElementById("TotalAmountErr").firstChild.data;
document.getElementById("TotalAmountHID").value = document.getElementById("TotalAmountErr").firstChild.data;

if(theValue.indexOf(".") != -1) {
theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
}

document.getElementById("TotalAmountErr").firstChild.data = theValue;
document.getElementById("TotalAmountHID").value = document.getElementById("TotalAmountErr").firstChild.data;

varDiscountFormula = varTotalValue/100;


if (varNumWords <= 2250){

	varDiscount = "0";
	
	document.getElementById("TotalDiscountErr").firstChild.data = varDiscount;
	theValue = document.getElementById("TotalDiscountErr").firstChild.data;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	
	if(theValue.indexOf(".") != -1) {
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	document.getElementById("TotalDiscountErr").firstChild.data = theValue;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;

} else if (varNumWords >= 2500 && varNumWords <= 3750){

	varDiscount = varDiscountFormula * 10;
	
	document.getElementById("TotalDiscountErr").firstChild.data = varDiscount;
	theValue = document.getElementById("TotalDiscountErr").firstChild.data;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	if(theValue.indexOf(".") != -1) {
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	document.getElementById("TotalDiscountErr").firstChild.data = theValue;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;

} else if (varNumWords >= 4000 && varNumWords <= 5250) {

	varDiscount = varDiscountFormula * 12.5;
	
	document.getElementById("TotalDiscountErr").firstChild.data = varDiscount;
	theValue = document.getElementById("TotalDiscountErr").firstChild.data;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	
	if(theValue.indexOf(".") != -1) {
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	document.getElementById("TotalDiscountErr").firstChild.data = theValue;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;

} else if (varNumWords >= 5500 && varNumWords <= 6250) {

	varDiscount = varDiscountFormula * 15;
	
	document.getElementById("TotalDiscountErr").firstChild.data = varDiscount;
	theValue = document.getElementById("TotalDiscountErr").firstChild.data;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	
	if(theValue.indexOf(".") != -1) {
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	document.getElementById("TotalDiscountErr").firstChild.data = theValue;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	
} else {

	varDiscount = varDiscountFormula * 15;
	
	document.getElementById("TotalDiscountErr").firstChild.data = varDiscount;
	theValue = document.getElementById("TotalDiscountErr").firstChild.data;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	if(theValue.indexOf(".") != -1) {
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	document.getElementById("TotalDiscountErr").firstChild.data = theValue;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
}

varDiscountValue = varTotalValue-varDiscount;

document.getElementById("TotalPayErr").firstChild.data = varDiscountValue;

theValue = document.getElementById("TotalPayErr").firstChild.data;
document.getElementById("TotalPayHID").value = document.getElementById("TotalPayErr").firstChild.data;

if(theValue.indexOf(".") != -1) {
theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
}

document.getElementById("TotalPayErr").firstChild.data = theValue;
document.getElementById("TotalPayHID").value = document.getElementById("TotalPayErr").firstChild.data;

// Show Deadline If More Than 10 Days Or More

	
if (idReqDays.selectedIndex == 0) {
	AddDays(1);
}

if (idReqDays.selectedIndex == 1) {
	AddDays(2);
}
	
if (idReqDays.selectedIndex == 2) {
	AddDays(3);
}
	
if (idReqDays.selectedIndex == 3) {
	AddDays(4);
}
	
if (idReqDays.selectedIndex == 4) {
	AddDays(5);
}

if (idReqDays.selectedIndex == 5) {
	
	document.getElementById("OrderMonth").style.display = "block";
	document.getElementById("OrderDate").style.display 	= "block";
	document.getElementById("OrderYear").style.display 	= "block";
	
	AddDays(6);

} else {
	
	document.getElementById("OrderMonth").style.display = "none";
	document.getElementById("OrderDate").style.display 	= "none";
	document.getElementById("OrderYear").style.display 	= "none";
}

document.orderform.valNumWords.value = document.orderform.NumWords.selectedIndex;
document.orderform.valReqDays.value = document.orderform.ReqDays.selectedIndex;
document.orderform.ReqDaysVal.value = document.orderform.ReqDays.options[document.orderform.ReqDays.selectedIndex].value;

} // End Function


function CalculateAmount2() {

SetVariables();

var RQlen2 = document.orderform.ReqDays2.length;

for (a=0; a<RQlen2; a++) {
	if (document.orderform.ReqDays2[a].selected) {
		ReqDays2 = document.orderform.ReqDays2[a].value;
	}
}

var NWlen = document.orderform.NumWords2.length;

for (b=0; b<NWlen; b++) {
	if (document.orderform.NumWords2[b].selected) {
		varNumWords2 = document.orderform.NumWords2[b].value;
	}
}

varPageCount = varNumWords2/250;

varTotalValue = varPageCount*ReqDays2;

document.getElementById("TotalAmountErr").firstChild.data = varTotalValue;
document.getElementById("TotalAmountHID").value = document.getElementById("TotalAmountErr").firstChild.data;

theValue = document.getElementById("TotalAmountErr").firstChild.data;
document.getElementById("TotalAmountHID").value = document.getElementById("TotalAmountErr").firstChild.data;

if(theValue.indexOf(".") != -1) {
theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
}

document.getElementById("TotalAmountErr").firstChild.data = theValue;
document.getElementById("TotalAmountHID").value = document.getElementById("TotalAmountErr").firstChild.data;

varDiscountFormula = varTotalValue/100;


if (varNumWords2 <= 2250){

	varDiscount = "0";
	
	document.getElementById("TotalDiscountErr").firstChild.data = varDiscount;
	theValue = document.getElementById("TotalDiscountErr").firstChild.data;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	
	if(theValue.indexOf(".") != -1) {
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	document.getElementById("TotalDiscountErr").firstChild.data = theValue;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;

} else if (varNumWords2 >= 2500 && varNumWords2 <= 3750){

	varDiscount = varDiscountFormula * 10;
	
	document.getElementById("TotalDiscountErr").firstChild.data = varDiscount;
	theValue = document.getElementById("TotalDiscountErr").firstChild.data;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	if(theValue.indexOf(".") != -1) {
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	document.getElementById("TotalDiscountErr").firstChild.data = theValue;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;

} else if (varNumWords2 >= 4000 && varNumWords2 <= 5250) {

	varDiscount = varDiscountFormula * 12.5;
	
	document.getElementById("TotalDiscountErr").firstChild.data = varDiscount;
	theValue = document.getElementById("TotalDiscountErr").firstChild.data;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	
	if(theValue.indexOf(".") != -1) {
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	document.getElementById("TotalDiscountErr").firstChild.data = theValue;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;

} else if (varNumWords2 >= 5500 && varNumWords2 <= 6250) {

	varDiscount = varDiscountFormula * 15;
	
	document.getElementById("TotalDiscountErr").firstChild.data = varDiscount;
	theValue = document.getElementById("TotalDiscountErr").firstChild.data;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	
	if(theValue.indexOf(".") != -1) {
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	document.getElementById("TotalDiscountErr").firstChild.data = theValue;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	
} else {

	varDiscount = varDiscountFormula * 15;
	
	document.getElementById("TotalDiscountErr").firstChild.data = varDiscount;
	theValue = document.getElementById("TotalDiscountErr").firstChild.data;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
	if(theValue.indexOf(".") != -1) {
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	document.getElementById("TotalDiscountErr").firstChild.data = theValue;
	document.getElementById("TotalDiscountHID").value = document.getElementById("TotalDiscountErr").firstChild.data;
}

varDiscountValue = varTotalValue-varDiscount;

document.getElementById("TotalPayErr").firstChild.data = varDiscountValue;

theValue = document.getElementById("TotalPayErr").firstChild.data;
document.getElementById("TotalPayHID").value = document.getElementById("TotalPayErr").firstChild.data;

if(theValue.indexOf(".") != -1) {
theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
}

document.getElementById("TotalPayErr").firstChild.data = theValue;
document.getElementById("TotalPayHID").value = document.getElementById("TotalPayErr").firstChild.data;

// Show Deadline If More Than 10 Days Or More
	
if (idReqDays2.selectedIndex == 0) {
	AddDays(1);
}

if (idReqDays2.selectedIndex == 1) {
	AddDays(2);
}
	
if (idReqDays2.selectedIndex == 2) {
	AddDays(3);
}
	
if (idReqDays2.selectedIndex == 3) {
	AddDays(4);
}
	
if (idReqDays2.selectedIndex == 4) {
	AddDays(5);
}

if (idReqDays2.selectedIndex == 5) {
	
	document.getElementById("OrderMonth").style.display = "block";
	document.getElementById("OrderDate").style.display 	= "block";
	document.getElementById("OrderYear").style.display 	= "block";
	
	AddDays(6);

} else {
	
	document.getElementById("OrderMonth").style.display = "none";
	document.getElementById("OrderDate").style.display 	= "none";
	document.getElementById("OrderYear").style.display 	= "none";
}

document.orderform.valNumWords.value = document.orderform.NumWords2.selectedIndex;
document.orderform.valReqDays.value = document.orderform.ReqDays2.selectedIndex;
document.orderform.ReqDaysVal.value = document.orderform.ReqDays2.options[document.orderform.ReqDays2.selectedIndex].value;

} // End Function

function IsNumeric(strString) {

var strValidChars = "0123456789-+";
var strChar;
var blnResult = true;

	for (i = 0; i<strString.length && blnResult==true; i++){
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1){
			blnResult = false;
		}
	}
	return blnResult;
}

function CheckValues(){
	
if (document.orderform.TitlePaper.value == ""){
	document.orderform.TitlePaper.style.borderColor = "#FF0000"; 
	document.getElementById("TitlePaperErr").firstChild.data = "Enter Order Topic!";
	location.href = "#HrefTitlePaperErr";
	document.orderform.TitlePaper.focus(); 
	return false;
} else {
	document.getElementById("TitlePaperErr").firstChild.data = "";
	document.orderform.TitlePaper.style.borderColor = "#bbbbbb";
}

if (document.orderform.PageDesc.value == ""){
  	document.getElementById("PageDescErr").firstChild.data = "Enter Order Description!";
	document.orderform.PageDesc.style.borderColor = "#FF0000"; 
	location.href = "#HrefPageDescErr";
  	document.orderform.PageDesc.focus(); 
	return false;
} else {
	document.getElementById("PageDescErr").firstChild.data = "";
	document.orderform.PageDesc.style.borderColor = "#bbbbbb";
}

if (document.orderform.FullName.value == ""){
	document.orderform.FullName.style.borderColor = "#FF0000"; 
	document.getElementById("FullNameErr").firstChild.data = "Enter Full Name!";
	location.href = "#HrefFullNameErr";
	document.orderform.FullName.focus(); 
	return false;
} else {
	document.getElementById("FullNameErr").firstChild.data = "";
	document.orderform.FullName.style.borderColor = "#bbbbbb";
}

if (document.orderform.Email.value == ""){
  document.getElementById("EmailErr").firstChild.data = "Enter Email Address!";
  document.orderform.Email.style.borderColor = "#FF0000"; 
  location.href = "#HrefEmailErr";
  document.orderform.Email.focus(); 
  return false;
} else if (document.orderform.Email.value != "") {
	Email=document.orderform.Email.value;
	attherate=false;
	dot=false;

	a=Email;
	b=a.length;

	for (c=1;c<=b;c++) {
		d=a.substr(c,1);

		if (d=="@") {
			attherate=true;
		}

		if (d==".") {
			dot=true;
		}
	}

	if (attherate==false || dot==false) {
		document.getElementById("EmailErr").firstChild.data = "Enter Valid Email Address!";
	  	document.orderform.Email.style.borderColor = "#FF0000"; 
		location.href = "#HrefEmailErr";
	  	document.orderform.Email.focus();
		return false;
	} else {
		document.getElementById("EmailErr").firstChild.data = "";
		document.orderform.Email.style.borderColor = "#bbbbbb"; 
	}
} else {
	document.orderform.EmailErr.value="";
	document.orderform.Email.style.borderColor = "#bbbbbb"; 
}

if (document.orderform.AltEmail.value != "") {
	AltEmail=document.orderform.AltEmail.value;
	attherate=false;
	dot=false;

	a=AltEmail;
	b=a.length;

	for (c=1;c<=b;c++) {
		d=a.substr(c,1);

		if (d=="@") {
			attherate=true;
		}

		if (d==".") {
			dot=true;
		}
	}

	if (attherate==false || dot==false) {
		document.getElementById("AltEmailErr").firstChild.data = "Enter Valid Alternate Email!";
	  	document.orderform.AltEmail.style.borderColor = "#FF0000"; 
		location.href = "#HrefAltEmailErr";
	  	document.orderform.AltEmail.focus();
		return false;
	} else {
		document.getElementById("AltEmailErr").firstChild.data = "";
		document.orderform.AltEmail.style.borderColor = "#bbbbbb"; 
	}
} else {
	document.orderform.AltEmailErr.value="";
	document.orderform.AltEmail.style.borderColor = "#bbbbbb"; 
}

if (IsNumeric(document.orderform.Phone.value) == false){
	document.getElementById("PhoneErr").firstChild.data = "Enter Numeric Values!";
	document.orderform.Phone.style.borderColor = "#FF0000"; 
	location.href = "#HrefPhoneErr";
	document.orderform.Phone.focus();
	return false;
} else {
	document.getElementById("PhoneErr").firstChild.data = "";
	document.orderform.Email.style.borderColor = "#bbbbbb"; 
}


}

function callEditOrder(){
location.href = "OrderForm_Edit.asp";
}

function saveSchoolCollegeLevel() {
document.getElementById("valSchoolCollegeLevel").value = document.getElementById("SchoolCollegeLevel").selectedIndex;
}

function savePaperType() {

if (document.getElementById("PaperType").selectedIndex == 4 || document.getElementById("PaperType").selectedIndex == 5) {

document.getElementById("SH-ReqDays1").style.display = "none";
document.getElementById("SH-ReqDays2").style.display = "block";

document.getElementById("SH-NumWords1").style.display = "none";
document.getElementById("SH-NumWords2").style.display = "block";

document.getElementById("valPaperType").value = document.getElementById("PaperType").selectedIndex;

CalculateAmount2();

} else {

document.getElementById("SH-ReqDays1").style.display = "block";
document.getElementById("SH-ReqDays2").style.display = "none";

document.getElementById("SH-NumWords1").style.display = "block";
document.getElementById("SH-NumWords2").style.display = "none";

document.getElementById("valPaperType").value = document.getElementById("PaperType").selectedIndex;

CalculateAmount();

}

}

function saveCitationStyle() {
document.getElementById("valCitationStyle").value = document.getElementById("CitationStyle").selectedIndex;
}

function saveNumSourceRef() {
document.getElementById("valNumSourceRef").value = document.getElementById("NumSourceRef").selectedIndex;
}

function saveReqDays() {
document.getElementById("valReqDays").value = document.getElementById("ReqDays").selectedIndex;
}

// CONTACT US

function LoadContactFunctions() {

	SetVariables();

	var getCurrentDate = new Date();
	
	idOrderMonth.selectedIndex	= getCurrentDate.getMonth()+1;
	idOrderDate.selectedIndex	= getCurrentDate.getDate();
	
	if (varOrderYear == "2010"){
		idOrderYear.selectedIndex = 1;

		CurrentYear = 1;
	}
	
	if (varOrderYear == "2011"){
		idOrderYear.selectedIndex = 2;
		CurrentYear = 2;
	}
	
	if (varOrderYear == "2012"){
		idOrderYear.selectedIndex = 3;
		CurrentYear = 3;
	}
	
	SetDeadline();

}

function ChkContactOldDate(){

	SetVariables();
	
	if ( YearSI == 0 ) { ShowAlert(); }
	
	if ( MonthSI == 0 ) { ShowAlert(); }
	
	if ( DateSI == 0 ) { ShowAlert(); }
	
	
	if ( MonthSI == CurrentMonth && DateSI < CurrentDate && YearSI == CurrentYear ) { ShowAlert(); }
	
	if ( MonthSI < CurrentMonth && DateSI == CurrentDate && YearSI == CurrentYear ) { ShowAlert(); }
	
	if ( MonthSI == CurrentMonth && DateSI == CurrentDate && YearSI < CurrentYear ) { ShowAlert(); }
	
	
	if ( MonthSI < CurrentMonth && DateSI > CurrentDate && YearSI == CurrentYear ) { ShowAlert(); }
	
	if ( MonthSI < CurrentMonth && DateSI < CurrentDate && YearSI == CurrentYear ) { ShowAlert(); }
	
	if ( MonthSI > CurrentMonth && DateSI > CurrentDate && YearSI < CurrentYear ) { ShowAlert(); }
	
	if ( MonthSI == CurrentMonth && DateSI > CurrentDate && YearSI < CurrentYear ) { ShowAlert(); }
	
	if ( MonthSI > CurrentMonth && DateSI == CurrentDate && YearSI < CurrentYear ) { ShowAlert(); }
	
	if ( MonthSI < CurrentMonth && DateSI < CurrentDate && YearSI < CurrentYear ) { ShowAlert(); }
	
	SetDeadline();
	
}

function ShowAlert() {
	strAlert = "Sorry! Your Cannot Select Old Date!";
	alert(strAlert);
	AddDays(0);
}


function CheckContactValues(){
	
if (document.orderform.FullName.value == ""){
	document.orderform.FullName.style.borderColor = "#FF0000"; 
	document.getElementById("FullNameErr").firstChild.data = "Enter Full Name!";
	location.href = "#HrefFullNameErr";
	document.orderform.FullName.focus(); 
	return false;
} else {
	document.getElementById("FullNameErr").firstChild.data = "";
	document.orderform.FullName.style.borderColor = "#bbbbbb";
}

if (document.orderform.Email.value == ""){
  document.getElementById("EmailErr").firstChild.data = "Enter Email Address!";
  document.orderform.Email.style.borderColor = "#FF0000"; 
  location.href = "#HrefEmailErr";
  document.orderform.Email.focus(); 
  return false;
} else if (document.orderform.Email.value != "") {
	Email=document.orderform.Email.value;
	attherate=false;
	dot=false;

	a=Email;
	b=a.length;

	for (c=1;c<=b;c++) {
		d=a.substr(c,1);

		if (d=="@") {
			attherate=true;
		}

		if (d==".") {
			dot=true;
		}
	}

	if (attherate==false || dot==false) {
		document.getElementById("EmailErr").firstChild.data = "Enter Valid Email Address!";
	  	document.orderform.Email.style.borderColor = "#FF0000"; 
		location.href = "#HrefEmailErr";
	  	document.orderform.Email.focus();
		return false;
	} else {
		document.getElementById("EmailErr").firstChild.data = "";
		document.orderform.Email.style.borderColor = "#bbbbbb"; 
	}
} else {
	document.orderform.EmailErr.value="";
	document.orderform.Email.style.borderColor = "#bbbbbb"; 
}

if (IsNumeric(document.orderform.Phone.value) == false){
	document.getElementById("PhoneErr").firstChild.data = "Enter Numeric Values!";
	document.orderform.Phone.style.borderColor = "#FF0000"; 
	location.href = "#HrefPhoneErr";
	document.orderform.Phone.focus();
	return false;
} else {
	document.getElementById("PhoneErr").firstChild.data = "";
	document.orderform.Email.style.borderColor = "#bbbbbb"; 
}

if (document.getElementById("QueryType").selectedIndex == 1 || document.getElementById("QueryType").selectedIndex == 2 || document.getElementById("QueryType").selectedIndex == 3) {

if (document.orderform.OrderID.value == "" || document.getElementById("OrderIDErr").firstChild.data == "Order ID Not Found!"){
		document.orderform.OrderID.style.borderColor = "#FF0000"; 
		document.getElementById("OrderIDErr").firstChild.data = "Order ID Not Found!";
		document.orderform.OrderID.focus(); 
		return false;
	} else {
		document.getElementById("OrderIDErr").firstChild.data = "";
		document.orderform.OrderID.style.borderColor = "#bbbbbb";
	}

}

}

function FuncQueryType(){
	
	idQueryType 	= document.getElementById("QueryType");
	disOrderID		= document.getElementById("OrderID")
	disOrderMonth	= document.getElementById("OrderMonth")
	disOrderDate	= document.getElementById("OrderDate")
	disOrderYear	= document.getElementById("OrderYear")
	
	if (idQueryType.selectedIndex == 1 || idQueryType.selectedIndex == 3) {
	
		disOrderID.style.display 	= "block";		
		disOrderMonth.style.display = "none";
		disOrderDate.style.display 	= "none";
		disOrderYear.style.display 	= "none";
	
	} else if (idQueryType.selectedIndex == 2) {
	
		disOrderID.style.display 	= "block";
		disOrderMonth.style.display = "block";
		disOrderDate.style.display 	= "block";
		disOrderYear.style.display 	= "block";
	
	} else {
	
		disOrderID.style.display 	= "none";
		disOrderMonth.style.display = "none";
		disOrderDate.style.display 	= "none";
		disOrderYear.style.display 	= "none";
	
	}
	
}

function EndOfMonthYear() {

	var MyDate = new Date();
	var Month=new Array(12);
	Month[0]="January";
	Month[1]="February";
	Month[2]="March";
	Month[3]="April";
	Month[4]="May";
	Month[5]="June";
	Month[6]="July";
	Month[7]="August";
	Month[8]="September";
	Month[9]="October";
	Month[10]="November";
	Month[11]="December";
	var Mon = Month[MyDate.getMonth()];
	var Year = MyDate.getFullYear();
	document.write(Mon + " " + Year);

}

// Small Contact Form

function IsNumeric(strString) {

var strValidChars = "0123456789-+";
var strChar;
var blnResult = true;

	for (i = 0; i<strString.length && blnResult==true; i++){
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1){
			blnResult = false;
		}
	}
	return blnResult;
}

function SmallContactForm(){
	
if (document.ContactSmallForm.FullName.value == ""){
	alert("Please Enter Your Full Name.");
	document.ContactSmallForm.FullName.focus(); 
	return false;
}


if (document.ContactSmallForm.Email.value == ""){
	alert("Please Enter Your Email Address.");
	document.ContactSmallForm.Email.focus(); 
	return false;
} else if (document.ContactSmallForm.Email.value != "") {
	Email=document.ContactSmallForm.Email2value;
	attherate=false;
	dot=false;

	a=Email;
	b=a.length;

	for (c=1;c<=b;c++) {
		d=a.substr(c,1);

		if (d=="@") {
			attherate=true;
		}

		if (d==".") {
			dot=true;
		}
	}

	if (attherate==false || dot==false) {
		alert("Please Enter Your Email Address.");
		document.ContactSmallForm.Email.focus();
		return false;
	}
}

if (document.ContactSmallForm.ContactNo.value == "") {
	alert("Please Enter Your Contact Number.");
	document.ContactSmallForm.ContactNo.focus();
		return false;
} else if (IsNumeric(document.ContactSmallForm.ContactNo.value) == false){
	alert("Please Enter Your Valid Contact Number.");
	document.ContactSmallForm2.ContactNo.focus();
	return false;
}

}

// Small Contact Form 2

function SmallContactForm2(){
	
if (document.ContactSmallForm2.FullName2.value == ""){
	alert("Please Enter Your Full Name.");
	document.ContactSmallForm2.FullName2.focus(); 
	return false;
}


if (document.ContactSmallForm2.Email2.value == ""){
	alert("Please Enter Your Email Address.");
	document.ContactSmallForm2.Email2.focus(); 
	return false;
} else if (document.ContactSmallForm2.Email2.value != "") {
	Email=document.ContactSmallForm2.Email2.value;
	attherate=false;
	dot=false;

	a=Email;
	b=a.length;

	for (c=1;c<=b;c++) {
		d=a.substr(c,1);

		if (d=="@") {
			attherate=true;
		}

		if (d==".") {
			dot=true;
		}
	}

	if (attherate==false || dot==false) {
		alert("Please Enter Your Email Address.");
		document.ContactSmallForm2.Email2.focus();
		return false;
	}
}

if (document.ContactSmallForm2.ContactNo2.value == "") {
	alert("Please Enter Your Contact Number.");
	document.ContactSmallForm2.ContactNo2.focus();
		return false;
} else if (IsNumeric(document.ContactSmallForm2.ContactNo2.value) == false){
	alert("Please Enter Your Valid Contact Number.");
	document.ContactSmallForm2.ContactNo2.focus();
	return false;
}

}