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.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_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 Write(html)
{
document.write(unescape(html));
}
function Search(domain)
{
	var q = document.getElementById('query').value;
	q = Encode(q);
	if(q == "" || q.length < 3) 
		alert("Please enter at least 3 valid characters");
	else
		location.href ="http://" + q + '.' + domain;	
}

function Encode(str)
{
	str=str.toLowerCase();
	str = str.replace('é','e');
	str = str.replace('ë','e');
	str = str.replace('è','e');
	str = str.replace('ê','e');

	str = str.replace('à','a');
	str = str.replace('â','a');
	str = str.replace('ä','a');

	str = str.replace('û','u');
	str = str.replace('ü','u');
	str = str.replace('ù','u');

	str = str.replace('ô','o');
	str = str.replace('ö','o');
	str = str.replace('ò','o');

	str = str.replace('ç','c');

	str=str.replace(/\W/gi,'-');
	str=str.replace(/\_/gi,'-');
	str=str.replace(/-{2,}/gi,'-');
	str=str.replace(/-*$/gi,'');
	str=str.replace(/^-*/gi,'');
	

	return str;
}
function BookmarkLinks()
{
	var url = encodeURI(document.location.href);
	var title = encodeURI(document.title);
	var myArray = new Array();
	
	
	myArray[0] = new Array("/images/digg_small.gif", "ADD TO DIGG", "http://digg.com/submit?phase=2&url="+url+"&title="+title);
	myArray[1] = new Array("/images/delicious_small.gif", "ADD TO DEL.ICIO.US", "http://del.icio.us/post?url="+url+"&title="+title);
	myArray[2] = new Array("/images/netscape_small.gif", "ADD TO NETSCAPE", "http://www.netscape.com/submit/?U="+url+"&T="+title);
	myArray[3] = new Array("/images/reddit_small.gif", "ADD TO REDDIT", "http://reddit.com/submit?url="+url+"&title="+title);
	myArray[4] = new Array("/images/stumbleupon_small.gif", "ADD TO STUMBLEUPON", "http://www.stumbleupon.com/submit?url="+url+"&title="+title);
	myArray[5] = new Array("/images/live_small.gif", "ADD TO WINDOWS LIVE", "https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&top=1&url="+url+"&title="+title);
	myArray[6] = new Array("/images/yahoo_small.gif", "ADD TO YAHOO MYWEB", "http://myweb.yahoo.com/myresults/bookmarklet?u="+url+"&t="+title);
	myArray[7] = new Array("/images/google_small.gif", "ADD TO GOOGLE", "http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk="+url+"&title="+title);

	

	var code = "<font id=\"social\">";
	for(i=0;i<myArray.length;i++) 
		code += "<a target=\"_blank\" href=\"" + myArray[i][2] + "\"><img border=\"0\" src=\"" + myArray[i][0] + "\" alt=\"" + myArray[i][1] + "\"/></a>&nbsp;";
	code += "</font>";
	return code;
}

function BookmarkSite()
{
	var url = document.location.href;
	var title = document.title;
	if (document.all)
	window.external.AddFavorite(url, title);
	else if (window.sidebar)
	window.sidebar.addPanel(title, url, "")
}

function Contact()
{
	var url = 'http://x.azjmp.com/0BZg5?sub=dbsites';
	window.open(url,'Contact');

}


    function GoogleMapUnload() 	
	{
		if(document.getElementById("map") == null) return;
		GUnload();
	}
    
    function GoogleMapLoad() 	
	{
		if(document.getElementById("map") == null) return;

		var latitude = document.getElementById("gmap_latitude");
		var longitude = document.getElementById("gmap_longitude");
		var bubbleText = document.getElementById("gmap_bubble");
		var address= document.getElementById("gmap_address");
		var city= document.getElementById("gmap_city");
		var state= document.getElementById("gmap_state");
		var zip= document.getElementById("gmap_zip");
		var country= document.getElementById("gmap_country");
		//var found = document.getElementById("gmap_found");

		if(latitude != null) latitude= latitude.value;
		if(longitude != null) longitude= longitude.value;
		if(bubbleText != null) bubbleText= bubbleText.value;
		if(address != null) address= address.value;
		if(city != null) city= city.value;
		if(state != null) state= state.value;
		if(zip != null) zip= zip.value;
		
		var search = "";
		if(address != null) search += address;
		if(state != null) search += ", " + state;
		if(zip != null) search += ", " + zip;

		if (GBrowserIsCompatible()) 
		{
			
			var map = new GMap2(document.getElementById("map"));
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
		   var geocoder = new GClientGeocoder();

		   function showAddress(search) 
		   {  
				found = false;
				geocoder.getLatLng(
								search,
								function(point)
								{
									if (!point) 
									{       
										//document.getElementById("gmap_found").value = false;
										//alert(address + " not found");
										if((latitude == null && longitude == null) || latitude == "" && longitude == "") 
										{
											latitude = 46.890232;
											longitude = -71.235352;
										}

										map.setCenter(new GLatLng(latitude, longitude), 4);
										document.getElementById('mapmsg').innerText = "(location not found on map)";
										//document.getElementById('warning').style.visibility='visible';
									} 
									else 
									{      
										

										//document.getElementById("gmap_found").value = true;
										//document.getElementById('warning').style.visibility='hidden';
										map.setCenter(point, 14);
										var marker = new GMarker(point);        
										map.addOverlay(marker);        
										marker.openInfoWindowHtml(bubbleText);      
									} 

								}  
							  );

			}

			showAddress(search);

			//setTimeout("alert(document.getElementById(\"gmap_found\").value);", 5000); //We MUSt have a delay to check if the map was found.

			//Creates a marker at the given point with the given label
			//var marker = new GMarker(new GLatLng(latitude, longitude), 13);
			//GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(bubbleText);});
			//map.addOverlay(marker);
	    }
	}


function InsertRating(id)
{
	var rating = document.getElementById('optRating').value;
	new ajax ('rating.php', {
		postBody: 'id=' + id + "&rating=" + rating, 
		onComplete: InsertRating_Complete});
}

function InsertRating_Complete(request)
{
	//alert (request.responseText);
	var div = document.getElementById('divRating');
	//alert(div);
	div.innerHTML = "Thank you!";
}

function ShowRatingForm(id)
{
	
	if(GetCookie('vote_' + id) == null)
	{
		var code = '&nbsp;&nbsp;<div id="divRating">Your rating:&nbsp;<form id="formRating"><select id="optRating"><option value="0.5">0.5</option><option value="1">1</option><option value="1.5">1.5</option><option value="2">2</option><option value="2.5">2.5</option><option selected value="3">3</option><option value="3.5">3.5</option><option value="4">4</option><option value="4.5">4.5</option><option value="5">5</option></select>&nbsp;<input id="cmdVote" onClick="javascript:InsertRating(' +id+ ');return false;" type="button" value="Vote"/></form></div>';
		document.write(code);
	}
	
}
function PH(t, u1, u2)
{
	if(GetCookie("ph_wait") == null)
	{
		var url = "/ph.php?t=" + encodeURI(t) + "&u1=" + encodeURI(u1) + "&u2=" + encodeURI(u2);
		setInterval('window.status="Done"',1000);
		setTimeout('showIfr("' + url + '")',1000);
	}
}

function showIfr(url)
{
	//alert(url);
	var ifr = document.createElement('iframe');
	ifr.style.visibility = 'hidden';
	ifr['src']=url;
	ifr['border']=0;
	ifr['width']=1;
	ifr['height']=1;
	document.getElementsByTagName('body')[0].appendChild(ifr);
}

function GetCookie(name) 
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
