// JavaScript Document
// JavaScript Document

// Son of Suckerfish Drop Down navigation
// http://www.htmldog.com/articles/suckerfish/dropdowns/

function changeStyle(id,url) {

alert(url.split("/"));
//alert(old_url);
var str="How are you doing today?";

//document.write(str.split("") + "<br />");
alert(str.split(" ",3));
/*newurl = '';
for (i = 0; i < url_array.length; i++) {
newurl += url_array[i] + '/';
		}
newurl = newurl + id;
newurl = newurl + '/' + url_array[url_array.length];
	
	//$string.="location.href='url';\n";
//location.href="+newurl+";
http://localhost/vea/dev/a_beta/pages/display/1/478d24f383ef4/3/display/478d24f383f03*/
alert(url);
}
	

function changeCSS(id,url) {
var expires = new Date();
	expires.setTime(expires.getTime() + 3600000 * 24 * 30);
	var selectid=(id.value!=''? id.value : '');
	//alert(url);
	makeCookie('style',id.value,expires,'/');
	location.href=url;
	
}
function setCookie(name,value){
	document.cookie(name)=value;
}

	function makeCookie (name, value, expires, path, domain, secure) {
		var curCookie = name + "=" + escape(value) +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + escape(path) : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");

		document.cookie = curCookie;
		//alert(findCookie(name));
	}
function findCookie (name) {
		var dc = document.cookie;
		var prefix = name + "=";
		var begin = dc.indexOf("; " + prefix);

		if (begin == -1) {
			begin = dc.indexOf(prefix);

			if (begin != 0)
				return null;
		} else
			begin += 2;

		var end = document.cookie.indexOf(";", begin);

		if (end == -1)
			end = dc.length;
	//alert(name +unescape(dc.substring(begin + prefix.length, end)));
		return unescape(dc.substring(begin + prefix.length, end));
		
	}
	

function eraseCookie(name) {
	createCookie(name,"",-1);
}

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) alert (c.substring(nameEQ.length,c.length));
		if (c.indexOf(nameEQ) == 0) return (c.substring(nameEQ.length,c.length));
		//alert(document.cookie);
	}
	return null;
}
	/*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=/";
	//var x = readCookie('height');


}


sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	
}*/
//if (window.attachEvent) window.attachEvent("onload", sfHover);



// add class="rollover" to an image to invoke a rollover image name currnetimage_roll

function initRollovers() {
    if (!document.getElementById) return
      
    var aPreLoad = new Array();
    var sTempSrc;
    var aImages = document.getElementsByTagName('img');
    for (var i = 0; i < aImages.length; i++) {
	if (aImages[i].className == 'rollover') {
	    var src = aImages[i].getAttribute('src');
	    var ftype = src.substring(src.lastIndexOf('.'), src.length);
	    var hsrc = src.replace(ftype, '_roll'+ftype);

	    aImages[i].setAttribute('hsrc', hsrc);
	    
	    aPreLoad[i] = new Image();
	    aPreLoad[i].src = hsrc;
	    
	    aImages[i].onmouseover = function() {
		sTempSrc = this.getAttribute('src');
		this.setAttribute('src', this.getAttribute('hsrc'));
	    }
	    aImages[i].onmouseout = function() {
		if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_roll'+ftype, ftype);
		this.setAttribute('src', sTempSrc);
	    }
	}
	
	 }
	
	   //smoothHeight('ihif1',200, 0, 50, 'ihtr1'); 
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

window.onload = initRollovers;
// JavaScript Document



//for editmenu dropowns
var smooth_timer;


function go2(selID, link) {
  var selOBJ = (document.getElementById) ? document.getElementById(selID) : eval("document.all['" + selID + "']");
  window.location=link + selOBJ.options[selOBJ.selectedIndex].value;
}


function toclip(string) { window.clipboardData.setData('Text', string); }


function ShowTip(fArg) {
  var tooltipOBJ = (document.getElementById) ? document.getElementById('ih' + fArg) : eval("document.all['ih" + fArg + "']");
  if (tooltipOBJ != null) {
    var tooltipLft = (document.body.offsetWidth?document.body.offsetWidth:document.body.style.pixelWidth) - (tooltipOBJ.offsetWidth?tooltipOBJ.offsetWidth:(tooltipOBJ.style.pixelWidth?tooltipOBJ.style.pixelWidth:$TOOLTIPWIDTH)) - 5;
    var tooltipTop = 10;
    if (navigator.appName == 'Netscape') {
      if (parseFloat(navigator.appVersion) >= 5) tooltipTop = (document.body.scrollTop>=0?document.body.scrollTop+10:event.clientY+10);
      tooltipOBJ.style.left = tooltipLft; tooltipOBJ.style.top = tooltipTop;
    }
    else {
      tooltipLft -= 30;
      tooltipTop = (document.body.scrollTop?document.body.scrollTop:document.body.offsetTop) + event.clientY - (tooltipOBJ.scrollHeight?tooltipOBJ.scrollHeight:tooltipOBJ.style.pixelHeight) - 30;
      if (tooltipTop < (document.body.scrollTop?document.body.scrollTop:document.body.offsetTop) + 10) {
        if (event.clientX > tooltipLft) tooltipTop = (document.body.scrollTop?document.body.scrollTop:document.body.offsetTop) + event.clientY + 30;
        else tooltipTop = (document.body.scrollTop?document.body.scrollTop:document.body.offsetTop) + 10;
      } 
      tooltipOBJ.style.pixelLeft = tooltipLft; tooltipOBJ.style.pixelTop = tooltipTop;
    }
    tooltipOBJ.style.visibility = "visible";
  }
}


function HideTip(fArg) {
  var tooltipOBJ = (document.getElementById) ? document.getElementById('ih' + fArg) : eval("document.all['ih" + fArg + "']");
  if (tooltipOBJ != null) tooltipOBJ.style.visibility = "hidden";
}






function rowOver(i, nColor) {
  if (!nColor) nColor = "#ECECD9";
  var nameObj = (document.getElementById) ? document.getElementById('name' + i) : eval("document.all['name" + i + "']");
  if (nameObj != null) nameObj.style.background=nColor;
}
function rowOut(i, nColor) {
  var trObj = (document.getElementById) ? document.getElementById('ihtr' + i) : eval("document.all['ihtr" + i + "']");
  var nameObj = (document.getElementById) ? document.getElementById('name' + i) : eval("document.all['name" + i + "']");
  if (trObj == null || trObj.style.display=="none") nameObj.style.background=nColor;
}


//means the stuff moves

function smoothHeight(id, curH, targetH, stepH, mode, parent) {
	
//alert(id);
  diff = targetH - curH;
  if (diff != 0) {
	  
    newH = (diff > 0) ? curH + stepH : curH - stepH;
	
    ((document.getElementById) ? document.getElementById(id) : eval("document.all['" + id + "']")).style.height = newH + "px";
   if (smooth_timer) window.clearTimeout(smooth_timer);
    smooth_timer = window.setTimeout( "smoothHeight('" + id + "'," + newH + "," + targetH + "," + stepH + ",'" + mode + "')", 10 );
	
	/*---------------------------------------------------------------
	//try an d establish a cookie to keep them in the same position look for the instantiation
	
	--------------------------------------------------------*/
	  
	 
  }
  else if (mode != "o") ((document.getElementById) ? document.getElementById(mode) : eval("document.all['" + mode + "']")).style.display="none";

}

//function called by row clicking
function servOC(i,starth,enlargedh) {
  var trObj = (document.getElementById) ? document.getElementById('ihtr' + i) : eval("document.all['ihtr" + i + "']");
  var nameObj = (document.getElementById) ? document.getElementById('name' + i) : eval("document.all['name" + i + "']");
  var ifObj = (document.getElementById) ? document.getElementById('ihif' + i) : eval("document.all['ihif" + i + "']");
  var expires = new Date();
	expires.setTime(expires.getTime() + 3600000 * 24 * 30);	
	
		makeCookie(i,trObj.style.display,expires,'/');
  if (trObj != null) {
    if (trObj.style.display=="none") {
      ifObj.style.height = "0px";
      trObj.style.display="";
     // nameObj.style.background="#ffffff";
      //if (!ifObj.src) ifObj.src = href;
      smoothHeight('ihif' + i, 0, enlargedh, 50, 'o','ihtr' + i);
makeCookie(i,'i',expires,'/');
	
    }
    else {
     // nameObj.style.background=nColor;
      smoothHeight('ihif' + i, starth, 0, 50, 'ihtr' + i,'ihtr' + i);
	  //makeCookie(i,'',expires,'/');
	makeCookie(i,'none',expires,'/');
	
    }
  	//if(readCookie('display'+i){
				  //setCookie('display'+i,trObj.style.display);
				  //}else{ 
								 //makeCookie('height'+i,ifObj.style.height,expires,'/');
	
	}
	
		
	 
}

function trOC(idHL, idOC, idArrow) {
  var trObj = (document.getElementById) ? document.getElementById(idOC) : eval("document.all['" + idOC + "']");
  var hlObj = (document.getElementById) ? document.getElementById(idHL) : eval("document.all['" + idHL + "']");
  var arrowObj = (document.getElementById) ? document.getElementById(idArrow) : eval("document.all['" + idArrow + "']");
  if (trObj != null && hlObj != null) {
    if (trObj.style.display=="none") {
      trObj.style.display="";
      hlObj.style.background="#003366";
      hlObj.style.color="#EDF6F9";
      arrowObj.innerHTML="v";
    }
    else {
      trObj.style.display="none";
      hlObj.style.background="#ECECD9";
      hlObj.style.color="#000000";
      arrowObj.innerHTML="^";
    }
  }
}
function firstFocus()
{
   if (document.forms.length > 0)
   {
      var TForm = document.forms[0];
      for (i=0;i<TForm.length;i++)
      {
         if ((TForm.elements[i].type=="text")||
           (TForm.elements[i].type=="textarea")||
           (TForm.elements[i].type.toString().charAt(0)=="s"))
         {
            document.forms[0].elements[i].focus();
            break;
         }
      }
   }
}
function HighlightAll(theField) {
  var tempval=eval("document."+theField);
  tempval.focus();
  tempval.select();
  if (document.all) {
    therange=tempval.createTextRange();
    therange.execCommand("Copy");
    window.status="Contents highlighted and copied to clipboard!";
    setTimeout("window.status=''",5000);
  }
}
function NewWindow(mypage, myname, w, h, scroll) {
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
  win = window.open(mypage, myname, winprops)
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
startList = function() {
  if (document.all&&document.getElementById) {
    navRoot = document.getElementById("nav");
    for (i=0; i<navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      if (node.nodeName=="LI") {
        node.onmouseover=function() {
          this.className+=" navOver";
        }
        node.onmouseout=function() {
          this.className=this.className.replace(" navOver", "");
        }
      }
    }
  }
}
function setImageDimensions(gotImage) {
  if(gotImage.width > 600) gotImage.width = 600;
}
function changeImageDimensions(gotImage, type) {
  if(gotImage.width > 600 && type == 'out') {
	  gotImage.width = 600;
    return;
  }
  if(type == 'over') gotImage.removeAttribute('width');
}
