function openNewWindow(ref,x,y){
	if(document.layers && nWindow && !nWindow.closed)nWindow.close();
	nWindow=window.open(ref,"","status=yes,dependent=yes,resizable=yes,scrollbars=yes,width="+x+",height="+y+"");
}
function goPage(){
	var ind=document.getElementById('pgnum').value;
	if(ind > lastindx)ind=lastindx;
	location=(indxbase+ind+'.html');
}
function insertGo(prompt){
	if(!document.layers){
		var str='<TD class="itmE">'+prompt+'&nbsp;&nbsp;</TD>'
		str +='<TD><INPUT class="itmE" type=text id="pgnum" size=5></TD><TD>&nbsp;&nbsp;</TD><TD><INPUT id=go type=button value="&nbsp;Go!&nbsp;" onclick="goPage();"></TD>'
		document.write(str);
	}
}
function showPhoto(phref,width,height){
	var newWindow = null;
	if(document.layers && newWindow && !newWindow.closed)newWindow.close();
	newWindow=window.open("","","status=yes,dependent=yes,resizible=no,width="+width+",height="+height+"");
	newWindow.document.write('<body bgcolor=#ffffff topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>');
	newWindow.document.write('<IMG src='+phref+' width=100% height=100%>');
	newWindow.document.write('</body>');
	newWindow.document.close();
}
var isie4=false;
function showPhotoSet(baseref,phref,width,height,count,tip){
	this.ver = navigator.appVersion.toLowerCase();
	this.dom=document.getElementById?1:0;
	isie4=(navigator.userAgent.toLowerCase().indexOf("msie")!=-1&&document.all&&!this.dom&&this.ver.indexOf("msie 5")<1&&this.ver.indexOf("msie 6")<1);
	var newWindow;
	var winheight=height+30;
	var tooltip=(tip)?tip:"Photo";
	newWindow=window.open("","","status=yes,dependent=yes,resizible=no,width="+(width+2)+",height="+(winheight+2)+"");	newWindow.document.write('<html><head><base href="'+baseref+'">');
	newWindow.document.write("<script language='JavaScript' type='text/javascript'>var currPhInd=1;function replacePhoto(newph,isie4){if(newph!=currPhInd){var currind=(isie4)?document.all('ph'+currPhInd).src:document.images['ph'+currPhInd].src;var newind=(isie4)?document.all('ph'+newph).src:document.images['ph'+newph].src;var currsrc=(isie4)?document.all('mphoto').src:document.images['mphoto'].src;var sepPos=currsrc.lastIndexOf('.');var newsrc=currsrc.substring(0,sepPos-1)+newph+currsrc.substring(sepPos);if(currind && newind){currind=currind.substring(0,currind.indexOf('_sel.gif'))+'.gif';newind=newind.substring(0,newind.indexOf('.gif'))+'_sel.gif';}if(isie4){document.all('ph'+currPhInd).src=currind;document.all('ph'+newph).src=newind;document.all('mphoto').src=newsrc;}else{document.images['ph'+currPhInd].src=currind;document.images['ph'+newph].src=newind;document.images['mphoto'].src=newsrc;}currPhInd=newph;}}</script>");
	newWindow.document.write('</head><body bgcolor=#d0d0d0 topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>');	newWindow.document.write('<TABLE width='+width+' height='+height+' cellPadding=0 cellSpacing=0 border=0><TR><TD align=center>');
	newWindow.document.write('<IMG name="mphoto" src="'+phref+'" border=1></TD></TR></TABLE>');
	newWindow.document.write('<TABLE width=100% height=30 cellPadding=0 cellSpacing=0 border=0><TR><TD align=center>');	
	if(count>9)count=9;
	newWindow.document.write('<TABLE cellpadding=1 celspacing=0 border=0><TR>');
	for(var i=1;i<=count;i++){
	newWindow.document.write('<TD><A href="javascript:replacePhoto('+i+','+isie4+')"><IMG name="ph'+i+'" src="./pic/ph'+i+((i==1)?'_sel':'')+'.gif" border=0 title="'+tooltip+' '+i+'"></A></TD>');}
	newWindow.document.write('</TR></TABLE>');
	newWindow.document.write('</TD></TR></TABLE>');
	newWindow.document.write('</body></html>');
	newWindow.document.close();
}
var selNode,nodeCnt;
function initPlaces(){
	selNode=0;nodeCnt=0;
}
function insertTheme(txt,count,state,level,openref,selref,serv){
		var usel="./pic/usel_lmr.gif";
		var mclass="tdunsel";
		var openimg="./pic/plus.gif";
		var width=level*18;
		if(state==1||state=="1")openimg="./pic/minus.gif";
		else if(state==2||state=="2"||count==0)openimg="./pic/ball.gif";
		var tag=(serv)?"_top":"_self";
		var s='<TABLE cellSpacing=0 cellPadding=0 border=0>\n<TR>\n<TD>';
		if(state!=2&&state!='2')s+='<IMG src="./pic/emp.gif" border=0 width='+width+' height=6><A href="'+openref+'" target="'+tag+'"><IMG src="'+openimg+'" border=0 width=16 height=11></A></TD>\n';
		else s+='<IMG src="./pic/emp.gif" border=0 width='+width+' height=6><IMG src="'+openimg+'" border=0 width=16 height=11></TD>\n';
		if(count>0){
			s+='<TD><TABLE cellPadding=0 cellSpacing=0 border=0><TR><TD><IMG src='+usel+'></TD><TD class="'+mclass+'" NOWRAP><A class=thema href=javascript:loadCategory("'+selref+'")>'+txt+'</A></TD><TD><IMG src='+usel+'></TD></TR></TABLE></TD>\n';}
		else {s+='<TD class="empth">'+txt+'</TD>\n';}
		s+='<TD class=nmtxt><IMG src=./pic/emp.gif>( '+count+' )</TD>\n</TR>\n</TABLE>';
		document.write(s);
}
function loadCategory(newref){
	top.location=newref;
}
var IDs=new Array();
var Servers=new Array();
var bNum=-1;
function insertPlace(ID,txt,state,level,openref,passive,serv){
		var aclass,mclass,lsel,msel,rsel;
		nodeCnt++;
		IDs[nodeCnt]=ID;
		if(bNum==ID){mclass="tdsel";aclass="sthema";lsel="./pic/sel_l.gif";msel="./pic/sel_m.gif";rsel="./pic/sel_r.gif";selNode=nodeCnt;}
		else{mclass="tdunsel";aclass="thema";lsel=msel=rsel="./pic/usel_lmr.gif";}
		if(serv)Servers[nodeCnt]=serv; else Servers[nodeCnt]="";
		var openimg="./pic/plus.gif";
		var width=level*18;
		var pass=(passive==1||passive=='1')?1:0;
		var srv=(serv)?serv:0;
		if(state==1||state=="1")openimg="./pic/minus.gif";
		else if(state==2||state=="2")openimg="./pic/ball.gif";
		var s='<TABLE cellSpacing=0 cellPadding=0 border=0>\n<TR>\n<TD>';
		if(state!=2&&state!='2')s+='<IMG src="./pic/emp.gif" border=0 width='+width+' height=6><A href="javascript:openNode(\''+openref+'\','+pass+','+srv+');"><IMG src="'+openimg+'" border=0 width=16 height=11></A></TD>\n';
		else s+='<IMG src="./pic/emp.gif" border=0 width='+width+' height=6><IMG src="'+openimg+'" border=0 width=16 height=11></TD>\n';
		s+='<TD><TABLE cellPadding=0 cellSpacing=0 border=0><TR><TD><IMG ID="li'+nodeCnt+'" src='+lsel+'></TD><TD ID= "mi'+nodeCnt+'"+ class="'+mclass+'" NOWRAP><A ID="at'+nodeCnt+'" class="'+aclass+'" href="javascript:selectNode('+nodeCnt+','+pass+');">'+txt+'</A></TD><TD><IMG ID="ri'+nodeCnt+'" src='+rsel+'></TD></TR></TABLE></TD>\n</TR>\n</TABLE>';
		document.write(s);
}
function openNode(openref,pass,serv){
		if(openref.indexOf('?')>0)openref+='&bnum='+bNum+'&pass='+pass;
		else openref+='?bnum='+bNum+'&pass='+pass;
		if(serv) top.location.href=openref;		
		else document.location.href=openref;
		return true;
}
function insertCategory(ID,txt,state,level,openref,serv){
		var usel="./pic/usel_lmr.gif";
		var mclass="tdunsel";
		var openimg="./pic/plus.gif";
		var width=level*18;
		if(state==1||state=="1")openimg="./pic/minus.gif";
		else if(state==2||state=="2")openimg="./pic/ball.gif";
		var tag=(serv)?"_top":"_self";
		var s='<TABLE cellSpacing=0 cellPadding=0 border=0>\n<TR>\n<TD>';
		if(state!=2&&state!='2')s+='<IMG src="./pic/emp.gif" border=0 width='+width+' height=6><A href="'+openref+'" target="'+tag+'"><IMG src="'+openimg+'" border=0 width=16 height=11></A></TD>\n';
		else s+='<IMG src="./pic/emp.gif" border=0 width='+width+' height=6><IMG src="'+openimg+'" border=0 width=16 height=11></TD>\n';
		if(!serv)s+='<TD><TABLE cellPadding=0 cellSpacing=0 border=0><TR><TD><IMG src='+usel+'></TD><TD class="'+mclass+'" NOWRAP><A class="thema" href=javascript:selectCategory('+ID+',php_href)>'+txt+'</A></TD><TD><IMG src='+usel+'></TD></TR></TABLE></TD>\n';
		else s+='<TD><TABLE cellPadding=0 cellSpacing=0 border=0><TR><TD><IMG src='+usel+'></TD><TD class="'+mclass+'" NOWRAP><A href="'+openref+'" target="'+tag+'">'+txt+'</A></TD><TD><IMG src='+usel+'></TD></TR></TABLE></TD>\n';
		s+='\n</TABLE>';
		document.write(s);
}
function insertPayCategory(ID,txt,state,level,openref,serv){
		var usel="./pic/usel_lmr.gif";
		var mclass="tdunsel";
		var openimg="./pic/plus.gif";
		var width=level*18;
		if(state==1||state=="1")openimg="./pic/minus.gif";
		else if(state==2||state=="2")openimg="./pic/ball.gif";
		var tag=(serv)?"_top":"_self";
		var s='<TABLE cellSpacing=0 cellPadding=0 border=0>\n<TR>\n<TD>';
		if(state!=2&&state!='2')s+='<IMG src="./pic/emp.gif" border=0 width='+width+' height=6><A href="'+openref+'" target="'+tag+'"><IMG src="'+openimg+'" border=0 width=16 height=11></A></TD>\n';
		else s+='<IMG src="./pic/emp.gif" border=0 width='+width+' height=6><IMG src="'+openimg+'" border=0 width=16 height=11></TD>\n';
		s+='<TD><TABLE cellPadding=0 cellSpacing=0 border=0><TR><TD><IMG src='+usel+'></TD><TD class="'+mclass+'" NOWRAP><A class="pthema" href=javascript:selectCategory('+ID+',php_payhref)>'+txt+'<IMG src="./pic/payment.gif" alt="'+paytip+'"  border=0></A></TD><TD><IMG src='+usel+'></TD></TR></TABLE></TD>\n';
		s+='\n</TABLE>';
		document.write(s);
}
function insertTopCategory(txt,state,ref,count,serv){
	var leftimg="./pic/plus.gif";
	if(state==1||state=="1")leftimg="./pic/minus.gif";
	else if(state==2||state=="2")leftimg="./pic/emp.gif";
	var tag=(serv)?"_top":"_self";
	var s='<TABLE cellSpacing=0 cellPadding=0 border=0><TR><TD>';
	s+='<A href="'+ref+'" target="'+tag+'"><IMG src="'+leftimg+'" border=0 width=16 height=11></A></TD>';
	s+='<TD><A  class="thema" href="'+ref+'">'+txt+'</A></TD>';
	if(count>0){
		s+='<TD class=nmtxt><IMG src=./pic/emp.gif>( '+count+' )</TD>';
	}		
	s+='</TR></TABLE>';
	document.write(s);
}
function insertTopRegion(ID,txt,state,lref,chgserver){
	var newserv=(chgserver)?1:0;
	var leftimg="./pic/plus.gif";
	var chr=(top_href.indexOf('?')>0)?'&':'?';
	var rref=top_href+chr+'ev='+ev+'&rgID='+ID+'&pass='+pass;
	if(state==1||state=="1")leftimg="./pic/minus.gif";
	else if(state==2||state=="2")leftimg="./pic/emp.gif";
	var s='<TABLE cellSpacing=0 cellPadding=0 border=0><TR><TD>';
	s+='<A href="javascript:go2SubTreeItem(\''+lref+'\',\''+rref+'\','+newserv+');"><IMG src="'+leftimg+'" border=0 width=16 height=11></A></TD>';
	s+='<TD><A  class="thema" href="javascript:go2SubTreeItem(\''+lref+'\',\''+rref+'\','+newserv+');">'+txt+'</A></TD>';
	s+='</TR></TABLE>';
	document.write(s);
}
function go2SubTreeItem(lref,rref,newserv){
	if(newserv){top.location.href=lref;}
	else{
		document.location.href=lref;
		if(rref&&rref!='undefined'&&rref!=undefined&&rref!=null)top.category.location.href=rref;
	}
}
function selectCategory(catID,phref){
	var char1=(php_href.indexOf('?')>0)?'&':'?';
	top.location=phref+char1+'ev='+extractParam(top.region.location,"ev")+'&catID='+catID+'&rgID='+top.region.bNum;
}
function selectNode(nodeNum,passive){
	
	
	
	var regRef;
	if(nodeNum!=selNode){
		if(0!=selNode){
			document.getElementById('li'+selNode).src='./pic/usel_lmr.gif';
			document.getElementById('mi'+selNode).className='tdunsel';
			document.getElementById('at'+selNode).className='thema';
			document.getElementById('ri'+selNode).src='./pic/usel_lmr.gif';
		}
		document.getElementById('li'+nodeNum).src='./pic/sel_l.gif';
		document.getElementById('mi'+nodeNum).className='tdsel';
		document.getElementById('at'+nodeNum).className='sthema';
		document.getElementById('ri'+nodeNum).src='./pic/sel_r.gif';
		if(Servers[nodeNum].length>0)
		{
			top.location=Servers[nodeNum];
		}
		else if(!passive)
		{
			
			var char1=(php_href.indexOf('?')>0)?'&':'?';
			//alert(php_href+char1+'ev='+extractParam(top.category.location,"ev")+'&regID='+IDs[nodeNum]);
			top.category.location=php_href+char1+'ev='+extractParam(top.category.location,"ev")+'&regID='+IDs[nodeNum];
		}
		selNode=nodeNum;
		bNum=IDs[selNode];
	}
}
function insertReturnButton(parStr){
	var chr=(retRef.indexOf('?')>0)?'&':'?';
	var s="<TABLE cellspacing=0 cellpadding=0 border=0><TR><TD><A href='"+retRef+chr+"ev="+retParam+"'><IMG src=./pic/bluebtn_l.gif border=0></A></TD>";
	var algn=(is.opera)?"top":"middle";
	s+="<TD background=./pic/bluebtn_m.gif class=bttext valign="+algn+"><A href='"+retRef+chr+"ev="+retParam+"' class=abttext>"+retTxt+"</A></TD>";
	s+="<TD><A href='"+retRef+chr+"ev="+retParam+"'><IMG src=./pic/bluebtn_r.gif border=0></A></TD></TR></TABLE>";
	document.write(s);
}
function insertSelRegion(regionStr){
	if(regionStr&&regionStr.length>0){
		document.write('<TABLE cellSpacing=0 cellPadding=0 border=0><TR><TD><IMG src="./pic/emp.gif" height=10 width=10></TD><TD class="smhdr" nowrap>'+regionStr+'</TD></TR></TABLE>');
	}
}
function insertTopRegionsLink(txt,lref,rref,chgserver){
	var newserv=(chgserver)?1:0;
	var s='<TABLE cellSpacing=0 cellPadding=0 border=0><TR><TD>';
	s+='<A href="javascript:go2TopRegions(\''+lref+'\',\''+rref+'\','+newserv+');"><IMG src="./pic/up.gif" border=0 width=16 height=11></A></TD>';
	s+='<TD><A  class="upper" href="javascript:go2TopRegions(\''+lref+'\',\''+rref+'\','+newserv+');">'+txt+'</A></TD></TR><TR><TD colspan=2 background=./pic/bord_u3.gif><IMG src=./pic/bord_u3.gif></TD></TR></TABLE>';
	document.write(s);
}
function go2TopRegions(lref,rref,newserv){
	bNum=-1;
	if(newserv){top.location.href=lref;}
	else{
		document.location.href=lref;
		if(rref&&rref!='undefined'&&rref!=undefined&&rref!=null)top.category.location.href=rref;
	}
}
function insertTopCategoriesLink(txt,topref,chgserver){
	var s='<TABLE cellSpacing=0 cellPadding=0 border=0><TR><TD>';
	var targ=(chgserver)?"_top":"_self";
	s+='<A href="'+topref+'" target="'+targ+'"><IMG src="./pic/up.gif" border=0 width=16 height=11></A></TD>';
	s+='<TD><A  class="upper" href="'+topref+'" target="'+targ+'">'+txt+'</A></TD></TR><TR><TD colspan=2 background=./pic/bord_u3.gif><IMG src=./pic/bord_u3.gif></TD></TR></TABLE>';
	document.write(s);
}
function insertObjectLocation(regTxt,regName,catTxt,catName,regRef,catRef){
    var s='<TR><TD colspan=10><TABLE cellSpacing=0 cellPadding=0 border=0 background=./pic/bline.gif><TR><TD valign=top><IMG src=./pic/search_ss.gif></TD>';
	s+='<TD class="rootRef">'+regTxt+'&nbsp;:</TD>';
	s+='<TD><A class="levelRef" href='+regRef+'>&nbsp;'+regName+'</A></TD>';
	s+='<TD><IMG src=./pic/emp.gif width=5></TD><TD class="rootRef">'+catTxt+'&nbsp;:</TD>';
	s+='<TD><A class="levelRef" href='+catRef+'>&nbsp;'+catName+'&nbsp;</A></TD></TR></TABLE></TD></TD></TR>';
	document.write(s);
}
function inserStep1Descripton(catName,regName,catStr,regStr){
	if(regStr && regStr.length>0)getDescription(regName,regStr);
	if(catStr && catStr.length>0)getDescription(catName,catStr);
}
function getDescription(name,str){	
	var s="<TABLE cellSpacing=0 cellPadding=0 border=0><TR><TD class=boldTxt>"+name+"</TD>\n";
	var elmts=str.split(".");
	var cnt=elmts.length;
	for(var i=0;i<cnt;i++){
		s+="<TD class='normTxt'>"+replaceSpecChar(elmts[i]);
		if(i<cnt-1)s+="<IMG width=10 height=12 src=./pic/arr_s.gif>";
		s+="</TD>\n";
	}
	s+="</TR></TABLE>";
	document.write(s);
}
/*function replaceSpecChar(str){
	var s="";
	var ch;
	for(var i=0;i<str.length;i++){
		ch=str.charAt(i);
		if(ch=='_')s+=' ';
		else if(ch=='!'){s+='&'+Ent[str.substr(i+1,2)]+';';i+=2;}
		else s+=ch;
	}
	return s;
}*/
function replaceSpecChar(str){
	var s="";
	if(str.indexOf('_')>=0){
		var ch;
		for(var i=0;i<str.length;i++){
			ch=str.charAt(i);
			if(ch=='_'){
				s+='&#';
				while((ch=str.charAt(++i))!='_')s+=ch;
				s+=';';
			}else{
				s+=ch;
			}
		}
	}else{
		s = str;
	}
	return s;
}
var msgOK=false;
function checkMessage(){
var msg;
	for(var i=0; i<document.forms[0].elements.length; ++i)
		if(document.forms[0].elements[i].name=="msg_text"){
			msg=document.forms[0].elements[i];
			break;
		}
    if(msg&&msg.value!="")return true;
	alert(msgWarning);
	if(msg)msg.focus();
  return false;
}
function checkContacts(){
	var name;
	var pa_input=document.getElementById("p_addr");
	if(pa_input){
		document.getElementsByName("post_addr")[0].value=encode_utf8(pa_input.value);
		if (pa_input.value!="") return true;
	}	
	for(var i=0; i<document.forms[0].elements.length; ++i)
		if((name=document.forms[0].elements[i].name)){
			if(name=="phone_num"||name=="fax_num"||name=="email"||name=="mobile"||name=="web_page")
				if(document.forms[0].elements[i].value!="")return true;
		}
	alert(contWarning);
	if(pa_input){pa_input.focus();}
  return false;
}
function getExtention(fPath){
	var idx=-1;
	if(fPath.length>0&&(idx=fPath.lastIndexOf('.'))>0){
		return fPath.substring(idx+1,fPath.length);
	}
	return "jpg";//for empty string
}
function formatStr(iStr,sub1,sub2){
	var str=iStr;
	str=str.replace(/sb_1/g,sub1);
	str=str.replace(/sb_2/g,sub2);
	return str;
}
function checkFiles(){
	var num="";
	var ext="";
	var bOK=true;
	var fileObj=document.getElementsByName('photo')[0];
	if(fileObj){
		ext=(getExtention(fileObj.value)).toLowerCase();
		if(!(ext=='jpg'||ext=='jpeg'))bOK=false;
	}
	else{
		for(var i=1;i<=5;i++){
			if(fileObj=document.getElementsByName('photo'+i.toString())[0]){
				ext=(getExtention(fileObj.value)).toLowerCase();
				if(!(ext=='jpg'||ext=='jpeg')){bOK=false;num=i.toString();break;}
			}
		}
	}
	if(!bOK){
		alert(formatStr(fileWarning,num,ext));
//		if(cont){cont.focus()};
	}
  return bOK;
}
function showPreviewFrame(){
	if((msgOK=(checkMessage()&&checkContacts()&&checkFiles()&&checkPrice()))){
		var prevFrm=document.getElementById("prevDiv");
		if(prevFrm){prevFrm.style.display="inline";scrollBy(0,600);return true;}
	}
	return false;
}
function hidePreviewFrame(){
	var prevFrm=document.getElementById("prevDiv");
	if(prevFrm){prevFrm.style.display="none";return true;}
	return false;
}
function restoreSelfTarget(){
	if((msgOK=(checkMessage()&&checkContacts()&&checkFiles()&&checkPrice()))){
 		document.forms[0].target='_self';return true;
	}
	return false;
}
function getBoolParam(parname){
	var par=location.search.substring(1);
	if(par.length != 0){
		var params="";
		if(par.indexOf('&')>=0)params=par.split('&');
		else params=par.split('%26');
		var values=new Array();
		for(var i=0;i<params.length;i++){
			var parts=params[i].split('=');
			values[parts[0]]=unescape(parts[1]);
		}
		var boolval=(parseInt(values[parname]) > 0);
		if(boolval)return true;
	}
	return false;
}

function extractParam(str, parname){
	var par=str.search.substring(1);
	if(par.length != 0){
		var params="";
		if(par.indexOf('&')>=0)params=par.split('&');
		else params=par.split('%26');
		var values=new Array();
		for(var i=0;i<params.length;i++){
			var parts=params[i].split('=');
			values[parts[0]]=unescape(parts[1]);
		}
		if (values[parname]) return values[parname];
		else return "";
	}
	return "";
}
function getStrParam(parname){
	return extractParam(location, parname);
}
function identify(par){
	var s="<TD><INPUT name='"+par+"' value='"+getStrParam(par)+"'></TD>\n";
	document.write(s);
}

