// JavaScript Document 
function toggleMap(e)  { 
 if (!e)  var e = (window.event);
 var tg = (window.event) ? e.srcElement : e.target;
 var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
 if (reltg.nodeName != 'DIV') return; 
 
 var state = document.getElementById('largemap').style.display;
 if (state == 'block') {
     document.getElementById('largemap').style.display = 'none';    
 } else {
 	 document.getElementById('largemap').style.display = 'block';   
 }	    
 }    
 function toggleMapon() {	
  	 document.getElementById('largemap').style.display = 'block';       
 
 }
 function setColumnHeight() {
	 var div = document.getElementById("main_content");
	 var hgt = div.offsetHeight;	 
	 document.getElementById("sidebar_left").style.height = hgt+'px';
	 document.getElementById("sidebar_right").style.height = hgt+'px';	 
  }
// window.onload = setColumnHeight; 
WindowOnload(setColumnHeight);

function showImage(adid,image,width,height)
{ 	
path = "/ads/showimage.php?adid=" + adid + "&image=" + image;	 
parameters = "toolbar=no,location=no,directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=" + width + ",height=" + height + ", left=20, top=0";
pic_window = window.open(path,'pic_window', parameters)
return;
}

function closeImage()
{
 
	pic_window.close(); 
}	 
sfHover = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("li");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
            this.className+="hover";
        }
        sfEls[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp("hover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);  
	
function fillLocation(form)
	{
 //		form1 = document.postad
  
		area = form.area[form.area.selectedIndex].value;		
		locationObj = form.locationName;	 

		// remove all options from locationName
		locationObj.length = 0;
		locationArray = new Array();
		locationArray = eval(area);
		
		for(x=0;x<locationArray.length;x++)
		{
			locationObj.options[locationObj.length] = new Option(locationArray[x],locationArray[x],true,false)
		}
		if(locationArray.length > 0) {
			locationObj[0].selected = true
		}
	}
function openlargepic(largepic) {
 
  var thing = document.getElementById("t1");
  if( typeof( thing.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; thing; thing = thing.offsetParent ) {
      posX += thing.offsetLeft;
      posY += thing.offsetTop;	  
    } 
	var topOffset = (posY - 315);
 //   return [ posX, posY ];
  } else {
	var topOffset = (thing.x - 315);  
  //   return [ thing.x, thing.y ];
  } 
 document.getElementById(largepic).style.top = topOffset + "px";
 document.getElementById(largepic).style.left = "185px";
 document.getElementById(largepic).style.display = 'block'; 
}
function closelargepic(largepic) {
//	document.write("lp= "+largepic);
	document.getElementById(largepic).style.display = 'none';
}

function WindowOnload(f) {
    var prev=window.onload;
    window.onload=function(){ if(prev)prev(); f(); }
}
 
function init() {
document.getElementsByTagName('input')[0].focus(); 
}
WindowOnload (init);

 
	function showImage(adID,image,width,height)
	{
	 
		path = "/ads/showimage.php?adID=" + adID+ "&image=" + image;

		parameters = "toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=auto, resizable=no, width=" + width + ",height=" + height + ", left=20, top=0";

		window.open(path,'', parameters)
		return;
	}	// function end showImage(adID,image,width,height)

	function allselect(total)
	{
		var formName, a, bb;
		
		formName	=	document.deletephoto;
		if(document.allselectform.select1.checked)
		{
			if(!formName.mainphoto.disabled)
			{
				formName.mainphoto.checked=true;
			}	//	if(!formName.mainphoto.disabled)
			for(var a=1;a<total;a++)
			{

				if(!eval("formName.internalphoto"+a+".disabled"))
				{
					eval("formName.internalphoto"+a+".checked=true");
				}	//	if(!eval("formName.internalphoto"+a+".disabled"))

			}	//	for(var a=1;a<total;a++)
		}	//	if(document.allselectform.select1.checked)
		else
		{
			if(!formName.mainphoto.disabled)
			{
				formName.mainphoto.checked=false;
			}	//	if(!formName.mainphoto.disabled)

			for(var a=1;a<total;a++)
			{

				if(!eval("formName.internalphoto"+a+".disabled"))
				{
					eval("formName.internalphoto"+a+".checked=false");
				}	//	if(!eval("formName.internalphoto"+a+".disabled"))

			}	//	for(var a=1;a<total;a++)

		}	//	if(document.allselectform.select1.checked)  else

	}	// function end allselect(total)

	function checkmain(total)
	{

		if(document.deletephoto.mainphoto.checked)
		{
			for(var a=1;a<total;a++)
			{

				if(!eval("document.deletephoto.internalphoto"+a+".disabled"))
				{
				  if(!eval("document.deletephoto.internalphoto"+a+".checked"))
					{
						alert("Main Photo can't be deleted before Other photos");
						return false;
					}
				}
			}	//	for(var a=1;a<total;a++)
			return true;
		}
		else
		{
			return true;
		}
	}	// function end checkmain()


 
