/* Registration form validation */
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){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
}



function trimStr(str)
{
    while(str.charAt(0) == (" ") )	
    {
	    str = str.substring(1);	
    }
    while(str.charAt(str.length-1) == " " )
    {
	    str = str.substring(0,str.length-1);	
    }	
    return str;
}

function checkRegistration() {

    if (trimStr(document.register_form.title.value) == ""){ 
        alert(alertMessage['title']);
        document.register_form.title.focus();
        document.register_form.title.select();
        return false;
    }
	
    if (trimStr(document.register_form.firstname.value) == ""){ 
        alert(alertMessage['firstname']);
        document.register_form.firstname.focus();
        document.register_form.firstname.select();
        return false;
    }
	
    if (trimStr(document.register_form.lastname.value) == ""){ 
        alert(alertMessage['lastname']);
        document.register_form.lastname.focus();
        document.register_form.lastname.select();
        return false;
    }
    
    if (trimStr(document.register_form.city.value) == ""){ 
        alert(alertMessage['city']);
        document.register_form.city.focus();
        document.register_form.city.select();
        return false;
    }
    
    if (trimStr(document.register_form.state.value) == ""){ 
        alert(alertMessage['state']);
        document.register_form.state.focus();
        document.register_form.state.select();
        return false;
    }  
    
    if (trimStr(document.register_form.postalcode.value) == ""){ 
        alert(alertMessage['postalcode']);
        document.register_form.postalcode.focus();
        document.register_form.postalcode.select();
        return false;
    }   
    
    if (trimStr(document.register_form.country.value) == ""){ 
        alert(alertMessage['country']);
        document.register_form.country.focus();
        document.register_form.country.select();
        return false;
    }  
    
    if (trimStr(document.register_form.company.value) == ""){ 
        alert(alertMessage['company']);
        document.register_form.company.focus();
        document.register_form.company.select();
        return false;
    }  
    
    if (trimStr(document.register_form.industry.value) == ""){ 
        alert(alertMessage['industry']);
        document.register_form.industry.focus();
        document.register_form.industry.select();
        return false;
    }       
    
    if (trimStr(document.register_form.phone.value) == ""){ 
        alert(alertMessage['phone']);
        document.register_form.phone.focus();
        document.register_form.phone.select();
        return false;
    }   
    
    if (trimStr(document.register_form.email.value) == ""){ 
        alert(alertMessage['email']);
        document.register_form.email.focus();
        document.register_form.email.select();
        return false;
    } 
    
    if (echeck(trimStr(document.register_form.email.value)) == false){ 
        alert(alertMessage['valid']);
        document.register_form.email.focus();
        document.register_form.email.select();
        return false;
    }     
    
    if (trimStr(document.register_form.password.value) == ""){ 
        alert(alertMessage['password']);
        document.register_form.password.focus();
        document.register_form.password.select();
        return false;
    } 
    
    if (trimStr(document.register_form.confirm_password.value) == ""){ 
        alert(alertMessage['confirm_password']);
        document.register_form.confirm_password.focus();
        document.register_form.confirm_password.select();
        return false;
    }                                      
    
    if (trimStr(document.register_form.password.value) != trimStr(document.register_form.confirm_password.value)){ 
        alert(alertMessage['no_match']);
        document.register_form.confirm_password.focus();
        document.register_form.confirm_password.select();
        return false;
    }    
    
    return true;
	
}

function activateSearch(){
    document.top_search.search.value = "";
    document.getElementById("search_keywords").style.color="#000000"; 
    //document.getElementById("search_keywords").style.fontStyle="normal";	
}

function nav_on_off(id){
	
	// check status of current menu  
	var toggle = "show";
	if(document.getElementById(id).style.visibility == "visible") {
	    var toggle = "hide";    	    
	}    
	
	// configure tabs
    var tabs = new Array();
        tabs[0] = "ind_nav"; 
        tabs[1] = "pro_nav";
        tabs[2] = "ser_nav";
        tabs[3] = "myp_nav"; 
    
    // hide all menus    
    for (i=0;i<=3;i++)
    {
       document.getElementById(tabs[i]).style.visibility = "hidden";
    }
        
    // apply change to current menu      	
    if(toggle == "show") {
	    document.getElementById(id).style.visibility = "visible";     
    } 	   	
}

function load_images(){

	
	Image1= new Image(189,30)
    Image1.src = "images/tabs-back_r2_c1.jpg";

    Image2 = new Image(189,30)
    Image2.src = "images/tabs-back_r2_c2.jpg";
    
    Image3 = new Image(188,30)
    Image3.src = "images/tabs-back_r2_c3.jpg";
		
} 

function tab_on(id, site){
  if(site == "PER"){ 	
	if(id == 'ind_tab'){
        document.getElementById(id).style.backgroundImage = "url(images/per-tabs-back_r2_c1.jpg)";	    
	}else if(id == 'con_tab'){
	    document.getElementById(id).style.backgroundImage = "url(images/per-tabs-back_r2_c3.jpg)";		
	}else{
	    document.getElementById(id).style.backgroundImage = "url(images/per-tabs-back_r2_c2.jpg)";	
	}
  }else{	
	if(id == 'ind_tab'){
        document.getElementById(id).style.backgroundImage = "url(images/tabs-back_r2_c1.jpg)";	    
	}else if(id == 'con_tab'){
	    document.getElementById(id).style.backgroundImage = "url(images/tabs-back_r2_c3.jpg)";		
	}else{
	    document.getElementById(id).style.backgroundImage = "url(images/tabs-back_r2_c2.jpg)";	
	}  
  }	    	
}

function tab_off(id, site){
  if(site == "PER"){ 
	if(id == 'ind_tab'){
        document.getElementById(id).style.backgroundImage = "url(images/per-tabs-back_r1_c1.jpg)";
	}else if(id == 'con_tab'){
	    document.getElementById(id).style.backgroundImage = "url(images/per-tabs-back_r1_c3.jpg)";		
	}else{
	    document.getElementById(id).style.backgroundImage = "url(images/per-tabs-back_r1_c2.jpg)";	
	}
  }else{
	if(id == 'ind_tab'){
        document.getElementById(id).style.backgroundImage = "url(images/tabs-back_r1_c1.jpg)";
	}else if(id == 'con_tab'){
	    document.getElementById(id).style.backgroundImage = "url(images/tabs-back_r1_c3.jpg)";		
	}else{
	    document.getElementById(id).style.backgroundImage = "url(images/tabs-back_r1_c2.jpg)";	
	}
  }		  			
}

function CheckForgotPasswordForm(errorMessage){
    if (trimStr(document.form1.Email.value) == ""){ 
        alert(errorMessage);
        document.document.form1.Email.focus();
        document.document.form1.Email.select();
        return false;
    } 
}
