/*function for user registration*/
/*function for user registration*/
function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores 
    if (fld.value == "") {
      //  fld.style.background = 'Yellow'; 
        error = "You didn't enter a username.\n";
    } else if ((fld.value.length < 5) || (fld.value.length > 20)) {
       // fld.style.background = 'Yellow'; 
       // error = "The username is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
      //  fld.style.background = 'Yellow'; 
        error = "The username contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validatePassword(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "") {
       // fld.style.background = 'Yellow';
        error = "You didn't enter a password.\n";
    } else if ((fld.value.length < 7) || (fld.value.length > 15)) {
        error = "The password is the wrong length. \n";
       // fld.style.background = 'Yellow';
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
       // fld.style.background = 'Yellow';
    } else if (!((fld.value.search(/(a-z)+/)) && (fld.value.search(/(0-9)+/)))) {
        error = "The password must contain at least one numeral.\n";
      // fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }
   return error;
}  

function validateName(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z ']/;  // allow letters, numbers 
    
    if (fld.value == "") {
      //  fld.style.background = 'Yellow'; 
        error = "You didn't enter a name.\n";
    } else if ((fld.value.length < 5) || (fld.value.length > 25)) {
       // fld.style.background = 'Yellow'; 
       // error = "The name is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
      //  fld.style.background = 'Yellow'; 
        error = "The name contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}


function registerValidation(){	
	var emailid=document.getElementById('email_id');
	if(emailid.value=='' || emailid.value==null){
		alert('please enter the email ');
		getElementFocus(emailid);
		return false;
	}

	if (echeck(emailid.value)==false){
		emailid.value=""
		emailid.focus()
		return false
	}	

	var pass=document.getElementById('pass');
	if(pass.value=='' || pass==null ){
	alert('please enter the password greater than six characters');
	getElementFocus(pass);
	return false;
	}
	
	if(pass.value.length <6  ){
		alert('please enter the password greater than six characters');
		getElementFocus(pass);
		return false;
	}
	
	var conpass=document.getElementById('confirm_pass');
	if(conpass.value=='' || conpass==null ){
		alert('please enter the conifrm password');
		getElementFocus(conpass);
		return false;
	}
	
	if(conpass.value!=pass.value ){
		alert('both passwords must be same');
		getElementFocus(conpass);
		return false;
	}
	
	var first_name=document.getElementById('first_name');
	error_fname=validateName(first_name);
	if(error_fname){
		alert(error_fname);
		getElementFocus(first_name);
		return false;
	}	
	
	var last_name=document.getElementById('last_tname');
	error_lname=validateName(last_name);
	if(error_lname){
		alert(error_lname);
		getElementFocus(last_name);
		return false;
	}
	
	var address=document.getElementById('address');
	if(address.value=='' || address==null){
		alert('please enter the address');
		getElementFocus(address);
		return false;
	}
	var age=document.getelementById('age');
	if(age.value==''|| age==null){
	alert('please enter the age');
	getElementFocus(age);
	return false;
	}
	var gender=document.getElementById('gender');
	if(gender.value=='' || gender==null)
	{
	alert('please select the gender');
	getElementFocus(gender);
	return false;
	
	}
	var status=document.getElementById('status');
	if(status.value==''|| status==null){
	alert('please enter the status ');
    getElementFocus(status);
	return false
	}
	
	var country=document.getElementById('country');
	if(country.value=='' || counrtry==null){
		alert('please select the country name');
		getElementFocus(country);
		return false;
	}

}


/*function for login form*/
function validateLoginFrom(){
	var user,pass='';
	email=document.getElementById('email');
	pass=document.getElementById('pass');	
	if(email.value=='' || email.value==null){
		alert('Please enter your email');
		getElementFocus(email);
		return false;
	}		
	if (echeck(email.value)==false){
		email.value=""
		email.focus()
		return false
	}	
	if(pass.value=='' || pass.value==null){
		alert('Please enter password');
		getElementFocus(pass);return false;
	}return true;
}

/*element focus*/
function getElementFocus(obj){
	if(obj){
		obj.focus();
	}
}


function setElementFocus(elem){
	if(elem){
		var obj=document.getElementById(""+elem+"");	
		if(obj.vlaue=='' || obj.vlaue==null){				
			obj.focus();
		}		
	}
}

function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 return true					
	}
	
	
	
/* Create a new XMLHttpRequest object to talk to the Web server */
//var xmlHttp = false;
function getHTTPObject(){
	if (window.ActiveXObject) 	
	return new ActiveXObject("Microsoft.XMLHTTP");	
	else if (window.XMLHttpRequest) 	
	return new XMLHttpRequest();	
	else {	
		alert("Your browser does not support AJAX.");	
		return null;	
	}
}

/*this is to delete the topics*/
function deleteTopics(id,id_name,table_name,msg,chng_status,child_tbl_name,img_name){
	if(confirm("Are you sure, you want to delete this "+msg+" ?")){		
		xmlHttp=getHTTPObject();			
	   // Build the URL to connect to	  	   
	   var child=child_tbl_name ? child_tbl_name : ""; 
	   
	   if(chng_status==1){	   	    		  
	 	  var url = "delete_topics.php?id="+escape(id)+"&field_name="+id_name+"&table_name="+table_name+"&chlid_table_name="+child;
	   }else{	   		
	      var url = "delete_permanant.php?id="+escape(id)+"&field_name="+id_name+"&table_name="+table_name+"&chlid_table_name="+child+"&image_name="+(img_name);
	   }
	   

	  // Open a connection to the server
	  xmlHttp.open("GET", url, true);
	  // Setup a function for the server to run when it's done
	  xmlHttp.onreadystatechange = updatePageDelete;
	  // Send the request
	  xmlHttp.send(null);
	}
}


function updatePageDelete() {
  if (xmlHttp.readyState==4) {
    var response = xmlHttp.responseText;
	document.forms[0].submit();
  }
}


function checkAllowedChar(checkStr, checkOK){
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++){
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length){
      allValid = false;
      break;
    }
  }
    return (allValid);
}

function validateAnswers(){
	var cnt=document.getElementById('field_count');
	var i;
	if(cnt){
		for(i=0;i<cnt.value;i++){
			var val=document.getElementById("answer"+i);
			if(val.value=="" || val.value==null){
				alert('Please add Answer');
				getElementFocus(val);
				return false;
			}
			
			var charAllowed = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_.0123456789()[],- ";
			if (!checkAllowedChar(val.value, charAllowed)){
				alert('You have entered invalid characters!'); 
				getElementFocus(val);
				return false;
			}
				
		}
	}/*else return false;*/
	
	return;
}


function validateQuestionsForm(){
	var q_bank_id=document.getElementById('question_bank_id');
	if(q_bank_id.value==0){
		alert('Please Select Question Bank');
		getElementFocus(q_bank_id);
		return false;
	}
	
	var topic_id=document.getElementById('topic_id');
	if(topic_id.value==0){
		alert('Please Select Topic');
		getElementFocus(topic_id);
		return false;
	}
	
	var question_style_id=document.getElementById('question_style_id');
	if(question_style_id.value==0){
		alert('Please Select Question Style');
		getElementFocus(question_style_id);
		return false;
	}
	
	var question=document.getElementById('question');
	if(question.value==0){
		alert('Please Enter Question ');
		getElementFocus(question);
		return false;
	}
	
	var charAllowed = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_.,;-'\"0123456789()[]? ";
	if (!checkAllowedChar(question.value, charAllowed)){
		alert('You have entered invalid characters in Question!'); 
		getElementFocus(question);
		return false;
	}
	
	var cnt=document.getElementById('field_count');
	var i;
	if(cnt){
		for(i=0;i<cnt.value;i++){
			var val=document.getElementById("answer"+i);
			if(val.value=="" || val.value==null){
				alert('Please add Answer');
				getElementFocus(val);
				return false;
			}
			
			var charAllowed_ans = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_.0123456789()[] ";
			if (!checkAllowedChar(val.value, charAllowed_ans)){
				alert('You have entered invalid characters '); 
				getElementFocus(val);
				return false;
			}
				
		}
	}/*else return false;*/
	
	var correct_ans=document.getElementById('correct_ans');
	if(correct_ans.value==0){
		alert('Please Select Correct Ans');
		getElementFocus(correct_ans);
		return false;
	}
	return;
}

function checkForCorrectAns(){	
	var cnt=document.getElementById('field_count');	
	if(cnt){		
		if(cnt.value<2){			
			alert('There should be 2 or more answers');
			return false;			
		}
		document.frm_questions.sel_cor_ans_val.value=1;
		return true;
	}
}

/*this is to add new publication from the other forms*/
function openPublicationForm(){
	path="add_new_publication.php";
	window.open('add_new_publications.php','new_wind','width=400, height=100,scrollbars=0,left=350,top=350,screenX=0,screenY=0'); 
    return false;		
}


function openFileForCoverageMonitorToAddNew(file_name){
	if(file_name){
		window.open(''+file_name+'','new_wind','width=450, height=130,scrollbars=0,left=350,top=350,screenX=0,screenY=0'); 
		return false;		
	}return false;
}

function openFile(file_name){
	if(file_name){
		window.open(''+file_name+'','ch_wind','width=450, height=130,scrollbars=0,left=350,top=350,screenX=0,screenY=0'); 
		return false;		
	}return false;
}

function checkAllowedChar(checkStr, checkOK){
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++){
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length){
      allValid = false;
      break;
    }
  }
    return (allValid);
}


function blockNonNumbers(obj, e, allowDecimal, allowNegative){
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	return isFirstN || isFirstD || reg.test(keychar);
}

/*function to validate veiw report form*/
function validation_select_client(){	
	var cm_coverage_title_id=document.getElementById('cm_coverage_title_id');
	if(cm_coverage_title_id.value==0){
		alert('Please select Coverage Title');
		getElementFocus(cm_coverage_title_id);
		return false;
	}
	
	var cm_select_client=document.getElementById('client_id');
	if(cm_select_client.value==0){
		alert('Please select Client');
		getElementFocus(cm_select_client);
		return false;
	}
}


/*function to validate veiw report form*/
function validationForGraphForm(){	
	/*var cm_coverage_title_id=document.getElementById('cm_coverage_title_id');
	if(cm_coverage_title_id.value==0){
		alert('Please select Coverage Title');
		getElementFocus(cm_coverage_title_id);
		return false;
	}*/
	
	var cm_select_client=document.getElementById('client_id');
	if(cm_select_client.value==0){
		alert('Please select Client');
		getElementFocus(cm_select_client);
		return false;
	}
}


/*User form validation*/
function validateUserForm(action){
	var user_name_obj=document.getElementById('user_name');
	if(user_name_obj.value=="" || user_name_obj.value==null){
		alert('Please Enter User Name');
		getElementFocus(user_name_obj);
		return false;
	}
	
	var charAllowed_ans = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._0123456789";
	if (!checkAllowedChar(user_name_obj.value, charAllowed_ans)){
		alert('Username may only contain Alphabates,Numbers,. and _'); 
		getElementFocus(user_name_obj);
		return false;
	}
	
//	alert(action);return false;
	var pass_obj=document.getElementById('pass');
	if(action!='edit'){		
		if(pass_obj.value=="" || pass_obj.value==null){
			alert('Please Enter Password');
			getElementFocus(pass_obj);
			return false;
		}
		
		var charAllowed_ans = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
		if (!checkAllowedChar(pass_obj.value, charAllowed_ans)){
			alert('Only Alphanumeric Password without space is allowed'); 
			getElementFocus(pass_obj);
			return false;
		}
	}else{
		if(pass_obj.value){
			var charAllowed_ans = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
			if (!checkAllowedChar(pass_obj.value, charAllowed_ans)){
				alert('Only Alphanumeric Password without space is allowed'); 
				getElementFocus(pass_obj);
				return false;
			}
		}
	}
	
	
	var name_obj=document.getElementById('name');
	if(name_obj.value=="" || name_obj.value==null){
		alert('Please Enter Name');
		getElementFocus(name_obj);
		return false;
	}
	
	
	
	var charAllowed_ans = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_' ";
	if (!checkAllowedChar(name_obj.value, charAllowed_ans)){
		alert('Please Enter Alphabates Only'); 
		getElementFocus(name_obj);
		return false;
	}	
	
	var branch_obj=document.getElementById('branch_id');
	if(branch_obj.value==0){
		alert('Please Select Branch');
		getElementFocus(branch_obj);
		return false;
	}	
}


/*validation for adding products*/
function validationProduct(){
	var category_id_obj=document.getElementById('category_id');
	if(category_id_obj.value==0){
		alert("Please Select Category.");
		getElementFocus(category_id_obj);
		return false;
	}
	
	var sizerange_id_obj=document.getElementById('sizerange_id');
	if(sizerange_id_obj.value==0){
		alert("Please Select Size Range.");
		getElementFocus(sizerange_id_obj);
		return false;
	}
	
	
	var fabric_id_obj=document.getElementById('fabric_id');
	if(fabric_id_obj.value==0){
		alert("Please Select Fabric.");
		getElementFocus(fabric_id_obj);
		return false;
	}
	
	
	var product_name_obj=document.getElementById('product_name');
	if(product_name_obj.value=="" || product_name_obj.value==null){
		alert("Please Enter Product Name.");
		getElementFocus(product_name_obj);
		return false;
	}
	
	var product_code_obj=document.getElementById('product_code');
	if(product_code_obj.value=="" || product_code_obj.value==null){
		alert("Please Enter Product Code.");
		getElementFocus(product_code_obj);
		return false;
	}
	
	var field_count_obj=document.getElementById('field_count');	
	//if(field_count_obj.value){
		for(var i=0; i<field_count_obj.value; i++){			
			var img_name=document.getElementById('img_name'+i);
			var color_name=document.getElementById('colors_id'+i);
			if(img_name.value){
				if(color_name.value==0){
					alert('Please Select Color for image');
					getElementFocus(color_name);
					return false;
				}
			}			
		}//end of for loop
	//}
	
	//return false;
}



/*validation for adding products*/
function validationEditProduct(){
	var category_id_obj=document.getElementById('category_id');
	if(category_id_obj.value==0){
		alert("Please Select Category.");
		getElementFocus(category_id_obj);
		return false;
	}
	
	var sizerange_id_obj=document.getElementById('sizerange_id');
	if(sizerange_id_obj.value==0){
		alert("Please Select Size Range.");
		getElementFocus(sizerange_id_obj);
		return false;
	}
	
	
	var fabric_id_obj=document.getElementById('fabric_id');
	if(fabric_id_obj.value==0){
		alert("Please Select Fabric.");
		getElementFocus(fabric_id_obj);
		return false;
	}
	
	
	var product_name_obj=document.getElementById('product_name');
	if(product_name_obj.value=="" || product_name_obj.value==null){
		alert("Please Enter Product Name.");
		getElementFocus(product_name_obj);
		return false;
	}
	
	var product_code_obj=document.getElementById('product_code');
	if(product_code_obj.value=="" || product_code_obj.value==null){
		alert("Please Enter Product Code.");
		getElementFocus(product_code_obj);
		return false;
	}
	
	var field_count_obj=document.getElementById('field_count');	
	//if(field_count_obj.value){
		for(var i=0; i<field_count_obj.value; i++){			
			var img_name=document.getElementById('img_name'+i);
			var color_name=document.getElementById('colors_id'+i);
			if(img_name.value){
				if(color_name.value==0){
					alert('Please Select Color for image');
					getElementFocus(color_name);
					return false;
				}
			}			
		}//end of for loop
	//}
	
	var edit_field_count_obj=document.getElementById('count_edit');	
	//if(field_count_obj.value){
		for(var i=0; i<edit_field_count_obj.value; i++){
			var color_name=document.getElementById('colors_id'+i);			
			if(color_name.value==0){
				alert('Please Select Color for image');
				getElementFocus(color_name);
				return false;
			}
		}//end of for loop
	//}
	
	//return false;
}


function displayImageInDiv(img_path,product_id,pcid){
		//alert(img_path);
		var name="display_image"+product_id;
		var dv_ojb=document.getElementById(""+name+"");
		//dv_ojb.innerHTML="";
		dv_ojb.innerHTML="<a href=\"product_details.php?pcid="+pcid+"\" target=\"_blank\"><img src=\""+img_path+"\"width=\"172\" height=\"257\" style=\"cursor:pointer; border:0px;\"></a>";
		return false;
}


/*validate forgot pass form*/
function validateForgotPass(){
	var email_obj=document.getElementById('email');
	if(email_obj.value=="" || email_obj.value==null){
		alert('Enter your Email');
		getElementFocus(email_obj);
		return false;
	}else{	
		if (echeck(email_obj.value)==false){
			email_obj.value="";
			getElementFocus(email_obj);
			return false;
		}	
	}
}



function popitup() {
 	var newsletter=document.getElementById('newsletter');	
	if(newsletter.value){
		newwindow2=window.open('','name','width=790, height=280,scrollbars=1,location=0,status=0');
		newwindow2.moveTo(100,270);
		var tmp = newwindow2.document;
		tmp.write(newsletter.value);
		tmp.close();
		return false;
	}
}





function checkAll(id){
	if(id){	
		var usr_obj=document.getElementById(id);
		alert(usr_obj.length);
		/*for (i = 0; i < field.length; i++){
			field[i].checked = true ;
		}*/
	}
	
}


function checkAll(){
	for (var i=0;i<document.forms[0].elements.length;i++)
	{
		var e=document.forms[0].elements[i];
		if ((e.name != 'usr') && (e.type=='checkbox'))
		{
			e.checked=document.forms[0].usr.checked;
		}
	}
}


//checkname[i].checked = exby.checked? true:false

function SetAllCheckBoxes(FormName, FieldName, CheckValue,exby)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
//			objCheckBoxes[i].checked = CheckValue;
			objCheckBoxes[i].checked = exby.checked? true:false;
}




function validateFeedback(){	
	var emailid=document.getElementById('email');
	if(emailid.value=='' || emailid.value==null){
		alert('please enter the email ');
		getElementFocus(emailid);
		return false;
	}

	if (echeck(emailid.value)==false){
		emailid.value=""
		emailid.focus()
		return false
	}
	
	var phone_obj=document.getElementById('phone');
	if(phone_obj.value==0){
		alert("Please Enter Phone no.");
		getElementFocus(phone_obj);
		return false;
	}
	
	var fname_obj=document.getElementById('fname');
	if(fname_obj.value==0){
		alert("Please Enter First name.");
		getElementFocus(fname_obj);
		return false;
	}
	
	var lname_obj=document.getElementById('lname');
	if(lname_obj.value==0){
		alert("Please Enter Last name.");
		getElementFocus(lname_obj);
		return false;
	}
	
	var address_obj=document.getElementById('address');
	if(address_obj.value==0){
		alert("Please Enter Address.");
		getElementFocus(address_obj);
		return false;
	}
	
	var comments_obj=document.getElementById('comments');
	if(comments_obj.value==0){
		alert("Please Enter Comments.");
		getElementFocus(comments_obj);
		return false;
	}
	
	
	
	return 0;
}


function updatePage() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
	var split_text=response.split("|");	
	var comment=split_text[0];
	var comment_id=split_text[1];
    //document.getElementById("div_comment").innerHTML = response;
	//document.getElementById("div_comment"+comment_id+"").innerHTML = comment;
	document.forms[0].submit();
  }
}



/**********************************************************************/
function validateTestimonialForm(){	
	var clinetname_obj=document.getElementById('clientname');
	if(clinetname_obj.value==0){
		alert("Please Enter Clinet name.");
		getElementFocus(clinetname_obj);
		return false;
	}
	
	/*var content_obj=document.getElementById('content');
	if(content_obj.value==0){
		alert("Please Enter Description.");
		getElementFocus(content_obj);
		return false;
	}*/
	return true;
}



/*function for login form*/
function validateCareerFrom(){
	var user,pass='';
	first_name=document.getElementById('first_name');	
	if(first_name.value=='' || first_name.value==null){
		alert('Please enter your first name');
		getElementFocus(first_name);
		return false;
	}
	
	last_name=document.getElementById('last_name');
	if(last_name.value=='' || last_name.value==null){
		alert('Please enter your last name');
		getElementFocus(last_name);
		return false;
	}
	
	phoneno=document.getElementById('phoneno');
	if(phoneno.value=='' || phoneno.value==null){
		alert('Please enter your phoneno');
		getElementFocus(phoneno);
		return false;
	}
	
	
	emailid=document.getElementById('emailid');
	if(emailid.value=='' || emailid.value==null){
		alert('Please enter your email');
		getElementFocus(emailid);
		return false;
	}
	if (echeck(emailid.value)==false){
		emailid.value=""
		emailid.focus()
		return false
	}	
	
	qualification=document.getElementById('qualification');
	if(qualification.value=='' || qualification.value==null){
		alert('Please enter your Qualification');
		getElementFocus(qualification);
		return false;
	}
	
	resume=document.getElementById('resume');
	if(resume.value=='' || resume.value==null){
		alert('Please enter your Resume');
		getElementFocus(resume);
		return false;
	}
	return true;
}





/*function for login form*/
function validateContactFrom(){
	var user,pass='';
	first_name=document.getElementById('first_name');	
	if(first_name.value=='' || first_name.value==null){
		alert('Please enter your first name');
		getElementFocus(first_name);
		return false;
	}
	
	last_name=document.getElementById('last_name');
	if(last_name.value=='' || last_name.value==null){
		alert('Please enter your last name');
		getElementFocus(last_name);
		return false;
	}
	
	address=document.getElementById('address');
	if(address.value=='' || address.value==null){
		alert('Please enter your address');
		getElementFocus(address);
		return false;
	}
	
	city=document.getElementById('city');
	if(city.value=='' || city.value==null){
		alert('Please enter your city');
		getElementFocus(city);
		return false;
	}
	
	state=document.getElementById('state');
	if(state.value=='' || state.value==null){
		alert('Please enter your state');
		getElementFocus(state);
		return false;
	}
	
	zipcode=document.getElementById('zipcode');
	if(zipcode.value=='' || zipcode.value==null){
		alert('Please enter your zipcode');
		getElementFocus(zipcode);
		return false;
	}
	
	country=document.getElementById('country');
	if(country.value=='' || country.value==null){
		alert('Please enter your country');
		getElementFocus(country);
		return false;
	}
	
	phoneno=document.getElementById('phoneno');
	if(phoneno.value=='' || phoneno.value==null){
		alert('Please enter your phoneno');
		getElementFocus(phoneno);
		return false;
	}
		
	emailid=document.getElementById('emailid');
	if(emailid.value=='' || emailid.value==null){
		alert('Please enter your email');
		getElementFocus(emailid);
		return false;
	}
	if (echeck(emailid.value)==false){
		emailid.value=""
		emailid.focus()
		return false
	}		
	return true;
}


function validateLogin(){
	user_name=document.getElementById('user_name');	
	if(user_name.value=='' || user_name.value==null){
		alert('Please enter username');
		getElementFocus(user_name);
		return false;
	}
	
	pass=document.getElementById('pass');
	if(pass.value=='' || pass.value==null){
		alert('Please enter password');
		getElementFocus(pass);
		return false;
	}
}

function changeImage(old_images,this_image,pk){		
	//alert(old_images);
	//return false;
	if(old_images){		
		newwindow=window.open('edit_project_images.php?old_images='+escape(old_images)+'&current_image='+escape(this_image)+'&id='+pk+'','name','width=600, height=50,scrollbars=1,location=0,status=0');
		newwindow.moveTo(210,350);
		return false;
	}return false;
}

function closewindow(path){
	if(path){		
		window.opener.location=path;		
		//window.opener.document.forms[0].submit();
		window.close();
	}	
}

function deleteImage(old_images,this_image,pk){
	if(confirm("Are you sure, you want to delete this image ?")){		
	  xmlHttp=getHTTPObject();			
	  // Build the URL to connect to	  	   	  
	  //var url = "delete_permanant.php?id="+escape(pk)+"&old_images="+old_images+"&this_image="+this_image;
	  var url = "delete_image.php?id="+escape(pk)+"&old_images="+old_images+"&this_image="+this_image;
	  // Open a connection to the server
	  xmlHttp.open("GET", url, true);
	  // Setup a function for the server to run when it's done
	  xmlHttp.onreadystatechange = updatePageImageDelete;
	  // Send the request
	  xmlHttp.send(null);
	}	
}


function updatePageImageDelete() {
  if (xmlHttp.readyState==4) {
	var response = xmlHttp.responseText;  
	var split_text=response.split("|");	
	var comment=split_text[0];
	var comment_id=split_text[1];	
	//document.forms[0].submit();  
	window.location="edit_product.php?id="+comment_id+"";  
	//var take_id="edit_product.php?id="+comment_id+"";  
	//alert(comment+ ' ' + comment_id + '***'+ take_id );
	  
   /* var response = xmlHttp.responseText;
    //alert(response);    
	document.forms[0].submit();*/
  }
}


function validatePaymentForm(){	
	first_name=document.getElementById('first_name');	
	if(first_name.value=='' || first_name.value==null){
		alert('Please enter first name');
		getElementFocus(first_name);
		return false;
	}
	
	
	last_name=document.getElementById('last_name');	
	if(last_name.value=='' || last_name.value==null){
		alert('Please enter last name');
		getElementFocus(last_name);
		return false;
	}
	
	
	address=document.getElementById('address');	
	if(address.value=='' || address.value==null){
		alert('Please enter address');
		getElementFocus(address);
		return false;
	}
	
	city=document.getElementById('city');	
	if(city.value=='' || city.value==null){
		alert('Please enter city');
		getElementFocus(city);
		return false;
	}
	
	state=document.getElementById('state');	
	if(state.value=='' || state.value==null){
		alert('Please enter state');
		getElementFocus(state);
		return false;
	}
	
	zip=document.getElementById('zip');	
	if(zip.value=='' || zip.value==null){
		alert('Please enter zip');
		getElementFocus(zip);
		return false;
	}
	
	country=document.getElementById('country');	
	if(country.value=='' || country.value==null){
		alert('Please enter country');
		getElementFocus(country);
		return false;
	}
	
	phoneno=document.getElementById('phone');	
	if(phoneno.value=='' || phoneno.value==null){
		alert('Please enter phoneno');
		getElementFocus(phoneno);
		return false;
	}
	
	emailid=document.getElementById('email');	
	if(emailid.value=='' || emailid.value==null){
		alert('Please enter emailid');
		getElementFocus(emailid);
		return false;
	}
	
	if (echeck(emailid.value)==false){
		emailid.value=""
		emailid.focus()
		return false
	}		
	
	
	pay_amt=document.getElementById('1-cost');	
	if(pay_amt.value=='' || pay_amt.value==null){
		alert('Please enter payment amount');
		getElementFocus(pay_amt);
		return false;
	}	
	
	invoice_no=document.getElementById('1-desc');	
	if(invoice_no.value=='' || invoice_no.value==null){
		alert('Please enter invoice number');
		getElementFocus(invoice_no);
		return false;
	}	
	return true;
}



function openMovieFile(){			
	newwindow=window.open('commercial_mv.php','name','width=270, height=240,scrollbars=1,location=0,status=0');
	newwindow.moveTo(400,220);
	return false;
	
}


function openResMovieFile(){			
	newwindow=window.open('residential_mv.php','name','width=270, height=240,scrollbars=1,location=0,status=0');
	newwindow.moveTo(400,220);
	return false;	
}




/* Create a new XMLHttpRequest object to talk to the Web server */
//var xmlHttp = false;
function getHTTPObject(){
	if (window.ActiveXObject) 	
	return new ActiveXObject("Microsoft.XMLHTTP");	
	else if (window.XMLHttpRequest) 	
	return new XMLHttpRequest();	
	else {	
		alert("Your browser does not support AJAX.");	
		return null;	
	}
}

/*this is to delete the topics*/
function deleteTopics(id,id_name,table_name,msg,chng_status,child_tbl_name,img_name){	
	 
	if(confirm("Are you sure, you want to delete this "+msg+" ?")){		
		xmlHttp=getHTTPObject();			
	   // Build the URL to connect to	  	   
	   var child=child_tbl_name ? child_tbl_name : ""; 
	   var img_name=img_name ? img_name : ""; 
	  
	   if(chng_status==1){	   	    		  
	 	  var url = "delete_topics.php?id="+escape(id)+"&field_name="+id_name+"&table_name="+table_name;
	   }else{	   			   	
	      var url = "delete_permanant.php?id="+escape(id)+"&field_name="+id_name+"&table_name="+table_name+"&chlid_table_name="+child+"&image_name="+img_name;
	   }
	   

	  // Open a connection to the server
	  xmlHttp.open("GET", url, true);
	  // Setup a function for the server to run when it's done
	  xmlHttp.onreadystatechange = updatePageDelete;
	  // Send the request
	  xmlHttp.send(null);
	}
}


function updatePageDelete() {
  if (xmlHttp.readyState==4) {
    var response = xmlHttp.responseText;
    //alert(response);
    document.forms[0].submit();
  }
}




function validateNewsletter(){
	//heading=document.getElementById('heading');	
	//alert(document.add_category.heading.value);return false;
	/*if(heading.value== " "){
		alert('Please enter newsletter heading');
		getElementFocus(heading);
		return false;
	}*/
		
	/*description=document.getElementById('description');	
	if(description.value=='' || description.value==null){
		alert('Please enter newsletter description');
		getElementFocus(description);
		return false;
	}	
	return 0;*/
//	return false;
}

function validateCategoryForm(){
	category=document.getElementById('category');	
	if(category.value== "" || category.value==null){
		alert('Please enter Category');
		getElementFocus(category);
		return false;
	}		
	return true;
}

function validateLabelForm(){
	label_key=document.getElementById('label_key');	
	if(label_key.value== "" || label_key.value==null){
		alert('Please enter label key');
		getElementFocus(label_key);
		return false;
	}		
	return true;
}
