loadingPage = false;
loadingQ = 0;
loadedQ = 0;
var loadingArray = new Array();

//function loadPage(loc) {
//  frames.loader.location=loc;
//}
function loadPage(page){
    document.getElementById('content').innerHTML = '<img src=\'Images/mozilla_blu.gif\' /> Loading...';
    new Ajax.Updater('content', page, {asynchronous:true, evalScripts:true});
}

function veiwImage(img) {
  openwindow
}
function changepic(imgName, photo) {
	directPath = "http://images.eliance.co.za/MT_Images/General/";
	parent.document.a.src = directPath + photo;
}
function initPage() {
  //loadPage('menu');
  //loadPage('content&homepage=1');
}
//function displayContent(loaderDiv, displayDiv) {
  //alert(displayDiv);
//  document.getElementById(displayDiv+'').innerHTML=frames.loader.document.getElementById(loaderDiv+'').innerHTML;
//}
function displayContent(loaderDiv, displayDiv) {
  //alert(displayDiv+loaderDiv);
  document.getElementById(displayDiv+'').innerHTML=document.getElementById(loaderDiv+'').innerHTML;
  document.getElementById(loaderDiv+'').innerHTML="";
}

// search jump to function for ajax drop down boxes.
function submitVehicleSearch(){
    //alert(document.SearchForm.sWebsiteUrl.value);
    //parent.document.SearchForm.action = parent.document.SearchForm.sWebsiteUrl.value +'?ipkCategoryID=0';
    myUrl = document.SearchForm.sWebsiteUrl.value +"/default.asp?ipkWebsiteID="+document.SearchForm.ifkGoToWebsiteID.value+"&load=vehicleSearch&ipkVehicleMakeID="+document.SearchForm.ipkVehicleMakeID.value+"&ipkVehicleSeriesID="+document.SearchForm.ipkVehicleSeriesID.value+"&ipkVehicleTypeID="+document.SearchForm.ipkVehicleTypeID.value
    document.SearchForm.action = myUrl; //"default.asp?topLevel=1&ipkWebsiteID=<%= session("ipkWebsiteID") %>&load=vehicleSearch&ipkCategoryID=0"; //ipkCategoryID=0";
    document.SearchForm.submit();
}
/*
function submitVehicleSearch(){
    //alert(parent.document.SearchForm.sWebsiteUrl.value);
    //parent.document.SearchForm.action = parent.document.SearchForm.sWebsiteUrl.value +'?ipkCategoryID=0';
    document.SearchForm.action = "default.asp?topLevel=1&load=vehicleSearch&ipkCategoryID=0";
    document.SearchForm.submit();
}*/


function displayMenu(menuName, displayDiv,ipkCategoryID){
    document.getElementById(displayDiv+'').innerHTML = '<img src=\'Images/mozilla_blu.gif\' /> Loading...';
    new Ajax.Updater(displayDiv+'','menus/'+ menuName+'.asp?ipkCategoryID='+ipkCategoryID, {asynchronous:true, evalScripts:true});
}

function displayCart(sessionID)
{
  document.getElementById('cart').innerHTML = '<img src=\'Images/mozilla_blu.gif\' /> Loading...';
  new Ajax.Updater('cart','menus/cart.asp?ipkSessionID='+sessionID, {asynchronous:true, evalScripts:true});
}

function viewImage(img) {
	sURL = "asp/viewImage.asp?img="+img;
	ID = "viewImage";
	t = window.open(sURL, ID);
	t.focus();
}

function changeMeta(desc,keys) {
  mTags = document.getElementsByTagName("meta");
  for( var i = 0; i < mTags.length; i++ ) {
    if( mTags[i].getAttribute("name") == "description" ) {
      mTags[i].setAttribute("content", desc);
    }
    if( mTags[i].getAttribute("name") == "keywords" ) {
      mTags[i].setAttribute("content", keys);
    }
  }
}

function clicked0(obj){if (obj.cells[0].children[0]){if (obj.cells[0].children[0].tagName == "A"){location.href = obj.cells[0].children[0].href;}}}

function checkEvent() {
  with (document.dateForm) {
    if (dTheMonth.value == '') {
      alert('Please select month');
      dTheMonth.focus;
      return false;
    }
    if (dTheYear.value == '') {
      alert('Please select year');
      dTheYear.focus;
      return false;
    }
    return true;
  }
}

// ajax populate important form fileds
function PopulateHiddenID(aform,afield,aValue){
	theField = eval("document."+aform+"."+afield);
	theField.value = aValue;
	//alert(theField.value);
}






var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
d.style.left = (cX+400) + "px";
d.style.top = (cY-200) + "px";
}
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}
