var saveAction=null, enableClick=true;
var layer,enable=false;
var commandPerformed=false;


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

//***************************************************************

function lc_setMenuPosition()
	{
	var width,width2,left;
	
	width=document.body.offsetWidth;
	width2=Math.max(width,this.mainTableWidth);
	this.layer.style.top=108;
	left=Math.ceil((width2-this.mainTableWidth)/2)+328;
	if (this.netscape) left+=10;
	this.layer.style.left=left;
	}
	

function layerControl()
	{
	var tmp;
	
	this.layer=document.getElementById("menu");
	tmp=document.getElementById("mainTable");
	this.mainTableWidth=tmp.width;
	this.netscape=(navigator.appName=="Netscape");

	this.setMenuPosition=lc_setMenuPosition;
	
	this.setMenuPosition();
	}

//***************************************************************

function sendCommand(cmd)
	{
	var obj;
	
	if (!enable) return;
	obj = navigator.appName=="Netscape" ? document.embeds["menuAnimation"] : document.menuAnimation;
	
	obj.TCallLabel("/",cmd);
	}
	
	
function onResize()
	{
	layer.setMenuPosition();
	}


function initLayer()
	{
	if (navigator.appName.indexOf("Netscape")!=-1 && !enable) setTimeout(initLayer,2000);
	enable=true;
	layer=new layerControl();
	window.onresize=onResize;
	sendCommand("movieShow");
	}


function menuAnimation_DoFSCommand(cmd,args)
	{
	var obj=document.getElementById("menu");
	obj=obj.style;
	
	switch(cmd)
		{
		case "uncoveringStarted":
			obj.visibility="visible";
			break;
		case "uncoveringFinished":
			//if (!commandPerformed) sendCommand("movieHide");
			break;
		case "coveringFinished":
			obj.visibility="hidden";
			break;
		}
	}



function topAnimation_DoFSCommand(cmd,args)
	{
	var obj=document.getElementById("menu");
	obj=obj.style;

	switch(cmd)
		{
		case "swapMenu":
			obj.visibility="visible";
			sendCommand("movieSwap");
			commandPerformed=true;
			break;
		}
	}
	


function viewPicture(pictUrl,width,height)
{
	var wnd;
	
	wnd=open(pictUrl,"view","width="+width+",height="+height);
	wnd.focus();
}


function submitForm(formName,mode,id,subid)
	{
	var url;
	var obj=document.forms[formName];
	var newAction;
	
	if (!enableClick) return;
	if (!saveAction) saveAction=obj.action;
	newAction="mode="+mode;
	if (id!=null) newAction+="&id="+id;
	if (subid!=null) newAction+="&subid="+subid;
	obj.action=saveAction+"?"+newAction;
	url=window.location.search.substr(1);
	if (url.length && document.cookie.indexOf("PHPSESSID=")==-1)
		{
		arr=url.split("&");
		for(i=0;i<arr.length;i++)
			{
			val=arr[i];
			val=val.split("=");
			if (val[0]=="PHPSESSID")
				{
				obj.action+="&PHPSESSID="+val[1];
				break;
				}
			}
		}

	obj.submit();
	enableClick=false;
	}

/*	
function submitForm(formName,mode,id,subid,remove_id)
	{
	var url;
	var obj=document.forms[formName];
	var newAction;
	
	if (!enableClick) return;
	if (!saveAction) saveAction=obj.action;
	newAction="mode="+mode;
	if (id!=null) newAction+="&id="+id;
	if (subid!=null) newAction+="&subid="+subid;
	if (remove_id!=null) newAction+="&remove_id="+remove_id;	
	obj.action=saveAction+"?"+newAction;
//	obj.action=saveAction+"&"+newAction;
	

	url=window.location.search.substr(1);
	if (url.length && document.cookie.indexOf("PHPSESSID=")==-1)
		{
		arr=url.split("&");
		for(i=0;i<arr.length;i++)
			{
			val=arr[i];
			val=val.split("=");
			if (val[0]=="PHPSESSID")
				{
				obj.action+="&PHPSESSID="+val[1];
				break;
				}
			}
		}

	obj.submit();
	enableClick=false;
	}
*/
	
	
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
	  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub menuAnimation_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call menuAnimation_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('Sub topAnimation_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call topAnimation_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('call sendCommand("xxx")\n');
	document.write('</SCRIPT\> \n');
}


function submitFormByKey(ev)
	{
	if (ev)
		{
		if (ev.which==13) 
			{
			mode("search");
			return false;
			}
		}
	else if (window.event.keyCode==13)
		{
		mode("search");
		return false;
		}
	
	return true;  
	}

	
function init()
	{
	initLayer();
	document.getElementById("searchText").onkeypress=submitFormByKey;
	//document.getElementById("searchCategoryId").onkeypress=submitFormByKey;
	document.getElementById("searchText").focus();
	}

function setStyle(elemName,className)
{
 document.getElementById(elemName).className=className;
}
