// JavaScript Document
function chkLangName(x)
{
	if(x == "")
	{
		alert('Please enter a language name.');
		return false;
	}
	document.frm.action = 'languages.php?addLang=1';
	document.frm.submit();
}
function editLangName(str, id)
{
	if(str == "")
	{
		alert('Please enter a language name.');
		return false;
	}
	document.frm.action='editLangName.php?change=1';
	//document.frm.idi.value=id;
	document.frm.submit();
}
function delLang(id)
{
	ret = confirm('Are you sure you want to delete this entry?');
	if(ret == false)
		return false;
	document.frm.action = 'languages.php?delLang=1&id='+id;
	document.frm.submit();
}
function regValidation() {
	var fName=document.form1.fName.value.length;
	var lName=document.form1.lName.value.length; 
	var add1=document.form1.add1.value.length;
	var add2=document.form1.add2.value.length;
	var city=document.form1.city.value.length;
	var zipcode=document.form1.zipcode.value.length;
	emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
	email=document.form1.email.value
	
	var returnval=emailfilter.test(document.form1.email.value);
	
	var phone=document.form1.phone.value.length;
	var mobPhone=document.form1.mobPhone.value.length;
	var email=document.form1.email.value.length;
	
	if(document.form2.basicValues[0].value==1) {
		if(document.form1.fName.value=="") {
			alert("Pleae enter first name");
			document.form1.fName.focus();
			return false;
		}
	}
	if(fName > 250) {
		alert("You can't enter more than 250 characters");
		document.form1.fName.focus();
		return false;
	}
	
	if(document.form2.basicValues[1].value==1) {
		if(document.form1.lName.value=="") {
			alert("Pleae enter last name");
			document.form1.lName.focus();
			return false;
		}
	}
	if(lName > 250) {
		alert("You can't enter more than 250 characters");
		document.form1.lName.focus();
		return false;
		
	}
	
	if(document.form2.basicValues[2].value==1) {
		if(document.form1.monthSel.value==0 || document.form1.daySel.value==0 || document.form1.yearSel.value==0 ) {
			alert("Pleae select date of birth");
			document.form1.monthSel.focus();
			return false;
		}
	}
	
	if(document.form2.basicValues[3].value==1) {
		if(document.form1.add1.value=="") {
			alert("Pleae enter address");
			document.form1.add1.focus();
			return false;
		}
	}
	if(add1 > 250) {
		alert("You can't enter more than 250 characters");
		document.form1.add1.focus();
		return false;
		
	}
	if(document.form2.basicValues[4].value==1) {
		if(document.form1.add2.value=="") {
			alert("Pleae enter address 2nd");
			document.form1.add2.focus();
			return false;
		}
	}
	if(add2 > 250) {
		alert("You can't enter more than 250 characters");
		document.form1.add2.focus();
		return false;
	}
	if(document.form2.basicValues[5].value==1) {
		if(document.form1.city.value=="") {
			alert("Pleae enter city");
			document.form1.city.focus();
			return false;
		}
	}
	if(city > 250) {
		alert("You can't enter more than 250 characters");
		document.form1.city.focus();
		return false;
	}
	if(document.form2.basicValues[6].value==1) {
		if(document.form1.zipcode.value=="") {
			alert("Pleae enter zipcode");
			document.form1.zipcode.focus();
			return false;
		}
	}
	if(zipcode > 250) {
		alert("You can't enter more than 250 characters");
		document.form1.zipcode.focus();
		return false;
		
	}
	if(document.form2.basicValues[7].value==1) {
		if(document.form1.countryId.value==0) {
			alert("Pleae select country");
			document.form1.countryId.focus();
			return false;
		}
	}
	
	if(document.form2.basicValues[8].value==1) {
		if(document.form1.phone.value=="") {
			alert("Pleae enter phone");
			document.form1.phone.focus();
			return false;
		}
	}
	if(phone > 250) {
		alert("You can't enter more than 250 characters");
		document.form1.phone.focus();
		return false;
		
	}
	
	if(document.form2.basicValues[9].value==1) {
		if(document.form1.mobPhone.value=="") {
			alert("Pleae enter mobile phone");
			document.form1.mobPhone.focus();
			return false;
		}
	}
	if(mobPhone > 250) {
		alert("You can't enter more than 250 characters");
		document.form1.mobPhone.focus();
		return false;
		
	}
	
	if(document.form2.basicValues[10].value==1) {
		if(document.form1.email.value=="") {
			alert("Pleae enter email");
			document.form1.email.focus();
			return false;
		}

	}
	if(form1.email.value!="") {
	if(returnval==false) {
		alert("Please enter valid email adderss");
		document.form1.email.focus();
		return false;
	}
	}
	if(email > 250) {
		alert("You can't enter more than 250 characters");
		document.form1.email.focus();
		return false;
		
	}
	
	if(document.form2.basicValues[11].value==1) {
		if(document.form1.picture.value=="") {
			alert("Pleae enter picture");
			document.form1.picture.focus();
			return false;
		}
	}
	var chkLenght="";
	fieldType="";
	chkLenght=form1.fieldMand.length;
	
	var fieldsLenghts=new Array();
	var filedsName=new Array();
	var filedsValues=new Array();
	var fieldType=new Array();
	if(chkLenght!=undefined) {
	
	for(i=0; i<chkLenght; i++) {
		filedsName[i]=document.all.fieldsName[i].innerHTML;
		fieldsLenghts[i]=document.form1.fields[i].value.length;
		filedsValues[i]=document.form1.fields[i].value;
		fieldType[i]=document.form1.fieldType[i].value;
		
		if(form1.fieldMand[i].value==1) {
		 if(document.form1.fields[i].value=="") {
			alert("Pleae enter "+filedsName[i]);
			document.form1.fields[i].focus();
			return false;
		}
		}
		if(fieldType[i]=="numeric") { 
			if(isNaN(filedsValues[i])) {
				alert("Pleae enter Numeric Value");
				document.form1.fields[i].focus();
				return false;
			}
	
		}
		if(fieldsLenghts[i] > 250) {
		alert("You can't enter more than 250 characters");
		document.form1.fields[i].focus();
		return false;
	}
	}
	fil="";
	val=""
	for(ii=0;ii<chkLenght;ii++){ 
		fil=fil+filedsName[ii]+"-";
		
		val=val+filedsValues[ii]+"-";
	}
	 document.form1.allFields.value=fil;
	 document.form1.allValues.value=val
	}
	if(chkLenght==undefined) {
		filedsName=(document.all.fieldsName.innerHTML);
		fieldsLenghts=document.form1.fields.value.length;
		fieldType=document.form1.fieldType.value;
		if(form1.fieldMand.value==1) {
		 if(document.form1.fields.value=="") {
			alert("Pleae enter "+filedsName);
			document.form1.fields.focus();
			return false;
		}
		}
		if(fieldType=="numeric") { 
			if(isNaN(filedsValues)) {
				alert("Pleae enter Numeric Value");
				document.form1.fields.focus();
				return false;
			}
	
		}
		if(fieldsLenghts > 250) {
		alert("You can't enter more than 250 characters");
		document.form1.fields.focus();
		return false;
	}
	fil="";
	val="";
	
	fil=fil+filedsName+"-";
	val=filedsValues+"-";
	document.form1.allFields.value=fil;
	document.form1.allValues.value=val
	}
	document.form1.submit();
}
function loginValidate() {
	if(document.login.userName.value=="") {
		alert("Please enter user name")
		document.login.userName.focus();
		return false;
	}
	else if(document.login.password.value=="") {
		alert("Please enter password")
		document.login.password.focus();
		return false;
	}
}
function changeBackground(links) {
	tdID=document.getElementById("links")
	tdID.style.color="green";
}
	function subChilds(elementName) {
		 linkid=document.getElementById("elementName")
		// alert(linkid)
		//linkid.style.display=block;
	}