/*
  -------------------------------------------------------------------------
	                    JavaScript Form Validator 
                                Version 2.0.2
	Copyright 2003 JavaScript-coder.com. All rights reserved.
	You use this script in your Web pages, provided these opening credit
    lines are kept intact.
	The Form validation script is distributed free from JavaScript-Coder.com

	You may please add a link to JavaScript-Coder.com, 
	making it easy for others to find this script.
	Checkout the Give a link and Get a link page:
	http://www.javascript-coder.com/links/how-to-link.php

    You may not reprint or redistribute this code without permission from 
    JavaScript-Coder.com.
	
	JavaScript Coder
	It precisely codes what you imagine!
	Grab your copy here:
		http://www.javascript-coder.com/
    -------------------------------------------------------------------------  
*/
function Validator(frmname)
{
  this.formobj=document.forms[frmname];
	if(!this.formobj)
	{
	  alert("BUG: couldnot get Form object "+frmname);
		return;
	}
	if(this.formobj.onsubmit)
	{
	
		
	 this.formobj.old_onsubmit = this.formobj.onsubmit;
	 this.formobj.onsubmit=null;
	}
	else
	{
	 this.formobj.old_onsubmit = null;
	}
	this.formobj.onsubmit=form_submit_handler;
	this.addValidation = add_validation;
	this.setAddnlValidationFunction=set_addnl_vfunction;
	this.clearAllValidations = clear_all_validations;
}
function set_addnl_vfunction(functionname)
{
  this.formobj.addnlvalidation = functionname;
}
function clear_all_validations()
{
	for(var itr=0;itr < this.formobj.elements.length;itr++)
	{
		this.formobj.elements[itr].validationset = null;
	}
}
function form_submit_handler()
{
	for(var itr=0;itr < this.elements.length;itr++)
	{
		if(this.elements[itr].validationset &&
	   !this.elements[itr].validationset.validate())
		{
		  return false;
		}
	}
	if(this.addnlvalidation)
	{
	  str =" var ret = "+this.addnlvalidation+"()";
	  eval(str);
    if(!ret) return ret;
	}
	return true;
}
function add_validation(itemname,descriptor,errstr)
{
  if(!this.formobj)
	{
	  alert("BUG: the form object is not set properly");
		return;
	}//if
	var itemobj = this.formobj[itemname];
  if(!itemobj)
	{
	  alert("BUG: Couldnot get the input object named: "+itemname);
		return;
	}
	if(!itemobj.validationset)
	{
	  itemobj.validationset = new ValidationSet(itemobj);
	}
  itemobj.validationset.add(descriptor,errstr);
}
function ValidationDesc(inputitem,desc,error)
{
  this.desc=desc;
	this.error=error;
	this.itemobj = inputitem;
	this.validate=vdesc_validate;
}
function vdesc_validate()
{
 if(!V2validateData(this.desc,this.itemobj,this.error))
 {
    this.itemobj.focus();
		return false;
 }
 return true;
}
function ValidationSet(inputitem)
{
    this.vSet=new Array();
	this.add= add_validationdesc;
	this.validate= vset_validate;
	this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
  this.vSet[this.vSet.length]= 
	  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
	 {
	   if(!this.vSet[itr].validate())
		 {
		   return false;
		 }
	 }
	 return true;
}
function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function V2validateData(strValidateStr,objValue,strError) 
{ 
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    } 
    switch(command) 
    { 
        case "req": 
        case "required": 
         { 
			if(trim(objValue.value)=="" && (objValue.name!="parent_id"))
			{
				alert(strError);
				objValue.focus();
				
				return false;
			}
           if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : Required Field"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : "+cmdvalue+" characters maximum "; 
               }//if 
               alert(strError); 
               return false; 
             }//if 
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : " + cmdvalue + " characters minimum  "; 
               }//if               
               alert(strError); 
               return false;                 
             }//if 
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alpha-numeric characters allowed "; 
                }//if 
                alert(strError); 
                return false; 
              }//if 
              break; 
           }//case alphanumeric 
        case "num": 
        case "numeric": 
           { 
		    var myregexp = /[^0-9]/;
              var charpos = objValue.value.search(myregexp); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Please enter a valid number"; 
                }//if               
                alert(strError); 
                return false; 
              }//if 
              break;               
           }//numeric 
		   
		    case "phonenumber": 
           { 
		    var myregexp = /[^0-9\(\)\-\+\.\s]/;
              var charpos = objValue.value.search(myregexp); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Please enter a valid phone number"; 
                }//if               
                alert(strError); 
                return false; 
              }//if 
              break;               
           }//n
		   
		   
		   
        case "alphabetic": 
        case "alpha": 
           { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alphabetic characters allowed "; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//alpha 
		case "alnumhyphen":
			{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _"; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 			
			break;
			}
        case "email": 
          { 
               if(!validateEmailv2(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Enter a valid Email address "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email 
        case "lt": 
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : value should be less than "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : value should be greater than "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = objValue.name+": Invalid characters found "; 
	              }//if                                                               
	              alert(strError); 
	              return false;                   
	            }//if 
			}
           break; 
         }//case regexp 
        case "dontselect": 
         { 
            if(objValue.selectedIndex == null) 
            { 
              alert("BUG: dontselect command for non-select Item"); 
              return false; 
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError = objValue.name+": Please Select one option "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
             break; 
         }//case dontselect 
    }//switch 
    return true; 
}

function conf_email()
{
	if(document.model_frm.email.value!=document.model_frm.conf_email.value)
		{
			alert("Confirm email not matching.");
			document.model_frm.conf_email.focus();
			return false;
		}
	
}

function check_skill()
{

	var benter = false;
	var i;

	for(i=0; i<document.statistic_frm.elements.special_skill.length ; i++)
	{

		if(document.statistic_frm.elements.special_skill[i].checked==true)	
		{
			
				benter=true;
			
		}
		
	}
	if(!benter)
	{
	alert("please select at least one special skill");
	return false;
	}
	
	
	// sport skill
	
	var senter = false;
	var i;

	for(i=0; i<document.statistic_frm.elements.sport_skill.length ; i++)
	{

		if(document.statistic_frm.elements.sport_skill[i].checked==true)	
		{
			
				senter=true;
			
		}
		
	}
	if(!senter)
	{
	alert("please select at least one sport skill");
	return false;
	}
	

	
}


function editcheck_skill()
{

	var benter = false;
	var i;

	for(i=0; i<document.editstatistic_frm.elements.special_skill.length ; i++)
	{

		if(document.editstatistic_frm.elements.special_skill[i].checked==true)	
		{
			
				benter=true;
			
		}
		
	}
	if(!benter)
	{
	alert("please select at least one special skill");
	return false;
	}
	
	
	// sport skill
	
	var senter = false;
	var i;

	for(i=0; i<document.editstatistic_frm.elements.sport_skill.length ; i++)
	{

		if(document.editstatistic_frm.elements.sport_skill[i].checked==true)	
		{
			
				senter=true;
			
		}
		
	}
	if(!senter)
	{
	alert("please select at least one sport skill");
	return false;
	}
	

	
}


function suredelete(msg)
		{
			if(confirm(msg))
		{
		sub_cat_del=confirm("Deleting this category will delete its subcategory too.");
			if(sub_cat_del)
			{
				
			return true;
			}
			else
			{
				
			 return false;	
			}
		}
		else
		{
			
		return false;
		}
		}
		
		
function conf(msg)
{
			if(confirm(msg))
			{
				return true;
			}
			else
			{
				 return false;	
			}
		
}
		
function trim(str) 
{ 
return str.replace(/^\s*|\s*$/g,""); 
}

function delete_photo(id)
{
	if(id)
	{
		if(confirm("Do you really want to delete this photo."))
		{
		return true;
		}
		else
		{
		return false;
		}
	}
	else
	{
		alert("please select image to delete");
		return false;
	}
}

function showdiv(id)
{

alert(id);

document.getElementById(id).style.display='';

}
function hidediv(id)
{
 document.getElementById(id).style.display='none';	
}


function showhidediv(show_id,hide_id)
{
	document.getElementById(show_id).style.display='';	
	document.getElementById(hide_id).style.display='none';	
	
}

	  
function check_image()
{

if(document.client_frm.logo.value=="")
{
//alert("Please upload a picture");
//return false;
}
	else
	{
			
			if(!validateFileExtension(document.client_frm.logo.value,'picture'))
			{
			 alert("Please upload a valid picture file");
			document.client_frm.logo.focus();
			
			 return false;
			}
	}

}

function validateFileExtension(fld,type) {
	switch(type)
	{
		case 'picture':
		
			if(!/(\.png|\.PNG|\.gif|\.GIF|\.jpg|\.JPG|\.jpeg|\.JPEG|\.giff|\.GIFF)$/i.test(fld)) {
				return false;
			}
			break;
		case 'pdf':
			if(!/(\.pdf|\.PDF)$/i.test(fld)) {
				return false;
			}	
			break;
		case 'mp3':
			if(!/(\.mp3|\.MP3|\.swf|\.SWF)$/i.test(fld)) {
				return false;
			}	
			break;
		case 'video':
			if(!/(\.swf|\.SWF)$/i.test(fld)) {
				return false;
			}	
			break;	
		default:
			alert('Please specify a valid file extension');
			return false	
	}
	return true;
}



/* for show hide div in model_registration */
function showhidedivs(showid)
{
	
	
	var alldiv= document.getElementsByTagName("div");
	for (var i = 0; i < alldiv.length; i++) 
	{ 
		if(alldiv[i].className=='steps')
		{
			alldiv[i].style.display='none';
			if(alldiv[i].id==showid)
			{
								
				alldiv[i].style.display='';
			}
						
			
		}
		
	}
	
}	


/* for show email already exist in model registration*/
function getHTTPObject() { 
  var xmlhttp; 

  if(window.XMLHttpRequest){ 
    xmlhttp = new XMLHttpRequest(); 
  } 
  else if (window.ActiveXObject){ 
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    if (!xmlhttp){ 
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    } 
    
} 
  return xmlhttp; 
} 
var http = getHTTPObject(); // We create the HTTP Object 

    	function handleHttpResponse_email()
	    {    
        	if (http.readyState == 4)
		 	{ 
              if(http.status==200)
			   { 
                  var resultsEmail=http.responseText; 
					
				  document.getElementById('divEmailInfo').innerHTML = resultsEmail; 
				  if(resultsEmail!='')
				  {
					document.model_frm.email.value='';
					document.getElementById('divEmailInfo').style.display = 'block'; 
				  }
				  else
				  	document.getElementById('divEmailInfo').style.display = 'none'; 
				 
				 
				  
              }
             } 
        } 
		
		function checkEmailAddress()
		 {      
            var emid = document.getElementById("email").value; 
			if(emid!="")
			{
				var url_email = "check_email.php?emid="+emid;
				http.open("GET", url_email, true); 
				http.onreadystatechange = handleHttpResponse_email; 
				http.send(null); 
			}
        } 
		
		/*function chkcountry()
		{
		
		
			if((document.model_frm.country.value)!="United States")
			{
				
				document.model_frm.getElementById("otherstate").style.display='';
				document.model_frm.getElementById("stateus").style.display='none';
			}
		}*/
		
function validation()
{
	var pval;
	if(trim(document.reg_frm.f_name.value)=='')	
	{
		alert("enter first name.");
		document.reg_frm.f_name.focus();
		return false;
		
	}
	if(trim(document.reg_frm.l_name.value)=='')	
	{
		alert("enter last name.");
		document.reg_frm.l_name.focus();
		return false;
		
	}
	
	var rxp =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/;
  if(document.reg_frm.email_address.value == "")
  {
     alert("Please enter  email address.");
	 document.reg_frm.email_address.focus();
	 return false;
  }
  else if(rxp.test(document.reg_frm.email_address.value)!=true)
	{
		alert('Invalid email address.');
		document.reg_frm.email_address.focus();
		return false;
	}
	
	if(document.reg_frm.dob.value=='')	
	{
		alert("Please enter date of birth.");
		document.reg_frm.dob.focus();
		return false;
		
	}
	
	if(document.reg_frm.gender.value=='')	
	{
		alert("Please select gender.");
		document.reg_frm.gender.focus();
		return false;
		
	}
	
	if(trim(document.reg_frm.city.value)=='')	
	{
		alert("Please enter city name.");
		document.reg_frm.city.focus();
		return false;
		
	}
	
	if(trim(document.reg_frm.state.value)=='')	
	{
		alert("Please enter state name.");
		document.reg_frm.state.focus();
		return false;
		
	}
	
	if(trim(document.reg_frm.country.value)=='')	
	{
		alert("Please select country.");
		document.reg_frm.country.focus();
		return false;
		
	}
	
	if(document.reg_frm.phone.value=='')
	{
		alert("enter phone no.");
		document.reg_frm.phone.focus();
		return false;
	}
	if(document.reg_frm.phone.value!="")
	{
		 var pval=document.reg_frm.phone.value;
		 if(!ValidChars("1234567890()-,",pval))
		  {
			alert("Please insert valid phone number.");
			document.reg_frm.phone.focus();
			return false;
		  }
	}
	if(document.reg_frm.zip.value=='')
	{
		alert("enter zip no.");
		document.reg_frm.zip.focus();
		return false;
	}
	if(document.reg_frm.zip.value!="")
	{
		
		var  pval= document.reg_frm.zip.value;
		
		 if(!ValidChars("1234567890()-,",pval))
		  {
			alert("Please insert valid zip number.");
			document.reg_frm.zip.focus();
			return false;
		  }
	}
	
	if(document.reg_frm.travel.value=='')
	{
		alert("Please select travel distance.");
		document.reg_frm.travel.focus();
		return false;
	}
	
	if(document.reg_frm.find_us.value=='')
	{
		alert("Please select how'd you find us.");
		document.reg_frm.find_us.focus();
		return false;
	}

	/*------------- show div ------------------*/
	showhidedivs('step_2');
	/*----------------end------------*/
}

function ValidChars(validchars,value) 
 { // v3.0
 
	var key='', keychar='';
	for(i=0;i<value.length;i++)
	{
		keychar = value.charAt(i);
		keychar = keychar.toLowerCase();
		validchars = validchars.toLowerCase();
		if (validchars.indexOf(keychar) == -1)
		{
			key=keychar;
		}
	}
	if(key!='')
		return false;
	else
		return true;
}

function checkcountry(frm)
{

	
	
if((frm.country.value)!="United States")
{
	
document.getElementById('state').style.display="none";
 document.getElementById("oth_state").style.display='';
 
}
else
{

document.getElementById('state').style.display='';
 document.getElementById("oth_state").style.display="none";	

}

}


function changefield()
{
	
}
function checkstate()
{
		/*var frmmodelreg = document.forms["model_frm"];
		var editfrmmodelreg = document.forms["editmodel_frm"];
	if(frmmodelreg.state.style.display=='')
	{
		if(frmmodelreg.state.value=="")
		{
	 alert("select state");
	 frmmodelreg.state.focus();
	 return false;
		}	
	}
	if(frmmodelreg.oth_state.style.display=='')
	{
		if(frmmodelreg.oth_state.value=='')
		{
	 alert("Please enter state.");
	 frmmodelreg.oth_state.focus();
	 return false;
		}
	}
	
	if(editfrmmodelreg.state.style.display=='')
	{
		if(editfrmmodelreg.state.value=="")
		{
	 alert("select state");
	 editfrmmodelreg.state.focus();
	 return false;
		}	
	}
	if(editfrmmodelreg.oth_state.style.display=='')
	{
		if(editfrmmodelreg.oth_state.value=='')
		{
	 alert("Please enter state.");
	 editfrmmodelreg.oth_state.focus();
	 return false;
		}
	}*/
	if(document.postjob_frm.state.style.display=='')
	{
		if(document.postjob_frm.state.value=="")
		{
	 alert("please select state.");	
	 return false;
		}
	}
	else
	{
		if(document.postjob_frm.oth_state.value=="")
		{
	 alert("please enter state.");	
	 return false;
		}
	}
	
	
}
function editcheckstate()
{
	if(document.editpostjob_frm.state.style.display=='')
	{
		if(document.editpostjob_frm.state.value=="")
		{
	 alert("please select state.");	
	 return false;
		}
	}
	else
	{
		if(document.editpostjob_frm.oth_state.value=="")
		{
	 alert("please enter state.");	
	 return false;
		}
	}
	
	
}



function check_termcondition()
{

	if(document.client_frm.term_chk.checked==false)
	{
	 alert("please accept terms and conditions.");	
	 return false;
	}
}

function checkjobdeletion(val)
 {

 if(val=='1')
 {
  document.getElementById("auto").style.display='';
  document.getElementById("manual").style.display="none";
  }
  else
  {
  document.getElementById("auto").style.display='none';
  document.getElementById("manual").style.display='';
  }
 }

function manageGender(val)
{
	var frm = val;
	
if((frm.gender.value)=="female")
{
	
document.getElementById("bust").style.display='';
document.getElementById("cup").style.display='';
document.getElementById("hips").style.display='';
}
	if((frm.gender.value)=="male")
	{
	document.getElementById("bust").style.display='none';
	document.getElementById("cup").style.display='none';
	document.getElementById("hips").style.display='none';
	}
	if((frm.gender.value)=="")
	{
	document.getElementById("bust").style.display='';
	document.getElementById("cup").style.display='';
	document.getElementById("hips").style.display='';
	}
}
function goback()
{
history.back();	
}
/*function validateemail()
{
  var rxp =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/;
  if(document.reg_frm.email_address.value == "")
  {
     alert("Please enter  email address.");
	 document.reg_frm.oldemail.focus();
	 return false;
  }
  else if(rxp.test(document.reg_frm.email_address.value)!=true)
	{
		alert('Invalid email address.');
		document.reg_frm.email_address.focus();
		return false;
	}
  
  return true;
}*/

		
/*
	Copyright 2003 JavaScript-coder.com. All rights reserved.
*/