// JavaScript Document
function popup(url) 
{
 var width  = 800;
 var height = 800;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=yes';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'Conative', params);
 if (window.focus) {newwin.focus()}
 return false;
}
function check_newsletter(){
	var t_name 	= trim(document.getElementById('txt_n_name').value);
	var t_email 	= trim(document.getElementById('txt_n_email').value);
	if(t_name == "" || t_name == "Your Name"){
		alert("Please type your Name");
		document.getElementById('txt_n_name').focus();
		document.getElementById('txt_n_name').select();
		return false;
	}else if(t_email == "" || t_email == "Your Email"){
		alert("Please type your Email");
		document.getElementById('txt_n_email').focus();
		document.getElementById('txt_n_email').select();
		return false;
	}else if(!checkEmail(t_email)){
		alert("Your email invalid.");
		document.getElementById('txt_n_email').focus();
		document.getElementById('txt_n_email').select();
		return false;
	}else{
		return true;
	}
}
function check_value(str){
	var t_name 		= trim(document.getElementById('txt_n_name').value);
	var t_email 	= trim(document.getElementById('txt_n_email').value);
	if(str == 'name'){
		if(t_name=='Your Name'){
			document.getElementById('txt_n_name').value = "";
		}
	}
	if(str == 'email'){
		if(t_email=='Your Email'){
			document.getElementById('txt_n_email').value = "";
		}
	}
}
function check_value_out(str){
	var t_name 		= trim(document.getElementById('txt_n_name').value);
	var t_email 	= trim(document.getElementById('txt_n_email').value);
	if(str == 'name'){
		if(t_name==''){
			document.getElementById('txt_n_name').value = "Your Name";
		}
	}
	if(str == 'email'){
		if(t_email==''){
			document.getElementById('txt_n_email').value = "Your Email";
		}
	}
}
function trimLeft(s)
{
 var i;
 i=0;
 var n;
 n = s.length;
 while((i<n)&&(s.charAt(i)==' ')) i++;
	s = s.substring(i);
 return(s);
} 

/*
 trimRight
 Remove all spaces at the end of a string
*/
function trimRight(s)
{
 var n;
 n = s.length;
 var i;
 i = s.length-1;
 while((i>=0)&&(s.charAt(i)==' ')) i--;
	s = s.substring(0,i+1);
 return(s);
}

/* 
 trim
 Remove all leading and trailing spaces in a string
*/
function trim(s)
{
 s = trimLeft(s);
 s = trimRight(s);
 return(s);
}
function checkEmail(txt_email) 
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(txt_email)){
	  return (true);
	}
	
	return (false)
}
