function setLanguage(lang) 
{
   	if (lang != "") 
	{
	     location.href = "/" + replaceQueryString(location.search, "sc_lang", lang);
    }
}

function compareProducts(selectedProductID, param) 
{
    if (selectedProductID != "") 
    {
        location.href = replaceQueryString(location.href, param, selectedProductID);
    }
}



function replaceQueryString(url,param,value) 
{
    var re = new RegExp("([?|&])" + param + "=.*?(&|$)","i");
    if (url.match(re)) 
    {
        return url.replace(re,'$1' + param + "=" + value + '$2');
    }
    else {
        if (url.indexOf("?") < 0) {
		    return url + '?' + param + "=" + value;
		}
		else 
		{
		    return url + '&' + param + "=" + value;
		}
    }
}



function shodeHideFaqCategory(divID) 
{

    var divCategory = document.getElementById(divID);
    var categFolder = document.getElementById("categ" + divID);
    if (divCategory) 
    {
        var displayedHidden = divCategory.style.display;
    
        //Hide all other categories
        var parentDiv = document.getElementById('categories');
        if (parentDiv) 
        {
            for (var i = 0; i < parentDiv.childNodes.length; i++) 
            {
                 if (parentDiv.childNodes[i].attributes && parentDiv.childNodes[i].attributes["name"] && parentDiv.childNodes[i].attributes["name"].value == "category") 
                 {
                     parentDiv.childNodes[i].style.display = "none";
                 } 
                 if (parentDiv.childNodes[i].attributes && parentDiv.childNodes[i].attributes["name"] && parentDiv.childNodes[i].attributes["name"].value == "categoryHeader") 
                 {
                     parentDiv.childNodes[i].attributes["class"].value = "faqCategCollapsed";
                 }
            }
        }
        if (displayedHidden == "block") 
        {
            categFolder.attributes["class"].value = "faqCategCollapsed";
            divCategory.style.display = "none";
        }
        else 
        {
          categFolder.attributes["class"].value = "faqCategExpanded";
          divCategory.style.display = "block";
        }
    }
}


function showHideFaq(divID, parentID) 
{
    var divCategory = document.getElementById(divID);
    var questionDIV = document.getElementById("quest" + divID);
    if (divCategory) 
    {
        var displayedHidden = divCategory.style.display;
    
       //Hide all other categories
       var parentDiv = document.getElementById(parentID);
       if (parentDiv) 
       {
            for (var i = 0; i < parentDiv.childNodes.length; i++) 
            {
                 if (parentDiv.childNodes[i].attributes && parentDiv.childNodes[i].attributes["name"] && parentDiv.childNodes[i].attributes["name"].value == "answer") 
                 {
                     parentDiv.childNodes[i].style.display = "none";
                 } 
                 if (parentDiv.childNodes[i].attributes && parentDiv.childNodes[i].attributes["name"] && parentDiv.childNodes[i].attributes["name"].value == "answerHeader") 
                 {
                     parentDiv.childNodes[i].attributes["class"].value = "faqQuestionCollapsed";
                 } 
            }
        }
        if (displayedHidden == "block") 
        {
            questionDIV.attributes["class"].value = "faqQuestionCollapsed";
            divCategory.style.display = "none";
        }
        else 
        {
            questionDIV.attributes["class"].value = "faqQuestionExpanded";
            divCategory.style.display = "block";
        }
    }
}


function showHideFeature(divID) 
{
   var div = document.getElementById(divID);
   if (div) 
   {
        if (div.style.display == "block") 
        {
            div.style.display = "none";
        }
        else 
        {
            div.style.display = "block";
        }
   }
}


function redirect(url) 
{
    location.href = url;
    return true;
}

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 ||e.which == 0)
    { //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
    }
}


function postSearch(searchedWord) 
{
	location.href = "/search.aspx?q=" + searchedWord + "&page=1" + "&cat=kb" ;
}

function postKBSearch(searchedWord) 
{
	location.href = "/search.aspx?q=" + searchedWord + "&page=1" + "&cat=kb" ;
}



function clearText(thefield)
{
      if (thefield.defaultValue == thefield.value)
      {
	      var hDefaultSearchText = document.getElementById("hDefaultSearchText");
		  if (thefield.value == hDefaultSearchText.value) 
		  {
		    thefield.value = "";
		  }
      }
}

