
function setField(fldName, val){
	document.getElementById(fldName).value = val;
}


function showhide(id){
	if(document.getElementById(id).style.display == "block"){
		document.getElementById(id).style.display = "none";
	}else{
		document.getElementById(id).style.display = "block";
	}
}

function showhideFL(id){
	if(document.getElementById('tl2').style.display == "block"){
		document.getElementById('tl2').style.display = "none";
		document.getElementById('tl2b').style.display = "none";
		document.getElementById('tl2c').style.display = "none";
	}else{
		document.getElementById('tl2').style.display = "block";
		document.getElementById('tl2b').style.display = "block";
		document.getElementById('tl2c').style.display = "block";
	}
}


function openrank(chkbox, tlselectID, e2ID){
	if (chkbox.checked){	
		setVisible('layer1');
		document.getElementById('active_line').value=tlselectID;  
	}  
}

function validate(cond, msg, url){
	if(!(cond)){
		alert(msg);
	}else{
		gotoPage(url);
	}
}

function rankIt(id, rankvalue, uid){
	if(uid==0){
		alert("You must be logged in for your vote to count.");
		setVisible("layer1");
		return;
	}
	var rv = getRadioVal(rankvalue);
	unsetRadioVal(rankvalue);
	setVisible("layer1");
	var id2 = "rank_" + id;
	document.getElementById(id2).value=rv;
	var rv2=document.getElementById(id2).value; 
}


function openPopup(url) {
 window.open(url, "popup_id", "scrollbars=0,toolbar=0,menubar=0,titlebar=0,borders=0,directories=0,resizable=no,status=0,width=200,height=300");
 return false;
}

function getRadioVal(rb){
var L=rb.length;var ret="";
for (var i = 0 ; i< L ; i++)
 { if(rb[i].checked) { ret=rb[i].value; break; } }
return(ret);
}

function unsetRadioVal(rb){
var L=rb.length;var ret="";
for (var i = 0 ; i< L ; i++){
	rb[i].checked = null;
}

}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "" ;
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

/*function gotoPage(url){
	location.href=\'url\';

}*/


/* -----------------------------------------------
   Floating layer - v.1
   (c) 2006 www.haan.net
   contact: jeroen@haan.net
   You may use this script but please leave the credits on top intact.
   Please inform us of any improvements made.
   When usefull we will add your credits.
  ------------------------------------------------ */

x = -230;
y = 0;
function setVisible(obj)
{
	obj=document.getElementById(obj);
	obj.style.visibility=(obj.style.visibility == 'visible') ? 'hidden' : 'visible';
}
function placeIt(obj)
{
	obj=document.getElementById(obj);
	tlbox=document.getElementById("timelinebox");
/*	tlbox=document.getElementById('<%=timelinebox%>').value;		*/
	tlLeft=tlbox.offsetLeft;
	tlTop=tlbox.offsetTop; 

	if (document.documentElement)
	{
		theLeft=document.documentElement.scrollLeft;
		theTop=document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		theLeft=document.body.scrollLeft;
		theTop=document.body.scrollTop;
	}
	theLeft += (x + tlLeft);
	theTop += (y + tlTop);
	obj.style.left=theLeft + 'px' ;
	obj.style.top=theTop + 'px' ;
	setTimeout("placeIt('layer1')",500);
}
window.onscroll=setTimeout("placeIt('layer1')",500);  


/***************************************
//
//     Cookie routines
//
****************************************/

/*==============================================================================

    Routines written by John Gardner - 2003 - 2005

    See www.braemoor.co.uk/software for information about more freeware
    available.

================================================================================

Routine to write a session cookie

    Parameters:
        cookieName        Cookie name
        cookieValue       Cookie Value
    
    Return value:
        true              Session cookie written successfullly
        false             Failed - persistent cookies are not enabled

   e.g. if (writeSessionCookie("pans","drizzle") then
           alert ("Session cookie written");
        else
           alert ("Sorry - Session cookies not enabled");
*/

function writeSessionCookie (cookieName, cookieValue) {
  if (testSessionCookie()) {
    document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; path=/";
    return true;
  }
  else return false;
}

/*==============================================================================

Routine to get the current value of a cookie

    Parameters:
        cookieName        Cookie name
    
    Return value:
        false             Failed - no such cookie
        value             Value of the retrieved cookie

   e.g. if (!getCookieValue("pans") then  {
           cookieValue = getCoookieValue ("pans2);
        }
*/

function getCookieValue (cookieName) {
  var exp = new RegExp (escape(cookieName) + "=([^;]+)");
  if (exp.test (document.cookie + ";")) {
    exp.exec (document.cookie + ";");
    return unescape(RegExp.$1);
  }
  else return false;
}

/*==============================================================================

Routine to see if session cookies are enabled

    Parameters:
        None
    
    Return value:
        true              Session cookies are enabled
        false             Session cookies are not enabled

   e.g. if (testSessionCookie())
           alert ("Session cookies are enabled");
        else
           alert ("Session cookies are not enabled");
*/

function testSessionCookie () {
  document.cookie ="testSessionCookie=Enabled";
  if (getCookieValue ("testSessionCookie")=="Enabled")
    return true 
  else
    return false;
}

/*==============================================================================

Routine to see of persistent cookies are allowed:

    Parameters:
        None
    
    Return value:
        true              Session cookies are enabled
        false             Session cookies are not enabled

   e.g. if (testPersistentCookie()) then
           alert ("Persistent coookies are enabled");
        else
           alert ("Persistent coookies are not enabled");
*/

function testPersistentCookie () {
  writePersistentCookie ("testPersistentCookie", "Enabled", "minutes", 1);
  if (getCookieValue ("testPersistentCookie")=="Enabled")
    return true  
  else 
    return false;
}

/*==============================================================================

Routine to write a persistent cookie

    Parameters:
        CookieName        Cookie name
        CookieValue       Cookie Value
        periodType        "years","months","days","hours", "minutes"
        offset            Number of units specified in periodType
    
    Return value:
        true              Persistent cookie written successfullly
        false             Failed - persistent cookies are not enabled
    
    e.g. writePersistentCookie ("Session", id, "years", 1);
*/       

function writePersistentCookie (CookieName, CookieValue, periodType, offset) {

  var expireDate = new Date ();
  offset = offset / 1;
  
  var myPeriodType = periodType;
  switch (myPeriodType.toLowerCase()) {
    case "years": 
     var year = expireDate.getYear();     
     // Note some browsers give only the years since 1900, and some since 0.
     if (year < 1000) year = year + 1900;     
     expireDate.setYear(year + offset);
     break;
    case "months":
      expireDate.setMonth(expireDate.getMonth() + offset);
      break;
    case "days":
      expireDate.setDate(expireDate.getDate() + offset);
      break;
    case "hours":
      expireDate.setHours(expireDate.getHours() + offset);
      break;
    case "minutes":
      expireDate.setMinutes(expireDate.getMinutes() + offset);
      break;
    default:
      alert ("Invalid periodType parameter for writePersistentCookie()");
      break;
  } 
  
  document.cookie = escape(CookieName ) + "=" + escape(CookieValue) + "; expires=" + expireDate.toGMTString() + "; path=/";
}  

/*==============================================================================

Routine to delete a persistent cookie

    Parameters:
        CookieName        Cookie name
    
    Return value:
        true              Persistent cookie marked for deletion
    
    e.g. deleteCookie ("Session");
*/    

function deleteCookie (cookieName) {

  if (getCookieValue (cookieName)) writePersistentCookie (cookieName,"Pending delete","years", -1);  
  return true;     
}


  
