// browser checking (for dhtml and some pixel-retentiveness)
ns4 = document.layers;
ie4 = document.all;
nn6 = document.getElementById && !document.all;
ff = navigator.userAgent.indexOf('Firefox');
ie6only = (document.implementation != null) && (document.implementation.hasFeature != null);

var layout;

// ie6 has an annoyingly well documented bug for loading cursor on mouseover.  This is a somewhat elegant fix for it
if (ie6only) {
	try {
	  document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}
}

function getExplorerVersion() {
	var ieVers = parseFloat(navigator.appVersion);
	if( navigator.appName != 'Microsoft Internet Explorer' ) return ieVers;
	var tempVers = navigator.appVersion;
	var i = tempVers.indexOf( 'MSIE ' );
	if( i >= 0 ) {
		tempVers = tempVers.substring( i+5 );
		ieVers = parseFloat( tempVers ); 
	}
	return ieVers;
}

ieold=(navigator.appName == "Microsoft Internet Explorer") && (getExplorerVersion() <= 6);
function resi() {
	if (ieold) {
		if (document.body.parentNode.clientWidth < 964) {
			document.body.className='fixed';
		} else if (layout=='fluid') {
			document.body.className='fluid';
		}
	}
}
if (ieold) window.onresize=resi;

function findObj(n, d) {
  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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function layoutSetup(ln, an, ac) {
	var today = new Date();
	var exp = new Date();
	exp.setTime(today.getTime() + 1000*60*24*60*365);
 	if (document.body) { document.body.className=ln; }
 	if ( (x=findObj('layout_size')) != null )  { x.innerHTML=an; x.className=ac; }
 	layout=ln;
	document.cookie='layout='+ln+'; expires=' + exp.toGMTString();
	createCookie("layout", ln, 365);
}

function layoutSwitch(toChange) {
   if (toChange==1) {
   	layout = (layout=='fluid') ? 'fixed' : 'fluid';
   }
   if (layout=='fluid') {
   	layoutSetup('fluid','Minimize','fluid');
   } else {
   	layoutSetup('fixed','Maximize','fixed');
   }
   resi();
}

function setupLayout() {
    if (document.body) {
        layout = document.body.className;
	} else {
		layout = "fixed";
	}
    //  old method  //  layout = document.cookie.substring(12, 7);
	var layout2 = readCookie('layout');
	if (layout2 == null) {
		layout2 = 'fixed';
	}
	if (layout != layout2) {
    	layoutSwitch(0);
	}
}

function clear_val(it) {
		it.value='';
		it.onclick='return false;';
}

function clear_inner(it) {
		it.innerHTML='';
		it.onclick='return false;';
}

function createCookie(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;
}


var firstClick = new Array(100);



function firstRemove(x) {
	for (i=1; i<firstClick.length; i++)
		if (firstClick[i]==x) return;
	firstClick[firstClick.length]=x;
	x.value='';
 }

