$(document).ready(function(){

	document.forms[0].HistoryRows.value = 4;

	document.forms[0].EducationRows.value = 4;

});

function addRecruitment()

{

	var frm = document.forms[0];

	if(frm.firstname.value=="")

	{

		alert("Input the FirstName");

		frm.firstname.focus();

		return;

	}

	if(frm.lastname.value=="")

	{

		alert("Input the LastName");

		frm.lastname.focus();

		return;

	}

	if(frm.position.value=="")

	{

		alert("Input the Position Applied");

		frm.position.focus();

		return;

	}

	if(frm.dateapplied.value=="")

	{

		alert("Input the DateApplied");

		frm.dateapplied.focus();

		return;

	}

	if(frm.birthdate.value=="")

	{

		alert("Input the BirthDate");

		frm.birthdate.focus();

		return;

	}

	if(frm.currentemployer.value=="")

	{

		alert("Input the Current Employer");

		frm.currentemployer.focus();

		return;

	}

	if(frm.title.value=="")

	{

		alert("Input the Title");

		frm.title.focus();

		return;

	}

	frm.saveFlag.value = 1;

	frm.action = "recruitment_form.php";

	document.forms[0].submit();

}

function addHistoryMore(tableID)

{

	

	var rowCount = document.forms[0].HistoryRows.value;

	var cVals = new Array(rowCount-4);

	var pVals = new Array(rowCount-4);

	var fVals = new Array(rowCount-4);

	var tVals = new Array(rowCount-4);

	

	if(rowCount > 4)

	{

		for(i = 0; i < rowCount-4;i++)

		{

			var cName = "company" + (4+i);

			var pName = "position" + (4+i);

			var fName = "employmentfrom" + (4+i);

			var tName = "employmentto" + (4+i);

			

			c = document.getElementsByName(cName);

			if(c != null)

				cVals[i] = c[0].value;

			p = document.getElementsByName(pName); 

			if(p != null)	

				pVals[i] = p[0].value;

			f = document.getElementsByName(fName);

			if(f != null)

			 	fVals[i] = f[0].value;

			t = document.getElementsByName(tName);

			if(t != null)

				tVals[i] = t[0].value;

		}

	}

		

	var oriHTML = $("#tableHistory").html();

	var tr1 = $("#historyTrs").html();

	tr1 = tr1.replace("companys","company"+rowCount);

	tr1 = tr1.replace("positions","position"+rowCount);

	tr1 = tr1.replace("employmentfroms","employmentfrom"+rowCount);

	tr1 = tr1.replace("employmenttos","employmentto"+rowCount);

	oriHTML += tr1;

	$("#tableHistory").html(oriHTML);

	if(rowCount > 4)

	{

		for(i = 0; i < rowCount-4;i++)

		{

			var cName = "company" + (4+i);

			var pName = "position" + (4+i);

			var fName = "employmentfrom" + (4+i);

			var tName = "employmentto" + (4+i);

			

			c = document.getElementsByName(cName); 

			c[0].value = cVals[i];

			p = document.getElementsByName(pName); 

			p[0].value = pVals[i];

			f = document.getElementsByName(fName); 

			f[0].value = fVals[i];

			t = document.getElementsByName(tName); 

			t[0].value = tVals[i];

		}

	}

	document.forms[0].HistoryRows.value = parseInt(document.forms[0].HistoryRows.value)+1;

}

function addEducationMore(tableID)

{

	var rowCount = document.forms[0].EducationRows.value;



	var cVals = new Array(rowCount-4);

	var pVals = new Array(rowCount-4);

	var fVals = new Array(rowCount-4);

	var tVals = new Array(rowCount-4);

	if(rowCount > 4)

	{

		for(i = 0; i < rowCount-4;i++)

		{

			var cName = "level" + (4+i);

			var pName = "major" + (4+i);

			var fName = "educationalfrom" + (4+i);

			var tName = "educationalto" + (4+i);

			

			c = document.getElementsByName(cName); 

			cVals[i] = c[0].value;

			p = document.getElementsByName(pName); 

			pVals[i] = p[0].value;

			f = document.getElementsByName(fName); 

			fVals[i] = f[0].value;

			t = document.getElementsByName(tName); 

			tVals[i] = t[0].value;

		}

	}

	

	var oriHTML = $("#EducationalTable").html();

	var tr1 = $("#educationTrs").html();

	tr1 = tr1.replace("levels","level"+rowCount);

	tr1 = tr1.replace("majors","major"+rowCount);

	tr1 = tr1.replace("educationalfroms","educationalfrom"+rowCount);

	tr1 = tr1.replace("educationaltos","educationalto"+rowCount);

	oriHTML += tr1;



	

	$("#EducationalTable").html(oriHTML);

	

	if(rowCount > 4)

	{

		for(i = 0; i < rowCount-4;i++)

		{

			var cName = "level" + (4+i);

			var pName = "major" + (4+i);

			var fName = "educationalfrom" + (4+i);

			var tName = "educationalto" + (4+i);

			

			c = document.getElementsByName(cName); 

			c[0].value = cVals[i];

			p = document.getElementsByName(pName); 

			p[0].value = pVals[i];

			f = document.getElementsByName(fName); 

			f[0].value = fVals[i];

			t = document.getElementsByName(tName); 

			t[0].value = tVals[i];

		}

	}

	document.forms[0].EducationRows.value = parseInt(document.forms[0].EducationRows.value)+1;

}



function addEnqurity()

{

	var frm = document.forms[0];

	

	

	var param = $(frm).serialize();

//	$.ajax({url:"getEnqurity.php?"+param, onSuccess: function(){ alert() } });

	

/*	$.ajax({type:"GET",url:"checkEnqurity.php?hidTransferID=" + 

					strApprovalNo + 

					"&txtAppliBlankNgDate=" + txtAppliBlankNgDate + "&txtAppliBlankOkDate=" + 

					txtAppliBlankOkDate,async:true,success:function(response){alert(response.text);}});*/

	

	

		

	if(frm.yourname.value=="")

	{

		alert("Input your name");

		frm.yourname.focus();

		return;

	}

	if(frm.email.value=="")

	{

		alert("Input your email address");

		frm.email.focus();

		return;

	}

	if(frm.comments.value=="")

	{

		alert("Input the comments");

		frm.comments.focus();

		return;

	}

	

	frm.saveFlag.value = 1;

	frm.action = "contact_us.php";

	document.forms[0].submit();

}



function resetEnqurity()

{

	var frm = document.forms[0];

	



	frm.yourname.value="";

	frm.email.value="";

	frm.comments.value="";

	frm.saveFlag.value = 0;

	frm.action = "contact_us.php";

	document.forms[0].submit();

}

///enews ///////////

function addENews()

{

	var frm = document.forms[0];

	

	if(frm.email.value=="")

	{

		alert("Input your email address");

		frm.email.focus();

		return;

	}

	frm.saveFlag.value = 1;

	frm.action = "index.php";

	frm.submit();

}





/////////////////////////highlights.php/////////

function highlightsLeftGo()

{

	var curDate = new Date();

	var curYear = curDate.getYear();

	

	if (curYear < 1000)

		curYear +=1900;

	var nextYear =parseInt(document.getElementById("topYear").value)+1;

	

	if (nextYear > curYear)

	{

		alert("pass the current year!");

		return;

	}

	$.ajax({type:"GET",url:"checkHighlights.php?nextYear=" + nextYear,async:true,

	success:function(response)

	{

		document.getElementById("topYear").value=nextYear;

		document.getElementById("ajaxResult").innerHTML = response;

	}

	});

}

function highlightsRightGo(minYear)

{

	if(parseInt(document.getElementById("topYear").value) < minYear+5)

	{

		alert("The end!");

		return;

	}

	var prevYear =parseInt(document.getElementById("topYear").value)-1;

	

	document.getElementById("topYear").value = prevYear;

	

	$.ajax({type:"GET",url:"checkHighlights.php?nextYear=" + prevYear,async:true,

		success:function(response)

		{

			

			document.getElementById("ajaxResult").innerHTML = response;

		}

		});

}

function highlightsBacktop()

{

	var date= new Date();

	var curYear = date.getYear();

	if (curYear < 1000)

		curYear +=1900;

	$.ajax({type:"GET",url:"checkHighlights.php?nextYear=" + curYear,async:true,

		success:function(response)

		{

			document.getElementById("topYear").value = curYear;

			document.getElementById("ajaxResult").innerHTML = response;

		}

		});

}

//////////////////////////production statistics/////////////

function topGo()

{

	var curDate = new Date();

	var curYear = curDate.getYear();

	if (curYear < 1000)

		curYear +=1900;

	var nextYear =parseInt(document.getElementById("topYear").value)+1; 

	if (nextYear > curYear)

	{

		alert("pass the current year!");

		return;

	}

	$.ajax({type:"GET",url:"checkProductionStatistics.php?nextYear=" + nextYear,async:true,

	success:function(response)

	{

		document.getElementById("topYear").value=nextYear;

		document.getElementById("ajaxResult").innerHTML = response;

	}

	});

}

function bottomGo(minYear)

{

	if(parseInt(document.getElementById("topYear").value) < minYear+5)

	{

		alert("The end!");

		return;

	}

	var prevYear =parseInt(document.getElementById("topYear").value)-1;

	$.ajax({type:"GET",url:"checkProductionStatistics.php?nextYear=" + prevYear,async:true,

		success:function(response)

		{

			document.getElementById("topYear").value=prevYear;

			document.getElementById("ajaxResult").innerHTML = response;

		}

		});

}

function productionGoTop()

{

	var date= new Date();

	var curYear = date.getYear();

	if (curYear < 1000)

		curYear +=1900;

	$.ajax({type:"GET",url:"checkProductionStatistics.php?nextYear=" + curYear,async:true,

		success:function(response)

		{

			document.getElementById("topYear").value = curYear;

			document.getElementById("ajaxResult").innerHTML = response;

		}

		});

}



//////////////////////////profit_loss

function profitLeftGo()

{

	var curDate = new Date();

	var curYear = curDate.getYear();

	if (curYear < 1000)

		curYear +=1900;

	var nextYear =parseInt(document.getElementById("topYear").value)+1; 

	if (nextYear > curYear)

	{

		alert("pass the current year!");

		return;

	}

	$.ajax({type:"GET",url:"checkProfit.php?nextYear=" + nextYear,async:true,

	success:function(response)

	{

		document.getElementById("topYear").value=nextYear;

		document.getElementById("ajaxResult").innerHTML = response;

	}

	});

}

function profitRightGo(minYear)

{

	if(parseInt(document.getElementById("topYear").value) < minYear+5)

	{

		alert("The end!");

		return;

	}

	var prevYear =parseInt(document.getElementById("topYear").value)-1;

	$.ajax({type:"GET",url:"checkProfit.php?nextYear=" + prevYear,async:true,

		success:function(response)

		{

			document.getElementById("topYear").value = prevYear;

			document.getElementById("ajaxResult").innerHTML = response;

		}

		});

}

function profitBacktop()

{

	var date= new Date();

	var curYear = date.getYear();

	if (curYear < 1000)

		curYear +=1900;

	$.ajax({type:"GET",url:"checkProfit.php?nextYear=" + curYear,async:true,

		success:function(response)

		{

			document.getElementById("topYear").value = curYear;

			document.getElementById("ajaxResult").innerHTML = response;

		}

		});

}

///////////////////////////banner_sheet

function capital1LeftGo()

{

	var curDate = new Date();

	var curYear = curDate.getYear();

	if (curYear < 1000)

		curYear +=1900;

	var nextYear =parseInt(document.getElementById("topYear1").value)+1; 

	if (nextYear > curYear)

	{

		alert("pass the current year!");

		return;

	}

	$.ajax({type:"GET",url:"checkBalance1.php?nextYear=" + nextYear,async:true,

	success:function(response)

	{

		document.getElementById("topYear1").value=nextYear;

		document.getElementById("ajaxResult1").innerHTML = response;

	}

	});

}

function capital1RightGo(minYear)

{

	if(parseInt(document.getElementById("topYear1").value) < minYear+5)

	{

		alert("The end!");

		return;

	}

	var prevYear =parseInt(document.getElementById("topYear1").value)-1;

	$.ajax({type:"GET",url:"checkBalance1.php?nextYear=" + prevYear,async:true,

		success:function(response)

		{

			document.getElementById("topYear1").value = prevYear;

			document.getElementById("ajaxResult1").innerHTML = response;

		}

		});

}



function capital2LeftGo()

{

	var curDate = new Date();

	var curYear = curDate.getYear();

	if (curYear < 1000)

		curYear +=1900;

	var nextYear =parseInt(document.getElementById("topYear2").value)+1; 

	if (nextYear > curYear)

	{

		alert("pass the current year!");

		return;

	}

	$.ajax({type:"GET",url:"checkBalance2.php?nextYear=" + nextYear,async:true,

	success:function(response)

	{

		document.getElementById("topYear2").value=nextYear;

		document.getElementById("ajaxResult2").innerHTML = response;

	}

	});

}

function capital2RightGo(minYear)

{

	if(parseInt(document.getElementById("topYear2").value) < minYear+5)

	{

		alert("The end!");

		return;

	}

	var prevYear =parseInt(document.getElementById("topYear2").value)-1;

	$.ajax({type:"GET",url:"checkBalance2.php?nextYear=" + prevYear,async:true,

		success:function(response)

		{

			document.getElementById("topYear2").value = prevYear;

			document.getElementById("ajaxResult2").innerHTML = response;

		}

		});

}



function capital3LeftGo()

{

	var curDate = new Date();

	var curYear = curDate.getYear();

	if (curYear < 1000)

		curYear +=1900;

	var nextYear =parseInt(document.getElementById("topYear3").value)+1; 

	if (nextYear > curYear)

	{

		alert("pass the current year!");

		return;

	}

	$.ajax({type:"GET",url:"checkBalance3.php?nextYear=" + nextYear,async:true,

	success:function(response)

	{

		document.getElementById("topYear3").value=nextYear;

		document.getElementById("ajaxResult3").innerHTML = response;

	}

	});

}

function capital3RightGo(minYear)

{

	if(parseInt(document.getElementById("topYear3").value) < minYear+5)

	{

		alert("The end!");

		return;

	}

	var prevYear =parseInt(document.getElementById("topYear3").value)-1;

	$.ajax({type:"GET",url:"checkBalance3.php?nextYear=" + prevYear,async:true,

		success:function(response)

		{

			document.getElementById("topYear3").value = prevYear;

			document.getElementById("ajaxResult3").innerHTML = response;

		}

		});

}



function capital1Backtop()

{

	var date= new Date();

	var curYear = date.getYear();

	if (curYear < 1000)

		curYear +=1900;

	$.ajax({type:"GET",url:"checkBalance1.php?nextYear=" + curYear,async:true,

		success:function(response)

		{

			document.getElementById("topYear1").value = curYear;

			document.getElementById("ajaxResult1").innerHTML = response;

		}

		});

}

function capital2Backtop()

{

	var date= new Date();

	var curYear = date.getYear();

	if (curYear < 1000)

		curYear +=1900;

	$.ajax({type:"GET",url:"checkBalance2.php?nextYear=" + curYear,async:true,

		success:function(response)

		{

			document.getElementById("topYear2").value = curYear;

			document.getElementById("ajaxResult2").innerHTML = response;

		}

		});

}

function capital3Backtop()

{

	var date= new Date();

	var curYear = date.getYear();

	if (curYear < 1000)

		curYear +=1900;

	$.ajax({type:"GET",url:"checkBalance3.php?nextYear=" + curYear,async:true,

		success:function(response)

		{

			document.getElementById("topYear3").value = curYear;

			document.getElementById("ajaxResult3").innerHTML = response;

		}

		});

}



////////////////////index///////////////



function gotoSharePrice()

{

	$.ajax({type:"GET",url:"index.php",async:true,

		success:function(response)

		{

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

			document.getElementById("shareprice").style.display = "block";

		}

		});

}

function gotoLatestNews()

{

	$.ajax({type:"GET",url:"index.php",async:true,

		success:function(response)

		{

			document.getElementById("latestnews").style.display = "block";

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

		}

		});

}




