var _imgPath='/A/img/';
var _cssPath='/A/css/';
var _cssImgPath='/A/css/img/';

var _currencyChar='';
function _cc(c){
    _currencyChar=c;
}

function _id(elementID){
    return document.getElementById(elementID);
}

function _name(elementName){
    return document.getElementsByName(elementName);
}

function trim(str) {
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}

function getElementsByClass(className,tagName){
	var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
	if (!tagName) tagName="*";
	var allElements = document.getElementsByTagName(tagName);
	var results = [];
	var element;
	for (var i = 0; (element = allElements[i]) != null; i++) {
		var elementClass = element.className;
		if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
			results.push(element);
	}
	return results;
}

function Hide(tohide) {
    _id(tohide).style.display = "none";       
}

function Show(toshow) {
    _id(toshow).style.display = "";
}

function focusSearch(){
    
}

function setupSearch(){
    
}

function setupCurrency(currencyISO,currencyChar){
    var _spans=getElementsByClass("currency","span");
    var _span;
    var _newClass = "c"+currencyISO;
    var hasClassName = new RegExp("(?:^|\\s)" + _newClass + "(?:$|\\s)");
    for (var i = 0; (_span = _spans[i]) != null; i++) {
		var elementClass = _span.className;
		elementClass = trim(elementClass.replace("currency_sel", ""));
		if (elementClass && elementClass.indexOf(_newClass) != -1 && hasClassName.test(_newClass)){
		    elementClass += " currency_sel";
		}
		_span.className = elementClass;
	}
	_cc(currencyChar);
}

function submitCurrency(currencyISO){
    var _form = _id("currency_form");
    var _input = _id("switch_currency");
    _input.value=currencyISO;
    _form.submit();
    return true;
}

function focusNewsletter(inputEmail){
    if (trim(inputEmail.value)=='Email Address'){
        inputEmail.value='';
    }
}

function exitNewsletter(inputEmail){
    if (trim(inputEmail.value)==''){
        inputEmail.value='Email Address';
    }
}

function focusSearch(inputSearch){
    if (trim(inputSearch.value)=='Site search'){
        inputSearch.value='';
    }
}

function exitSearch(inputSearch){
    if (trim(inputSearch.value)==''){
        inputSearch.value='Site search';
    }
}

function switchReadmore(){
    var _readmoreList=getElementsByClass("readmore_con","div");
    var _readmore;
    for (var i = 0; (_readmore = _readmoreList[i]) != null; i++) {
	    if (_readmore.className == 'readmore_con'){
	        _readmore.className = 'readmore_con readmore_open';
	    }
	    else{
	        _readmore.className = 'readmore_con';
	    }
	}
}

function sc_switchDesc(display,bundleId){
    var _a = _id("a_"+bundleId);
    var _b = _id("b_"+bundleId);
    if (display==1){
        _a.style.display='none';
        _b.style.display='';
    }
    else{
        _a.style.display='';
        _b.style.display='none';
    }
}

function sc_switchDescC(display,categoryId){
    var _a = _id("a_"+categoryId);
    var _b = _id("c_"+categoryId);
    if (display==1){
        _a.style.display='none';
        _b.style.display='';
    }
    else{
        _a.style.display='';
        _b.style.display='none';
    }
}

function setupTabControl(pid){
    var _tabs=getElementsByClass("tab","div");   
    if (_tabs.length>0){
       var _tab;
        for (var i = 0; (_tab = _tabs[i]) != null; i++) {
            if (i==pid){
                _tab.className="bg_sprite tab ta sel";
            }
            else{
                _tab.className="bg_sprite tab td";
            }            
	    } 
    }
    var _pages=getElementsByClass("tabpage","div");   
    if (_pages.length>0){
        var _page;
        for (var i = 0; (_page = _pages[i]) != null; i++) {
            if (i==pid){
                _page.className='tabpage text_wrapper';
            }
            else{
                _page.className='tabpage hidden';
            }            
	    } 
    }
}
    
// Menu code
function highlightButtonUp(menuButton, buttonNum) {
  bt = _id(menuButton);
  btl = _id("a_" + menuButton);
  line1 = _id("menu_spacebar" + buttonNum);
  line2num = buttonNum + 1;
  line2 = _id("menu_spacebar" + line2num);
  bt.style.backgroundImage="url('"+_cssImgPath+"menu/bcg_grey.png')";
  bt.style.borderLeft="1px solid #9A9A9A";
  bt.style.borderRight="1px solid #9A9A9A";
  btl.style.color="#000000";
  btl.style.paddingLeft="14px";
  btl.style.paddingRight="14px";
  line1.style.visibility="hidden";
  line2.style.visibility="hidden";
}

function greyOutButtonUp(menuButton, buttonNum) {
  bt = _id(menuButton);
  btl = _id("a_" + menuButton);
  line1 = _id("menu_spacebar" + buttonNum);
  line2num = buttonNum + 1;
  line2 = _id("menu_spacebar" + line2num);
  bt.style.backgroundImage="";
  bt.style.borderLeft="none";
  bt.style.borderRight="none";
  btl.style.color="#FFFFFF";
  btl.style.paddingLeft="15px";
  btl.style.paddingRight="15px";
  line1.style.visibility="";
  line2.style.visibility="";
}
function highlightButtonBottom(menuButton, buttonNum) {
  bt = _id(menuButton);
  btl = _id("a_" + menuButton);
  line1 = _id("bottom_menu_spacebar" + buttonNum);
  line2num = buttonNum + 1;
  line2 = _id("bottom_menu_spacebar" + line2num);
  bt.style.backgroundImage="url('"+_cssImgPath+"menu/bcg_grey.png')";
  bt.style.borderLeft="1px solid #9A9A9A";
  bt.style.borderRight="1px solid #9A9A9A";
  btl.style.paddingLeft="6px";
  btl.style.paddingRight="6px";
  line1.style.visibility="hidden";
  line2.style.visibility="hidden";
}

function greyOutButtonBottom(menuButton, buttonNum) {
  bt = _id(menuButton);
  btl = _id("a_" + menuButton);
  line1 = _id("bottom_menu_spacebar" + buttonNum);
  line2num = buttonNum + 1;
  line2 = _id("bottom_menu_spacebar" + line2num);
  bt.style.backgroundImage="";
  bt.style.borderLeft="none";
  bt.style.borderRight="none";
  btl.style.paddingLeft="7px";
  btl.style.paddingRight="7px";
  line1.style.visibility="";
  line2.style.visibility="";
}

var g_PopupIFrame;
function IsIE(version) {
    return ((BrowserDetect.browser == "Explorer") && (BrowserDetect.version < version));
}

function IsAnyIE() {
    return (BrowserDetect.browser == "Explorer");
}

function showSubMenuUp(divId, imgId, buttonNum) {
   highlightButtonUp(imgId, buttonNum);
   showSubMenu(divId, imgId);
}

function showSubMenuBottom(divId, imgId, buttonNum) {
   highlightButtonBottom(imgId, buttonNum);
   showSubMenu(divId, imgId);
}

function showSubMenu(divId, imgId) {
    if(_currentOpenedComboDiv != null)
    {
        _currentOpenedComboDiv.style.visibility="hidden";
        _currentOpenedComboDiv = null;
    }

  var divElement = _id(divId);
  var imgElement = _id(imgId);
  if ((!imgElement) || (!divElement)) return;
  var e = imgElement;
  var position = {x:0,y:0};
  var maxRight = 800;
  while (e)
  {
      position.x += e.offsetLeft;
      position.y += e.offsetTop;
      e = e.offsetParent;
  }
  
  if (document.body)
  {
    maxRight = document.body.clientWidth;
  }

  if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft))
  {
      position.x -= document.documentElement.scrollLeft;
      //position.y -= document.documentElement.scrollTop;
  }
  else if (document.body && (document.body.scrollTop || document.body.scrollLeft))
  {
      position.x -= document.body.scrollLeft;
      //position.y -= document.body.scrollTop;
  }
  else if (window.pageXOffset || window.pageYOffset)
  {
      position.x -= window.pageXOffset;
      //position.y -= window.pageYOffset;
  }
    
  if ((position.x + divElement.offsetWidth) > maxRight)
  {
    position.x = position.x - divElement.offsetWidth + imgElement.offsetWidth;
  }
  divElement.style.top =  position.y + imgElement.offsetHeight + 'px';
  divElement.style.left = position.x + 'px';
  divElement.style.display = "";

  if (IsIE(7))
  {
    //Increase default zIndex of div by 1, so that DIV appears before IFrame
    divElement.style.zIndex=divElement.style.zIndex+1;

    var iFrame = document.createElement("IFRAME");
    iFrame.setAttribute("src", "/Blank.htm");

    //Match IFrame position with divPopup
    iFrame.style.position="absolute";
    iFrame.style.left =divElement.offsetLeft + 'px';
    iFrame.style.top =divElement.offsetTop + 'px';
    iFrame.style.width =divElement.offsetWidth + 'px';
    iFrame.style.height =divElement.offsetHeight + 'px';

    document.body.appendChild(iFrame);

    //Store iFrame in global variable, so it can get removed when divPopup is hidden 
    g_PopupIFrame=iFrame;
  }
}

function showSubMenuReverseUp(divId, imgId, buttonNum) {
   highlightButtonUp(imgId, buttonNum);
   showSubMenuReverse(divId, imgId);
}

function showSubMenuReverseBottom(divId, imgId, buttonNum) {
   highlightButtonBottom(imgId, buttonNum);
   showSubMenuReverse(divId, imgId);
}

function showSubMenuReverse(divId, imgId)
{
    if(_currentOpenedComboDiv != null)
    {
        _currentOpenedComboDiv.style.visibility="hidden";
        _currentOpenedComboDiv = null;
     }

  var divElement = _id(divId);
  var imgElement = _id(imgId);
  if ((!imgElement) || (!divElement)) return;
  var e = imgElement;
  var position = {x:5,y:0};
  if (IsIE(8)) position.x -= 5;
  var maxRight = 800;
  while (e)
  {
      position.x += e.offsetLeft;
      position.y += e.offsetTop;
      e = e.offsetParent;
  }
  
  if (document.body)
  {
    maxRight = document.body.clientWidth;
  }

  if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft))
  {
      position.x -= document.documentElement.scrollLeft;
      //position.y -= document.documentElement.scrollTop;
  }
  else if (document.body && (document.body.scrollTop || document.body.scrollLeft))
  {
      position.x -= document.body.scrollLeft;
      //position.y -= document.body.scrollTop;
  }
  else if (window.pageXOffset || window.pageYOffset)
  {
      position.x -= window.pageXOffset;
      //position.y -= window.pageYOffset;
  }
    
  divElement.style.top =  "0px";
  divElement.style.left = "0px";
  divElement.style.display = "";
  divElement.style.top =  position.y + imgElement.offsetHeight + 'px';
  divElement.style.left = position.x - divElement.offsetWidth + imgElement.offsetWidth + 'px';
  

  if (IsIE(7))
  {
    //Increase default zIndex of div by 1, so that DIV appears before IFrame
    divElement.style.zIndex=divElement.style.zIndex+1;

    var iFrame = document.createElement("IFRAME");
    iFrame.setAttribute("src", "/Blank.htm");

    //Match IFrame position with divPopup
    iFrame.style.position="absolute";
    iFrame.style.left =divElement.offsetLeft + 'px';
    iFrame.style.top =divElement.offsetTop + 'px';
    iFrame.style.width =divElement.offsetWidth + 'px';
    iFrame.style.height =divElement.offsetHeight + 'px';

    document.body.appendChild(iFrame);

    //Store iFrame in global variable, so it can get removed when divPopup is hidden 
    g_PopupIFrame=iFrame;
  }
}

function hideSubMenuUp(divId, imgId, buttonNum) {
   greyOutButtonUp(imgId, buttonNum);
   hideSubMenu(divId, imgId);
}

function hideSubMenuBottom(divId, imgId, buttonNum) {
   greyOutButtonBottom(imgId, buttonNum);
   hideSubMenu(divId, imgId);
}

function hideSubMenu(divId, imgId)
{
    if (!_id(divId)) return;
    _id(divId).style.display = "none";
    if (IsIE(7))
    {
        document.body.removeChild(g_PopupIFrame);
        g_PopupIFrame=null;
    }
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();            

// End menu code

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}


/* AJAX */

function XMLWriter()
{
    this.XML=[];
    this.Nodes=[];
    this.State="";
    this.FormatXML = function(Str)
    {
        if (Str)
            return Str.toString().replace(/&/g, "&amp;").replace(/\"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
        return ""
    }
    this.BeginNode = function(Name)
    {
        if (!Name) return;
        if (this.State=="beg") this.XML.push(">");
        this.State="beg";
        this.Nodes.push(Name);
        this.XML.push("<"+Name);
    }
    this.EndNode = function()
    {
        if (this.State=="beg")
        {
            this.XML.push("/>");
            this.Nodes.pop();
        }
        else if (this.Nodes.length>0)
            this.XML.push("</"+this.Nodes.pop()+">");
        this.State="";
    }
    this.Attrib = function(Name, Value)
    {
        if (this.State!="beg" || !Name) return;
        this.XML.push(" "+Name+"=\""+this.FormatXML(Value)+"\"");
    }
    this.WriteString = function(Value)
    {
        if (this.State=="beg") this.XML.push(">");
        this.XML.push(this.FormatXML(Value));
        this.State="";
    }
    this.Node = function(Name, Value)
    {
        if (!Name) return;
        if (this.State=="beg") this.XML.push(">");
        this.XML.push((Value=="" || !Value)?"<"+Name+"/>":"<"+Name+">"+this.FormatXML(Value)+"</"+Name+">");
        this.State="";
    }
    this.CDATASectionNode = function(Name, Value)
    {
        if (!Name) return;
        if (this.State=="beg") this.XML.push(">");
        this.XML.push((Value=="" || !Value)?"<"+Name+"/>":"<"+Name+"><![CDATA["+this.FormatXML(Value)+"]]></"+Name+">");
        this.State="";
    }
    this.Close = function()
    {
        while (this.Nodes.length>0)
            this.EndNode();
        this.State="closed";
    }
    this.ToString = function(){return this.XML.join("");}
}

function GetNodeValue(Node)
{
    var _value;
    if(Node.childNodes.length>0)
    {
        _value = Node.childNodes[0].nodeValue;
    }
    else
    {
        _value = Node.nodeValue;
    }    
    if ((_value) && (_value != null) && (_value != ""))
    {
        return _value;
    }
    return "";
}
function GetChildNodeValue(Node,ChildNodeName)
{
    var _nodeList = Node.getElementsByTagName(ChildNodeName);
    if (_nodeList.length > 0)
    {
        return GetNodeValue(_nodeList[0]);
    }
    return "";
}

function AjaxFormatRequest(method,paramFunction)
{
    var XML=new XMLWriter();
    XML.BeginNode("ajax");
        XML.BeginNode("head");
            XML.Node("visirorid" ,Cookies['VisitorID']);
            XML.Node("visirotuid",Cookies['VisitorUID']);          
            XML.Node("version",Cookies['Version']);     
            XML.Node("method",method);
       XML.EndNode();
       XML.BeginNode("request");  
            paramFunction(XML);
       XML.EndNode();
    XML.EndNode();
    XML.Close();          
    return 'ajax_request=' + XML.ToString();
}

function AjaxFormatResponse(XmlString,XmlProcessingFunction,HideProgressFunction)
{
    var xmlDoc;
    if (XmlString)
    {
        XmlString = XmlString.replace(/&/g,"&amp;");
    }
    try //Internet Explorer
    {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async="false";
      xmlDoc.loadXML(XmlString);
    }
    catch(e)
    {
      try //Firefox, Mozilla, Opera, etc.
      {
          parser=new DOMParser();
          xmlDoc=parser.parseFromString(XmlString,"text/xml");
      }
      catch(e)
      {
          alert(e.message);
          if (HideProgressFunction) HideProgressFunction();
          return;
      }
    }
    try
    {
        if (xmlDoc && xmlDoc.documentElement && (xmlDoc.documentElement.tagName == "ajax"))
        {
            // process success element from head
            var headNode = xmlDoc.getElementsByTagName("head")[0];
            if (headNode)
            {
                var successNode = headNode.getElementsByTagName("success")[0];
                if (GetNodeValue(successNode.firstChild) == "1")
                {
                    // process response
                    var responseNode = xmlDoc.getElementsByTagName("response")[0];
                    if (XmlProcessingFunction) XmlProcessingFunction(responseNode, null);
                    if (HideProgressFunction) HideProgressFunction();
                }
                else
                {
                    // display error massages
                    var errorMessage = "";
                    var errorListNode = xmlDoc.getElementsByTagName("errorlist")[0];
                    if (errorListNode)
                    {
                        for (var i=0;i<errorListNode.childNodes.length;i++)
                        {
                            errorMessage += GetNodeValue(errorListNode.childNodes[i].firstChild);
                            errorMessage += "\r\n";
                        }
                        if (XmlProcessingFunction) 
                        {
                            XmlProcessingFunction(null, errorMessage);
                        }
                        else
                        {                        
                            alert(errorMessage);
                        }
                    }
                    else
                    {
                        if (XmlProcessingFunction) 
                        {
                            XmlProcessingFunction(null, "Error list is not defined.");
                        }
                        else
                        {                        
                            alert ("Error list is not defined.");
                        }                        
                    }
                    if (HideProgressFunction) HideProgressFunction();
                }            
            }
            else
            {
                if (HideProgressFunction) HideProgressFunction();
            }            
        }
        else
        {
            if (HideProgressFunction) HideProgressFunction();        
        }
    }
    catch (e)
    {
        alert(e.message);
        if (HideProgressFunction) HideProgressFunction();
    }
}

function AjaxDisplayError(errorMessage,functiontodisplayerror)
{
    if (errorMessage != null)
    {
        if(functiontodisplayerror)
        {
            functiontodisplayerror(errorMessage);
        }
        else
        {
            alert(errorMessage);
        }
        return true;
    }
    return false;
}

var Cookies = {
	init: function () {
		var allCookies = document.cookie.split('; ');
		for (var i=0;i<allCookies.length;i++) {
			var cookiePair = allCookies[i].split('=');
			this[cookiePair[0]] = cookiePair[1];
		}
	},
	create: function (name,value,days) {
		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+"="+value+expires+"; path=/";
		this[name] = value;
	},
	erase: function (name) {
		this.create(name,'',-1);
		this[name] = undefined;
	}
};
Cookies.init();

function ajaxRequest(theURL, sendString, callbackFunction, displayProgressFunction, hideProgressFunction)
  {
  	var thisRequestObject;
  	
  	if (displayProgressFunction) displayProgressFunction();
  	
  	thisRequestObject = initiateRequest();
  	thisRequestObject.onreadystatechange = processRequest;
  	
  	function initiateRequest()
  	{
        if (typeof XMLHttpRequest != 'undefined') return new XMLHttpRequest();
        else if (window.ActiveXObject) {
            var avers = ["Microsoft.XMLHTTP", "Msxml2.XMLHTTP"]; // "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP.4.0", "Msxml2.XMLHTTP.5.0"
            for (var i = avers.length -1; i >= 0; i--) {
                try {
                    obj = new ActiveXObject(avers[i]);
                    return obj;
                } catch(e) {}
            }
        }  	
        if (hideProgressFunction) hideProgressFunction();
        throw new Error('XMLHttp (AJAX) not supported');
  	}
  	
  	function processRequest()
  	{
  		if (thisRequestObject.readyState == 4)
  		{
  			if (thisRequestObject.status == 200)
  			{
  				if (callbackFunction)
  				{
  				    AjaxFormatResponse(thisRequestObject.responseText,callbackFunction,hideProgressFunction)
  			    }
  			}
  			else
  			{
  				//alert("There was an error: (" + thisRequestObject.status + ") " + thisRequestObject.statusText);
  				if (hideProgressFunction) hideProgressFunction();
  			}
  		}
  	}
  	
  	this.sendGetData = function()
  	{
  		if (theURL)
  		{
  			thisRequestObject.open("GET", theURL, true);
  			thisRequestObject.send(sendString);
  		}
  	}
  	
  	this.sendPostData = function()
  	{
  		if (theURL)
  		{
  			thisRequestObject.open("POST", theURL, true);
  			thisRequestObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  			thisRequestObject.send(sendString);
  		}
  	}
}


function toHtml(value)
{ 
  value = value.replace(/\&amp;/gi,'&');
  value = value.replace(/\&lt;/gi,'<');
  value = value.replace(/\&gt;/gi,'>');
  value = value.replace(/&amp;nbsp;/gi,'&nbsp;');
  value = value.replace(/&nbsp;/gi,' ');
  value = value.replace(/<br \/>/gi,'\n\r');
  return value;
}

function ToHideShow(tohide) {
    if (_id(tohide).style.display == "") {
        _id(tohide).style.display = "none";
    }
    else {
    	_id(tohide).style.display = "";
    }
}

function ParseF(Value){
    Value = ""+Value;
    return parseFloat(Value.replace(',','.'));
}

/*Combo*/

var _currentOpenedComboDiv;
var _useOnClick;

document.onclick = comboHideOpenComboOnDocumentClick;

function comboHideOpenComboOnDocumentClick(name)
{
      if(_useOnClick == true)
      {
          if(_currentOpenedComboDiv != null)
          {
            _currentOpenedComboDiv.style.visibility="hidden";
            _currentOpenedComboDiv = null;
          }
      }
      _useOnClick = true;
} 


function cancelOnClick(element)
{
	if(window.event) 
	{
	    window.event.cancelBubble= true;
	}
	else
	{
	    if (element.stopPropagation) element.stopPropagation();
	}
}

function getPxValue(value)
{
    var     string = new String(value); 
            string = string.replace("px","");
    var     number = parseInt(string);
    return  number;
}

function comboPopup(name)
{   
    _useOnClick = false;
    var _comboDiv       = document.getElementById("comboDiv"        + name);
    var _comboImgArrow  =  document.getElementById("comboImgArrow"  + name);
     
    if(_comboDiv ==_currentOpenedComboDiv)
    {
        comboHide(name);
    }
    else
    {
        if (IsIE(7))
        {
            comboPopupIE6(_comboImgArrow,name);
        }
        else
        {
            comboPopupIE7(_comboImgArrow,name);
        }
    }
} 

// IE7 & Opera & FF & Safari
function comboPopupIE7(element,name) 
{
    var base_o;
    var x;
    var y;
    var comboDiv    = document.getElementById("comboDiv"   + name);
    var comboInput  = document.getElementById("comboInput" + name); 
    var comboList   = document.getElementById("comboList"  + name);       

    if(_currentOpenedComboDiv != comboDiv) 
    {
      if(_currentOpenedComboDiv != null)
      {
        _currentOpenedComboDiv.style.visibility="hidden";
      }
      _currentOpenedComboDiv = null;
    }
    
    y = comboInput.offsetHeight;
    x = 0;           
    

    var e = comboInput;
    while (e)
    {
        x += e.offsetLeft;
        y += e.offsetTop;
        e = e.offsetParent;
    } 

    var p1 = getPxValue(comboList.offsetWidth);
    var p2 = getPxValue(comboInput.offsetWidth); 
    
    comboDiv.style.visibility = "visible"; 
    comboDiv.style.top        = y  + 1 + "px";
    comboDiv.style.left       = x + "px";

    if (p1 <= p2)
    {
        comboDiv.style.width = (p2 + 14) + "px";
    }
    _currentOpenedComboDiv = comboDiv; 
}




// IE6 Only
function comboPopupIE6(element,name) 
{
    var base_o;
    var x;
    var y;
    var comboDiv    = document.getElementById("comboDiv"   + name);
    var comboInput  = document.getElementById("comboInput" + name); 
    var comboList   = document.getElementById("comboList"  + name);       


    if(comboDiv.style.visibility=="visible")
    {
      return;
    }

    if(_currentOpenedComboDiv != comboDiv) 
    {
      if(_currentOpenedComboDiv != null)
      {
        _currentOpenedComboDiv.style.visibility="hidden";
      }
      _currentOpenedComboDiv = null;
    }
    


    
    y = comboInput.offsetHeight;
    x = 0;           

    var e = comboInput;
    while (e)
    {
        x += e.offsetLeft;
        y += e.offsetTop;
        e = e.offsetParent;
    } 
    comboDiv.style.visibility = "visible";
    
    var p1 = getPxValue(comboList.clientWidth);
    var p2 = getPxValue(comboInput.clientWidth); 
    var p3 = getPxValue(comboList.offsetHeight);
 
    //comboDiv.style.visibility = "visible";
    comboDiv.style.top        = y  + 1 + "px";
    comboDiv.style.left       = x + "px";

    
    if (p1 <= p2)
    {
        comboDiv.style.width = (p2 + 14) + "px";
    }
    else
    {
        comboDiv.style.width = p1 + "px";     
    }

    if(p3 >= 250)
    {
      comboDiv.style.height = 250 + "px"; 
    }
     _currentOpenedComboDiv = comboDiv;
}

function comboHide(name)
{
      var comboDiv = document.getElementById("comboDiv"   + name); 
      comboDiv.style.visibility="hidden";
      _currentOpenedComboDiv = null;
}

function comboShow(name)
{

    var comboDiv = document.getElementById("comboDiv"   + name); 
     if(comboDiv.style.visibility=="visible")
     {

       return;
     }
      comboDiv.style.visibility="visible";
      _currentOpenedComboDiv = comboDiv;      
} 

function comboSetValue(element,name) 
{
    var comboDiv    = document.getElementById("comboDiv"   + name);
    var comboInupt  = document.getElementById("comboInput" + name);
    var comboHidden = document.getElementById(name);



    comboInupt.value  = element.getAttribute("valueName");
    comboHidden.value = element.getAttribute("valueID");
    comboHidden.onchange();
    comboDiv.style.visibility="hidden";
}

function comboSortSetValue(element,name) 
{
    var comboDiv    = document.getElementById("comboDiv"   + name);
    var comboInupt  = document.getElementById("comboInput" + name);
    var comboHidden = document.getElementById(name);



    comboInupt.value  = element.getAttribute("valueName");
    comboHidden.value = element.getAttribute("valueID");
    comboHidden.onchange();
    comboDiv.style.visibility="hidden";
    document.forms["form_sort"].submit();    
}

function elementOnMouseOver(e)
{
    e.className="comboover";
}
function elementOnMouseOut(e)
{
    e.className="comboout";
}
