//chart

var zoomin = true;
var zoom = 1;
var xpos;
var ypos;
var xmin;
var xmax;
var ymin;
var ymax;
var info = new Array();
var temp = 0;
var imagecheck = 0;
var searchid = 0;
var cat=-1;
var companys;
var compinfo = new Array();
var showstreet = true;
var streetchoice = "all";
var streets;
var streetsearch =0;
var showchoices = new Array();

var showspot = true;
var spotchoice = "all";
var spots;
//var streetsearch =0;
var showspotchoices = new Array();

//var showlength=0;

function getimageinfo (name){// get zoom, x, y from imagename
try{
	////alert(name);
pos = name.indexOf("curacao-");
////alert(pos);
name = name.substr(pos+8); 
////alert(name);
zoom = parseInt(name.substr(0,1));
name = name.substr(3);
ypos = name.substr(0,name.indexOf("_"));
name = name.substr(name.indexOf("_")+2);
xpos = name.substr(0,name.indexOf("."));
xpos = parseInt(xpos);
ypos= parseInt(ypos);
}catch(e){}

	
}


function navigate(x,y){// navigate through the map   x = -1,0,1/ y=-1,0,1


var name = 	document.all("1").src; 
getimageinfo (name);


ypos = ypos+y;
xpos = xpos+x;

ypos = nexty(ypos);
xpos=  nextx(xpos);



	writemap(xpos,ypos);
	
	
	if(zoom>1){
	
	findedges();	
	
	}


}
function writemap(xpos,ypos){// write the images to the table  xpos = images column / ypos= images row
Imagecheck =0;
//if(xpos<1){xpos=1;}
//if(ypos<1){ypos=1;}
//if(xpos>16){xpos=16;}
//if(ypos>13){ypos=13;}

document.all("1").style.filter = 'alpha(opacity=50)';
document.all("2").style.filter = 'alpha(opacity=50)';
document.all("3").style.filter = 'alpha(opacity=50)';
document.all("4").style.filter = 'alpha(opacity=50)';
document.all("5").style.filter = 'alpha(opacity=50)';
document.all("6").style.filter = 'alpha(opacity=50)';
document.all("7").style.filter = 'alpha(opacity=50)';
document.all("8").style.filter = 'alpha(opacity=50)';
document.all("9").style.filter = 'alpha(opacity=50)';

	image01 = new Image();
	image02 = new Image();
	image03 = new Image();
	image04 = new Image();
	image05 = new Image();
	image06 = new Image();
	image07 = new Image();
	image08 = new Image();
	image09 = new Image();

	

image01.src = "../chart/maps/curacao/level"+zoom+"/curacao-"+zoom+"_r"+ypos+"_c"+xpos+".jpg";
image02.src = "../chart/maps/curacao/level"+zoom+"/curacao-"+zoom+"_r"+ypos+"_c"+(xpos+1)+".jpg";
image03.src = "../chart/maps/curacao/level"+zoom+"/curacao-"+zoom+"_r"+ypos+"_c"+(xpos+2)+".jpg";
image04.src = "../chart/maps/curacao/level"+zoom+"/curacao-"+zoom+"_r"+(ypos+1)+"_c"+xpos+".jpg";
image05.src = "../chart/maps/curacao/level"+zoom+"/curacao-"+zoom+"_r"+(ypos+1)+"_c"+(xpos+1)+".jpg";
image06.src = "../chart/maps/curacao/level"+zoom+"/curacao-"+zoom+"_r"+(ypos+1)+"_c"+(xpos+2)+".jpg";
image07.src = "../chart/maps/curacao/level"+zoom+"/curacao-"+zoom+"_r"+(ypos+2)+"_c"+xpos+".jpg";
image08.src = "../chart/maps/curacao/level"+zoom+"/curacao-"+zoom+"_r"+(ypos+2)+"_c"+(xpos+1)+".jpg";
image09.src = "../chart/maps/curacao/level"+zoom+"/curacao-"+zoom+"_r"+(ypos+2)+"_c"+(xpos+2)+".jpg";

//do{}
//while(!image01.complete || !image02.complete || !image03.complete || !image04.complete || !image05.complete || !image06.complete || !image07.complete || !image08.complete || !image09.complete)


document.all("1").src = image01.src;
document.all("2").src = image02.src;
document.all("3").src = image03.src;

document.all("4").src = image04.src;
document.all("5").src = image05.src;
document.all("6").src = image06.src;

document.all("7").src = image07.src;
document.all("8").src = image08.src;
document.all("9").src = image09.src;
document.getElementById('companylayer').innerHTML="";
document.getElementById('streets').innerHTML="";
document.getElementById('spots').innerHTML="";

	findedges();
	imgname = document.all("1").src;
	pos = imgname.indexOf("curacao-");
////alert(pos);
  imgname = imgname.substr(pos); 

	findme(xmin,xmax,ymin,ymax,imgname );



}
function checkall(){
	
	imagecheck = imagecheck + 1;
	if(imagecheck==9){
document.all("1").style.filter = 'alpha(opacity=100)';
document.all("2").style.filter = 'alpha(opacity=100)';
document.all("3").style.filter = 'alpha(opacity=100)';
document.all("4").style.filter = 'alpha(opacity=100)';
document.all("5").style.filter = 'alpha(opacity=100)';
document.all("6").style.filter = 'alpha(opacity=100)';
document.all("7").style.filter = 'alpha(opacity=100)';
document.all("8").style.filter = 'alpha(opacity=100)';
document.all("9").style.filter = 'alpha(opacity=100)';

	imagecheck = 0;
	}
}

function clearopacity(){

imagecheck=0;
document.all("1").style.filter = 'alpha(opacity=50)';
document.all("2").style.filter = 'alpha(opacity=50)';
document.all("3").style.filter = 'alpha(opacity=50)';
document.all("4").style.filter = 'alpha(opacity=50)';
document.all("5").style.filter = 'alpha(opacity=50)';
document.all("6").style.filter = 'alpha(opacity=50)';
document.all("7").style.filter = 'alpha(opacity=50)';
document.all("8").style.filter = 'alpha(opacity=50)';
document.all("9").style.filter = 'alpha(opacity=50)';

	
}
function nexty (y){// checks if map (yref) is on edges and corrects y= image row

	switch(zoom){
		case 1:

			if (y<1){

				y=1;
			}
			if(y>6){// max down


				y=6;
			}
			break;	
		case 2:
			if (y<1){
				y=1;
			}
		if(y>20){
			y=20;
		}	
		break;
		case 3:
		if (y<6){
			y=6;
		}
		if(y>62){
			y=62;
		}	
		break;
	}

	return y;
}
function nextx (x){// checks if map (xref) is on edges and corrects x= image column

	switch (zoom){
		case 1:
			if(x<1){
				x=1;
			}
			if (x>5){// max rechts
				x=5;
			}
			break;
	case 2:
		if(x<1){
			x=1;
		}
		if (x>17){
			x=17;
		}
		break;
	
	case 3:
		if(x<7){
			x=7;
		}
		if (x>52){
			x=52;
		}
		break;
	}

	return x;
}

function zoomit(sender){ // zooms in or out cf zoomin bool (true=+ false=-) sender = clicked object

nozoom = true;
if(sender.src){

var name = 	sender.src; 

} else {
var name = sender;
}

getimageinfo(name);

if(zoomin == true){
	if((zoom+1)<=3){
		zoom = zoom+1;
		nozoom=false;
	} else {
		zoom=zoom-1;
		zoomin=false;
		nozoom = false;
	} 
	} else if(zoomin == false){
			if((zoom-1)>1){
				zoom = zoom-1;
				nozoom=false;
			}else if(!sender.src && (zoom-1)>0){
				zoom = zoom-1;
				nozoom=false;
			}else {
				zoom=zoom+1;
				zoomin=true;
				nozoom = false;
			}
}






if(nozoom==false && zoomin==true){
ypos = (ypos*3)-2;
xpos = (xpos*3)-2;
} else if(nozoom==false && zoomin == false){
ypos = Math.floor(parseInt(ypos)/3);
xpos = Math.floor(parseInt(xpos)/3);
}

ypos = nexty (ypos);
xpos = nextx (xpos);

if(nozoom==false){

writemap(xpos,ypos);

}
	//////alert(sender.src);
document.all("level").innerHTML = zoom;
}

function findedges(){// checks the upper/lower y coord and left/right x coord 126 width image 96 height image
	if (zoom==1){zm=9;}
	if (zoom==2){zm=3;}
	if (zoom==3){zm=1;}
	

	xmin = zm *(xpos*126-126);
	xmax = zm * ((xpos + 2)* 126)-20;
	ymin = zm *(ypos*96-96);
	ymax = zm * ((ypos+2)*96)-20;


	
}




function zin(){

zoomin = true;
if(zoom==3){
document.all("level").innerHTML = "Lowest";
} else {

zoomit(document.all("5").src);
}
}
function zout(){

zoomin = false;
if(zoom==1){
document.all("level").innerHTML = "Highest";
} else {
zoomit(document.all("5").src);
}
}


function findme(minx,maxx,miny,maxy,startimage){

document.all("loading").style.visibility = "visible";
//document.getElementById('housesdiv').innerHTML = '<center><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p class="loading"><strong>Loading real estate...</strong></p><center>';

request = false;
try{
	request = new HttpRequest();
	} catch (trymicrosoft) {
		try{
		request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (tryothermicrosoft){
		try{
		request= new ActiveXObject("microsoft.XMLHTTP");
		} catch(failed){
		request=false;
		}
	}
}
if(!request){
//alert("Fatel Error");

}

timenow = new Date();
now = Math.round(100*Math.random())*timenow.getUTCMilliseconds();



uri="find.php?xmin="+minx+"&xmax="+maxx+"&ymin="+miny+"&ymax="+maxy+"&startimage="+startimage+"&sesid="+now;
//alert(uri);

request.open("GET", uri, true);
request.onreadystatechange = foundsloaded;
request.send(null);

}

function foundsloaded () {

	if(request.readyState==4 && request.status==200){
		//alert(request.responseText);
		 
		  
		infodoc = request.responseText;
		parts = infodoc.split("</part>");
		companys = parts[0].split("<company>");
		//alert(parts[1]);
		route = parts[1].split("<route>");
		////alert(route);
		//routes = route.split("<route>");
		streets = parts[2].split("<street>");
		spots = parts[3].split("<spot>");
		
		//alert(spots);
		
		
		////alert(route);
		//alert(companys);
		showcompanys(companys);
		showroutes(route);
		showstreets(streets);
		showspots(spots);
		document.all("loading").style.visibility = "hidden";

	}
}




function showspots (spotlist){

for(var x in spotlist){
			if(spotlist[x]!=""){
				var spot = spotlist[x].split("<col>");			
				var spotid = spot[1];
				var spotposx = xmatchpostolevel(spot[2]);
				var spotposy = ymatchpostolevel(spot[3]);
				var spottype = spot[4];
				var spotlevel =spot[5];
				var spotname =spot[6];
				var spotimage =spot[7];
				var spotlayer =spot[8];
				
				
				//alert (spot[5]);
				// id layer is streets
			//	alert(streetname);
				//if(spotsearch == spotname){
					//		document.getElementById('spots').innerHTML += '<div class="spotsearch" id="'+spotname+'" style="position:absolute; top:'+(spotposy)+'; left:'+spotposx+'; z-index:-1; background:">'+spotname+'</div';
		//	}
				
				
					
					
					for(var x=0;x<showspotchoices.length;x++){//the spot kinds choice in spot menu
						//alert(showspotchoices[x]);
						if(showspotchoices[x]==spottype && !document.getElementById("spot"+spotid)){
							if(spotlayer!="false"){
							//alert(showspotchoices[x]+"/"+spottype)
						document.getElementById('spots').innerHTML += '<div class="spot" id="spot'+spotid+'" style="position:absolute; top:'+(spotposy)+'; left:'+spotposx+'; z-index:-1; background:"><img src="'+spotimage+'" border=0 width="15" height="15" alt="'+spotname+'\n\nClick for more info"  onClick="showspotinfo('+"'"+spotlayer+"'"+')" ></div>';
						} else {
						
						document.getElementById('spots').innerHTML += '<div class="spot" id="spot'+spotid+'" style="position:absolute; top:'+(spotposy)+'; left:'+spotposx+'; z-index:-1; background:"><img src="'+spotimage+'" border=0 width="15" height="15" alt="'+spotname+'"  ></div>';
						}
						}
					}
					//alert(document.getElementById(spotid));
					if(zoom>=spotlevel && !document.getElementById("spot"+spotid)){
							if(spotlayer!="false"){
							//alert(spotlevel);
						document.getElementById('spots').innerHTML += '<div class="spot" id="spot'+spotid+'" style="position:absolute; top:'+(spotposy)+'; left:'+spotposx+'; z-index:-1; background:"><img src="'+spotimage+'" border=0 width="15" height="15" alt="'+spotname+'\n\nClick for more info"  onClick="showspotinfo('+"'"+spotlayer+"'"+')" ></div>';
						} else {
						
						document.getElementById('spots').innerHTML += '<div class="spot" id="spot'+spotid+'" style="position:absolute; top:'+(spotposy)+'; left:'+spotposx+'; z-index:-1; background:"><img src="'+spotimage+'" border=0 width="15" height="15" alt="'+spotname+'"  ></div>';
						}
						
						
					}
					
				}
			}
//alert(document.getElementById('spots').innerHTML);
}

function showstreets (streetlist){

for(var x in streetlist){
			if(streetlist[x]!=""){
				var street = streetlist[x].split("<col>");			
				var streetname = street[1];
				var streetposx = xmatchpostolevel(street[2]);
				var streetposy = ymatchpostolevel(street[3]);
				var streettype = street[4];
				var streetlevel =street[5];
				//alert (street[1]);
				// id layer is streets
			//	alert(streetname);
				if(streetsearch == streetname){
							document.getElementById('streets').innerHTML += '<div class="streetsearch" id="'+streetname+'" style="position:absolute; top:'+(streetposy)+'; left:'+streetposx+'; z-index:-1;filter:alpha(opacity=75); background:ffffff"><img src="images/flag.gif" width=15 height=15 border=0>'+streetname+'</div';
			}
				
				
					
					
					for(var x=0;x<showchoices.length;x++){//the street kinds choice in street menu
						if(showchoices[x]==streettype && !document.getElementById(streetname)){
							document.getElementById('streets').innerHTML += '<div id="'+streetname+'" style="position:absolute; top:'+(streetposy)+'; left:'+streetposx+'; z-index:-1; background:"><table><tr><td class="road'+x+'" >'+streetname+'</td></tr></table></div>';
						
						}
					}
					
					if(zoom>=streetlevel && !document.getElementById(streetname)){
							
						document.getElementById('streets').innerHTML += '<div class="street" id="'+streetname+'" style="position:absolute; top:'+(streetposy)+'; left:'+streetposx+'; z-index:-1; background:">'+streetname+'</div>';
						
					}
					
				}
			}
//alert(document.getElementById('streets').innerHTML);
}

function showroutes(routelist){
	
	for(var x in routelist){
			if(routelist[x]!=""){
				
				var line = routelist[x].split("<col>");
				
				var linename = line[1];
				var linepos = line[2];
				var lineimg = line[3];
				var linecolor = line[4];
				var colors = linecolor.split("/");
				////alert(linecolor);
				var lines = linepos.split("-");
				////alert(lines);
				imageline = new Image();
				var imagename = "route.php?image=../chart/maps/curacao/level"+zoom+"/"+lineimg;
					
				for(var y in lines){
				   var positions = lines[y].split("/");
				  var colornr = colors[y].split(",");
				  
				   imagename = imagename + "&xi["+y+"]="+positions[0]+"&yi["+y+"]="+positions[1]+"&xo["+y+"]="+positions[2]+"&yo["+y+"]="+positions[3]+"&c1["+y+"]="+colornr[0]+"&c2["+y+"]="+colornr[1]+"&c3["+y+"]="+colornr[2];
					////alert(imagename);
					}
			////alert(imagename);
			
				imageline.src = imagename+"&lines="+(parseInt(y)+1);
				////alert("http://www.curacaohome.com/chartjs/route.php?image=../chart/maps/willemstad/level1/downtown_1_r2_c3.jpg&xi[0]=10&yi[0]=10&xo[0]=70&yo[0]=60&c1[0]=0&c2[0]=0&c3[0]=0&xi[1]=20&yi[1]=40&xo[1]=100&yo[1]=160&c1[1]=0&c2[1]=0&c3[1]=0&lines=2");
				//document.all("1").src=imageline.src
				for(var i=1;i<=9;i++){
					var curimg=document.all(""+i).src;
					pos = curimg.indexOf("curacao-");
					////alert(pos);
					curimg = curimg.substr(pos); 
					if(curimg==lineimg){
					////alert(imageline.src);
					document.all(""+i).src= imageline.src;
					}
					
				}
				
			}		

		}	
}

function compinformation (idcomp,xcomp,ycomp,fullnamecomp,iconcomp,namecomp,addresscomp,phonecomp,faxcomp,mobtelcomp,emailcomp,catcomp,logosmallcomp,linkcomp,urlcomp,menucomp,varlinkcomp, variconcomp,classifiedscomp,auctioncomp,couponcomp,layerlink, level,gallerycomp){


				this.id = idcomp;
				this.x = xmatchpostolevel(xcomp);
				this.y = ymatchpostolevel(ycomp);
				this.fullname = fullnamecomp.replace(/\n/,'<br>');
				this.icon = iconcomp;
				this.name = namecomp.replace(/\n/,'<br>');
				this.address = addresscomp.replace(/\n/,'<br>');
				if(phonecomp==""){phonecomp="-";}
				this.phone = phonecomp.replace(/\n/,'<br>');
				if(faxcomp==""){faxcomp="-";}
				this.fax = faxcomp;
				if(mobtelcomp==""){mobtelcomp="-";}
				this.mobtel = mobtelcomp;
				if(emailcomp==""){emailcomp="-";}
				this.email = emailcomp;
				
				this.cat = catcomp.replace(/\<cat\>/gi,'<br>');;
				if(logosmallcomp==""){logosmallcomp="false";}
				
				this.logosmall = logosmallcomp;
				this.infopage = linkcomp;
				if(urlcomp==""){urlcomp="-";}
				this.url = urlcomp;
				this.menu = menucomp;
				this.varlink = varlinkcomp;
				this.varicon = variconcomp;
				this.classifieds = classifiedscomp;
				this.auction = auctioncomp;
				this.coupon = couponcomp;
				this.layerlink = layerlink;
				this.level = level;
				this.gallery = gallerycomp;
                
}
function showcompanys(companylist){
	
	
		////alert(companys.lenght);
		for(var x in companys){
			if(companys[x]!=""){
				////alert(companys[x]);
				
				//document.getElementById('companylayer').innerHTML += companys[x]+"<br>";
				var comp = companys[x].split("<col>");
				
				////alert(comp[16]);
				var idcomp = comp[1];
				var xcomp = xmatchpostolevel(comp[2]);
				var ycomp = ymatchpostolevel(comp[3]);
				var fullnamecomp = comp[4].replace(/<br>/,'\n');
				var iconcomp = comp[5];
				var namecomp = comp[6].replace(/<br>/,'\n');
				var addresscomp = comp[7].replace(/<br>/,'\n');
				var phonecomp = comp[8].replace(/<br>/,'\n');
				var faxcomp = comp[9];
				var mobtelcomp = comp[10];
				var emailcomp = comp[11];
				var catcomp = comp[12];
				var logosmallcomp = comp[13];		
				var linkcomp = comp[14];
				var urlcomp = comp[15];
				var menucomp = comp[16];
				var varlinkcomp = comp[17];
				var variconcomp = comp[18];
				var classifiedscomp = comp[19];
				var auctioncomp = comp[20];
				var couponcomp = comp[21];
				var layerlink = comp[22];
				var level = comp[23];
				var gallerycomp = comp[24];

				//alert(layerlink);
				compinfo[idcomp] = new compinformation (idcomp,xcomp,ycomp,fullnamecomp,iconcomp,namecomp,addresscomp,phonecomp,faxcomp,mobtelcomp,emailcomp,catcomp,logosmallcomp,linkcomp,urlcomp,menucomp,varlinkcomp, variconcomp,classifiedscomp,auctioncomp,couponcomp,layerlink, level,gallerycomp);
				//alert(searchid+"/"+idcomp);
				if(level==""){level=4;}
				if(zoom>=level || idcomp==searchid || catcomp.indexOf(cat)>=0){
				
				if(searchid>0 && idcomp==searchid){
				
				//alert(searchid+"/"+fullnamecomp);
				document.getElementById('companylayer').innerHTML += '<div class="flag"  onClick="showcompinfo('+idcomp+')" id=comp'+idcomp+' style="position:absolute; top:'+(ycomp)+'; left:'+xcomp+'; z-index:100; cursor:hand; background:#FFFFFF"><img src="images/flag.gif" width="15" height="15"  id="iconimg" alt="'+fullnamecomp+"\n"+addresscomp+'\n'+phonecomp+'\n\nClick for more info" />'+fullnamecomp+'</div';
			//		//alert(document.getElementById('companylayer').innerHTML);
					} else if (catcomp.indexOf(cat)>=0){
					document.getElementById('companylayer').innerHTML += '<div class="cat" id=comp'+idcomp+' style="position:absolute; top:'+(ycomp)+'; left:'+xcomp+'; z-index:100; cursor:hand; background:"><img src="images/point.gif" width="10" height="10" onClick="showcompinfo('+idcomp+')" id="iconimg" alt="'+fullnamecomp+"\n"+addresscomp+'\n'+phonecomp+'\n\nClick for more info" />'+namecomp+'</div';
					////alert(catcomp.indexOf(cat)+"-"+cat+"-"+catcomp);
					} else{
					//alert(iconcomp);
					document.getElementById('companylayer').innerHTML += '<div id=comp'+idcomp+' style="position:absolute; top:'+ycomp+'; left:'+xcomp+'; z-index:2; cursor:hand; background:"><img src="'+iconcomp+'" width="10" height="10" onClick="showcompinfo('+idcomp+')" id="iconimg" alt="'+fullnamecomp+"\n"+addresscomp+'\n'+phonecomp+'\n\nClick for more info" />'+namecomp+'</div';
						}
						
						
					} 
								
			}
		}
	
	
	
}


function xmatchpostolevel(posx){

if(zoom==1){

return Math.floor((posx/9)-xmin/9);
}
if(zoom==2){
	
return Math.floor((posx/3)-xmin/3);
}
if(zoom==3){
	
return posx-xmin;

}


}
function ymatchpostolevel(posy){

if(zoom==1){
return Math.floor((posy/9)-ymin/9);
}
if(zoom==2){
return Math.floor((posy/3)-ymin/3);
}
if(zoom==3){
return posy-ymin;

}


}

function showspotinfo(layerlink){
//alert(id);
document.all("spotinfo").innerHTML='<iframe src="spotlink/'+layerlink+'" width=382 height=270 frameborder=0></iframe>';
document.all("spotinfomaster").style.visibility = "visible";

}

function showcompinfo(id){
//	alert(compinfo[id].layerlink)
if(compinfo[id].layerlink!='false'){
	//alert(document.all("compinfo").height382 294);
document.all("layerinfo").innerHTML='<iframe src="layerlink'+compinfo[id].layerlink+'" width=382 height=294 frameborder=0></iframe>';//"<ifame src='../"+compinfo[id].layerlink+"'></ifame>";	
//alert(document.all("compinfo").innerHTML);
document.all("layerinfo").style.overflowX = "hidden";


document.all("layerinfo").style.visibility = "visible";
document.all("compinfomenu").style.visibility = "visible";
return;
}
	
////alert(compinfo[id].fullname);
document.all("compid").value = id;
////alert(document.all("compid").value);
if(compinfo[id].logosmall=="false"){
document.all("logo").innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="382" height="77"><param name="movie" value="images/en_top.swf"><param name=quality value=high><embed src="images/en_top.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="380" height="77"></embed></object>';
} else {

document.all("logo").innerHTML = "<center><img src='../images/logo/"+compinfo[id].logosmall+"'/ width='365' alt='"+compinfo[id].fullname+"'></center>";

}

document.all("name").innerHTML = "<br>"+compinfo[id].fullname;
document.all("address").innerHTML = compinfo[id].address+"<br>";
document.all("tel").innerHTML = compinfo[id].phone;
document.all("mobile").innerHTML = compinfo[id].mobtel;
document.all("fax").innerHTML = compinfo[id].fax;
if(compinfo[id].email!="-"){
//document.all("email").innerHTML = "<a href='mailto:"+compinfo[id].email+"'><img src='../images/icons/_email.gif' width=32 height=32 border=0></a>";
document.all("email").innerHTML = "<a href ='../contacter/index.php?id="+compinfo[id].id+"' target='_blank'><img src='../images/icons/_email.gif' width='32' hight='32' border='0' alt='Email: "+compinfo[id].email+"'></img></a>";


} else{
document.all("email").innerHTML = "";
}

if(compinfo[id].url!="-"){
document.all("website").innerHTML = "<a href='http://"+compinfo[id].url+"' target=_blank ><img src='../images/icons/internet_explore1.gif' width=33 height=32 border=0 alt='Url: "+compinfo[id].url+"'></a>";
} else{
document.all("website").innerHTML = "";
}
if (compinfo[id].gallery!=""){
document.all("fotopage").innerHTML += "<a href = '../fotobook/index.php?company="+compinfo[id].gallery+"' target=main><img src='../images/icons/camera_32.gif' width=32 height=32 border=0></a>";
}
document.all("catagory").innerHTML = compinfo[id].cat;

document.all("extra").innerHTML = "<br>";
////alert(compinfo[id].varicon);
if(compinfo[id].varicon!="false"){
document.all("extra").innerHTML += "<a href='"+compinfo[id].varlink+"' target=mainFrame><img src='../images/var/"+compinfo[id].varicon+"' border='0'></a>";
}
if(compinfo[id].menu!="false"){
document.all("extra").innerHTML += "<a href='"+compinfo[id].menu+"'><img src='../images/var/menu.gif' border='0'></a>";
}
if(compinfo[id].auction!=""){
document.all("extra").innerHTML +='<a href = "../Auction/APSearch.asp?cmd=SEARCH&searchname='+compinfo[id].auction+'" target = _self><img src="../images/icons/shopping-cart_32_hot.gif" border="0" width = "32" height = "32" alt="Auction"></img></a>';
}		
if(compinfo[id].classifieds!=""){
document.all("extra").innerHTML +='<a href = "../Classifieds/CPSearch.asp?cmd=SEARCH&searchname='+compinfo[id].classifieds+'" target = _self><img src="../images/icons/bulletin_board_32.gif" border="0" width = "32" height = "32" alt="Auction"></img></a>';
}		
if(compinfo[id].infopage!=""){
document.all("extra").innerHTML += "<a href = '../chart/print_info.php?comp="+document.all("compid").value+"&lang=us' target=main><img src='../images/icons/info_32_hot.gif'  border='0'></a>";
}		
//if(compinfo[id].infopage!=""){
document.all("exinfo").innerHTML = "<a href = '../print_company_info.php?comp="+compinfo[id].id+"&lang=us' target=_blank><img src='../images/control/printer.gif' width='16' height='16' border='0' alt='print'></a>";
//}

//if(document.all("compinfo").clientHeight<document.all("compinfo").scrollHeight){
//document.all("logo").innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="365" height="70"><param name="movie" value="images/en_top.swf"><param name=quality value=high><embed src="images/en_top.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="365" height="70"></embed></object>';

//}
document.all("compinfo").style.overflowX = "hidden";


document.all("compinfo").style.visibility = "visible";
document.all("compinfomenu").style.visibility = "visible";


}

function searchdb(data, type){


document.all("searchoptionsmenu").style.visibility = "hidden";
document.all("completter").style.visibility = "hidden";
document.all("streetletter").style.visibility = "hidden";
document.all("catletter").style.visibility = "hidden";
document.all("searchtabel").style.visibility = "visible";
document.all("searchloading").innerHTML ="<center><br><br><br>One Moment Please<br><br>Searching: "+data+"</center>";
document.all("closetxt").style.visibility = "visible";

//alert('');
request = false;
try{
	request = new HttpRequest();
	} catch (trymicrosoft) {
		try{
		request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (tryothermicrosoft){
		try{
		request= new ActiveXObject("microsoft.XMLHTTP");
		} catch(failed){
		request=false;
		}
	}
}
if(!request){
alert("Fatel Error");

}

timenow = new Date();
now = Math.round(15651*Math.random())*timenow.getUTCMilliseconds();



uri="search.php?data="+data+"&type="+type;
////alert(uri);

request.open("GET", uri, true);
request.onreadystatechange = searchloaded;
request.send(null);



}
function searchloaded(){
	
	if(request.readyState==4 && request.status==200){
	document.all("compinfo").style.visibility = "hidden";
	document.all("compinfomenu").style.visibility = "hidden";
	//document.all("logo").innerHTML = "";

	 document.all("searchloading").innerHTML ="";
		//alert(request.responseText);
		var data = request.responseText;
		document.all("searchloading").innerHTML =data;
		document.all("searchloading").innerHTML +="<img src='../chart/images/control/close.jpg' align='right' onClick='closesearch()'>";;
		
		//+document.all("searchloading").innerHTML;
		
	
		//alert(document.all("searchloading").innerHTML);
	}
}
function closesearch(){
//document.all("searchloading").style.visibility = "hidden";
document.all("compinfo").style.visibility = "hidden";
	document.all("compinfomenu").style.visibility = "hidden";
	document.all("searchloading").innerHTML ="";
	document.all("searchtabel").style.visibility = "hidden";

	
	
}

function submittext(e,text){
if(e.keyCode ==13){
    searchdb(text,'freetxt');
	 }
 	}

function showclick(showid,showvalue){

if(document.getElementById(showid).checked == true){
	showchoices[showid.substr(4)]=showvalue;
} else {
	showchoices[showid.substr(4)] = 'false';
}
//alert(showchoices.length);
//alert(showid.substr(4));
//alert(showid);
//alert(showvalue);
//alert(showchoices[showid.substr(4)]);
navigate(0,0);
}
function showspotsmenu(showid,showvalue){

if(document.getElementById(showid).checked == true){
	showspotchoices[showid.substr(8)]=showvalue;
} else {
	showspotchoices[showid.substr(8)] = 'false';
}

//alert(showchoices.length);
//alert(showid.substr(4));
//alert(showid);
//alert(showvalue);
//alert(showchoices[showid.substr(4)]);
navigate(0,0);//alert(showid.substr(8));

}

function showall(){
if(document.getElementById("allhide").innerHTML=='Show all'){
	document.getElementById("allhide").innerHTML='Hide all';
	
	for(x=0;x<showchoices.length;x++){
	//showchoices["show"+x]=
	document.getElementById("show"+x).checked=true;
	showchoices[x]=document.getElementById("show"+x).value;
	//alert(showchoices[x]);

}	
	
	
} else{
	//alert(document.getElementById("allhide").innerHTML);
	document.getElementById("allhide").innerHTML='Show all';
	for(x=0;x<showchoices.length;x++){
	//showchoices["show"+x]=
	document.getElementById("show"+x).checked=false;
	showchoices[x]="false";
	//alert(showchoices["show"+x]);
	}
	
}
//alert(showlength);

	navigate(0,0);
}

