var sVersion = "1_30"
        var sBaseSearchString = "http://www.google.com/search?"
        var sPreLang = "hl="
        var sLanguage = ""
        var sPreSearchLang = "&lr=lang_"
        var sMainCookieName = "MainSearchOption";
        var sSubCookieName = "SubSearchOption";        
        var iLastSubOption = 1;

        function searchDnn(){
        //load the right URL in the results frame
        var sCurrentSubId = "SearchOption" + iLastSubOption
        sLanguage = document.getElementById("LangOption").value;
        
        //Get the complete searchstring
        var sSearchString = "&q=" + document.getElementById(sCurrentSubId).value + "+" + formatSearchString (document.getElementById('searchbox').value)
        
        //Add language filtering if needed
        if (sLanguage != ""){
        	sSearchString = sPreLang + sLanguage + sSearchString + sPreSearchLang + sLanguage;
        }
        parent.Results.location.href = sBaseSearchString + sSearchString
        
        }

        function formatSearchString(strSearch){
        //Replace all spaces in the search phrase with a + character
        strSearch = strSearch.replace(/ /g, "+");
        return (strSearch);
        }
            
        function setSearchOption(iOption){
        //Load the right subsearch options if the main search option has changed
        showSubSearch(iOption)
        }
        
        function showSubSearch(iOption){
        var sId = "SearchOption" + iLastSubOption;
        document.getElementById(sId).style.display = "none";
        sId = "SearchOption" + iOption;
        var oCurrentOptions = document.getElementById(sId)
        oCurrentOptions.style.display = "inline";
        getSearchOption(oCurrentOptions);
        iLastSubOption = iOption;
        }        

        function getSearchOption(oOptions){
        //Load the right search string and write the current option to a cookie
        var result = oOptions.options.selectedIndex;
        createCookie (sSubCookieName , oOptions.options.selectedIndex, 31);
        var sMainSearchOption = document.getElementById("SearchMain").options.selectedIndex;
        createCookie (sMainCookieName , sMainSearchOption, 31);
        }
        
        function getLastSearch(){
        //Read the last main search option form the cookies
        iLastSubOption = readCookie (sMainCookieName)
        if (iLastSubOption == null) iLastSubOption = 0;        
        //Set the main search option
        document.getElementById("SearchMain").options.selectedIndex = iLastSubOption;
        
        //Show the right subsearch options block
        var sSubSearchOptions = "SearchOption" + iLastSubOption;
        var oSubSearch = document.getElementById(sSubSearchOptions);
        
        oSubSearch.style.display = "inline";
        oSubSearch.options.selectedIndex = readCookie (sSubCookieName);
        
        //Select the right option in the Subsearch list
        
        }        

        function createCookie(name,value,days){
        //Write a Cookie  
        if (days) {
            var date = new Date();
            date.setTime(date.getTime()+(days*24*60*60*1000));
            var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+sVersion+"="+value+expires+"; path=/";
        }

        function readCookie(name){
        //Read a Cookie 
        var nameEQ = name + sVersion + "=";
        var ca = document.cookie.split(';');
        	for(var i=0;i < ca.length;i++) {
        	    var c = ca[i];
        	    while (c.charAt(0)==' ') c = c.substring(1,c.length);
        	    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        	}
        return null;
        }

        function eraseCookie(name) {
        createCookie(name,"",-1);
        }


