/******************************************************/
/*	Description :	Main Site Routines	               /
/*	**			:	Compatible with CMS v3+	  		   /
/*	Version		:	5.4 							   /
/*	Date Stamp  :	8/18/08 - SN					   /
/******************************************************/

//-----------------------------------------------------Stock Macromedia Rollover Code->>

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_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//	Returns true if a supported browser (IE 4.x or higher; Netscape 6.x or higher) 
//	is being used
function isBrowserSupported() {
	var isSupported = false

	if(navigator.appName == 'Microsoft Internet Explorer') {
		if(getIEVersionNum() >= 5) {
		  	isSupported = true;
		}
	}
	else if(navigator.appName == 'Netscape') {
		if(getNetscapeVersionNum() >= 5) {
			isSupported = true;
		}
	}
	
	return isSupported;
}

//	Gets the version number for Internet Explorer
function getIEVersionNum() {
	var brVer = navigator.userAgent;
	var brVerId = brVer.indexOf('MSIE');
	var brNum = brVer.substr(brVerId, 8);

	return brNum.substring(5, 6);
}

//	Gets the version number for Netscape
function getNetscapeVersionNum() {
	var brVer = navigator.userAgent;
	var reg = new RegExp('/');
	var brVerId = brVer.search(reg);
	var brNum = brVer.substring(brVerId + 1);

	return brNum.substring(0, 1);
}

//	Opens a window that is centered on the screen
function openCenteredWindow(url, name, width, height) {

	// Compute the window's top and left positions so that it is centered
	var windowWidth 	= width;
	var windowHeight 	= height;
	var screenWidth 	= screen.availWidth;
	var screenHeight 	= screen.availHeight;
	var left 			= screenWidth  / 2 - windowWidth  / 2;
	var top 			= screenHeight / 2 - windowHeight / 2;
	var properties		= "resizable=yes,left=" + left + ",top=" + top + ",width=" + 
		windowWidth + ",height=" + windowHeight;

	window.open(url, name, properties);
}

//	Trims a string
function trimString(str) {
	//	Remove leading whitespaces
	while (str.charAt(0) == ' '  || str.charAt(0) == '\t' ||
		   str.charAt(0) == '\r' || str.charAt(0) == '\n') {
		str = str.substring(1,str.length);
	}
	
	//	Remove trailing whitespaces
	while (str.charAt(str.length - 1) == ' '  || str.charAt(str.length - 1) == '\t' ||
		   str.charAt(str.length - 1) == '\r' || str.charAt(str.length - 1) == '\n') {
    	str = str.substring(0, str.length - 1);
	}
	
	return str;
}

//	Netscape 4.x bug fix - reloads the page when the browser is resized
function MM_reloadPage(init) {  
	if (init==true) with (navigator) {
		if((appName=="Netscape") && (parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth; 
			document.MM_pgH=innerHeight; 
			onresize=MM_reloadPage; 
		}
	}
	else if(innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) {
		location.reload();
	}
}

//---------------------------------------------------------------------------Form Alert Script->>
// v2.1 [IE/FF][RH]

function form_alert(id, c){
	// highlights background (ugly..)
	obj=new Array();
	obj[0]=document.getElementById(id+"-1");
	obj[1]=document.getElementById(id+"-2");
	if(obj[0]&&obj[1]){
		for(var i=0;i<obj.length;i++){
			bg=(c)?inv_bc:"transparent";
			fg=(c)?inv_fg:"transparent";
			obj[i].style.background=bg;
			obj[i].style.color=fg;
		}
	}
}
function form_alert2(id,c){
	// highlights border (cleaner)
	color=(c)?inv_bc:def_bc;
	document.emailForm[id].style.border="1px solid "+color;
}



//---------------------------------------------------------------------------Div Toggle Ctrls->>
// Vs. 2.8

//	divToggle (...) [USAGE]
//		Creates explorer style collapsable divs
//		@Params:
//		[0] ->	id  		-> Div ID
//		[1]	->	useImgs		-> using +/- images (optional, default: true)
//		#Notes:
//		-	name the controlling image-link the same ID as the div with "Ctrl" at the end !important
//		-	ie: div ID = "div", image ID = "divCtrl"
//		-	plus/minus images MUST be in the same folder
//		-	plus/minus images can be any extension (gif|jpg|etc)

function divToggle()
{
	var a=divToggle.arguments;
	var id=a[0];
	var useImgs=(a[1]!=null)?a[1]:false;
	elem=document.getElementById(id);
	elem.style.display=(elem.style.display=="none" || elem.style.display=="")?"block":"none";
	
	if(useImgs){
		// toggle (path)/(plus|minus).(gif|jpg)
		img=document.getElementById(id+"Ctrl");
		lS=img.src.lastIndexOf("/") + 1;	// last slash
		path=img.src.substr(0,lS);			// read path
		pm=img.src.substr(lS);				// read img name
		ext=pm.substr(pm.lastIndexOf("."));	// get img extension
		img.src=path + ((pm=="minus"+ext)?"plus"+ext:"minus"+ext);
	}
}

//----------------------------------------------------------------------------------Bookmark Page->>
// v1.2 [IE][SN]

//	bookmark_init (...) [USAGE]
//		Creates bookmark link for IE browsers only
//		@Params:
	//		[0] ->	string1  	-> Link Template
	//		[1]	->	string2		-> Non-Compliant Output
		// 	[EXAMPLE]	[bookmark_init("[ :Bookmark Us: ]","");]
		//		string1 = "[ :Bookmark Us: ]"
		//		string2 = ''
		//			on  IE: a link that says 'Bookmark Us'
		//			not IE: nothing output
		
function bookmark_init(string1,string2){
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)){
		s1p=string1.split(/:/);
		outStr=s1p[0] + '<a href="javascript:bookmark();">' +s1p[1]+ '</a>' + s1p[2];
	}else
		outStr=string2;
	document.write(outStr);
}

function bookmark()
{
	url=location.href;
	title=document.title;
	window.external.AddFavorite(url,title)
}