 function imgOverAd(img)
{
	document.mainimg.src = 'UploadFolder/320/' + img.name;
	img.style.cursor = 'hand'; img.style.cursor = 'pointer';
}	

function imgOutAd(img)
{
	img.style.cursor = 'default'; img.style.cursor = 'default';
}

function getPageSizeMenu(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}



function showdiv(maxwidth, maxheight, text, type)
{
        // Types
        // 0 = Get Ad details
        // 1 = Hino

	var arrayPageSize = getPageSizeMenu();

        document.getElementById("overlay").style.height = arrayPageSize[1] + "px";
        document.getElementById("newdiv").style.height = maxheight + "px";
        document.getElementById("newdiv").style.width = maxwidth + "px";
        document.getElementById("newdiv").style.left = 50;
        document.getElementById("newdiv").style.top = 50;
        document.getElementById("newdiv").style.left = ((arrayPageSize[2]/2) - (maxwidth / 2)) + "px";
        document.getElementById("newdiv").style.top = ((arrayPageSize[3]/2) - (maxheight / 2)) + "px";

        if ( type == 0 ) {
	  getad (text, "newdiv", type);
        } else if (type == 1) {
	  getform (text, "newdiv", type);
        }

	// Set Opacity to Zero To Fade-In
	//document.getElementById("newdiv").filters.alpha.opacity = 0;
	//document.getElementById("overlay").filters.alpha.opacity = 0;

        document.getElementById("newdiv").style.visibility = "visible";
        document.getElementById("overlay").style.visibility = "visible";

        // Use These Lines to create Fade-In (Doesnt display with Firefox)
	// show overlay in scripts.old
        //showoverlay(maxwidth, maxheight);

}

function showpht(vehid, output, picture) {
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Your Browser Doesnt Support Ajax!");
    return;
  }
  

  xmlHttp.onreadystatechange=function()
  {
    if(xmlHttp.readyState==4)
    {
      document.getElementById(output).innerHTML=xmlHttp.responseText;
    }
  }
  var url="getpht.asp?id=" + vehid + "&picture=" + picture;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

function canceldiv() {
	document.getElementById("overlay").style.visibility = "hidden";
	document.getElementById("newdiv").style.visibility = "hidden";
	document.getElementById("newdiv").innerHTML = "";
}

function GetXmlHttpObject()
{
  var xmlHttp;
  try
  { //Firefox,Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  { //Internet Explorer
    try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}

function getform(id, output, type)
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Your Browser Doesnt Support Ajax!");
    return;
  }
  

  xmlHttp.onreadystatechange=function()
  {
    if(xmlHttp.readyState==4)
    {
      document.getElementById(output).innerHTML=xmlHttp.responseText;
    }
  }
  var url="getform.asp?id=" + id + "&type=" + type;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

function getad(id, output, type)
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Your Browser Doesnt Support Ajax!");
    return;
  }
  

  xmlHttp.onreadystatechange=function()
  {
    if(xmlHttp.readyState==4)
    {
      document.getElementById(output).innerHTML=xmlHttp.responseText;
    }
  }
  var url="getad.asp?id=" + id + "&type=" + type;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

function emailsubmited () {
  var iframe = document.getElementById("iframesubmit");
  iframe.parentNode.removeChild(iframe);

  var emailhtml = '<p class="emailtext">';
  emailhtml = emailhtml + '<h1 class="ad">Thanks for your email someone will contact you shortly</h1>';
  emailhtml = emailhtml + '<br /><input type="button" onclick="canceldiv();" Value="Close" />';
  emailhtml = emailhtml + '</p>';
  document.getElementById("newdiv").innerHTML = emailhtml;
}
