// SNF JAVASCRIPT utility_functions.js VERSION 1.0
// Function to jump to a URL in a <select> menu
//  In this case, the name of the array containing the URLs
//  is determined based on the name of the pulldown menu.
function jumpToURL(formName,menuName) {
	 var obj = eval("document." + formName + "." + menuName);
	 var index = obj.selectedIndex;
	 var url = eval(menuName + "_URLs[" + index + "]");
	 if (url != "") {
		location.href=url;
	 }
}

function checkLangResults (form) {

    Item = form.locale.selectedIndex
    Result = form.locale.options[Item].value

    if (Result == ""){
        return false
    }else{
     
        lang = "lang=" + Result.substr(0,Result.indexOf("_"));
        cc = "cc=" + Result.substr(Result.indexOf("_")+1 , Result.length);
     
        if(cc.search("cy") > 0) {
            cc = "cc=gr";
        }
        
        if(cc.search("lu") > 0) {
            cc = "cc=be";
        }
                
        langAndcc = lang + "&" + cc ;
        tt = window.location.search ; 
     
        if( tt == "" || tt == "?"){
            window.location.search = lang + "&" +cc;
            return false;
        }
    
        if(tt.search("lang") >0 && tt.search("cc") >0){
         
            posLang = tt.search("lang=") ;
            posCc = tt.search("cc=") ;
            orgLang = tt.substring(posLang, posLang+7) ;
            orgCc = tt.substring(posCc, posCc+5) ;
            fullCc = tt.slice(posCc,tt.length) ;
            posCc = fullCc.search("cc=") ;
            
            if(fullCc.indexOf("&") > 0)
                orgCc = fullCc.substring(posCc, fullCc.indexOf("&")) ;
            else
                orgCc = fullCc.substring(posCc, fullCc.length) ;
    
            finalUrl = tt.replace(orgLang, lang).replace(orgCc, cc);

            if (tt.indexOf("&supportTaskId=")>0) {
                i = tt.indexOf("&supportTaskId=")
                f = tt.indexOf("&",i+1)
                if (f < 1) {
                    f = tt.length;
                } 
                Result = tt.substring(i,f)

                finalUrl = finalUrl.replace(Result,""); 
            }



            window.location.search = finalUrl;
            
        } else{
    
            if(tt.search("locale=") >0){
            
                firstStr = tt.substring(tt.indexOf("?")+1,tt.indexOf("locale="));
                secStr = tt.substring(firstStr.length+1,tt.length);
    
                if(secStr.indexOf("&") > 0){
                    Result = secStr.substring(secStr.search("locale=")+7,secStr.indexOf("&")) ;
                }else{
                    Result = secStr.substring(secStr.search("locale=")+7,secStr.length) ;
                }
    
                finalUrl =  tt.replace("locale="+Result,langAndcc) ; 
            }else{
                 langAndcc = lang + "&" + cc ;
                 finalUrl =  tt + "&"+langAndcc ; 
            }

            if (tt.indexOf("&supportTaskId=")>0) {
                i = tt.indexOf("&supportTaskId=")
                f = tt.indexOf("&",i+1)
                if (f < 1) {
                    f = tt.length;
                } 
                Result = tt.substring(i,f)

                finalUrl = finalUrl.replace(Result,""); 
            }

            window.location.search = finalUrl ;
        }
        
        return false;
    }
}
function tlSearchgetRadioButtonValue2 (radio)
  {   
    for (var i = 0; i < radio.length; i++){
		if (radio[i].checked) { break }
    }
    return radio[i].value
  }
function tlSearchSubmit2() 
  {  
	var href="";
	href = href + tlSearchgetRadioButtonValue2(document.tlSearch.action);
	var test = document.tlSearch.tx.value;
	var m = "";
	var count = 0;
	while (test.indexOf('+')!=-1) {
		count = test.indexOf('+');
		m = m + escape(test.substr(0, count))+'%2B';
		count++;
		test = test.substr(count);    
	}
	m = m + escape(test);
	href = href + m;
	window.location=href;
  }
function errSearchgetRadioButtonValue2 (radio)	{   
	for (var i = 0; i < radio.length; i++){
		if (radio[i].checked) { break }
	}
	return radio[i].value
  }
function errSearchSubmit2()   {  
    var href="";
    href = href + errSearchgetRadioButtonValue2(document.errSearch.action);
    var test = document.errSearch.tx.value;
    var m = "";
    var count = 0;
    while (test.indexOf('+')!=-1) {
    	count = test.indexOf('+');
    	m = m + escape(test.substr(0, count))+'%2B';
    	count++;
    	test = test.substr(count);    
    }
    m = m + escape(test);
    href = href + m;
    window.location=href;
  }