
var btnNames = ["overview","features","samples","download","buy","doc","faq","contact","terms"];

function lhBtn_init()
{
	var tmpStr = curPg.toLowerCase();
	
	for(i=0;i<btnNames.length;i++)
	{
		if (btnNames[i] == tmpStr)
			$('lhBtn_'+btnNames[i]).className = "grButton_active";	
		else
			$('lhBtn_'+btnNames[i]).className = "grButton";
	}
}

function go(url)
{
	document.location = url;
}


function show_terms()
{
	var wd = 550;
	var ht = 400;
	
	var myBars = 'directories=no,location=no,menubar=no,status=no,toolbar=no';
	var myOptions = 'scrollbars=yes,width='+wd+',height='+ht+',resizeable=yes';
	
	xPos = (screen.width - wd)/2;
	yPos = (screen.height - ht)/2;
	var myPos = 'left='+xPos+',top='+yPos+'screenX='+xPos+',screenY='+yPos;
	
	window.open("terms_popup.php","",myBars+','+myOptions+','+myPos);
}

function t(obj)
{
	obj.style.borderLeft = '2px solid #000000';
	obj.style.borderRight = '2px solid #000000';
}

function tt(obj)
{
	obj.style.borderLeft = '';
	obj.style.borderRight = '';
}

function p_pForm()
{
	if (validateF())
	{
		//copy values to paypal fields
		var F = document.forms['buynow_form'];
		
		F.first_name.value 		= F.txt_fname.value;
		F.last_name.value 		= F.txt_lname.value;
		F.country.value			= F.sel_country.value;
		F.custom.value			= F.txt_email.value;
	
		return true;
	}
	else
		return false;
}

function focus_form()
{
	document.forms['buynow_form'].txt_fname.focus();
}

function validateF()
{
	var F = document.forms['buynow_form'];
	
	if (F.txt_fname.value=="")
	{
		alert('Please enter your First name');
		F.txt_fname.focus();
		return false;
	}
	
	if (F.txt_lname.value=="")
	{
		alert('Please enter your Last name');
		F.txt_lname.focus();
		return false;
	}
	
	if (F.sel_country.value=="")
	{
		alert('Please select a country');
		F.sel_country.focus();
		return false;
	}
	
	if (F.txt_email.value =="")
	{
		alert('Please enter an email id');
		F.txt_email.focus();
		return false;
	}
	
	if (!validateEmail(F.txt_email.value))
	{
		alert('Please enter a valid email id');
		F.txt_email.focus();
		return false;
	}
		
	return true;
}

function validateEmail(email)
{
	//illegal email chars
	if (email.indexOf(' ')>-1)
		return false;
	if (email.indexOf("'")>-1)
		return false;
	if (email.indexOf('"')>-1)
		return false;
	
	//find wrong email format	
	pos1 = email.indexOf('@');
	pos2 = email.indexOf('.',pos1);

	if (pos1==-1)
		return false;
	if (pos2 ==-1)
		return false;
	if (pos1>0 && pos2>(pos1+1))
		return true;	//valid email
	else
		return false;
}