function $(field){var element =  document.getElementById(field);return element;return false;}
function $F(element){var element =  document.getElementById(element).value;return element;}

function bookmarksite(title, url)
{
	var agt = navigator.userAgent;
	if (document.all)
	{window.external.AddFavorite(url, title);}
	else if (window.sidebar)
	{window.sidebar.addPanel(title, url, "");}
	//else {alert('Press Ctrl-D to bookmark this page');}
	else if (agt.search(/chrome/i)>0 || agt.search(/safari/i)>0){alert('Press Ctrl-D to bookmark this page');}
}

function openWindow(url)
{
	popupWin = window.open(url,'new_page','width=450,height=450,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,location=no,status=no,directories=no,copyhistory=no')
	popupWin.focus();
}

function validateContactForm()
{
	var email = document.getElementById("contactemail").value;
	var goodContactEmail = email.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
	apos=email.indexOf("@");
	dotpos=email.lastIndexOf(".");
	lastpos=email.length-1;
	var badContactEmail = (apos<1 || dotpos-apos<2 || lastpos-dotpos<2);
	if ($F("contactlastname") == "")
	{
		hideAllErrorsContactForm();
		$("errorContactName").style.display = "inline";
		$("contactlastname").focus();
		$('contactlastname').className='inputerror';
		return false;
	}
	else if (!goodContactEmail && badContactEmail)
	{
		hideAllErrorsContactForm();
		$("errorContactEmail").style.display = "inline";
		$("contactemail").select();
		$("contactemail").focus();
		$('contactemail').className='inputerror';
		return false;
	}
	else if ($F("contactComments") == "")
	{
		hideAllErrorsContactForm();
		$("errorContactComments").style.display = "inline";
		$("contactComments").select();
		$("contactComments").focus();
		$('contactComments').className='inputerror';
		return false;
	}
	else if ($F("verificationcode") == "")
	{
		hideAllErrorsContactForm();
		$("errorContactVerVode").style.display = "inline";
		$("verificationcode").select();
		$("verificationcode").focus();
		$('verificationcode').className='inputerror';
		return false;
	}

	return true;
}
function hideAllErrorsContactForm()
	{
	$("errorContactName").style.display = "none";
	$("errorContactEmail").style.display = "none";
	$("errorContactComments").style.display = "none";
	$("errorContactVerVode").style.display = "none";

	$('contactlastname').className='fieldbox11';
	$('contactemail').className='fieldbox11';
	$('contactComments').className='fieldbox11';
	$('verificationcode').className='fieldbox11';
}

function validateNewsletterForm()
{
	var email = document.getElementById("Newsletteremail").value;
	var goodNewsletterEmail = email.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
	apos=email.indexOf("@");
	dotpos=email.lastIndexOf(".");
	lastpos=email.length-1;
	var badNewsletterEmail = (apos<1 || dotpos-apos<2 || lastpos-dotpos<2);
	if ($F("Newslettername") == "" || $F("Newslettername")=="name")
	{
		hideAllErrorsNewsltForm();
		$("errorNewsletterName").style.display = "inline";
		$("Newslettername").select();
		$("Newslettername").focus();
		return false;
	}
	else if (!goodNewsletterEmail && badNewsletterEmail)
	{
		hideAllErrorsNewsltForm();
		$("errorNewsletterEmail").style.display = "inline";
		$("Newsletteremail").select();
		$("Newsletteremail").focus();
		return false;
	}
	return true;
}
function hideAllErrorsNewsltForm()
{
	$("errorNewsletterName").style.display = "none";
	$("errorNewsletterEmail").style.display = "none";
}

function show_hide_div(div_id, cross)
{
	var div_id;
	$(div_id).style.display = $(div_id).style.display == 'none' ? '' : 'none';
	if (cross!=""){$(cross).innerHTML == "[-]" ? $(cross).innerHTML = "[+]"	: $(cross).innerHTML = "[-]";}
}

function ShowTip(div_id, title, desc)
{
var div_id= $(div_id);
div_id.style.display = 'inline';
div_id.style.align='justify';
div_id.style.position = 'absolute';
div_id.style.width = '400px';
div_id.style.backgroundColor = '#ffffe0';
div_id.style.border = ' 1px #999999 solid';
div_id.style.padding = '5px';
div_id.innerHTML = '<b>' + title + '</b><div style="padding-left:10; padding-top:5; padding-right:5; font-family: Verdana, Arial; font-size: 11px">' + desc + '</div>';
}
function HideTip(div_id){
	var div_id= $(div_id);div_id.style.display = 'none';}

function showHelpContent(id) {
	var id;	var url = "getHelpContent.asp?id="+id;var divToUpdate = "helpContentPopUp"+id;
	if ($("more"+id).innerHTML=='Less')
	{	$(divToUpdate).hide();moreless(id);return false;}
	new Ajax.Updater(divToUpdate, url, {onComplete: showResponseH, onException:showExceptionH, onFailure:showExceptionH, asynchronous:true, method: 'GET', evalScripts:false});
	moreless(id);
	function showResponseH(req) {

//	var divToUpdateW=$(divToUpdate).getWidth();
//	var divToUpdateH=$(divToUpdate).getHeight();
//	var fromTop=(document.viewport.getScrollOffsets().top)+divToUpdateH+10;
//	var fromLeft=(document.viewport.getScrollOffsets().left)+((document.viewport.getWidth()-divToUpdateW));
//	$(divToUpdate).style.top=(fromTop<0?0:fromTop)+'px';
//	$(divToUpdate).style.left=(fromLeft<0?0:fromLeft)+'px';
//	alert(fromLeft);
//	$(divToUpdate).style.position='absolute';		

		$(divToUpdate).show();

	}
	
	
	function showExceptionH(req) {alert('Exception:'+req.responseText);}
	function moreless(id){$("more"+id).innerHTML = ($("more"+id).innerHTML=='Less') ? 'More' : 'Less';}
/*how to use:
<a onclick="showHelpContent(19);return false;" href="#"><span id="more19">More</span></a>
<div id="helpContentPopUp19" style="display:none;"></div>
*/
}

function infoBox(div_id,title,desc,width,xbutton){
	var div_id;var title;var desc;var width;var xbutton;
	if($(div_id).style.display=='none') {
		if(xbutton==1){
			new Draggable(div_id);
			xbuttonContent='<p align=right><a href="#" onclick="hide_info_bubble(\''+div_id+'\',\''+xbutton+'\');return false;"><img border="0" src="./images/closesm.gif"></a></p>';
		}
		else if(xbutton==0){
			xbuttonContent='';
		}
		var bubbleContent='<table style="cursor: move;WIDTH: '+width+';" cellspacing="0" cellpadding="0"><tbody><tr><td valign=top style="WIDTH: 12px;"><img alt="" src="./images/nw.gif" border="0" /></td><td style="BACKGROUND: #339900;"></td><td valign=top  WIDTH=12px><img alt="" src="./images/ne.gif" border="0" /></td></tr><tr><td style="BACKGROUND: #339900; WIDTH: 12px;"></td><td style="BACKGROUND: #339900;padding-top:10px;padding-bottom:8px;padding-left:6px;padding-right:6px;">';
		var bubbleContent=bubbleContent+'<span style="FONT-SIZE: 10pt; COLOR: #ffffff; FONT-FAMILY: Tahoma"><strong>'+title+'</strong></span><br><span style="FONT-SIZE: 8pt; COLOR: #ffffff; FONT-FAMILY: Tahoma">'+desc+'</span>'+xbuttonContent;
		var bubbleContent=bubbleContent+'</td><td style="BACKGROUND: #339900; WIDTH: 12px;"></td></tr><tr><td valign=bottom style="WIDTH: 12px;"><img alt="" src="./images/sw.gif" border="0" /></td><td style="BACKGROUND: #339900;"></td><td valign=bottom  style="WIDTH: 12px;"><img alt="" src="./images/se.gif" border="0" /></td></tr></tbody></table>';
		$(div_id).innerHTML=bubbleContent;
		$(div_id).show();
		$(div_id).style.position='absolute';
	}
	else {
		if(xbutton==1){
			$(div_id).hide();
		}
	}
}



function myNotes(){
/*
a = (b=c) ? d : e
(b=c) is true then a=d
(b=c) is false then a=e
*/
}