var flashVersion = "10.0.0";
TestFlash();

function TestFlash()
{
    arrVersion = flashVersion.split(".");
    
    if (arrVersion[0] > swfobject.getFlashPlayerVersion().major)
    {
        location.replace("/noflash.htm");
    }
}

function GetHostName()
{
    var hostname = window.location.hostname;
    if (window.location.port != "")
    hostname += ":" + window.location.port;
    return hostname;
}

function LoadPushFlash(url, tabfield, link, target, header)
{
    var flashvars = {}
    flashvars.link = link;
    flashvars.target = target;
    flashvars.header = header;
    var params = {};
    params.menu = "false";
    params.wmode = "transparent";
    var attributes = {};
    swfobject.embedSWF(url, tabfield, "326", "216", flashVersion,"/~/media/Flash/swfobject/expressInstall.ashx", flashvars, params, attributes);
}

function UpdateBreadCrumb(str)
{
    return str;
}


function SubmitSearch(e)
{
    if (IsEnter(e))
    {
        Search();
        return false;
    }
    return true;
}

function IsEnter(e)
{
    var keynum

    if(window.event) // IE
    {
        keynum = e.keyCode
    }
    else if(e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which
    }

    if(keynum==13)
    {
        return true;
    }
    return false;
}

function Search()
{
    query = document.getElementById('query');
    product = document.getElementById('product');
    type = document.getElementById('type');
    language = document.getElementById('language');

    url = "/Publications.aspx?page=1";

    if (query != null && query.value != "")
    {
        url += "&query=" + Url.encode(query.value);
    }

    if (product != null && product.value != "")
    {
        url += "&product=" + Url.encode(product.value);
    }

    if (type != null && type.value != "")
    {
        url += "&type=" + Url.encode(type.value);
    }

    if (language != null && language.value != "")
    {
        url += "&language=" + Url.encode(language.value);
    }
    window.location.href= url;
}

function Clear()
{
    document.getElementById('query'). value = "";
    document.getElementById('product').selectedIndex = -1
    document.getElementById('type').selectedIndex = -1;
    document.getElementById('language').selectedIndex = -1;
}


var Url = {   
  
    // public method for url encoding   
    encode : function (string) {   
        return escape(this._utf8_encode(string));   
    },   
  
    // public method for url decoding   
    decode : function (string) {   
        return this._utf8_decode(unescape(string));   
    },   
  
    // private method for UTF-8 encoding   
    _utf8_encode : function (string) {   
        string = string.replace(/\r\n/g,"\n");   
        var utftext = "";   
  
        for (var n = 0; n < string.length; n++) {   
  
            var c = string.charCodeAt(n);   
  
            if (c < 128) {   
                utftext += String.fromCharCode(c);   
            }   
            else if((c > 127) && (c < 2048)) {   
                utftext += String.fromCharCode((c >> 6) | 192);   
                utftext += String.fromCharCode((c & 63) | 128);   
            }   
            else {   
                utftext += String.fromCharCode((c >> 12) | 224);   
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);   
                utftext += String.fromCharCode((c & 63) | 128);   
            }   
  
        }   
  
        return utftext;   
    },   
  
    // private method for UTF-8 decoding   
    _utf8_decode : function (utftext) {   
        var string = "";   
        var i = 0;   
        var c = c1 = c2 = 0;   
  
        while ( i < utftext.length ) {   
  
            c = utftext.charCodeAt(i);   
  
            if (c < 128) {   
                string += String.fromCharCode(c);   
                i++;   
            }   
            else if((c > 191) && (c < 224)) {   
                c2 = utftext.charCodeAt(i+1);   
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));   
                i += 2;   
            }   
            else {   
                c2 = utftext.charCodeAt(i+1);   
                c3 = utftext.charCodeAt(i+2);   
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));   
                i += 3;   
            }   
  
        }   
  
        return string;   
    }   
  
}

function makeThisMyHomepage(home)
{
 if (document.all)
  {
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage(home); //document.body.setHomePage('http://www.widex.pro');
  }
  else if (window.sidebar)
  {
    if(window.netscape)
    {
      try
      {  
        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
      }  
      catch(e)  
      {  
        alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");  
      }
    } 
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage',home); //prefs.setCharPref('browser.startup.homepage','http://www.widex.pro');
  }
}