// JavaScript Document
function preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=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 unblur() {
	this.blur();
}

function blurLinks() {
	links = document.getElementsByTagName("a");
	for(i=0; i<links.length; i++) {
		links[i].onfocus = unblur;
	}
	inputs = document.getElementsByTagName("input");
	for(i=0; i<inputs.length; i++) {
		if (inputs[i].type == 'button' || inputs[i].type == 'submit') {
			inputs[i].onfocus = unblur;
		}
	}

}


function setFocus(obj) {
	x = document.getElementById(obj);
	x.focus();
}

function flashObjects (objPath,objWidth,objHeight,objTitle,objParam,altPath,altWidth,altHeight,altTitle) {
	document.write('<object type="application/x-shockwave-flash" data="'+objPath+'"width="'+objWidth+'" height="'+objHeight+'" '+objParam+'> \
					<param name="movie" value="'+objPath+'" /> \
					<param name="quality" value="high" /> \
					<param name="wmode" value="transparent" /> \
					<img src="'+altPath+'" width="'+altWidth+'" height="'+altHeight+'" alt="'+altTitle+'" /></object>');
}

function meadiaPlayerObjects (objPath, objWidth, objHeight) {
	document.write('<OBJECT ID="MediaPlayer" CLASSID="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" standby="Loading Microsoft Windows Media Player components..."  TYPE="application/x-oleobject" width="'+objWidth+'" height="'+objHeight+'"  align="center"> \
			            <PARAM NAME="url" VALUE="'+objPath+'"> \
			            <PARAM NAME="AutoStart" VALUE=1> \
			            <PARAM NAME="ShowControls" VALUE=1> \
			            <PARAM NAME="uiMode" VALUE="full"> \
						<PARAM NAME="enableContextMenu" value="true"> \
						<embed type="application/x-mplayer2" src="'+objPath+'" ShowControls="1" AutoStart="1" ShowDisplay="0" ShowStatusBar="1" width="'+objWidth+'" height="'+objHeight+'"></embed> \
				      </OBJECT>');
}

function showMap(el) {
	x = $(el);
	x.style.visibility = 'visible';
}

function markSelected(el) {
	if (el.parentNode.className != 'selected') {
		el.parentNode.className = 'hover';
	}
	//return false;
}

function unmarkSelected(el) {
//	alert (el.parentNode.className);
	if (el.parentNode.className != 'selected') {
		el.parentNode.className = '';
	}
	//return false;
}

function formElementsStyle () {
	if(document.getElementsByTagName) {

		var className = 'tr_hover',
		pattern = new RegExp('(^|\\s+)' + className + '(\\s+|$)'),			
		rows = document.getElementsByTagName('tr');

		for (var i = 0, n = rows.length; i < n; ++i) {
				rows[i].onmouseover = 
					function() {
						this.className += ' ' + className;
					};
				rows[i].onmouseout = 
					function() {
						this.className = this.className.replace(pattern, ' ');
					};
		}
	}
	rows = null;	
}

function popUp(URL) {
	window.open( URL, "myWindow", "status = 1, height = 600, width = 700, resizable = yes" )
}


function popUpPrint(URL) {
	window.open( URL, "myWindow", "status = 1, height = 600, width = 700, toolbar=no, scrollbars=yes, menubar=no, resizable = yes" )	
}

function fade(el) {
	el.style.opacity =  0.5; 
	el.style.MozOpacity =  0.5; 	
	el.style.KhtmlOpacity =  0.5; 
	el.style.filter = "alpha(opacity=50)";
}

function unfade(el) {
	el.style.opacity =  1; 
	el.style.MozOpacity =  1; 	
	el.style.KhtmlOpacity =  1; 
	el.style.filter = "alpha(opacity=100)";
}


function btnHover(el) {
	el.className = 'searchBtnHover';
}

function btnRestore(el) {
	el.className = 'searchBtn';
}

function emptyFormFields(el,val) {
	if (el.value == val ) {
		el.value = '';
	}	
}

function fillFormFields(el,val) {
	if (el.value == '' ) {
		el.value = val;
	}
}

function formValid(form, errors, min_length){
	errors.innerHTML = '';
	var elements = form.getElementsBySelector('[rel="validate"]');
	for (i=0;i<elements.length;i++) {
		if (elements[i] == null || elements[i].value == '' || (min_length>-1 && elements[i].value.length < min_length)) {
			errors.innerHTML = errors.innerHTML + elements[i].title + '<br />';
		}
	}
	if (errors.innerHTML == '') {
		return true;
	} else {
		return false;
	}
}

//main navigation 
navHover = function() {
	if (document.getElementById('mainNav')){
		var lis = document.getElementById("mainNav").getElementsByTagName("LI");
		for (var i=0; i<lis.length; i++) {
			lis[i].onmouseover=function() {
				this.className+=" iehover";
			}
			lis[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" iehover\\b"), "");
			}
		}
	}
}


rnavHover = function() {
	if (document.getElementById('regions')){
		var lis = document.getElementById("regions").getElementsByTagName("LI");
		for (var i=0; i<lis.length; i++) {
			lis[i].onmouseover=function() {
				this.className+=" iehover";
			}
			lis[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" iehover\\b"), "");
			}
		}
	}
}



if (window.attachEvent) window.attachEvent("onload", navHover);
if (window.attachEvent) window.attachEvent("onload", rnavHover);

function showHideLang(whichLayer) {
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function hideMap() {
	Element.hide('map');
	Element.show('type');
	Element.show('basiclocation');
}
