
function hoverStyle(id, offSet) {
	
	verticalPosition = -44; // default
	
	if(offSet){  // check if adjustment is needed
		verticalPosition =+ offSet; // 
	}
	
	//alert("verticalPosition = " + verticalPosition);
	
    id = id.replace(/nav-secondary-/, "");  // just get id number
	document.getElementById("left-"  + id).style.backgroundPosition = "0 " + verticalPosition + "px";
	document.getElementById("right-" + id).style.backgroundPosition = "0 " + verticalPosition + "px";
}

function activeStyle(id, offSet) {
	
	verticalPosition = -22; // default
	
	if(offSet){  // check if adjustment is needed
		verticalPosition =+ offSet; // 
	}
	
	id = id.replace(/nav-secondary-/, "");  // just get id number
	document.getElementById("left-"  + id).style.backgroundPosition = "0 " + verticalPosition + "px";
	document.getElementById("right-" + id).style.backgroundPosition = "0 " + verticalPosition + "px";
}

function defaultStyle(id) {
	
	id = id.replace(/nav-secondary-/, "");  // just get id number
	document.getElementById("left-"  + id).style.backgroundPosition = "0 0";
	document.getElementById("right-" + id).style.backgroundPosition = "0 0";
}

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


function changeDisplay(id, attribute) {
	document.getElementById(id).style.display = attribute;
}

function changeCssClass(id, CssClass) {		
    //alert(" id = " + id);
	//alert(" CssClass = " + CssClass);
	id.className = CssClass;  
}

function changeBackgroundPosition(id, position) {		
    //alert(" id = " + id);
	//alert(" position = " + position);
	document.getElementById(id).style.backgroundPosition = position; 
}


function changeDisplayDelay(id, attribute) {	
	window.setTimeout("ChangeDisplay('" + id + "','" + attribute + "')", 500);	
}

var TabPreviousNews    = "1";
function ChangeTabNews(Tab, vertical) {
	
  //alert("Tab = " + Tab); /* test */
  
  document.getElementById("tabs-news-link-" + Tab).style.color = "#333333"; /* grey */
  document.getElementById("tabs-news-link-" + TabPreviousNews).style.color = "#ffffff"; /* light grey */
  document.getElementById("tabs-news").style.backgroundPosition = "0 " + vertical; 
  document.getElementById("news-tab-" + TabPreviousNews).style.display = "none";
  document.getElementById("news-tab-" + Tab            ).style.display = "block";
  TabPreviousNews = Tab;   
}

var TabPreviousRelated = "1";
function changeTabRelated(Tab, vertical) {

  document.getElementById("tabs-related").style.backgroundPosition = "0 " + vertical; 
  document.getElementById("related-tab-" + TabPreviousRelated).style.display = "none";
  document.getElementById("related-tab-" + Tab               ).style.display = "block";
  
  TabPreviousRelated = Tab;   
}

function ShowAbuseForm(id) {
	
	document.getElementById("abuse" + id).style.display = "block";
	document.getElementById("abuse" + id).innerHTML = '                                         ' +
	  ' <form id="abuse-form-' + id + '" name="abuse-form-' + id + '">                          ' +
	  '     <input class="text-box" type="text" value="Enter a title here" />                   ' +
	  '     <textarea rows="2">Limit: 500 characters. HTML is prohibited.</textarea>            ' +
	  '     <input name="cancel" type="button" class="button secondary left" value="Cancel"     ' +
	  '      onclick="document.getElementById(\'abuse' + id + '\').style.display = \'none\';    ' +
	  '         document.getElementById(\'abuse' + id + '\').style.background = \'white\';  "/> ' +
	  '     <input name="Submit" type="button" class="button" value="Submit" />                 ' +
	  ' </form>                                                                                 ' +
	  ' <br class="clear" />                                                                    '
}



// === /search key words ============================

function characterCount(text) {
	
	document.getElementById("character-count").innerHTML = "Character Count: " + text.value.length ;
	//alert("text.value.length = " + text.value.length);
	if (text.value.length >= 5){
		//alert("text.value.length = " + text.value.length);
		document.getElementById("character-count").style.color = "red";
		
	}
}


/**
function ShowAbuseForm(id) {
	
	document.getElementById("abuse" + id).style.display = "block";
	document.getElementById("abuse" + id).innerHTML = '                                         ' +
	  ' <form id="abuse' + id + '" name="abuse' + id + '">                                      ' +
	  '     <input class="text-box" type="text" value="Enter a title here" />                   ' +
	  '     <textarea rows="2">Limit: 500 characters. HTML is prohibited.</textarea>            ' +
	  '     <input name="cancel" type="button" class="button secondary left" value="Cancel"     ' +
	  '      onclick="document.getElementById(\'abuse' + id + '\').style.display = \'none\';"/> ' +
	  '     <input name="Submit" type="button" class="button" value="Submit" />                 ' +
	  ' </form>                                                                                 ' +
	  ' <br class="clear" />                                                                    '
}
*/

function getCookie(document,NameOfCookie) {
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(NameOfCookie + "=");
		if (c_start != -1) { 
			c_start = c_start + NameOfCookie.length + 1; 
			c_end = document.cookie.indexOf(";",c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end)) ;
		} 
	}
	return "";
}

function setCookie(document,NameOfCookie,value,expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie = NameOfCookie+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path=/";
}
 
function checkCookieLocal(document) {
	if(document.mainLoginForm.rememberme.checked == true){
		var fieldValue = document.mainLoginForm.userid.value;
		var passwordVal = document.mainLoginForm.password.value;
		setCookie(document,'userid',fieldValue,365);
		setCookie(document,'passwordVal',passwordVal,365);
	}
	else {
		del_cookie(document,'userid'); 
	}
}
        
function del_cookie(NameOfCookie) {
	//document.cookie = NameOfCookie + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/"; 
	document.cookie = 'userid=; expires=Thu, 01-Jan-70 00:00:01 GMT;path=/';
}

function toggleGuideLines(evt) {
	    evt = (evt) ? evt : event;
	    var target = (evt.target) ? evt.target : evt.srcElement;
	    var block = document.getElementById("tips");
	    if (target.id == "flag2") {
	        block.style.display = "block";
	    } else if (target.id == "flag1"){
			block.style.display = "block";
		} else {
	        block.style.display = "none";
	    }
  	}
	
