function getURL()
{
	var l = encodeURIComponent(window.location);
	location.href = "../emailthispage/emailthispage_new.php?source=" +l;
	return true;
}

function echeck(str)
{
 	var problem = 'NO';
	var at = '@';
	var dot = '.';
	var lat = str.indexOf(at);
	var lstr = str.length;
	var ldot = str.indexOf(dot);

if (str.indexOf(at)==-1){
   problem = 'YES';
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
   problem = 'YES';
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    problem = 'YES';
}

if (str.indexOf(at,(lat+1))!=-1){
    problem = 'YES';
}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
    problem = 'YES';
 }

if (str.indexOf(dot,(lat+2))==-1){
    problem = 'YES';
}

if (str.indexOf(" ")!=-1){
    problem = 'YES';
}

if (problem == 'NO'){
	return true;
}

else
{
	return false;
}					

}
	
function validate()
{
	var fn = document.contact.firstname.value;
	var ln = document.contact.lastname.value;
	var c = document.contact.company.value;
	var e = document.contact.email.value;
	var p = document.contact.phone.value;
	var qc = document.contact.QorC.value;
	
if (fn == "" || ln == "" || c == "" || e == "" || p == "" || qc == "")
{
	alert("Please enter information on required fields.");
	return false;
}
else if (fn == "" && ln == "" && c == "" && e == "" && p == "" && qc == "")
{
	alert("Please enter information on required fields.");
	return false;		
}
else if (echeck(e) == false)
{
	alert("Please enter a valid email address.");
	return false;
}
else
{
	//alert("Thank you. We will get back to you shortly.");
	return true;
}
}

function choose()
{
	var s = document.getElementById("sID");
	var o1 = document.getElementById("otherId");
	var o2 = document.getElementById("oId"); 
if (s.selectedIndex == 9)
{
	o1.innerHTML = 'Others, pls. specify:';
	o2.innerHTML = '<input type="text" name="others" size="25">';
}

else if (s.selectedIndex == 1 || s.selectedIndex == 3)
{
	o1.innerHTML = 'If Google or Yahoo, Keyword Typed In:';
	o2.innerHTML = '<input type="text" name="keyword" size="25">';
}

else
{
	o1.innerHTML = '';
	o2.innerHTML = '';
}
}

/*function openNew()
{
	window.location.href = "http://www.callboxinc.com/thankyou.html";
}*/

// PRELOADING IMAGES
if (document.images) {
 btn1_down=new Image(); btn1_down.src="btn1down.gif"; 
 btn1_up  =new Image(); btn1_up.src  ="btn1up.gif"; 
 btn2_down=new Image(); btn2_down.src="btn2down.gif"; 
 btn2_up  =new Image(); btn2_up.src  ="btn2up.gif"; 
}

// EVENT HANDLERS
function pressButton(btName) {
 if (document.images)
  eval('document.'+btName+'.src='+btName+'_down.src');
}

function releaseButton(btName) {
 if (document.images)
  eval('document.'+btName+'.src='+btName+'_up.src');
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
