/*<![CDATA[*/
<!--
	
		
function toggleExpandNew(objectid) {

	subdiv = document.getElementById(objectid+"subdiv");
	subimg = document.getElementById(objectid+"subimg");

	if (getElementsCount(objectid) > 0) {
   
		if (subdiv.style.display == "block"){

			subdiv.style.display = "none";
			subimg.src = "/images/icon_plus.gif";
			subimg.alt = "Expand";

			
		} else {

			subdiv.style.display = "block";
			subimg.src = "/images/icon_minus.gif";
			subimg.alt = "Collapse";
		}
	} 


}

function getElementsCount(objectId){
	var submenu = document.getElementById(objectId+"sub");
	var subelements = submenu.getElementsByTagName("li");
	return subelements.length;
}

function DisplayMoreLinks(objectId, type) {
    var submenu = document.getElementById(objectId + "subm");
    var morelink = document.getElementById(objectId + "MoreLink");
    var lesslink = document.getElementById(objectId + "LessLink");
    
   if(type==1){
       submenu.style.display = "block";
       lesslink.style.display = "block";
       morelink.style.display = "none";
       
   }
   else if(type==0){
       submenu.style.display = "none";
       lesslink.style.display = "none";
       morelink.style.display = "block";
   }

}

function sort(type) 
{
    var url = window.location.href;
    var rankPrefix = "&sortby=";
    var orderPrefix = "&sortdirection=";
    var orderValue;
    
    if (getQuery("sortdirection")== null|| getQuery("sortdirection")=="descending"){

        orderValue="ascending";      
    }
    else if(getQuery("sortdirection")=="ascending"){
        orderValue ="descending";
    }

    if (url.indexOf("sortby") == -1) {
        window.location.href = url + rankPrefix + type + orderPrefix + orderValue;
    } else {
        window.location.href = changeURLPar(changeURLPar(url,"sortby",type),"sortdirection",orderValue);
    }
}


function changeURLPar(destiny,par,par_value)
{
    var pattern = par+'=[^&]*';
    var replaceText = par+'='+par_value;

    if (destiny.match(pattern))
    {
     //var tmp = '/\\'+par+'=[^&]*/';
    // tmp = destiny.replace(eval(tmp),replaceText);
    tmp = destiny.replace(destiny.match(pattern),replaceText);
     return (tmp);

    }
    else
    {
         if (destiny.match('[\?]'))
         {
          return destiny+'&'+ replaceText;
         }
         else
         {
          return destiny+'?'+replaceText;
         }
    }
    return destiny+'\n'+par+'\n'+par_value;
}


function getQuery(name)
{
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r!=null) 
        return unescape(r[2]); 
    return null;
} 
//-->
/*]]>*/
