// JavaScript Document

var bName = navigator.appName;
var agt = navigator.userAgent.toLowerCase();
var NS = (bName == "Netscape");
var IE = (bName == "Microsoft Internet Explorer");
var IE5x = (agt.indexOf("msie 5") != -1);
var bVer = parseInt(navigator.appVersion);
var NS4 = (NS && bVer < 5);
var NS6 = (NS && bVer >= 5);
// rwc: 15-Sep-03. the above works!  Use these vars.
var IESP2 = (agt.indexOf("sv1") != -1); // IE with Service Pack 2
var isMac = (agt.indexOf('mac') != -1);
var isMacIE5x = (isMac && IE5x);


function check_lbs() {
txt=document.isn.lbs;
if (txt.value.length<1) { alert("Please, enter your weight"); return false; }
return true;
}

function check_kg() {
txt=document.isn1.kg;
if (txt.value.length<1) { alert("Please, enter your weight"); return false; }
return true;
}

function showit(id) {

some=document.getElementById(id).style;
eval("some.display = \"" + 'block' + "\""); 
}

function hideit(id) {

some=document.getElementById(id).style;
eval("some.display = \"" + 'none' + "\""); 
}

function openWindow(url,w,h) {
e=window.open(url,'_blank', 'resizable=yes,width='+w +', height=' +h +',scrollbars=yes,toolbar=no,menubar=no,status=yes,location=no');
}

function checkcomment(e) {

document.getElementById('t_contact').style.color="black";
document.getElementById('t_comment').style.color="black";
document.getElementById('t_email').style.color="black"; 

var ret=0;
txt=document.tstest.contact;
if (txt.value.length<2) { ret=1; document.getElementById('t_contact').style.color="red"; } else { txt.style.background="#FFFFFF"; }
txt=document.tstest.comment;  
if (txt.value.length<2) {  document.getElementById('t_comment').style.color="red"; ret=1;} else {
txt.style.background="#FFFFFF"; }

if (!check_email(document.tstest.email.value) || document.tstest.email.value.length<2) { document.getElementById('t_email').style.color="red"; ret=1; } 


if(ret==1) { alert('Please, check all fields marked as red.'); return false; }
 else {
return true;
}

}

function checkcomment_user(e) {

document.getElementById('t_contact').style.color="black";
document.getElementById('t_comment').style.color="black";

var ret=0;

txt=document.tstest.contact;
if (txt.value.length<2) { ret=1; document.getElementById('t_contact').style.color="red"; } else { txt.style.background="#FFFFFF"; }

txt=document.tstest.comment;  
if (txt.value.length<2) {   document.getElementById('t_comment').style.color="red";  ret=1; } 


if(ret==1) { alert('Please, check all fields marked as red.'); return false; }
 else {
return true;
}

}


function showhide(id)

{ some=document.getElementById(id).style;


if (some.display=="none") {

 eval("some.display = \"" + 'block' + "\""); 

 }

else 
eval("some.display = \"" + 'none' + "\"");


}

function setLyr(obj,lyr)
{
	var coors = findPos(obj);
	
	var x = document.getElementById(lyr);
	x.style.top = coors[1] -200 + 'px';
	x.style.left = coors[0]-200 + 'px';
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function check_email(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
e=trim(e);
for(i=0; i < e.length ;i++){
	if(ok.indexOf(e.charAt(i))<0) { 
	return (false);
	}	
}
return true;
}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
} 

function checksignup() {

document.getElementById('t_firstname').style.color="black";
document.getElementById('t_lastname').style.color="black";
document.getElementById('t_email').style.color="black";

var ret=0;

txt=document.tstest.firstname;
if (txt.value.length<2) { ret=1; document.getElementById('t_firstname').style.color="red"; } else { txt.style.background="#FFFFFF"; }

txt=document.tstest.lastname;  
if (txt.value.length<2) {   document.getElementById('t_lastname').style.color="red";  ret=1; } 

if (!check_email(document.tstest.email.value) || document.tstest.email.value.length<2) {   document.getElementById('t_email').style.color="red";  ret=1; } 

if(ret==1) { alert('Please, check all fields marked as red.'); return false; }
 else {
return true;
}

}// checksignup

function stopSubmit() {
return false;
}