// JavaScript Document

function LoadFunctions()
{
	SetVariables();
	setCurrentDate();
	CalculateAmount();
//	CalculateAmount2();
	saveSchoolCollegeLevel();
	savePaperType();
	saveCitationStyle();
	saveNumSourceRef();
}

function SetVariables()
{
	
	var getCurrentDate = new Date();
	
	idOrderMonth 	= document.getElementById("OrderMonth");
	idOrderDate 	= document.getElementById("OrderDate");
	idOrderYear 	= document.getElementById("OrderYear");
	
	idOrderMonthHID	= document.getElementById("OrderMonthHID");
	idOrderDateHID 	= document.getElementById("OrderDateHID");
	idOrderYearHID 	= document.getElementById("OrderYearHID");
	
	idReqDays		= document.getElementById("ReqDays");
	idReqDays2		= document.getElementById("ReqDays2");
	idReqDaysHID	= document.getElementById("ReqDaysHID");
	idReqDays2HID	= document.getElementById("ReqDays2HID");
	
	idReqDaysValHID	= document.getElementById("ReqDaysValHID");
	
	idNumWords		= document.getElementById("NumWords");
	idNumWords2		= document.getElementById("NumWords2");
	idNumWordsHID	= document.getElementById("NumWordsHID");
	idNumWords2HID	= document.getElementById("NumWords2HID");
	
	idTotalAmountErr 	= document.getElementById("TotalAmountErr");
	idTotalDiscountErr 	= document.getElementById("TotalDiscountErr");
	idTotalPayErr		= document.getElementById("TotalPayErr");
	idTotalAmountHID 	= document.getElementById("TotalAmountHID");
	idTotalDiscountHID	= document.getElementById("TotalDiscountHID");
	idTotalPayHID		= document.getElementById("TotalPayHID");

	YearSI	= idOrderYear.selectedIndex;
	DateSI 	= idOrderDate.selectedIndex;
	MonthSI = idOrderMonth.selectedIndex;
	
	varGetFullYear = getCurrentDate.getFullYear();
	
	if (varGetFullYear == "2011") { setCurrentYear = 1; }
	
	if (varGetFullYear == "2012") { setCurrentYear = 2; }
	
	if (varGetFullYear == "2013") { setCurrentYear = 3; }
	
	if (varGetFullYear == "2014") { setCurrentYear = 4; }
	
	if (varGetFullYear == "2015") { setCurrentYear = 5; }
	
	if (varGetFullYear == "2016") { setCurrentYear = 6; }
	
	if (varGetFullYear == "2017") { setCurrentYear = 7; }
	
	if (varGetFullYear == "2018") { setCurrentYear = 8; }
	
	if (varGetFullYear == "2019") { setCurrentYear = 9; }
	
	if (varGetFullYear == "2020") { setCurrentYear = 10; }
	
	CurrentMonth	= getCurrentDate.getMonth()+1;
	CurrentDate		= getCurrentDate.getDate();
	CurrentYear 	= setCurrentYear;
	
}

function setCurrentDate()
{
	SetVariables();

	MonthSI	= CurrentMonth;
	DateSI	= CurrentDate;
	YearSI	= CurrentYear;
}

function ChkOldDate(){

	SetVariables();
	
	if ( MonthSI == 0 || DateSI == 0 || YearSI == 0 ) { showError("", 10); }
	
	if ( MonthSI == CurrentMonth && DateSI < CurrentDate && YearSI == CurrentYear ) { showError("", 10); }
	
	if ( MonthSI < CurrentMonth && DateSI == CurrentDate && YearSI == CurrentYear ) { showError("", 10); }
	
	if ( MonthSI == CurrentMonth && DateSI == CurrentDate && YearSI < CurrentYear ) { showError("", 10); }	
	
	if ( MonthSI < CurrentMonth && DateSI > CurrentDate && YearSI == CurrentYear ) { showError("", 10); }
	
	if ( MonthSI < CurrentMonth && DateSI < CurrentDate && YearSI == CurrentYear ) { showError("", 10); }
	
	if ( MonthSI > CurrentMonth && DateSI > CurrentDate && YearSI < CurrentYear ) { showError("", 10); }
	
	if ( MonthSI == CurrentMonth && DateSI > CurrentDate && YearSI < CurrentYear ) { showError("", 10); }
	
	if ( MonthSI > CurrentMonth && DateSI == CurrentDate && YearSI < CurrentYear ) { showError("", 10); }
	
	if ( MonthSI < CurrentMonth && DateSI < CurrentDate && YearSI < CurrentYear ) { showError("", 10); }
	
	if (MonthSI == 2 && DateSI == 29 && YearSI == 1 || MonthSI == 2 && DateSI == 29 && YearSI == 3 || MonthSI == 2 && DateSI == 29 && YearSI == 4 || MonthSI == 2 && DateSI == 29 && YearSI == 5 || MonthSI == 2 && DateSI == 29 && YearSI == 7 || MonthSI == 2 && DateSI == 29 && YearSI == 8 || MonthSI == 2 && DateSI == 29 && YearSI == 9) { showError("LeapYear", 10); }
	
	if (MonthSI == 2 && DateSI == 30 || MonthSI == 2 && DateSI == 31) { showError("NotLeapYear", 10); }
	
	if (MonthSI == 4 && DateSI == 31 || MonthSI == 6 && DateSI == 31 || MonthSI == 9 && DateSI == 31 || MonthSI == 11 && DateSI == 31) { showError("InvalidDateInMonth", 10); }
}

function showError(chkDateParam, totalDays) {
	if (chkDateParam == "LeapYear")
	{
		strAlert = "Sorry! This Year Is Not Leap Year.";
	}
	else if (chkDateParam == "NotLeapYear")
	{
		strAlert = "Sorry! You Cannot Select 30th or 31st In Februrary.";
	}
	else if (chkDateParam == "InvalidDateInMonth")
	{
		strAlert = "Sorry! You Cannot Select 31st In Selected Month.";
	}
	else
	{
		strAlert = "Sorry! You Cannot Select Old Date!";
	}
	alert(strAlert);
	AddDays(totalDays);
}

function AddDays(Cnt) {
	
	SetVariables();

	if (CurrentMonth == 1 || CurrentMonth == 3 || CurrentMonth == 5 || CurrentMonth == 7 || CurrentMonth == 8 || CurrentMonth == 10 || CurrentMonth == 12)
	{	
		varTotalDates 	= 31;	
	}
	else if	(CurrentMonth == 4 || CurrentMonth == 6 || CurrentMonth == 9 || CurrentMonth == 11)
	{	
		varTotalDates 	= 30;	
	}
	else
	{
		ChkLeapYear = varGetFullYear;
		if (ChkLeapYear == "2012" || ChkLeapYear == "2016" || ChkLeapYear == "2020")
		{	
			varTotalDates 	= 29;
		}
		else
		{
			varTotalDates 	= 28;
		}
	}
	
	varTotalMonths 	= 12;
	varAddedDays 				= CurrentDate+Cnt;
	
	idOrderMonth.selectedIndex 	= CurrentMonth;
	idOrderMonthHID.value 		= idOrderMonth.selectedIndex;
	
	idOrderDate.selectedIndex	= varAddedDays;
	idOrderDateHID.value 		= idOrderDate.selectedIndex;
	
	idOrderYear.selectedIndex	= CurrentYear;
	idOrderYearHID.value		= idOrderYear.selectedIndex;
	
	if ( varAddedDays > varTotalDates )
	{		
		idOrderDate.selectedIndex	= varAddedDays - varTotalDates;
		idOrderDateHID.value 		= idOrderDate.selectedIndex;
		
		varAddedMonth				= CurrentMonth + 1;
		
		idOrderMonth.selectedIndex 	= varAddedMonth;
		idOrderMonthHID.value 		= idOrderMonth.selectedIndex;
		
		if ( varAddedMonth > varTotalMonths )
		{			
			idOrderMonth.selectedIndex	= varAddedMonth - varTotalMonths;
			idOrderMonthHID.value 		= idOrderMonth.selectedIndex;
			
			idOrderYear.selectedIndex	= CurrentYear+1;
			idOrderYearHID.value 		= idOrderYear.selectedIndex;			
		}
	}

}

function CalculateAmount()
{	
	SetVariables();
	
	DisOne 		= 10;
	DisTwo 		= 12.5;
	DisThree 	= 15;
	DisFour 	= 20;
	
	var RQlen = idReqDays.length;
	
	for (a=0; a<RQlen; a++)
	{
		if (idReqDays[a].selected)
		{
			ReqDays = idReqDays[a].value;
		}
	}
	
	var NWlen = idNumWords.length;
	
	for (b=0; b<NWlen; b++)
	{
		if (idNumWords[b].selected)
		{
			varNumWords = idNumWords[b].value;
		}
	}
	
	varPageCount = varNumWords/250;	
	varTotalValue = varPageCount*ReqDays;
		
	idTotalAmountErr.firstChild.data = varTotalValue;
	idTotalAmountHID.value = idTotalAmountErr.firstChild.data;
	
	theValue = idTotalAmountErr.firstChild.data;
	idTotalAmountHID.value = idTotalAmountErr.firstChild.data;
	
	if(theValue.indexOf(".") != -1)
	{
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	
	idTotalAmountErr.firstChild.data = theValue;
	idTotalAmountHID.value = idTotalAmountErr.firstChild.data;
	
	varDiscountFormula = varTotalValue/100;
	
	
	if (varNumWords <= 2250)
	{
	
		varDiscount = "0";
		
		idTotalDiscountErr.firstChild.data = varDiscount;
		theValue = idTotalDiscountErr.firstChild.data;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		
		if(theValue.indexOf(".") != -1)
		{
			theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
		}
		idTotalDiscountErr.firstChild.data = theValue;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
	
	}
	else if (varNumWords >= 2500 && varNumWords <= 3750)
	{
	
		varDiscount = varDiscountFormula * DisOne;
		
		idTotalDiscountErr.firstChild.data = varDiscount;
		theValue = idTotalDiscountErr.firstChild.data;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		if(theValue.indexOf(".") != -1)
		{
			theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
		}
		idTotalDiscountErr.firstChild.data = theValue;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
	
	}
	else if (varNumWords >= 4000 && varNumWords <= 5250)
	{
	
		varDiscount = varDiscountFormula * DisTwo;
		
		idTotalDiscountErr.firstChild.data = varDiscount;
		theValue = idTotalDiscountErr.firstChild.data;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		
		if(theValue.indexOf(".") != -1)
		{
			theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
		}
		idTotalDiscountErr.firstChild.data = theValue;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
	
	}
	else if (varNumWords >= 5500 && varNumWords <= 6250)
	{
	
		varDiscount = varDiscountFormula * DisThree;
		
		idTotalDiscountErr.firstChild.data = varDiscount;
		theValue = idTotalDiscountErr.firstChild.data;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		
		if(theValue.indexOf(".") != -1)
		{
			theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
		}
		idTotalDiscountErr.firstChild.data = theValue;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		
	}
	else
	{
	
		varDiscount = varDiscountFormula * DisFour;
		
		idTotalDiscountErr.firstChild.data = varDiscount;
		theValue = idTotalDiscountErr.firstChild.data;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		if(theValue.indexOf(".") != -1)
		{
			theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
		}
		idTotalDiscountErr.firstChild.data = theValue;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
	}
	
	varDiscountValue 				= varTotalValue-varDiscount;	
	idTotalPayErr.firstChild.data 	= varDiscountValue;	
	theValue 						= idTotalPayErr.firstChild.data;
	idTotalPayHID.value 			= idTotalPayErr.firstChild.data;
	
	if(theValue.indexOf(".") != -1)
	{
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	
	idTotalPayErr.firstChild.data 	= theValue;
	idTotalPayHID.value 			= idTotalPayErr.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)
	{
		AddDays(7);
	}
	
	if (idReqDays.selectedIndex == 6)
	{
		AddDays(9);
	}
	
	if (idReqDays.selectedIndex == 7)
	{		
		idOrderMonth.style.display 	= "block";
		idOrderDate.style.display 	= "block";
		idOrderYear.style.display 	= "block";
		
		AddDays(10);	
	}
	else
	{		
		idOrderMonth.style.display 	= "none";
		idOrderDate.style.display 	= "none";
		idOrderYear.style.display 	= "none";
	}
	
	idNumWordsHID.value 	= idNumWords.selectedIndex;
	idReqDaysHID.value 		= idReqDays.selectedIndex;
	idReqDaysValHID.value 	= idReqDays.options[idReqDays.selectedIndex].value;

}

function CalculateAmount2()
{	
	SetVariables();
	
	DisOne 		= 10;
	DisTwo 		= 12.5;
	DisThree 	= 15;
	DisFour 	= 20;
	
	var RQlen = idReqDays2.length;
	
	for (a=0; a<RQlen; a++)
	{
		if (idReqDays2[a].selected)
		{
			ReqDays = idReqDays2[a].value;
		}
	}
	
	var NWlen = idNumWords2.length;
	
	for (b=0; b<NWlen; b++)
	{
		if (idNumWords2[b].selected)
		{
			varNumWords = idNumWords2[b].value;
		}
	}
	
	varPageCount = varNumWords/250;	
	varTotalValue = varPageCount*ReqDays;
		
	idTotalAmountErr.firstChild.data = varTotalValue;
	idTotalAmountHID.value = idTotalAmountErr.firstChild.data;
	
	theValue = idTotalAmountErr.firstChild.data;
	idTotalAmountHID.value = idTotalAmountErr.firstChild.data;
	
	if(theValue.indexOf(".") != -1)
	{
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	
	idTotalAmountErr.firstChild.data = theValue;
	idTotalAmountHID.value = idTotalAmountErr.firstChild.data;
	
	varDiscountFormula = varTotalValue/100;
	
	
	if (varNumWords <= 2250)
	{
	
		varDiscount = "0";
		
		idTotalDiscountErr.firstChild.data = varDiscount;
		theValue = idTotalDiscountErr.firstChild.data;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		
		if(theValue.indexOf(".") != -1)
		{
			theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
		}
		idTotalDiscountErr.firstChild.data = theValue;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
	
	}
	else if (varNumWords >= 2500 && varNumWords <= 3750)
	{
	
		varDiscount = varDiscountFormula * DisOne;
		
		idTotalDiscountErr.firstChild.data = varDiscount;
		theValue = idTotalDiscountErr.firstChild.data;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		if(theValue.indexOf(".") != -1)
		{
			theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
		}
		idTotalDiscountErr.firstChild.data = theValue;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
	
	}
	else if (varNumWords >= 4000 && varNumWords <= 5250)
	{
	
		varDiscount = varDiscountFormula * DisTwo;
		
		idTotalDiscountErr.firstChild.data = varDiscount;
		theValue = idTotalDiscountErr.firstChild.data;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		
		if(theValue.indexOf(".") != -1)
		{
			theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
		}
		idTotalDiscountErr.firstChild.data = theValue;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
	
	}
	else if (varNumWords >= 5500 && varNumWords <= 6250)
	{
	
		varDiscount = varDiscountFormula * DisThree;
		
		idTotalDiscountErr.firstChild.data = varDiscount;
		theValue = idTotalDiscountErr.firstChild.data;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		
		if(theValue.indexOf(".") != -1)
		{
			theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
		}
		idTotalDiscountErr.firstChild.data = theValue;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		
	}
	else
	{
	
		varDiscount = varDiscountFormula * DisFour;
		
		idTotalDiscountErr.firstChild.data = varDiscount;
		theValue = idTotalDiscountErr.firstChild.data;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
		if(theValue.indexOf(".") != -1)
		{
			theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
		}
		idTotalDiscountErr.firstChild.data = theValue;
		idTotalDiscountHID.value = idTotalDiscountErr.firstChild.data;
	}
	
	varDiscountValue 				= varTotalValue-varDiscount;	
	idTotalPayErr.firstChild.data 	= varDiscountValue;	
	theValue 						= idTotalPayErr.firstChild.data;
	idTotalPayHID.value 			= idTotalPayErr.firstChild.data;
	
	if(theValue.indexOf(".") != -1)
	{
		theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
	}
	
	idTotalPayErr.firstChild.data 	= theValue;
	idTotalPayHID.value 			= idTotalPayErr.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)
	{
		AddDays(7);
	}
	
	if (idReqDays2.selectedIndex == 6)
	{
		AddDays(9);
	}
	
	if (idReqDays2.selectedIndex == 7)
	{		
		idOrderMonth.style.display 	= "block";
		idOrderDate.style.display 	= "block";
		idOrderYear.style.display 	= "block";
		
		AddDays(10);	
	}
	else
	{		
		idOrderMonth.style.display 	= "none";
		idOrderDate.style.display 	= "none";
		idOrderYear.style.display 	= "none";
	}
	
	idNumWords2HID.value 	= idNumWords2.selectedIndex;
	idReqDays2HID.value 	= idReqDays2.selectedIndex;
	idReqDaysValHID.value 	= idReqDays2.options[idReqDays2.selectedIndex].value;

}

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.getElementById("Terms").checked==false) {
	alert("Please Read Terms and Conditions Before Submiting Form. Thankyou");
	return false;
}
	
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 == 5 || document.getElementById("PaperType").selectedIndex == 6)
	{
		document.getElementById("SH-ReqDays1").style.display = "none";
		document.getElementById("SH-ReqDays2").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("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() {
idReqDaysHID.value = document.getElementById("ReqDays").selectedIndex;
}

// CONTACT US

function LoadContactFunctions() {

	var getCurrentDate = new Date();
	
	idOrderMonth 	= document.getElementById("OrderMonth");
	idOrderDate 	= document.getElementById("OrderDate");
	idOrderYear 	= document.getElementById("OrderYear");
	
	idOrderMonthHID	= document.getElementById("OrderMonthHID");
	idOrderDateHID 	= document.getElementById("OrderDateHID");
	idOrderYearHID 	= document.getElementById("OrderYearHID");

	YearSI	= idOrderYear.selectedIndex;
	DateSI 	= idOrderDate.selectedIndex;
	MonthSI = idOrderMonth.selectedIndex;
	
	varGetFullYear = getCurrentDate.getFullYear();
	
	if (varGetFullYear == "2011") { setCurrentYear = 1; }
	
	if (varGetFullYear == "2012") { setCurrentYear = 2; }
	
	if (varGetFullYear == "2013") { setCurrentYear = 3; }
	
	if (varGetFullYear == "2014") { setCurrentYear = 4; }
	
	if (varGetFullYear == "2015") { setCurrentYear = 5; }
	
	if (varGetFullYear == "2016") { setCurrentYear = 6; }
	
	if (varGetFullYear == "2017") { setCurrentYear = 7; }
	
	if (varGetFullYear == "2018") { setCurrentYear = 8; }
	
	if (varGetFullYear == "2019") { setCurrentYear = 9; }
	
	if (varGetFullYear == "2020") { setCurrentYear = 10; }
	
	idOrderMonth.selectedIndex	= getCurrentDate.getMonth()+1;
	idOrderDate.selectedIndex	= getCurrentDate.getDate();
	idOrderYear.selectedIndex 	= setCurrentYear;

}

function ChkContactOldDate(){

	SetVariables();
	
	if ( MonthSI == 0 || DateSI == 0 || YearSI == 0 ) { showError("", 0); }
	
	if ( MonthSI == CurrentMonth && DateSI < CurrentDate && YearSI == CurrentYear ) { showError("", 0); }
	
	if ( MonthSI < CurrentMonth && DateSI == CurrentDate && YearSI == CurrentYear ) { showError("", 0); }
	
	if ( MonthSI == CurrentMonth && DateSI == CurrentDate && YearSI < CurrentYear ) { showError("", 0); }	
	
	if ( MonthSI < CurrentMonth && DateSI > CurrentDate && YearSI == CurrentYear ) { showError("", 0); }
	
	if ( MonthSI < CurrentMonth && DateSI < CurrentDate && YearSI == CurrentYear ) { showError("", 0); }
	
	if ( MonthSI > CurrentMonth && DateSI > CurrentDate && YearSI < CurrentYear ) { showError("", 0); }
	
	if ( MonthSI == CurrentMonth && DateSI > CurrentDate && YearSI < CurrentYear ) { showError("", 0); }
	
	if ( MonthSI > CurrentMonth && DateSI == CurrentDate && YearSI < CurrentYear ) { showError("", 0); }
	
	if ( MonthSI < CurrentMonth && DateSI < CurrentDate && YearSI < CurrentYear ) { showError("", 0); }
	
	if (MonthSI == 2 && DateSI == 29 && YearSI == 1 || MonthSI == 2 && DateSI == 29 && YearSI == 3 || MonthSI == 2 && DateSI == 29 && YearSI == 4 || MonthSI == 2 && DateSI == 29 && YearSI == 5 || MonthSI == 2 && DateSI == 29 && YearSI == 7 || MonthSI == 2 && DateSI == 29 && YearSI == 8 || MonthSI == 2 && DateSI == 29 && YearSI == 9) { showError("LeapYear", 0); }
	
	if (MonthSI == 2 && DateSI == 30 || MonthSI == 2 && DateSI == 31) { showError("NotLeapYear", 0); }
	
	if (MonthSI == 4 && DateSI == 31 || MonthSI == 6 && DateSI == 31 || MonthSI == 9 && DateSI == 31 || MonthSI == 11 && DateSI == 31) { showError("InvalidDateInMonth", 0); }
}

function CheckContactValues(){
	
if (document.ContactForm.FullName.value == ""){
	document.ContactForm.FullName.style.borderColor = "#FF0000"; 
	document.getElementById("FullNameErr").firstChild.data = "Enter Full Name!";
	location.href = "#HrefFullNameErr";
	document.ContactForm.FullName.focus(); 
	return false;
} else {
	document.getElementById("FullNameErr").firstChild.data = "";
	document.ContactForm.FullName.style.borderColor = "#bbbbbb";
}

if (document.ContactForm.Email.value == ""){
  document.getElementById("EmailErr").firstChild.data = "Enter Email Address!";
  document.ContactForm.Email.style.borderColor = "#FF0000"; 
  location.href = "#HrefEmailErr";
  document.ContactForm.Email.focus(); 
  return false;
} else if (document.ContactForm.Email.value != "") {
	Email=document.ContactForm.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.ContactForm.Email.style.borderColor = "#FF0000"; 
		location.href = "#HrefEmailErr";
	  	document.ContactForm.Email.focus();
		return false;
	} else {
		document.getElementById("EmailErr").firstChild.data = "";
		document.ContactForm.Email.style.borderColor = "#bbbbbb"; 
	}
} else {
	document.ContactForm.EmailErr.value="";
	document.ContactForm.Email.style.borderColor = "#bbbbbb"; 
}

if (IsNumeric(document.ContactForm.Phone.value) == false){
	document.getElementById("PhoneErr").firstChild.data = "Enter Numeric Values!";
	document.ContactForm.Phone.style.borderColor = "#FF0000"; 
	location.href = "#HrefPhoneErr";
	document.ContactForm.Phone.focus();
	return false;
} else {
	document.getElementById("PhoneErr").firstChild.data = "";
	document.ContactForm.Email.style.borderColor = "#bbbbbb"; 
}

if (document.getElementById("QueryType").selectedIndex == 1 || document.getElementById("QueryType").selectedIndex == 2 || document.getElementById("QueryType").selectedIndex == 3) {

if (document.ContactForm.OrderID.value == "" || document.getElementById("OrderIDErr").firstChild.data == "Order ID Not Found!"){
		document.ContactForm.OrderID.style.borderColor = "#FF0000"; 
		document.getElementById("OrderIDErr").firstChild.data = "Order ID Not Found!";
		document.ContactForm.OrderID.focus(); 
		return false;
	} else {
		document.getElementById("OrderIDErr").firstChild.data = "";
		document.ContactForm.OrderID.style.borderColor = "#bbbbbb";
	}

}

}

function FuncQueryType(){
	
	idQueryType 	= document.getElementById("QueryType");
	disOrderID		= document.getElementById("OrderID")
	disOrderMonth	= idOrderMonth
	disOrderDate	= idOrderDate
	disOrderYear	= idOrderYear
	
	if (idQueryType.selectedIndex == 1 || idQueryType.selectedIndex == 2 || idQueryType.selectedIndex == 4) {
	
		disOrderID.style.display 	= "block";		
		disOrderMonth.style.display = "none";
		disOrderDate.style.display 	= "none";
		disOrderYear.style.display 	= "none";
	
	} else if (idQueryType.selectedIndex == 3) {
	
		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);

}

var xmlHttp

function showCustomer(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="http://www.dissertationshelp.co.uk/ODH/forms/ChkOrderID.asp";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{
if (document.getElementById("OrderID").value != "")
{
document.getElementById("OrderIDErr").innerHTML=xmlHttp.responseText;
	if (document.getElementById("OrderIDErr").innerHTML != "Order ID Not Found!") {
	document.ContactForm.OrderID.style.borderColor = "#bbbbbb";
	} else {
	document.ContactForm.OrderID.style.borderColor = "#ff0000";
	}
}
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
