function gotoIntraURL(pUrl,indexNum) {
	if (indexNum != GetCookie('countrySelector')){
		/*SetCookie('countrySelector', indexNum, exp);*/
		if (pUrl != '') { 
			url = new String(pUrl);
			window.location.href = url;// + "?index=" + indexNum;
		}
	}
}

function gotoURL(pUrl,indexNum) {
		if (pUrl != '') { 
			url = new String(pUrl);
			window.location.href = url;
	}
}

// open in new window if class name not _self
function gotoURL2(obj) {
		if (obj.value != '') { 
			
			
			url = new String(obj.value);
			
			if(obj.className!='_self'){
				window.open(url);
			}
			else{
				window.location.href = url;
			}
			
	}
}

/*
--------------------------------------------------------
Search
--------------------------------------------------------
*/

function postSearch(searchStr){
	//document.mainform.search.value = searchStr;
	// if newsletter subscribe page don't use post/gets 
	//if(document.mainform.hSubscriberID){
		//window.location.href = "/search.aspx?search=" + searchStr;
		//return false
	//}
	//else{
		//document.mainform.method="post";
	//}
	//alert("http://"+window.location.hostname+"/search.aspx?search=" + searchStr);
	//document.mainform.action="http://www.dhigroup.com/search.aspx?search=" + encodeURI(searchStr); //window.location.hostname 
	//document.mainform.submit();
	if (searchStr != '') {
		location = "/search.aspx?search=" + encodeURI(searchStr);
			return true;
	}
	else {
		return false;
	}
}

function pagePostSearch( page,searchStr)
{

document.mainform.method="post";
	//}
	//alert("http://"+window.location.hostname+"/search.aspx?search=" + searchStr);
	document.mainform.action="http://"+window.location.hostname+"/search.aspx?page="+page+"&search=" + encodeURI(searchStr);
	document.mainform.submit();
    window.location.href = "http://"+window.location.hostname+"/search.aspx?page="+page+"&search=" + encodeURI(searchStr);
		return false
}

function __OLDpostIntranetSearch(searchStr,filter){
	document.mainform.search.value = searchStr;
	document.mainform.method="get";
	document.mainform.action="/Intranet/search.aspx?search=" + searchStr;
	document.mainform.submit();
}

function postIntranetSearch(searchStr,filterCategoryObj){
	// clean up spaces around string 
	
	
	var filterCategory = "";
	
	if(filterCategoryObj){
		var filterCategory = filterCategoryObj.options[filterCategoryObj.options.selectedIndex].value;
	}
	if(searchStr){
	
		document.mainform.method="get";
		document.mainform.action="/search.aspx?search="+searchStr+"&filter="+filterCategory;
		//document.mainform.submit();
		document.location.href="/search.aspx?search="+searchStr+"&filter="+filterCategory;
	}
}
function trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}


function checkEnter(e,caller) //e is event object passed from function invocation
{

	var characterCode //literal character code will be stored in this variable

	if(e && e.which)
	{ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else
	{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13)//if generated character code is equal to ascii 13 (if enter key)
	{ 
		document.getElementById(caller).click();
		return false
	}
	else
	{
		return true
	}
}


/*
--------------------------------------------------------
Cookies for countrySelector
--------------------------------------------------------
*/
	
var expDays = 100;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg){     
	//		alert ("GetCookie:" + getCookieVal (j));
			return getCookieVal (j);
		}
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}
function SetCookie (name, value) {  
	alert(value);
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");

}

function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


/*
--------------------------------------------------------
/Cookies for countrySelector
--------------------------------------------------------
*/

function popUp(url,el,w,h){
day = new Date();
id = day.getTime();

if(w==null){
w = 500;
}

if(h==null){
h = 550;
}
eval("page" + id + " = window.open(url, '" + id + "', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width="+w+", height="+h+"');");

}

function loadContent(url,el){
if(document.getElementById("selectedLink")){
	document.getElementById("selectedLink").id = "";

	
}
el.id = "selectedLink";
	window.bulletinContent.location.href = url;
}


/* Download Software */    
//Disable download button
function disableDownloadButton(myForm) {
    if (myForm != null) {
        myForm.disabled = true;
        document.forms[0].submit();
        return false;
    }
}
   
    
/*
--------------------------------------------------------
/unfolding feature
--------------------------------------------------------
*/


window.onload = function () {
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].className == 'entrance')
			x[i].onclick = clickNav;
	}
	closeNav();
	if (top.setNav)
		setNav(top.setNav,'currentPage');
}

function closeNav()
{
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].className == 'contentwrap')
			x[i].style.display = 'none';
	}
}

function clickNav(e)
{
	if (!e) var e = window.event;
	if (e.target) var tg = e.target;
	else if (e.srcElement) var tg = e.srcElement;
	while (tg.nodeName != 'DIV') // Safari GRRRRRRRRRR
		tg = tg.parentNode;
	var nextSib = tg.nextSibling;
	while (nextSib.nodeType != 1)
		nextSib = nextSib.nextSibling;
	var nextSibStatus = (nextSib.style.display == 'none') ? 'block' : 'none';
	nextSib.style.display = nextSibStatus;
}
