////////////////////////////referer - start

function AddReferrer(){
	var qs		= new queryString();
	var ref = qs.getParameter("ref")
	if(isnull(ref)) return
	//alert("ref  : "+ ref)
	var xml = new ActiveXObject("Microsoft.XMLDOM")
	xml.async=false;
	if(!xml.load("/site/sr.asp?ref="+ref)){
		//alert(xml.parseError.reason)
	}
	else{
		//alert(xml.xml)
	}
	
}
function CStr(vle,dflt)
{
    dflt += "";
    if(dflt=="undefined") dflt = "";
    if(dflt=="null")      dflt = "";

       vle += "";
    if(vle=="undefined") return dflt;
    if(vle=="null")      return dflt;
    
    return vle;
}
function trim(vle)
{
        var trm = CStr(vle);
    return  trm.replace(/(^\s*)|(\s*$)/g, "");
}
function queryString()
{
	this.url					= window.location.href;
	var arr0					= this.url.split("?");
	
	this.asp					= "";
	this.query					= "";
	this.param					= {};
	this.folders				= [];
	
	if(arr0.length==1)
	{
		this.asp				= arr0[0];
		this.folders			= this.asp.split("/");
	}
	else if(arr0.length==2)
	{
		this.asp				= arr0[0];
		this.folders			= this.asp.split("/");
		
		this.query				= arr0[1];
		var arr					= arr0[1].split("&");
	
		for(var j=0; j<arr.length; j++)
		{
			if(!arr[j])					continue;
			if(trim(arr[j])=="")		continue;
			
			var	name			= arr[j].split("=")[0].toLowerCase();
			var	value			= arr[j].split("=")[1];
		
			this.param[name]	= value;
		}
	}
}
function queryString.prototype.getParameter(name)
{
	return this.param[name.toLowerCase()];
}


AddReferrer()


////////////////////////////referer - end




function addDinamicPropertiesToMenuObjects(obj){
	var imObj;
	try{
		if(obj.showImg==1) imObj=eval("imUpM"+obj.id+"Off");
	}catch(e){}
	obj.cursor="hand"
	obj.onmouseover="showUpperMenuDiv("+obj.id+");onClassName("+obj.id+")"
	obj.onmouseout="hideUpperMenuDiv("+obj.id+");offClassName("+obj.id+")"
	if(obj.id==home_pi) obj.onclick='go("'+homePath+'")'
	else obj.onclick=obj.fnc
	obj.className=menuClasses[obj.dpt]
	//case 1 : not active:
	if(obj.act!=1){
		obj.cursor="default"
		obj.onmouseover="onClassName("+obj.id+")"
		obj.onmouseout="offClassName("+obj.id+")"
		obj.onclick=""
	}
	//case 2 : is current:
	if(ifCurrent(obj)){
		if(obj.act==1){
			obj.cursor=(_existDoc)?"hand":"default";
			obj.onclick=(_existDoc)?obj.onclick:"";
		}
		obj.className=menuClasses[obj.dpt]+"_S"
		obj.onmouseover=(obj.act==1)?"showUpperMenuDiv("+obj.id+")":""
		obj.onmouseout=(obj.act==1)?"hideUpperMenuDiv("+obj.id+")":""
		try{
			if(obj.showImg==1) imObj=eval("imUpM"+obj.id+"On");
		}catch(e){}
	}
	else{
	//case 3 : is parent:
		if(ifParentOfCurrent(obj)){
			obj.className=menuClasses[obj.dpt]+"_H"
			obj.onmouseover=(obj.act==1)?"showUpperMenuDiv("+obj.id+")":""
			obj.onmouseout=(obj.act==1)?"hideUpperMenuDiv("+obj.id+")":""
			try{
				if(obj.showImg==1) imObj=eval("imUpM"+obj.id+"On");
			}catch(e){}
		}
	}
	try{
	if(imObj && obj.showImg==1){
		obj.label="<img id='contImg"+obj.id+"' \
			src='"+imObj.src+"' \
			width='"+imObj.width+"' \
			height='"+imObj.height+"' border='0'><br>"
	}
	else{
		obj.label=obj.txt.replace(/\&amp;\#34;/g,"\"").replace(/\&amp;\#39;/g,"\'");
		if(!isnull(UpperMenuBullet)) obj.label="<img class='UpperMenuBullet' src='"+UpperMenuBullet.src+"' border='0' width='"+UpperMenuBullet.width+"' height='"+UpperMenuBullet.height+"'>"+obj.label+"<img class='UpperMenuBullet' src='"+img_path+"trans.gif' border='0' width='"+UpperMenuBullet.width+"' height='"+UpperMenuBullet.height+"'>"
	}
	}
	catch(e){
		obj.label=obj.txt.replace(/\&amp;\#34;/g,"\"").replace(/\&amp;\#39;/g,"\'");
		if(!isnull(UpperMenuBullet)) obj.label="<img class='UpperMenuBullet' src='"+UpperMenuBullet.src+"' border='0' width='"+UpperMenuBullet.width+"' height='"+UpperMenuBullet.height+"'>"+obj.label+"<img class='UpperMenuBullet' src='"+img_path+"trans.gif' border='0' width='"+UpperMenuBullet.width+"' height='"+UpperMenuBullet.height+"'>"
	
	}
	obj.href=getHrefFromOnclick(obj.onclick)
	obj.target=getTargetFromOnclick(obj.onclick)
}

//main function for build upper menus HTML:
var ccc = 0
function createUpperMenus(){
	//build div that contain sub-menus:
	function _createMenusDiv(menu){
		if((Number(menu.dpt)+1)>=MAX_DEPTH) return "";

		var subMenus=getSubUppMenus(menu)
		if(isnull(subMenus) || subMenus.length==0) return "";
		var s="<div id='contDiv"+menu.id+"' style='z-index:100;position:absolute;display:none; \
					width:"+getWidth(subMenus,0)+";' \
					class='"+containerDivClass+(subMenus[0].dpt>1?"_Lev"+(subMenus[0].dpt+1):"")+"' >\
			<table dir='"+dir+"' id='contTable"+menu.id+"' cellpadding='0' cellspacing='0' width='100%' border='0' class='upperSubMenu'>"
			for(var i=0;i<subMenus.length;i++){
				addDinamicPropertiesToMenuObjects(subMenus[i])
				s+="<tr class='"+subMenus[i].className+"' \
						onmouseover='"+subMenus[i].onmouseover+"' onmouseout='"+subMenus[i].onmouseout+"'>\
					<td width='100%' style='width:100%;' nowrap='"+NOWRAP+"' class='"+subMenus[i].className+"' \
							title='"+(!isnull(subMenus[i].hnt)?subMenus[i].hnt:"")+"' \
							align='"+align+"' >\
						<a id='contText"+subMenus[i].id+"' \
							active='"+subMenus[i].act+"' \
							href='"+subMenus[i].href+"' "+subMenus[i].target+" \
							class='"+subMenus[i].className+"' \
							style='cursor:"+subMenus[i].cursor+";' \
							align='"+align+"' >" 
							+ subMenus[i].label +"\
						</a>\
					</td>"
					if((Number(subMenus[i].dpt)+1)<MAX_DEPTH){
						s+="<td valign='top' width='0' style='font-size:0px;width:0px;' >"
							+ _createMenusDiv(subMenus[i]) +"\
						</td>"
					}
				s+="</tr>"
				if(i!=(subMenus.length-1)){
					s+="<tr colspan='"+(((subMenus[i].dpt+1)<MAX_DEPTH)?2:1)+"' class='"+horizDelimClass+(subMenus[0].dpt>1?"_Lev"+(subMenus[0].dpt+1):"")+"'>\
						<td class='"+horizDelimClass+(subMenus[0].dpt>1?"_Lev"+(subMenus[0].dpt+1):"")+"'></td>\
					</tr>";
				}
			}
			s+="</table>\
		</div>"
		return s;
	}
	var menusItems=getSubUppMenus();
	if(isnull(menusItems) || menusItems.length==0) return;
	var s=""
	try{
		s+="<table id='upperMenus' name='upperMenus' cellpadding='0' cellspacing='0' width='100%' border='0' class='upperMenu'>\
			<tr class='upperMenu'>"
				for(var i=0;i<menusItems.length;i++){
					addDinamicPropertiesToMenuObjects(menusItems[i])
					s+="<td class='"+menusItems[i].className+"' valign='top' \
						onmouseover='"+menusItems[i].onmouseover+"' \
						onmouseout='"+menusItems[i].onmouseout+"' \
						title='"+(!isnull(menusItems[i].hnt)?menusItems[i].hnt:"")+"' \
						id='tdCont"+menusItems[i].id+"' nowrap='nowrap' \
						style='direction:"+dir+"' \
					>\
						<a id='contText"+menusItems[i].id+"' nowrap='nowrap' align='center' \
							active='"+menusItems[i].act+"' \
							href='"+menusItems[i].href+"' "+menusItems[i].target+" \
							class='"+menusItems[i].className+"' \
							style='height:100%;cursor:"+menusItems[i].cursor+";' \
						>"
							s+=menusItems[i].label +"\
						</a><br>"
							s+=_createMenusDiv(menusItems[i]) +"\
					</td>"
					if(i!=(menusItems.length-1)){
						s+="<td class='"+vertDelimClass+(menusItems[0].dpt>1?"_Lev"+menusItems[0].dpt:"")+"'></td>";
					}
				}
				s+="</tr>\
		</table>"
		document.write(s)
	}
	//catch(e){alert(e.description);}
	catch(e){}
}
