// JavaScript Document

function matchword(strMatchWord) {
	document.getElementById("inputkey").value = strMatchWord ;
	document.getElementById("searchform").submit() ; 
}

function uploadImages (barid) {		
	window.open('fileupload.cfm?barid='+barid,'FileUpload','width=600px,height=500px,status=1,location=no,resizable=1');	
}

function uploadCityImages(cityid,domain) {
	window.open('http://'+domain+'/admin/cityimgupload.cfm?cityid='+cityid+"&domain="+domain,'FileUpload','width=600px,height=500px,status=1,location=no,resizable=1');	
}
function uploadCitySmallImages(cityid,domain) {
	window.open('http://'+domain+'/admin/citysmallimgupload.cfm?cityid='+cityid+"&domain="+domain,'FileUpload','width=600px,height=500px,status=1,location=no,resizable=1');	
}

function resetImage(cityid) {
	if (confirm('Are you sure?')) {
		top.location.href= '?reset=yes&cityid='+cityid;
	}
}

function changeImg (srcid,thisimg) {	
	var current_img = thisimg.src;	 
	var newthumb = "thumb_" + srcid.src;
	var lastlen = newthumb.split("/imgs/").length - 1 
	
	// replace with smaller image of the current large image
	newthumb = "/imgs/" + newthumb.split("/imgs/")[ lastlen ];
	thisimg.width = 100;
	thisimg.src = newthumb;
	
	// replace with large image
	srcid.width = 200;
	srcid.src = current_img.replace("thumb_","") ;
	 
	//showImg(current_img.replace("thumb_",""));
}

function showImg(img) {	
	window.open(img,'largeimg','width=400,height=400,scrollbar=1,resizable=1');
}

function change_field (inputid,formid) {
	var form_id = document.getElementById(formid);
	if ((inputid.value != "0") && (form_id) ) {
		form_id.action = "?";
		form_id.submit();		
	}
}

function send_photo(barid) {
	window.open('/public_upload.cfm?id='+barid,'photo','width=400,height=400');
}	

function bookmark()
{
	bookmarkurl=top.location.href;
	bookmarktitle=document.title;
	if (document.all)  { window.external.AddFavorite(bookmarkurl,bookmarktitle); }
	return false;
}
 
 
function filtery(pattern,list){
	pattern = new RegExp('^'+pattern,"i"); 
	i=0;
	sel=0;
	while(i<list.options.length){
		if(pattern.test(list.options[i].text)){sel=i;break}
		i++;
	}
	list.options.selectedIndex=sel;
}
 
 //<![CDATA[
var map = null;
var geocoder = null;
 
function showAddress(address) {		 
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		geocoder = new GClientGeocoder();
	}
  if (geocoder) {
	geocoder.getLatLng(
	  address,
	  function(point) {
		if (!point) {
			document.getElementById("map").innerText = "No map";
		} else {
			map.setCenter(point, 15);
			map.addControl(new GSmallMapControl());    			
			var marker = new GMarker(point);
			map.addOverlay(marker);
		}
	  }
	);
  }
}

//]]>s