// JavaScript Document for ExoticAutoBuyer.com Copyright 2007 ExoticAutoBuyer.com Version 1.0 April 10, 2007

// Submit Enter - to allow submitting forms by hitting enter key on a password field.
function submitenter(p_field,p_event) {
var x_key;

if (window.event) {
  x_key = window.event.keyCode;
}
else if (p_event) {
       x_key = p_event.which;
     }
     else {
       return true;
	  }
	  
if (x_key == 13) {
  p_field.form.submit();
  return false;
  } 
else
  return true;
}

/*
* Rollover Function
*/
function swapImage(img, bOn) {
	img.src  = bOn ? img.src.replace(".gif", "_on.gif") : img.src.replace("_on.gif", ".gif");
	
}

/*
* Switches the main image with the medium version of the thumbnail selected
*/
function UpdateMainImage(p_source) {
	document.images["imgMain"].style.visibility = "visible";
	document.images["imgMain"].src = p_source;
}	
	
function UpdateMainImg(idx) {
	document.images["imgMain"].style.visibility = "visible";
	document.images["imgMain"].src = g_arrPreImg[idx-1].src;
}

//Function to delete images from ad_image table
function deleteADImage(ad_id, image_id, termId, flagstatus, flagvalue, makechange){
	var answer=confirm("Warning: Are you sure you want to delete this image?");
	if (answer==true)
	{
		window.location= "placeads2.php?ad_id="+ad_id+"&Delete=yes&deleteID="+image_id+"&termId="+termId+"&"+flagstatus+"="+flagvalue+"&makechange="+makechange;
	}
}

//Function to show URL in window
function showinwindow(href, winname,width, height) {
    t = (screen.height-height)/2;
	l = (screen.width-width)/2;
	pic=window.open(href,winname,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,dependent=no,width='+width+',height='+height+',screenX=0,screenY=0,top='+t+',left='+l);
}

function approvecheck(ad_id)
{
	var answer=confirm("Are you sure you want to approve this ad?");
	if (answer==true)
	{
		window.location= "adDetails.php?ad_id="+ad_id+"&Approve=yes";
	}
}

function declinecheck(ad_id)
{
	var answer=confirm("Are you sure you want to decline this ad?");
	if (answer==true)
	{
		window.location= "adDetails.php?ad_id="+ad_id+"&Decline=yes";
	}
}

function deletead(ad_id)
{
	var answer=confirm("Are you sure you want to delete this ad?");
	if (answer==true)
	{
		window.location= "adDetails.php?ad_id="+ad_id+"&DeleteAd=yes";
	}
}

function makechangecheck(ad_id, termId, flagstatus, flagvalue, adstatus)
{	
	if (adstatus==0)
	{
		window.location= "placeads.php?ad_id="+ad_id+"&termId="+termId+"&editstate=true&makechange=1&"+flagstatus+"="+flagvalue;
	}
	else
	{
		window.location="buyers_edit.php?buyid="+ad_id+"&ad_id="+ad_id+"&r=1";
	}
}

function renewcheck(ad_id, termId)
{	
	window.location= "placeads.php?ad_id="+ad_id+"&termId="+termId+"&editstate=true&Renew=1";
}

/*
function deleteADImage(page_name, delete_name, delete_id, id_name, id){
	var answer=confirm("Warning: Are you sure you want to delete this image?");
	if (answer==true)
	{
		window.location= page_name+"?"+delete_name+"="+ delete_id +"&"+id_name+"="+id;
	}
}*/