// JavaScript Document
function openWind(pid) {
	bigWindow = window.open('big_image.php?PID='+ pid +'&POS=P','test','height=535,width=535,top=0,left=0,toolbar=no,titlebar=no,location=no,scrollbars=1')
	bigWindow.focus();
}
////////////////////////////
function test(obj,msg){
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	if (regex.test(obj.value)){
		return true;
	}else{
		alert(msg);
		obj.focus();
		return false;
	}
}
function checkempty(obj,msg){
	if(obj.value==''){
		alert(msg);
		obj.focus()
		return false;
	}
	return true;
}
function confirmpass(obj,obj1,msg){
	if(obj1.value!=obj.value){
		alert(msg);
		obj1.select()
		obj1.focus()
		return false;
	}
	return true;
}
function checkdate(obj,msg){
	if(obj.value==''){
		alert(msg);
		document.all.trigger.focus();
		return false;
	}
	return true;
}
/////////////////////
function checkAll(theForm, cName, allNo_stat){
	var n=theForm.elements.length;
	for (var i=0;i<n;i++){
		if (theForm.elements[i].className.indexOf(cName) !=-1){
			if (allNo_stat.checked) {
				theForm.elements[i].checked = true;
			}else{
				theForm.elements[i].checked = false;
			}
		}
	}
}
/*
function clearImage(){
//    r = window.clipboardData.clearData("Image")
}
ci = setInterval("clearImage()", 10);
/////////////////////

function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
*/
/////////////////////
function CheckAdmLogin(){
	if(checkempty(document.frmRegUser.txtuname,"Information: Enter Username")==false) return false;
	if(checkempty(document.frmRegUser.txtpassword,"Information: Enter Password")==false) return false;
	return true;
}
function chkAddEmail(){
	if(test(document.form1.email,"Information: Enter valid email address")==false) return false;
	return true;	
}
function chkModEmail(){
	for(i=2;i<(document.form1.elements.length-2);i++){
		if(document.form1.elements[i].className.indexOf("input") !=-1){
			if(test(document.form1.elements[i],"Information: Enter valid email address")==false) return false;
		}
	}
	return true;
	
}
function chkMailFrm(){
	if(checkempty(document.frmsendmailing.txtFromName,"Information: Enter From Name")==false) return false;
	if(test(document.frmsendmailing.txtFromEmail,"Information: Enter From Email")==false) return false;
	if(checkempty(document.frmsendmailing.txtSubject,"Information: Enter Subject")==false) return false;
	return true;	
}
function chkcdFrm(){
	if(checkempty(document.frmcdetail.sCompany,"Information: Enter Company Name")==false) return false;
	if(checkempty(document.frmcdetail.cEml,"Information: Enter Company Email Address")==false) return false;
	if(checkempty(document.frmcdetail.tacp,"Information: Enter Admin Panel Title")==false) return false;
	if(checkempty(document.frmcdetail.tfs,"Information: Enter Front Site Title")==false) return false;
	if(checkempty(document.frmcdetail.surl,"Information: Enter URL")==false) return false;
	return true;
}
function chkAddCat(){
	for(i=5;i<(document.frmAddCategory.elements.length-3);i++){
		if(checkempty(document.frmAddCategory.elements[i],"Information: Enter Category Name")==false) return false;
	}
	return true;
	
}
function modCatFrm(){
	for(i=2;i<(document.frmModify.elements.length-2);i++){
		if(document.frmModify.elements[i].className.indexOf("input") !=-1){
			if(checkempty(document.frmModify.elements[i],"Information: Enter Category Name")==false) return false;
		}
	}
	return true;
	
}
function chkAddCur(){
	if(checkempty(document.frmAddCurrency.curname,"Information: Enter Currency Name")==false) return false;
	if(checkempty(document.frmAddCurrency.curcode,"Information: Enter Three Characters Currency Code\ni.e USD,GBP")==false) return false;
	if(checkempty(document.frmAddCurrency.cursmbl,"Information: Enter Currency Symbol\ni.e $,£")==false) return false;
	if(checkempty(document.frmAddCurrency.currate,"Information: Enter Currency Rate")==false) return false;
	return true;
}
function chkAddLang(){
	if(checkempty(document.frmAddLang.langname,"Information: Enter Language Name")==false) return false;
	if(checkempty(document.frmAddLang.langsufix,"Information: Enter Language Suffix\ni.e fr for french,en for English")==false) return false;
	if(checkempty(document.frmAddLang.langname,"Information: Select Flag")==false) return false;
	return true;
}
function chkAddDic(){
	for(i=1;i<(document.frmAddDic.elements.length-2);i++){
		if(checkempty(document.frmAddDic.elements[i],"Information: Enter Translation")==false) return false;
	}
	return true;
}
function moddFrm(){
	for(i=1;i<(document.frmdModify.elements.length-1);i++){
		if(checkempty(document.frmdModify.elements[i],"Information: Enter Translation")==false) return false;
	}
	return true;
}
function chkAddProd(){
	for(i=2;i<(document.frmAddProduct.elements.length-1);i++){
		if(document.frmAddProduct.elements[i].className.indexOf("input") !=-1){
			if(i==2){
				if(checkempty(document.frmAddProduct.elements[i],"Information: Enter Product Article Number")==false) return false;
			}
			if(checkempty(document.frmAddProduct.elements[i],"Information: Enter Product Name")==false) return false;
		}
	}
	return true;
}
function chkModProd(){
	for(i=2;i<(document.frmModProduct.elements.length-1);i++){
		if(document.frmModProduct.elements[i].className.indexOf("input") !=-1){
			if(i==2){
				if(checkempty(document.frmModProduct.elements[i],"Information: Enter Product Article Number")==false) return false;
			}
			if(checkempty(document.frmModProduct.elements[i],"Information: Enter Product Name")==false) return false;
		}
	}
	return true;
}
function chkChangePass(){
	if(checkempty(document.frmChangePass.oPass,"Information: Enter Old Password")==false) return false;
	if(checkempty(document.frmChangePass.NPass,"Information: Enter New Password")==false) return false;
	if(checkempty(document.frmChangePass.CNPass,"Information: Confirm New Password")==false) return false;
	if(confirmpass(document.frmChangePass.NPass,document.frmChangePass.CNPass,"Information: New and Confirm Password should be same")==false) return false;
	return true;
}
function chkAddUser(){
	if(checkempty(document.frmAddUser.UserName,"Information: Enter Username")==false) return false;
	if(checkempty(document.frmAddUser.Password,"Information: Enter Password")==false) return false;
	if(checkempty(document.frmAddUser.ContactPerson,"Information: Enter Contact Person Name")==false) return false;
	return true;
}
function frmModUser(){
	for(i=2;i<(document.frmModUser.elements.length-1);i++){
		if(document.frmModUser.elements[i].className.indexOf("input") !=-1){
			if(checkempty(document.frmModUser.elements[i],"Information: Enter Rquired Information")==false) return false;
		}
	}
	return true;
}
function chkAddgImg(){
	for(i=2;i<(document.frmAddGImg.elements.length-1);i++){
		if(document.frmAddGImg.elements[i].className.indexOf("input") !=-1){
			if(checkempty(document.frmAddGImg.elements[i],"Information: Enter Rquired Information")==false) return false;
		}
	}
	return true;
}
function modGalFrm(){
	for(i=3;i<(document.frmModifyGal.elements.length-1);i++){
		if(document.frmModifyGal.elements[i].className.indexOf("input") !=-1){
			if(checkempty(document.frmModifyGal.elements[i],"Information: Enter Rquired Information")==false) return false;
		}
	}
	return true;
}
function chkAddDoc(){
	for(i=2;i<(document.frmAddDocument.elements.length-1);i++){
		if(document.frmAddDocument.elements[i].className.indexOf("input") !=-1){
			if(checkempty(document.frmAddDocument.elements[i],"Information: Enter Rquired Information")==false) return false;
		}
	}
	return true;
}
function modDocFrm(){
	for(i=2;i<(document.frmModifyDoc.elements.length-1);i++){
		if(document.frmModifyDoc.elements[i].className.indexOf("input") !=-1){
			if(checkempty(document.frmModifyDoc.elements[i],"Information: Enter Rquired Information")==false) return false;
		}
	}
	return true;
}
function chkAddStaff(){
	if(checkempty(document.frmAddStaff.admname,"Information: Enter Username")==false) return false;
	if(checkempty(document.frmAddStaff.admpass,"Information: Enter Password")==false) return false;
}
function chkAddNews(){
	for(i=1;i<(document.frmAddNews.elements.length-2);i++){
		if(document.frmAddNews.elements[i].className.indexOf("input") !=-1){
			if(checkempty(document.frmAddNews.elements[i],"Information: Enter Rquired Information")==false) return false;
		}
	}
	return true;
}
function chkModNews(){
	for(i=1;i<(document.frmModNews.elements.length-1);i++){
		if(document.frmModNews.elements[i].className.indexOf("input") !=-1){
			if(checkempty(document.frmModNews.elements[i],"Information: Enter Rquired Information")==false) return false;
		}
	}
	return true;
}
//////////////////////
function doSubmit(val){
	document.frmActions.act.value=val;
	document.frmActions.submit();
}
function doSubmitprog10(val){
	document.frmActions.act.value=val;
	document.frmActions.submit();
}
function doSubmit4(val){
	document.frmActions.act.value=val;
	return true;
}
function doSubmit2(val){
	document.frmowner.act2.value=val;
	document.frmowner.submit();
}
function doModSubmit(pg){
	document.frmActions.action=pg;
	document.frmActions.act.value="mod";
	document.frmActions.submit();
}
function doModSubmitprog(pg){
	document.frmActions5.action=pg;
	document.frmActions5.act.value="mod";
	document.frmActions5.submit();
}
function doModSubmit2(pg){
	document.frmowner.action=pg;
	document.frmowner.act2.value="mod";
	document.frmowner.submit();
}
function ShowAdd(){
	document.getElementById("AddFrmArea").style.display='block';
}
function HideAdd(){
	document.getElementById("AddFrmArea").style.display='none';
}
function showList(val) {
  sList = window.open(val, "list", "width=800,height=650","scrollbars=yes,resizable=yes","top=10,left=10");
}

function remLink() {
  if (window.sList && window.sList.open && !window.sList.closed)
    window.sList.opener = null;
}
function pick(symbol) {
  if (window.opener && !window.opener.closed)
    window.opener.document.frmActions.courses_1.value = symbol;
	 window.opener.document.frmActions.courses_3.value = symbol;
	window.opener.document.frmActions.stockBox.value = symbol;
  window.close();
}
function pick2(symbol) {
  if (window.opener && !window.opener.closed)
    window.opener.document.frmActions.courses_2.value = symbol;
	window.opener.document.frmActions.stockBox.value = symbol;
  window.close();
}
function ShowHideStudentidYes()
{
	document.getElementById('yes_id').style.display = 'block';
	document.getElementById('No_id2').style.display = 'none';
	
}
function ShowHideStudentidNo()
{
	document.getElementById('No_id2').style.display = 'block';
	document.getElementById('yes_id').style.display = 'none';

}
function CheckEmpty(elementId,divid,updatefeild)
{
	var element = document.getElementById(elementId);
	var element2 = document.getElementById(divid);
	var element3 = document.getElementById(updatefeild);
	if(element.value==""){
	element2.style.display='block';
	element3.value='false';
	
	}else{
	element2.style.display='none';
	element3.value='true';
	}

}
function CheckFormisValid(elementId,divid,formaction,formname)
{
	var element = document.getElementById(elementId);
	var element2 = document.getElementById(divid);
	var element3 = document.getElementById(formaction);
	var element4 = document.getElementById(formname);
	if(element.value=="false" || element.value==""  || document.getElementById('txtname2').value=="" || document.getElementById('txtlastname').value=="" || document.getElementById('txtloginname').value=="" || document.getElementById('txtdob2').value=="" || document.getElementById('txtpassword123').value=="" || document.getElementById('txtcellphone').value=="" || document.getElementById('txtemailid').value=="" || document.getElementById('txtqualification').value=="" || (document.getElementById('isstudent_0').checked && document.getElementById('student_id').value=="" )){
	element2.style.display='block';
	return false;
	
	}else{
	element2.style.display='none';
	element3.value='AddSignup';
	element4.submit();
	return true;
	}

}
function showAvb(val,feild2) {
	var link1=document.getElementById(feild2);
	var valueoffeild=link1.value;
	var alink1=val+valueoffeild
	if(valueoffeild==""){
		return false;
	}
	else{
  sList = window.open(alink1,"alink1", "width=150,height=100","scrollbars=yes,resizable=yes","top=10,left=10");
	}
}
function CheckFormisValid_update_signup(elementId,divid,formaction,formname)
{
	var element = document.getElementById(elementId);
	var element2 = document.getElementById(divid);
	var element3 = document.getElementById(formaction);
	var element4 = document.getElementById(formname);
	if(element.value=="false" || element.value==""  || document.getElementById('txtname2').value=="" || document.getElementById('txtlastname').value=="" || document.getElementById('txtloginname').value=="" || document.getElementById('txtdob2').value=="" || document.getElementById('txtpassword123').value=="" || document.getElementById('txtcellphone').value=="" || document.getElementById('txtemailid').value=="" || (document.getElementById('txtstudentid').value=="" )){
	element2.style.display='block';
	return false;
	
	}else{
	element2.style.display='none';
	element3.value='UpdateSignup';
	element4.submit();
	return true;
	}

}
function CheckFormisValid_cmpsgs(elementId,divid,formname)
{
	var element = document.getElementById(elementId);
	var element2 = document.getElementById(divid);
	var element4 = document.getElementById(formname);
	if(element.value=="false" || element.value==""  || document.getElementById('txtname').value=="" || document.getElementById('txtphone').value=="" || document.getElementById('txtemailid').value=="" || document.getElementById('txtsubject2').value=="" ){
	element2.style.display='block';
	return false;
	
	}else{
	element2.style.display='none';
	return true;
	}

}

function CheckFormisValid_cmpsgs2(elementId,divid,formname)
{
	var element = document.getElementById(elementId);
	var element2 = document.getElementById(divid);
	var element4 = document.getElementById(formname);
	if(document.getElementById('txtname').value=="" || document.getElementById('txtphone').value=="" || document.getElementById('txtemailid').value==""){
	element2.style.display='block';
	return false;
	
	}else{
	element2.style.display='none';
	return true;
	}

}
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid email address.")
e.select()
}
return returnval
}
function chkAppform2(){
if(document.getElementById('courses_3').value=="" || document.getElementById('txtname').value=="" || document.getElementById('txtguardian').value=="" || document.getElementById('txtqualification').value=="" ){
	document.getElementById('form_status').style.display="block";
	return false;
	
	}else{
	document.getElementById('form_status').style.display="none";
	return true;
	}
}
