var timerID = null;
var nOption = 0;
var Arr=new Array()
var sLast=0
var LastText=""
var status=0
var sfind=0


function bookmarksite(title, url){
  if (document.all)
  window.external.AddFavorite(url, title);
  else if (window.sidebar)
  window.sidebar.addPanel(title, url, "")
}


function initScrollLayer() {
  ////var wndo = new dw_scrollObj('wn', 'lyr1', 't1');    show findsystem only
  ////var wndo = new dw_scrollObj('wn2', 'lyr2', 't2');    show findsystem only
  var wndo = new dw_scrollObj('wn3', 'lyr3', 't3');

    //   
    if(document.getElementById("XSIZE"))
	    {
			var up1=document.getElementById("XSIZE").getAttribute("up1");
			var down1=document.getElementById("XSIZE").getAttribute("down1");
		}	

  //		 
  if(up1)
   {
////	document.getElementById("t1").style.width=up1*150-650   ////system find only
////	document.getElementById("t2").style.width=down1*175-100 ////system find only
   }	
	  
  dw_scrollObj.GeckoTableBugFix('wn'); 
  dw_scrollObj.GeckoTableBugFix('wn2'); 
  dw_scrollObj.GeckoTableBugFix('wn3'); 
  
  scrollInit()  // srcolling text            show findsystem only
  


}

//link a <<  >> + show categories  + show subcategories + page
function ClickLink(obj)
	{
		var t="index_1.asp?a=1&TAB_PAGE=" + obj.getAttribute("page")
		var t3='<%=Request.QueryString("GETLINK")%>'
		var t6='<%=Request.QueryString("COMBOSUBCAT")%>'
				
				
		if (t3!="") t3="&GETLINK=" + t3
		if (t6!="") t6="&COMBOSUBCAT=" + t6
		obj.href=t +  t3 +  t6
	}


function SelectLinksFromSubCategory(obj)
	{
		var t=document.getElementById(obj.id).value
		p=t.substring(0,4)
		if (p!="CAT_")
			{
				t=t.substring(4,t.length)
				var t1='<%=Request.QueryString("TAB_PAGE")%>'
				var t3='<%=Request.QueryString("GETSUBCAT")%>'
		   
				if (t1!="") t1="&TAB_PAGE=" + t1
				if (t3!="") t3="&GETSUBCAT=" + t // t3
				var t6="&COMBOSUBCAT=" + t
				window.location.replace("http://www.topxtop.com/index_1.asp?a=1&GETLINK=1" + t1 +  t3 +   t6 )	 
			} 
	}			
			
var IE = document.all?true:false

//mouse coordinates
function getMouseXY() {

if (IE){var position = document.body.scrollTop;}
else {var position = window.pageYOffset;}
document.getElementById("follow").style.top = position ;
document.getElementById("menu1Container").style.top = position+25 ;

return true
}


// init function for scroll tabs 
function init() 
{
	//window.onscroll = getMouseXY;
	window.onresize=initScrollLayer;
}


// scroll categories in search
function initScrollCategories()
 {
	var p
	p=document.getElementById("InitCat").innerHTML
	var x= new RegExp("&amp;","g")
	p=p.replace(x,"&")
	Arr=p.split(";;")
	if (sLast==0) 	startclock() 
			else document.getElementById("idSearchText").value=LastText;
 }

//trim
function Trim(stringToTrim) 
{
	return stringToTrim.replace(/^\s*|\s*$/g ,"");
}
 
//timer list cattgories in search
function startclock()
	{
		++nOption
		if (nOption<Arr.length-1)
			{
				document.getElementById("idSearchText").value =Trim(Arr[nOption])
			}  
		else
			{
				nOption = 0;
			}

		timerID = setTimeout("startclock()",2000)
	}

// search lost focus new timer	
function xBlur()
     {
	   if (document.getElementById("idSearchText").value =="")  
	    {
	     startclock()
		 sLast=0
		} 
     }	 	

//clear from search	
function xFocus()
	{
	  if (sLast==0)
	   {
	    document.getElementById("idSearchText").value =""
	    clearTimeout(timerID);
	   }	
	}



xoff = 0;
yoff = 0;
tempx = 0;
tempy = 0;

if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = MouseLayer;

function MouseLayer(e) {
if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft 
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
  }  

/*
if (document.getElementById("menu1Container").style.visibility != "visible")
{
document.getElementById("menu1Container").style.left = tempX -10;
}
if (document.getElementById("menu1Container").style.visibility != "visible")
{
document.getElementById("menu1Container").style.left = tempX -10;
}

*/
return true
}

function MM_findObj(n, d) { //v4.0

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  var tempX = 0;
  var tempY = 0;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v;
 }
}

// get top + left for element by id	
function getElementPositionObj(elemID) 
	{
	    var offsetTrail = elemID;
	    var offsetLeft = 0;
	    var offsetTop = 0;
	    while (offsetTrail) 
			{
			    offsetLeft += offsetTrail.offsetLeft;
			    offsetTop += offsetTrail.offsetTop;
			    offsetTrail = offsetTrail.offsetParent;
			}
			
			if (navigator.userAgent.indexOf("Mac") != -1 &&  typeof document.body.leftMargin != "undefined") 
				{
				    offsetLeft += document.body.leftMargin;
				    offsetTop += document.body.topMargin;
				}
				
				return {left:offsetLeft, top:offsetTop};
	}




function changetable(id,line,pos) {

document.getElementById("menu1Insert").innerHTML = document.getElementById(id).innerHTML;
if (IE){var position = document.body.scrollTop;}
else {var position = window.pageYOffset;}
var t=document.body.clientWidth  
if(t=="undefined") t= document.body.innerWidth 

if (line==1) {
place=parseInt(document.getElementById("lyr1").style.left);
if (place!=0) {
place=place+1
}
document.getElementById("menu1Container").style.top = position+21 ;
if (pos==-1)
{
	document.getElementById("menu1Container").style.left = 260 ;
}
else
{
if (pos==-2)
{
	document.getElementById("menu1Container").style.left = t-160 ;
}
	else
	{
		var tt=document.getElementById("lyr1").getElementsByTagName("td")
		var yy=tt[(pos-1)*3]
		var dd=getElementPositionObj(yy.childNodes[0])
		document.getElementById("menu1Container").style.left =dd.left   //((((pos-1)*150)+282)+((pos-1)*2))+place ;
	}
}

}

if (line==2) {
place=parseInt(document.getElementById("lyr2").style.left);
if (place!=0) {
place=place+1
}
document.getElementById("menu1Container").style.top = position+46 ;
if (pos==-1)
{
	document.getElementById("menu1Container").style.left = 260 ;
}
else
{
if (pos==-2)
{
	document.getElementById("menu1Container").style.left = t-160 ;
}
	else
	{
		var tt=document.getElementById("lyr2").getElementsByTagName("td")
		var yy=tt[(pos-1)*3]
		var dd=getElementPositionObj(yy.childNodes[0])
		document.getElementById("menu1Container").style.left =dd.left    // ((((pos-1)*175)+282)+((pos-1)*2))+place ;
	}
}
}

if (line==3)
{
	document.getElementById("menu1Container").style.top = position+50;       ////  show findsystem only  +25
	if (pos==-1)
	{
		document.getElementById("menu1Container").style.left = 15 ;
	}
	if (pos==-2)
	{
		document.getElementById("menu1Container").style.left = t-78 ;
	}
}

}


//to unicode	
 function ToUnicode(unicode)
	{

     var tstr = unicode
     var bstr = '';
	 if (tstr!="")
		{
			for(i=0; i < tstr.length; i++)
				{
					//if(tstr.charCodeAt(i)>127) 
					// {
						bstr += '&#' + tstr.charCodeAt(i) + ';';
					// } 
					//else 
						// {
							//  bstr += tstr.charAt(i);
							// }
				}
		}	
			return (bstr);
    }	 
	

//set scrolling to top possition=0	
function scrollToTop()
{
  //if (status==0)
	//{
		window.top.scroll(0,0);  
	//	status=1;		
    //}
}  


//??????????????????
function FF()
 {
   if (document.readyState=='complete') //'interactive' || document.readyState=='loading'  || document.readyState=='complete' ) 
	{ 
		status=0;
		window.top.scrollToTop(); 
		status=1;
	} 
 }  

 
// check load before onload
	function initOnLoad(sElementName) 
		{  
			status=0;
			var oElement = (sElementName == "body") ? document[sElementName] :document.getElementById(sElementName); 
			if(oElement != null && typeof(oElement) != "undefined") 
				{ 
					//window.top.scrollToTop();  ////show findsystem only
					window.top.init();
					window.top.initScrollLayer();
					window.top.initScrollCategories();     ////show findsystem only
					window.top.scrollInit();		     ////show findsystem only
				} 
			else 
				{ 
					setTimeout(function() 	{initOnLoad(sElementName);}, 0); 
				} 
		}  

//key pressed search enter
function PressSearchEnter(e)	
{
var zzz ,ddd

	//enter
	if (e)
		{
			if(e.keyCode==13)  
				{
					ddd=document.getElementById("InitCat").innerHTML;
					var x= new RegExp("&amp;","g")
					ddd=ddd.replace(x,"&")	
					var kkk=zzz + ";;"
					if (ddd.indexOf(kkk)!=-1) zzz=""
										else  zzz=document.getElementById("idSearchText").value;
					
					sLast=1;
					var p1='<%=Request.QueryString%>';
					var q=p1.indexOf("&search=1&keyword=");
					if (q!=-1) p1=p1.substring(0,q);
					p1=p1.replace("a=1","");
					p1="";
					var sss="http://www.topxtop.com/index_1.asp?a=1" + p1  + "&search=1&keyword=" + encodeURIComponent(zzz) + "&keyword2=" + encodeURIComponent(ToUnicode(zzz) )
					if (sfind!=0) sss=sss + "&find=" + sfind 
					window.location.replace(sss);

				}		

			else if (e.keyCode!=13)  
				{
					sLast=1;
				}
		}
	
	else if (sfind!=0)	//find system
		{
			if (top.document.getElementById("idSearchText")) 
				{
					zzz=top.document.getElementById("idSearchText").value
					ddd=top.document.getElementById("InitCat").innerHTML;
				}
				
			else if (document.getElementById("idSearchText")) 
				{
					zzz=document.getElementById("idSearchText").value
					ddd=document.getElementById("InitCat").innerHTML;
				}

			var x= new RegExp("&amp;","g")
			ddd=ddd.replace(x,"&")	
			if (zzz!="")
				{
					sLast=1;
					var p1='<%=Request.QueryString%>';
					var q=p1.indexOf("&search=1&keyword=");
					if (q!=-1) p1=p1.substring(0,q);
					p1=p1.replace("a=1","");
					p1="";
					var kkk=zzz + ";;"
					if (ddd.indexOf(kkk)!=-1) zzz=""
					var sss="http://www.topxtop.com/index_1.asp?a=1" + p1
					sss=sss + "&search=1&keyword=" + encodeURIComponent(zzz) + "&keyword2=" + encodeURIComponent(ToUnicode(zzz)) + "&find=" + sfind 
					top.location.replace(sss);
				}	
		}
	 
	else if (document.getElementById("idSearchText").value=="") 
	    {
			sLast=0;
		}	
} 
 
// Center_Default.xsl  + Center_Default_HTML.xsl
function Fun1(p1,p2,p3 ,p4,p5) 
{
 location.replace("http://www.topxtop.com/index_1.asp?a=1&ID=" + p1 + "&COMBOSUBCAT=" + p2 + "&RIGHT=" + p3 + "&LEFT=" + p4 +"&FRAME=" + p5)
}

//inc_Search.xsl + inc_Search_HTML.xsl
function Fun2(p1,p2,p3,p4,p5,p6)
{
  location.replace("http://www.topxtop.com/index_1.asp?a=1&ID=" + p1 + "&RIGHT=" + p2 + "&LEFT=" + p3 + "&FRAME=" + p4 + "&search=1&keyword=" + p5 + " &keyword2=" + p6 )
}

//inc-Search_tabs.xsl + inc-Search_tabs_HTML.xsl  
function Fun3(p1,p2)
{
 ypSlideOutMenu.showMenu('menu1');changetable('SEARCHES',p1,p2)
} 

//inc-Search_tabs.xsl + inc-Search_tabs_HTML.xsl  
function Fun4()
{
 ypSlideOutMenu.hideMenu('menu1') 
} 

//inc-Search_tabs.xsl + inc-Search_tabs_HTML.xsl  
function Fun6(p1,p2 ,p3 )
 {
  ypSlideOutMenu.showMenu('menu1');changetable('CAT_' + p1 ,p2 ,p3)
 }
 

//ScrollingText_Data_Site.xsl + ScrollingText_Data_Site_HTML.xsl
function Fun7(p1)
{
	location.replace("http://www.topxtop.com/GetData.asp?Param=55&DATA1=" + p1)
}	


//ScrollingText_Data_Site.xsl + ScrollingText_Data_Site_HTML.xsl
function Fun8(p1,p2 ,p3)
{
	location.replace("http://www.topxtop.com/index_1.asp?a=1&Param=55&ID=" + p1 + "&FRAME=" + p2 + "&COMBOSUBCAT=" + p3 + "&RIGHT=0&LEFT=0") //// LEFT=0" find system only
}	


//SIDE_GetListLinks.xsl + SIDE_GetListLinks_HTML.xsl
function Fun9(p1,p2,p3,p4,p5)
{
	location.replace("http://www.topxtop.com/index_1.asp?a=1&ID=" + p1 + "&COMBOSUBCAT=" + p2 + "&RIGHT=" + p3 + "&LEFT=" + p4 + "&FRAME=" + p5)
}							


//SIDE_GetListSubCats.xsl + SIDE_GetListSubCats_HTML.xsl
function F10(p1,p2,p3,p4,p5)
{
	location.replace("http://www.topxtop.com/index_1.asp?a=1&ID=" + p1 + "&sideCAT=" + p2 + "&RIGHT=" + p3 + "&LEFT=" + p4 + "&FRAME=" + p5)
}


//SIDE_GetListSubCats.xsl + SIDE_GetListSubCats_HTML.xsl
function F11(p1,p2,p3)
{
	location.replace("http://www.topxtop.com/index_1.asp?COMBOSUBCAT=" + p1 + "&LEFT=" + p2 + "&RIGHT=" + p3 )
}	


//all xlst onmouseover onmoveout
function Fun12(p1,p2 ,p3 )
 {
  ypSlideOutMenu.showMenu('menu1');changetable(p1 ,p2 ,p3)
 }
 
//all xlst scrolling categories + search
function Fun13(p1,p2,p3)
{
 dw_scrollObj.scrollBy(p1,p2,p3); return false 
} 

