
/**************************************************************************************************
This file is for common javascript function used across application
'*** MODIFICATION LOG ***
'Modification Log                :   First version: Added code for Recommend
'Date 06 09 2009                 :   Shantanu Agarwal
'Modification Log                :   Added logic for language toggle
'Date 08 09 2009                 :   Shantanu Agarwal
'Modification Log                :   Added logic for Left Navigation 
'Date 10 09 2009                 :   Shantanu Agarwal
'Modification Log                :   Commented the left navi code as was giving error
'Date 10 09 2009                 :   Shantanu Agarwal
'Modification Log                :   Added the logic for highlighting the first level navigation in header
'Date 15 09 2009                 :   Shantanu Agarwal
'Modification Log                :   Changes for left navigation and added code for global search
'Date 16 09 2009                 :   Shantanu Agarwal
'Modification Log                :   Changes for left navigation
'Date 26 09 2009                 :   Shantanu Agarwal
'Modification Log                :   Function added for bookmark functionality for different browser
'Date 29 09 2009                 :   Shantanu Agarwal
'Modification Log                :   Function added for bookmark functionality for different browser is deleted.
'Date 30 09 2009                 :   Shantanu Agarwal
'Modification Log                :   Changed the logic for left navi implementation
'Date 01 10 2009                 :   Shantanu Agarwal
'Modification Log                :   Page was not getting posted when user is hitting enter while searching something.
'Date 03 10 2009                 :   Shantanu Agarwal
'Modification Log                :   Few changes for google search
'Date 08 10 2009                 :   Shantanu Agarwal
'Modification Log                :   Changes done for highlighting the left nav from header and left nav both
'Date 08 10 2009                 :   Shantanu Agarwal
'Modification Log                :   Changes done for Google search
'Date 08 10 2009                 :   Shantanu Agarwal
'Modification Log                :   Changed the page path for google search
'Date 11 11 2009                 :   Shantanu Agarwal
'Modification Log                :   Converted the URL to lower case  and corrected the German Text
'Modification Log                :   Changes made for left navi implementation                
'Date 15 11 2009                 :   Shantanu Agarwal
'Modification Log                :   changes for converting recommend labels into German
'Date 16 11 2009/20 11 2009      :   Shantanu Agarwal
'Modification Log                :   Make the changes to highlight left navi in case if page is not mentioned in left navi
'Date 27 11 2009                 :   Shantanu Agarwal
'Modification Log                :   Changes made to redirect the screen to welcome page if change langauge is clicked on search page
'Date 28 11 2009                 :   Mamta Mander
'Modification Log                :   Changes made to set the back to top class based on current locale
'*************************************************************************************************/

//on page load set the back to top class
$(document).ready(function()
{    
	var bkToTopAnchor = $("a.backTop");
	var strCurrentLocale = getLanguage();
	
    if (strCurrentLocale == "de")
    {
	    bkToTopAnchor.addClass("backTopGerman");
    }
	else
	{
	    bkToTopAnchor.addClass("backTop");
	}
});

//<!-- Function for Recommend Page Start-->

var blnError = '0';
var cntError = 0;

function trim(strText)
{
    return strText.replace(/^\s+/,'').replace(/\s+$/,'');
}

/*function showThankYou()
{
//alert('1');
    if (document.getElementById("__HidComments").value == "Done")
    {
    document.getElementById("__HidName").value="";
	document.getElementById("__HidYourEmail").value="";
	document.getElementById("__HidColleagueEmail").value="";
	document.getElementById("inYourName").value="";
	document.getElementById("inYourEmail").value="";
	document.getElementById("inComments").value="";
	document.getElementById("inColleagueEmail").value="";
	}

}*/
function __doPostBack(eventTarget, eventArgument) 
{
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
	theform = document.forms["Form1"];
		//theform = document.Form1;
	}
	else 
	{
		theform = document.forms["Form1"];
	}
	if(eventTarget == 'OverlayreminderSubmit')
	{
	    theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
	    theform.__EVENTARGUMENT.value = eventArgument;
	    theform.submit();    
    }
    else
    {
        theform.__EVENTTARGET.value = eventTarget;
        theform.__EVENTARGUMENT.value = eventArgument;
        theform.submit();
    }
}
			
function validate()
{
	var elementsInputs;
	//Function to validate email
	if (validateForm() == false)
	{
	    return false;
	}
	document.getElementById("__HidName").value=trim(document.getElementById("inYourName").value);
	document.getElementById("__HidYourEmail").value=trim(document.getElementById("inYourEmail").value);
	document.getElementById("__HidComments").value=trim(document.getElementById("inComments").value);
	document.getElementById("__HidColleagueEmail").value=trim(document.getElementById("inColleagueEmail").value);

__doPostBack('OverlayreminderSubmit','');
}
	
function validateForm()
{   var email1,email2;

    document.getElementById('lblErrorName').style.display = 'none';
    document.getElementById('lblErrorEmail1').style.display = 'none';
    document.getElementById('lblErrorEmail2').style.display = 'none';
    document.getElementById('lblAllMandatMsg').style.display = 'none'
    
    document.getElementById("lblYourName").className="";
    document.getElementById("lblYourEmail").className="";
    document.getElementById("lblColleagueEmail").className="";
    
    
    email1 = trim(document.getElementById("inYourEmail").value);
    email2 = trim(document.getElementById("inColleagueEmail").value);
    blnError = '0';
    cntError='0';
    if ((trim(document.getElementById("inYourName").value)==null)||(trim(document.getElementById("inYourName").value)==""))
    {
    cntError = 1;
    blnError='1'
    }
     if ((email1==null)||(email1==""))
    {
     cntError = cntError + 1;
     blnError='1'
    } 
    
     if ((email2==null)||(email2==""))
    {
     cntError = cntError + 1;
     blnError='1'
    } 
    
    
    if (cntError > 1)
    {
        //alert(cntError );
        document.getElementById('lblAllMandatMsg').style.display = 'block'
        
        if ((trim(document.getElementById("inYourName").value)==null)||(trim(document.getElementById("inYourName").value)==""))
        {
            document.getElementById("lblYourName").className="fieldValidatorsRecommend";
        }
        
        if ((email1==null)||(email1==""))
        {
             document.getElementById("lblYourEmail").className="fieldValidatorsRecommend";
        } 
        
        if ((email2==null)||(email2==""))
        {
             document.getElementById("lblColleagueEmail").className="fieldValidatorsRecommend";
        } 
        cntError = 0;
    }
    if (cntError == 1)
    {
        if ((trim(document.getElementById("inYourName").value)==null)||(trim(document.getElementById("inYourName").value)==""))
        {
            document.getElementById("lblYourName").className="fieldValidatorsRecommend";
            
            document.getElementById('lblErrorName').style.display = 'block'
        }
        
        if ((email1==null)||(email1==""))
        {
            document.getElementById("lblYourEmail").className="fieldValidatorsRecommend";
            document.getElementById('lblErrorEmail1').innerHTML="Please enter your e-mail ID.";
            if (getLanguage() == "de")
            {
                document.getElementById('lblErrorEmail1').innerHTML="Bitte geben Sie Ihre E-Mail-ID.";
            }
            document.getElementById('lblErrorEmail1').style.display = 'block'
        } 
        
        if ((email2==null)||(email2==""))
        {
            document.getElementById("lblColleagueEmail").className="fieldValidatorsRecommend";
            document.getElementById('lblErrorEmail2').innerHTML="Please enter a recipient.";
            if (getLanguage() == "de")
            {
                document.getElementById('lblErrorEmail2').innerHTML="Bitte geben Sie einen Empfänger.";
            }
            document.getElementById('lblErrorEmail2').style.display = 'block'
        }
    }
    if ((trim(email1)!=null)&&(trim(email1)!=""))
    {
        if (echeck(email1)==false)
        {
            document.getElementById("lblYourEmail").className="fieldValidatorsRecommend";
            document.getElementById('lblErrorEmail1').style.display = 'block';
            document.getElementById('lblErrorEmail1').innerHTML="Your e-mail ID is not valid.";
            if (getLanguage() == "de")
            {
                document.getElementById('lblErrorEmail1').innerHTML="Ihre E-Mail-ID ist nicht gültig.";
            }
            blnError = '1';
            //return false;
        }
    }
    if ((trim(email2)!=null)&&(trim(email2)!=""))
    {
        if (echeck(email2)==false)
        {
            
            document.getElementById("lblColleagueEmail").className="fieldValidatorsRecommend";
            document.getElementById('lblErrorEmail2').style.display = 'block';
            document.getElementById('lblErrorEmail2').innerHTML="The recipient's e-mail ID is not valid.";
            if (getLanguage() == "de")
            {
                document.getElementById('lblErrorEmail2').innerHTML="Der Empfänger E-Mail-ID ist nicht gültig.";
            }
            blnError = '1';
    //        return false;
        }
    }
    
    if (blnError == '1')
    {
    return false;
    }
    return true;
}
			
function echeck(str) 
{
     var emailReg = "^[A-Za-z0-9._+%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$";
     var regex = new RegExp(emailReg);
     return regex.test(str);
}
			
function echeck_old(str) 
{
    var at="@";
    var dot=".";
    var lat=str.indexOf(at);
    var lstr=str.length;
    var ldot=str.indexOf(dot);
    if (str.indexOf(at)==-1)
    {
       //alert("Invalid E-mail ID");
       return false;
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
      // alert("Invalid E-mail ID");
       return false;
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
       // alert("Invalid E-mail ID");
        return false;
    }

     if (str.indexOf(at,(lat+1))!=-1){
       // alert("Invalid E-mail ID");
        return false;
     }

     if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
       // alert("Invalid E-mail ID");
        return false;
     }

     if (str.indexOf(dot,(lat+2))==-1){
       // alert("Invalid E-mail ID");
        return false;
     }
	
     if (str.indexOf(" ")!=-1){
       // alert("Invalid E-mail ID");
        return false;
     }
     return true;					
}
function RecommendLabelsToGerman()
{
    if (getLanguage() == "de")
    {
        document.getElementById('RecommH1').innerHTML = "Diese Seite weiterempfehlen";
        document.getElementById('RecommP1').innerHTML = "Hier können Sie diese Seite empfehlen, ein Kollege.";
        document.getElementById('lblAllMandatMsg').innerHTML = "Bitte geben Sie die Werte für die mit * gekennzeichneten Felder";
        document.getElementById('lblErrorName').innerHTML = "Bitte geben Sie Ihren Namen ein.";
        document.getElementById('lblYourName').innerHTML = "Ihr Name:<span>*</span>";
        document.getElementById('lblErrorEmail1').innerHTML = "Bitte geben Sie Ihre E-Mail-ID";
        document.getElementById('lblYourEmail').innerHTML = "Ihre Email Adresse:<span>*</span>";
        
        document.getElementById('lblComments').innerHTML = "Kommentar hinzufügen:<span>*</span>";
        document.getElementById('lblErrorEmail2').innerHTML = "Bitte geben Sie einen Empfänger";
        document.getElementById('lblColleagueEmail').innerHTML = "Ihr Kollege E-Mail-Adresse:<span>*</span>";
        
        document.getElementById('RecommH2').innerHTML = "Diese Seite weiterempfehlen";
        document.getElementById('RecommP2').innerHTML = "Danke, dass Sie diese Seite empfohlen haben";
        document.getElementById('RecommendSubmit').value="übermitteln";
        document.getElementById('RecommendCancel').value="stornieren";
        document.getElementById('btnClose').value="schließen";
        
    }
}

//<!-- Functions for Recommend Page End-->

/*Functions to toggle language* Start*/
function changeLangToggleText()
{
//RecommendLabelsToGerman();
var OriginalURL = window.location.toString();
    if ((getLanguage()) == "de")
    {
        document.getElementById("languageLink").innerHTML="ENGLISH";
    }
    else
    {
        document.getElementById("languageLink").innerHTML="DEUTSCH";
    }
}

function languageToggle()
{
    var OriginalURL = window.location.toString();
    var OriginalURLSmall = OriginalURL.toLowerCase();
    var NewURL='';
    if ((getLanguage()) == "en")
    {
        if ((OriginalURLSmall.search("searchresults.aspx")) > -1 )
      	    NewURL = OriginalURL.substring(0,OriginalURL.lastIndexOf("/")+1) + "home/Welcome.aspx";
	else
	    NewURL=OriginalURL;
		
        NewURL = NewURL .replace("/en/","/de/");
        NewURL = NewURL .replace("/EN/","/de/");
        NewURL = NewURL .replace("/En/","/de/");
        NewURL = NewURL .replace("/eN/","/de/");
    }
    else
    {
        if ((OriginalURLSmall.search("searchresults.aspx")) > -1 )
	    NewURL = OriginalURL.substring(0,OriginalURL.lastIndexOf("/")+1) + "home/Welcome.aspx";
	else
	    NewURL=OriginalURL;
	    
        NewURL = NewURL.replace("/de/","/en/");
        NewURL = NewURL.replace("/DE/","/en/");
        NewURL = NewURL.replace("/De/","/en/");
        NewURL = NewURL.replace("/dE/","/en/");
        
    }
    
    window.location=NewURL;
}

/*Functions to toggle language* End*/

/*Functions for Left Navigation Start*/

function LeftNavi()
{

    var li_second='';
    var li_third='';
    var li_fourth='';
    var myString = '0';
    var strLeftNavIDs = '';
    strLeftNavIDs= document.getElementById("__LeftNavIDs").value;
    var leftnavSplit = strLeftNavIDs.split(";");
    var sPath = window.location.pathname;
    //sPath = Spath.replace("/En/","/de/");
    sPath = sPath.toLowerCase(); 
    if ((sPath.search("/adidasgrouprelaunch/")) > -1)
        {
            sPath = sPath.replace("/adidasgrouprelaunch","");
            sPath = sPath.replace("/adidasgrouprelaunch","");
        }
        sPath = sPath.replace("/workarea/adidas/","/");
        sPath = sPath.replace("/iw-mount/default/main/","/");
    //var PageName = sPath.substring(sPath.lastIndexOf("/") + 1);
    var PageName = sPath;
    var HighLightPageName = '';
    var parentPath = '';
    var chilePath = '';
    var ParentID = '0';
    var blnFound = '0';
    for(var i = 0; i < leftnavSplit.length; i++) 
    { 
        var leftnavSplit_1 = leftnavSplit[i].split(",");
        HighLightPageName =leftnavSplit_1[0].toLowerCase();
        
        if (HighLightPageName == PageName) 
        {
        	myString = leftnavSplit_1[1];
        	break;
        }
        
       /* parentPath = HighLightPageName.substring(0,HighLightPageName.lastIndexOf("/"));
        childPath = PageName.substring(0,PageName.lastIndexOf("/"));
        if (parentPath == childPath)
        {
            ParentID = leftnavSplit_1[1].toLowerCase();
        }*/
    } 
    if (myString == 0)
    {
        var PageName_split =  PageName.split("/");
        for (var c =0; c < PageName_split.length - 1; c++)
        {
            if (ParentID == 0)
            {
                childPath = PageName.substring(0,PageName.lastIndexOf("/"));
                PageName = childPath;
                for(var i = 0; i < leftnavSplit.length; i++) 
                { 
                    var leftnavSplit_1 = leftnavSplit[i].split(",");
                    HighLightPageName =leftnavSplit_1[0].toLowerCase();
                    parentPath = HighLightPageName.substring(0,HighLightPageName.lastIndexOf("/"));
                    if ((parentPath == childPath) && parentPath.length > 0)
                    {
                        ParentID = leftnavSplit_1[1].toLowerCase();
                        break;
                    }
                }
            }
        } 
    }
    if ((myString != 0) | (myString == 0 & ParentID !=0 ))
    {
        if (myString == 0 & ParentID !=0 )
            myString = ParentID;
        var mySplitResult = myString.split(".");
        li_second = mySplitResult[0]
        if ((mySplitResult.length == 2)||(mySplitResult.length > 2))
        {
            li_third = li_second + '.' + mySplitResult[1];
        }
        if (mySplitResult.length > 2)
        {
            li_fourth = li_third + '.' + mySplitResult[2];
        }
       		ShowLeftNavi(li_second,li_third,li_fourth);
    }
}

/*function getArgs(query) { 
    var args = new Object(); 
    //var query = location.search.substring(1); 
    var pairs = query.split("&"); 
    for(var i = 0; i < pairs.length; i++) 
    { 
        var pos = pairs[i].indexOf('navi'); 
        if (pos == -1) return 0; 
        var argname = pairs[i].substring(0,pos); 
        var value = pairs[i].substring(pos+5); 
        //args[argname] = unescape(value); 
    } 
    return value; 
} */



function ShowLeftNavi(li_second,li_third,li_fourth)
{

    var i = 1;
    var original_li_second = li_second;
    var li_name =li_second + "." + i;
    var browser=navigator.appName;
    var b_version=navigator.appVersion;
	
    while(document.getElementById(li_name))
    {
	document.getElementById(li_name).style.visibility="visible";
	document.getElementById(li_name).style.display="block";
	i=i+1;
	li_name = li_second + "." + i;
    }

    if (!li_third == "" && li_fourth == "")
    {
        i=1;
        li_name =li_third + "." + i;
        li_sec ="";
        while(document.getElementById(li_name))
        {
	        document.getElementById(li_name).style.visibility="visible";
	        document.getElementById(li_name).style.display="block";
	        i=i+1;
	        li_name = li_third + "." + i;
        }
        document.getElementById(original_li_second).className="active";
        

	//var version=parseFloat(b_version);

	if (b_version.search("MSIE 6.0;") != -1)
	{
		//01Dec document.getElementById(li_third).className="Current3rdLevel_6";
		document.getElementById(li_third).className="active";
		document.getElementById(li_third).id="current";
	}
	else	
	{
			
		document.getElementById(li_third).className="active";//"Current3rdLevel";
		document.getElementById(li_third).id="current";
			
	}
    }
    else if (li_third == "" && li_fourth == "")
    {
        document.getElementById(original_li_second).className="active";//"Current2ndLevel";
        document.getElementById(original_li_second).id="current";
    }
    
    
	if (!li_fourth == "")
        {
            i=1;
            li_name =li_third + "." + i;
            li_sec ="";
            while(document.getElementById(li_name))
            {
            
    	        document.getElementById(li_name).style.visibility="visible";
    		document.getElementById(li_name).style.display="block";
    		i=i+1;
    		li_name = li_third + "." + i;
            }
            document.getElementById(original_li_second).className="active";
            if (b_version.search("MSIE 6.0;") != -1)
	    {       
	    	document.getElementById(li_third).className="active";
	    	document.getElementById(li_fourth).className="active";//01Dec
	        document.getElementById(li_fourth).id="current";////
	    }       
	    else
	    {
	        document.getElementById(li_third).className="active";
	        document.getElementById(li_fourth).className="active";
	        document.getElementById(li_fourth).id="current";////
	    }
        }
        else
        {
        /*alert('else');
            if (!li_third == "")
            {
                document.getElementById(original_li_second).className="active";
               // document.getElementById(li_third).className="Current3rdLevel";
            }
            else
            {
                document.getElementById(original_li_second).className="Current2ndLevel";
            }*/
    }
    
}

function HideLevels(num)
{
    var li_sec;
    var li_third;
    while(document.getElementById(num))
    {
        var i =1;
        li_sec = num + "." + i;
        while(document.getElementById(li_sec))
        {
            var k =1;
            document.getElementById(li_sec).style.visibility="hidden";
            document.getElementById(li_sec).style.display="none";
            //document.getElementById(li_sec).className="";
            li_third = li_sec + "." + k;
            while(document.getElementById(li_third))
            {
                document.getElementById(li_third).style.visibility="hidden";
                document.getElementById(li_third).style.display="none";
                //document.getElementById(li_third).className="";
                k++;
                li_third = li_sec + "." + k;
                }	
                i=i+1;
                li_sec = num + "." + i;
                }
        num++;
    }

}
 /*Functions for Left Navigation End*/  
  
/*Functions to highlight first level navigation Start*/  
function HighlightFirstLevelNavi()
{  
    if (document.getElementById("__BranchName"))
    {
        var branchName = document.getElementById("__BranchName").value;
        if (branchName != "")
        	document.getElementById(branchName).className = "active";
    }
}
/*Functions to highlight first level navigation End*/  

/*Functions for Gloabl Search Start*/  
function check_Key_Press(event)
{
    if(null == event )
    {
        event = window.event;
    }
    if(event.keyCode=="13")
    {
        if((null != document.getElementById("q")) && ('undefined' != document.getElementById("q")))
        {
            var theForm = document.forms['theForm'];
            var param = document.getElementById("inputSearch").value;
            param = param.replace(/"/g,'%22');
            param = param.replace(/&/g,'%26');
            param = param.replace(/'/g,'%27');
             param = encodeURIComponent(param);
            if ((getLanguage()) == "en")
            {
                //var searchURL =  "search.aspx?q=" + param + '&search=Search&proxyreload=1&output=xml_no_dtd&client=corporate_relaunch&site=WIKIS&proxystylesheet=corporate_relaunch&filter=0';
                searchURL =  "/en/searchResults.aspx?q=" + param + '&search=Search&output=xml_no_dtd&client=adiGroup_CorpRL&site=adiGroup_RL&lr=lang_en&proxystylesheet=adiGroup_CorpRL&filter=0&restrict=lang_en"';
            }
            else
            {
                searchURL =  "/de/searchResults.aspx?q=" + param + '&search=Search&output=xml_no_dtd&client=adiGroup_CorpRL_de&site=adiGroup_RL &lr=lang_de&proxystylesheet=adiGroup_CorpRL_de&filter=0&restrict=lang_de"';
            }
        theForm.action=searchURL;
       }
       else
       {
          val_search();
       }
    }
}
	 
function val_search()
{
    var searchURL='';
    if(document.getElementById("inputSearch").value=="")
    {
        document.getElementById("inputSearch").focus();
        return false;
    }
    else
    {
        var theForm = document.forms['theForm'];
        var param = document.getElementById("inputSearch").value;
        param = param.replace(/"/g,'%22');
        param = param.replace(/&/g,'%26');
        param = param.replace(/'/g,'%27');
         param = encodeURIComponent(param);
        if ((getLanguage()) == "en")
        {
            //var searchURL =  "search.aspx?q=" + param + '&search=Search&proxyreload=1&output=xml_no_dtd&client=corporate_relaunch&site=WIKIS&proxystylesheet=corporate_relaunch&filter=0';
            searchURL =  "/en/searchResults.aspx?q=" + param + '&search=Search&output=xml_no_dtd&client=adiGroup_CorpRL&site=adiGroup_RL&lr=lang_en&proxystylesheet=adiGroup_CorpRL&filter=0&restrict=lang_en"';
        }
        else
        {
            searchURL =  "/de/searchResults.aspx?q=" + param + '&search=Search&output=xml_no_dtd&client=adiGroup_CorpRL_de&site=adiGroup_RL &lr=lang_de&proxystylesheet=adiGroup_CorpRL_de&filter=0&restrict=lang_de"';
        }
        document.write('');
        window.location=searchURL;
    }
}
	
function check_KeyPress(event)
{
    if(null == event )
    {
        event = window.event;
    }
    if(event.keyCode=="13")
    {
        if((null != document.getElementById("q")) && ('undefined' != document.getElementById("q")))
        {
            var theForm = document.forms['theForm1'];
            var param = document.getElementById("searchInput").value;
            param = param.replace(/"/g,'%22');
            param = param.replace(/&/g,'%26');
            param = param.replace(/'/g,'%27');
             param = encodeURIComponent(param);
            if ((getLanguage()) == "en")
            {
                //var searchURL =  "search.aspx?q=" + param + '&search=Search&proxyreload=1&output=xml_no_dtd&client=corporate_relaunch&site=WIKIS&proxystylesheet=corporate_relaunch&filter=0';
                searchURL =  "/en/searchResults.aspx?q=" + param + '&search=Search&output=xml_no_dtd&client=adiGroup_CorpRL&site=adiGroup_RL&lr=lang_en&proxystylesheet=adiGroup_CorpRL&filter=0&restrict=lang_en"';
            }
            else
            {
                searchURL =  "/de/searchResults.aspx?q=" + param + '&search=Search&output=xml_no_dtd&client=adiGroup_CorpRL_de&site=adiGroup_RL &lr=lang_de&proxystylesheet=adiGroup_CorpRL_de&filter=0&restrict=lang_de"';
            }
            theForm.action=searchURL;
        }
        else
        {
            valsearch();
        }
    }
}

function valsearch()
{
    if(document.getElementById("searchInput").value=="")
    {
        document.getElementById("searchInput").focus();
        return false;
    }
    else
    {

        var param = document.getElementById("searchInput").value;
        param = param.replace(/"/g,'%22');
        param = param.replace(/&/g,'%26');
        param = param.replace(/'/g,'%27');
         param = encodeURIComponent(param);
         if ((getLanguage()) == "en")
            {
                //var searchURL =  "search.aspx?q=" + param + '&search=Search&proxyreload=1&output=xml_no_dtd&client=corporate_relaunch&site=WIKIS&proxystylesheet=corporate_relaunch&filter=0';
                searchURL =  "/en/searchResults.aspx?q=" + param + '&search=Search&output=xml_no_dtd&client=adiGroup_CorpRL&site=adiGroup_RL&lr=lang_en&proxystylesheet=adiGroup_CorpRL&filter=0&restrict=lang_en"';
            }
            else
            {
                searchURL =  "/de/searchResults.aspx?q=" + param + '&search=Search&output=xml_no_dtd&client=adiGroup_CorpRL_de&site=adiGroup_RL &lr=lang_de&proxystylesheet=adiGroup_CorpRL_de&filter=0&restrict=lang_de"';
            }
                    document.write('');
         window.location=searchURL;
    }
}
function getLanguage()
{

   var OriginalURL = window.location.toString();
   OriginalURL = OriginalURL.toLowerCase(); 
   var Language='';
    if ((OriginalURL.search("/de/")) ==-1)
    {
        return Language = "en";
    }
    else
    {
        return Language= "de";
    }
}
/*Functions for Gloabl Search End*/  
/*Functions for Location handling START*/
function SetMouseOut(i)
{
    var location = "localtion_" + i;
    if(document.getElementById(location).className=="locationselected")
    {
        document.getElementById(location).style.color="#fff";
    }
    else
    {
        document.getElementById(location).style.color="#4892B3";
    }
}

function SetMouseOver(i)
{

    var location = "localtion_" + i;
    if(document.getElementById(location).className=="locationselected")
    {
        document.getElementById(location).style.color="#fff";
    }
    else
    {
        document.getElementById(location).style.color="#f59600";
    }
}


function ShowAllLocations(alphabet)
{
    var selectedAlphabet;
    var selectname='';
    var totalLocation = document.getElementById('__TotalLocation').value;
    for(var i=1;i<=totalLocation;i++)
    {
        selectedAlphabet="LocationCode_" + i;
        var location = "localtion_" + i;
        //var coloring = "location_" + i + "_colorcode";
        if(i!=alphabet && alphabet!=0)
        {
            document.getElementById(location).className = "";
            document.getElementById(location).style.color="#4892B3";
	        document.getElementById(selectedAlphabet).style.visibility="hidden";
	        document.getElementById(selectedAlphabet).style.display="none";
        }
        else
        {
            if (alphabet!=0)
            {
                document.getElementById(location).className = "locationselected";
                document.getElementById(location).style.color="white";
                document.getElementById('SeeallLocations').style.visibility="visible";
	            document.getElementById('SeeallLocations').style.display="block";
	            document.getElementById('AllLocations').style.visibility="hidden";
	            document.getElementById('AllLocations').style.display="none";
            }
            else
            {
                document.getElementById(location).className = "";
		        document.getElementById(location).style.color="#4892B3";                  
                document.getElementById('SeeallLocations').style.visibility="hidden";
	            document.getElementById('SeeallLocations').style.display="none";
	            document.getElementById('AllLocations').style.visibility="visible";
	            document.getElementById('AllLocations').style.display="block";
            }
	            document.getElementById(selectedAlphabet).style.visibility="visible";
	            document.getElementById(selectedAlphabet).style.display="block";
        }
    }
}
function HighLightCharacters()
{
    ShowAllLocations('0');
}
/*Functions for Location handling END*/

var WindowObjectReference = null; // global variable

function adidasShareThisPopup(url)

{

  if(WindowObjectReference == null || WindowObjectReference.closed)

  {

    WindowObjectReference = window.open(url,

   "adidasShareThis", "resizable=yes,scrollbars=yes,status=yes");

  }

  else

  {

    WindowObjectReference.focus();

  };

}




var WindowObjectReference_search = null; // global variable

function adidasShareThisPopup_search(url)
{

var fullURL = window.location.toString();
alert(fullURL);
url = url + fullURL + '&l=' + fullURL.length;

  if(WindowObjectReference_search == null || WindowObjectReference_search.closed)

  {
    WindowObjectReference_search = window.open(url,
   "adidasShareThis", "resizable=yes,scrollbars=yes,status=yes");
  }
  else
  {
    WindowObjectReference_search.focus();

  }
}