function comingSoon() {
	alert('Coming soon');
	// return false;
}
function search() {
	document.frmSearch.submit();
}
function openLightBox(x) {
	var cHeight = 0;
	if (document.getElementById('divMainContent') != null) {
		if (parseInt(document.getElementById('divMainContent').clientHeight) > cHeight) {
			found = true; 
			cHeight = parseInt(document.getElementById('divMainContent').clientHeight);
			cHeight = cHeight + 300;
		}
	}
	var st = 0;
	var oH = cHeight;
	st = f_scrollTop();

	if(x) {
		var imgs  = document.getElementsByTagName('IMG');
		for (y = 0; y < imgs.length ; y++ )
		{
			if(imgs[y].id ) {
				var re = new RegExp(/lb_img/i);
				if(imgs[y].id.match(re)) {
					imgs[y].style.display = 'none';
				}
			}
		}


		var xs = "lb_img_" + x;
		document.getElementById(xs).style.display = "block";
	}
	document.getElementById('fade').style.height = oH + "px";
	//document.getElementById('lb_img').src = src;
	document.getElementById('light').style.top = (st + 50) + "px";
	document.getElementById('light').style.display='block';
	var gh = document.getElementById('light').clientWidth;
	var cw = f_clientWidth();
	var ll = (cw/2) - (gh/2);
	document.getElementById('light').style.left = 300 + "px";
	document.getElementById('fade').style.display='block';
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function signUp() {
	//window.location = '/cgi-bin/subscribe.cgi';
	var email = document.getElementById('s_email').value;
	var name = document.getElementById('s_name').value;
	if(email && name) {
		var params = "email=" + email + "&name="+name;
		jx.load('/cgi-bin/signup.cgi?'+params,function(data){
			if (data != "0") {
				alert("Subscribed successfully, thank you!");
				document.getElementById('s_email').value = "";
				document.getElementById('s_name').value = "";
			} else {
				alert("There was an error subscribing or you have already subscribed.");
			}
		});
	} else {
		alert("Please fill in both Name and Email")
	}
}
function printContent(id){
	str=document.getElementById(id).innerHTML;
	newwin=window.open('','printwin','left=100,top=100');
	newwin.document.write('<HTML><HEAD>');
	newwin.document.write('<script>');
	newwin.document.write('function chkstate(){');
	newwin.document.write('if(document.readyState=="complete"){');
	newwin.document.write('window.close()');
	newwin.document.write('}');
	newwin.document.write('else{');
	newwin.document.write('setTimeout("chkstate()",2000)');
	newwin.document.write('}');
	newwin.document.write('}');
	newwin.document.write('function print_win(){');
	newwin.document.write('window.print();');
	newwin.document.write('chkstate();');
	newwin.document.write('}');
	newwin.document.write('<\/script>');
	newwin.document.write('</HEAD>');
	newwin.document.write('<BODY onload="print_win()">');
	newwin.document.write(str);
	newwin.document.write('</BODY>');
	newwin.document.write('</HTML>');
	newwin.document.close();
}
function rsPasswd() {
	var strEmail;
	if(document.getElementById('email')) {
		strEmail = document.getElementById('email').value;
	}
	if(!strEmail) {
		strEmail = prompt('What is your Email address\n',strEmail);
	}
	if(strEmail) {
		jx.load('/cgi/cc/pr.pl?email='+strEmail,function(data){
			if (data != "0") {
				if(data == "1") {
					alert("Your password has been reset and\n\nemailed to your email address\n\n");
				}
				if(data == "2") {
					alert("Could not reset your password\n\nPlease try again\n\n");
				}
				if(data == "3") {
					alert("Could not find any accounts with specified email address\n\n");
				}
				// alert('data: ' + data);
			} else {
				alert("The Email address is invalid.(" + data + ")");
			}
		});	
	}
}

function getSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return {winw : myWidth, winh : myHeight};;
}

function initGlobal() {
	var winSize = getSize();
	var commonW = 640;
	if(BrowserDetect.browser == "Explorer") {
		commonW = 620;
	}
		
	if(document.getElementById('divHeader')) {
		document.getElementById('divHeader').style.width = (winSize.winw - 30) + 'px';
	}
	if(document.getElementById('divLinks')) {
		document.getElementById('divLinks').style.width = (winSize.winw - 30) + 'px';
	}
	if(document.getElementById('divHeadLinks')) {
		document.getElementById('divHeadLinks').style.width = (winSize.winw - 30) + 'px';
	}	
	if(document.getElementById('divSearchBar')) {
		document.getElementById('divSearchBar').style.width = (winSize.winw - 30) + 'px';
	}		
	if(document.getElementById('divCenter')) {
		document.getElementById('divCenter').style.width = (winSize.winw - commonW) + 'px';
	}	
	if(document.getElementById('divMainContent')) {
		document.getElementById('divMainContent').style.width = (winSize.winw - (commonW+10)) + 'px';
		var cH = parseInt(document.getElementById('divMainContent').clientHeight);
		var lH = parseInt(document.getElementById('divLeft').clientHeight); 
		var rH = parseInt(document.getElementById('divRight').clientHeight);
		var newH = cH;
		if(lH > newH) {
			newH = lH;
		}
		if(rH > newH) {
			newH = rH;
		}
		if(newH > cH) {
			document.getElementById('divMainContent').style.height = newH+ 'px';
			newH = newH + 10;
		}
		if(newH > lH) {
			document.getElementById('divLeft').style.height = newH + 'px';
		}
		if(newH > rH) {
			document.getElementById('divRight').style.height = newH + 'px';
		}
	}	
}
