var timerID = null;
var nOption = 0;
var Arr=new Array()
var sLast=0
var LastText=""
var status=0



function rowOf(theRow, xxx)
{
if (xxx==0) thePointerColor="#eaeaea"
else if (xxx==1) thePointerColor="#ffffff"
theRow.style.backgroundColor = thePointerColor;
    return true;
} // end of the 'setPointer()' function



function bookmarksite(title, url){
  if (document.all)
  window.external.AddFavorite(url, title);
  else if (window.sidebar)
  window.sidebar.addPanel(title, url, "")
}


function initScrollLayer() {
  var wndo1 = new dw_scrollObj('wn2', 'lyr2', 't2');
  var wndo = new dw_scrollObj('wn3', 'lyr3', 't3');


 // dw_scrollObj.GeckoTableBugFix('wn'); 
  dw_scrollObj.GeckoTableBugFix('wn2'); 
  dw_scrollObj.GeckoTableBugFix('wn3'); 
  
 // scrollInit()  // srcolling text
  


}

//link a <<  >> + show categories  + show subcategories + page
function ClickLink(obj)
	{
		var t="index.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("index.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;
 }
}

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
	{
		document.getElementById("menu1Container").style.left = ((((pos-1)*106)+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+21 ;
if (pos==-1)
{
	document.getElementById("menu1Container").style.left = 260 ;
}
else
{
if (pos==-2)
{
	document.getElementById("menu1Container").style.left = t-160 ;
}
	else
	{
		document.getElementById("menu1Container").style.left = ((((pos-1)*98)+282)+((pos-1)*2))+place-2 ;
	}
}
}

if (line==3)
{
	document.getElementById("menu1Container").style.top = position+69 ;
	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 = '';
      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.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;
	} 
 }  


		function listbox_move(listID, direction) {

			var listbox = document.getElementById(listID);
			var selIndex = listbox.selectedIndex;

			if(-1 == selIndex) {
				alert("Please select an option to move.");
				return;
			}

			var increment = -1;
			if(direction == 'up')
				increment = -1;
			else
				increment = 1;

			if((selIndex + increment) < 0 ||
				(selIndex + increment) > (listbox.options.length-1)) {
				return;
			}

			var selValue = listbox.options[selIndex].value;
			var selText = listbox.options[selIndex].text;
			listbox.options[selIndex].value = listbox.options[selIndex + increment].value
			listbox.options[selIndex].text = listbox.options[selIndex + increment].text

			listbox.options[selIndex + increment].value = selValue;
			listbox.options[selIndex + increment].text = selText;

			listbox.selectedIndex = selIndex + increment;
		}

		function listbox_moveacross(sourceID, destID) {
			var src = document.getElementById(sourceID);
			var dest = document.getElementById(destID);

			for(var count=0; count < src.options.length; count++) {

				if(src.options[count].selected == true) {
						var option = src.options[count];

						var newOption = document.createElement("option");
						newOption.value = option.value;
						newOption.text = option.text;
						newOption.selected = true;
						try {
								 dest.add(newOption, null); //Standard
								 src.remove(count, null);
						 }catch(error) {
								 dest.add(newOption); // IE only
								 src.remove(count);
						 }
						count--;

				}

			}
			
			listbox_selectall(sourceID, false)
			listbox_selectall(destID, false)	

		}
		function listbox_selectall(listID, isSelect) {

			var listbox = document.getElementById(listID);
			if (listbox)
			{
				for(var count=0; count < listbox.options.length; count++) {
					listbox.options[count].selected = isSelect;
				}
			}
		}
		
		
		//save list fields show
		function funSaveListFieldsShow()
		{
			inp=document.getElementById("Fields_Desc");
			uu=0
			ss=0;
			for(var count=0; count < inp.length; count++) {
				if (inp[count].value==15) uu=1
				if(uu==1) ss=ss+1
			}
			//if (ss<=5) alert('Field "DB" not removed ')
			//else {
					
				 var sxml=""
				 var userid=document.getElementById("userid").value 

				 var inp=document.getElementById("Fields_Desc")
				 var n=0;
				 for (var i=0;i<inp.length;i++)
					{
						sxml=sxml + inp[i].value + '|'
					}
					if (sxml.length!=0) sxml=sxml.substring(0,sxml.length-1)
					sxml='<ROOT><U USER="'+ userid + '" F="' + sxml + '"/></ROOT>'

					document.F3.action=location.href;	
					document.getElementById("XMLFIELD").value=sxml
					$('#mask').hide();	
					$('#start_emb').hide('slow');					
					document.F3.submit()
			//}		
		}
		

