﻿
var redirectPage;
var siteUrl;
var _d = document;
var _w = window;

function setRedirectPage(url){
	redirectPage = url;
}

function setSiteUrl(url)
{ 
	siteUrl = url;
}

function processRedirect(){
	_w.location= siteUrl + redirectPage + '';
	return false;
}

function allLink(link)
{
	redirectPage = link.getAttribute("RedirectPage");
}


function loadBrowserFix(cssLinkId)
{
	version=0
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		temp=navigator.appVersion.split("MSIE")
		version=parseFloat(temp[1])
	}
	cssLink = _d.getElementById(cssLinkId);	
	switch(Math.floor(version))
	{
		case 6:
			cssLink.href = '/css/browser/ie60fixes.css';
			break;
		case 7:
			cssLink.href = '/css/browser/ie70fixes.css';
			break;
	}
}

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (_d.getElementById) { // DOM3 = IE5, NS6
		_d.getElementById(id).style.display = 'none';
	}
	else {
		if (_d.layers) { // Netscape 4
			_d.id.display = 'none';
		}
		else { // IE 4
			_d.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (_d.getElementById) { // DOM3 = IE5, NS6
		_d.getElementById(id).style.display = 'block';
	}
	else {
		if (_d.layers) { // Netscape 4
			_d.id.display = 'block';
		}
		else { // IE 4
			_d.all.id.style.display = 'block';
		}
	}
}

function togglediv(id) {
	//safe function to show an element with a specified id
		 
	if (_d.getElementById) { // DOM3 = IE5, NS6
		if(_d.getElementById(id).style.display == 'none'){
			_d.getElementById(id).style.display = 'block';
		}else{
			_d.getElementById(id).style.display = 'none';
		}
	}
	else {
		if (_d.layers) { // Netscape 4
			if(_d.id.display == 'none'){
				_d.id.display = 'block';
			}else{
				_d.id.display = 'none';
			}
		}
		else { // IE 4
			if(_d.all.id.style.display == 'none'){
				_d.all.id.style.display = 'block';
			}else{
				_d.all.id.style.display = 'none';
			}
		}
	}
}

/*
* Helper object with custom methods for DHTML/AJAX/etc type handling
*/
var _dom = {
	getId: function (id) {
		if(_d.getElementById)
		{
			return _d.getElementById(id);
		}
	}
};

function radAjaxRequest(id)
{
	var radPanel = _w[id];
	if(radPanel)
	{
		radPanel.AjaxRequest();
	}
}


function setCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	setCookie(name,"",-1);
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=809,height=526');");
}

function popUpWidthHeight(URL, width, height) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + "');");
}

/* ================== start basic Validation scripts ================ */
function checkLength(ctrl,maxLength){
  taLength=ctrl.value.length; // look at current length
  if (taLength>maxLength) { // clip characters
    ctrl.value = ctrl.value.substring(0,maxLength);
    //alert('This field only accepts ' + maxLength + ' characters');
  }
}
/* =================== end basic Validation scripts ================= */