// JavaScript Document


<!--DIV SCROLL-->
var timer;
function scrollY(eyeD, ext){
	timer=setInterval(function(){ 
	document.getElementById(eyeD).scrollTop += ext 
	},1);
}

function scrollX(eyeD, ext){
	timer=setInterval(function(){ 
	document.getElementById(eyeD).scrollLeft += ext 
	},1);
}

function confirmRequest(prompt)
{
var agree=confirm(prompt);
if (agree)
	return true ;
else
	return false ;
}

function newWindow(mypage,myname,w,h,features) {
  var win = null;
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}

function mailpage()
{
var loc = document.title.replace(/&/gi,"%26");
mail_str = "mailto:?subject=Check out the " + loc + " website.'";
mail_str += "&body=I thought you might be interested in the " + loc;
mail_str += ". You can view it at, " + location.href ; 
location.href = mail_str;
}

function DisplayPanel(art)
{

	DarkenPage();
    ShowDisplayPanel(art);
}

function ShowDisplayPanel(artID)
{
    var display_panel = document.getElementById('display_panel');
    
    // w is a width of the newsletter panel
    w = Math.round((document.body.clientWidth*0.75));
    // h is a height of the newsletter panel
    h = 250;
    
    // get the x and y coordinates to center the newsletter panel
    //xc = Math.round((document.body.clientWidth/2)-(w/2))
    xc = 17
	//yc = Math.round((document.body.clientHeight/2)-(h/2))
    yc = 60
	
    // show the newsletter panel
    display_panel.style.left = xc + "px";
    display_panel.style.top  = yc + "px";

	
	display_panel.innerHTML = "<div class='closetab' onclick='javascript:CloseMe();'>Close</div>";

    display_panel.style.display = 'block';

}

function CloseMe()
{
    // hide the newsletter panel
    var display_panel = document.getElementById('display_panel');
    display_panel.style.display = 'none';
    // lighten the page again
    LightenPage();
}

// this function puts the dark screen over the entire page
function DarkenPage()
{
    var page_screen = document.getElementById('page_screen');
    //page_screen.style.height = document.body.parentNode.scrollHeight + 'px';
    page_screen.style.height = '100%';
    page_screen.style.display = 'block';
}

// this function removes the dark screen and the page is light again
function LightenPage()
{
    var page_screen = document.getElementById('page_screen');
    page_screen.style.display = 'none';
}


function makeHttpRequest(url, callback_function, return_xml)
{
   var http_request = false;

   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
       }
   } else if (window.ActiveXObject) { // IE
       try {
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
           try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {}
       }
   }

   if (!http_request) {
       alert('Unfortunatelly you browser doesn\'t support this feature.');
       return false;
   }
   http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {
           if (http_request.status == 200) {
               if (return_xml) {
                   eval(callback_function + '(http_request.responseXML)');
               } else {
                   eval(callback_function + '(http_request.responseText)');
               }
           } else {
               alert('There was a problem with the request.(Code: ' + http_request.status + ')');
           }
       }
   }
   http_request.open('GET', url, true);
   http_request.send(null);
}



function validateForm() 
{
 var okSoFar=true

 with (document.cmxform)
 {

  var myindex=enquiry_type.selectedIndex;
  if (myindex==-1) {   
    okSoFar=false;
    alert("\nYou must make a selection for the Enquiry Type.");
    enquiry_type.focus();
  }

  if (contact_name.value=="" && okSoFar)
  {
    okSoFar=false;
    alert("Please enter your name.");
    contact_name.focus();
  }
  if (contact_telephone.value=="" && okSoFar)
  {
    okSoFar=false;
    alert("Please enter your telephone number.");
    contact_telephone.focus();
  }

  var foundAt = contact_email.value.indexOf("@",0)
  if (foundAt < 1 && okSoFar)
  {
    okSoFar = false;
    alert ("Please enter a valid email address.");
    contact_email.focus();
  }

  
  if (enquiry.value=="" && okSoFar)
  {
    okSoFar=false;
    alert("Please enter your enquiry comments.");
    enquiry.focus();
  }
  if (okSoFar==true)  document.cmxform.submit();
 }
}


function reSize(img,$xmax,$ymax) {
	var tmpimg = new Image();
	tmpimg.src = img.src;
	//alert(this.width + ' - ' + this.height);
	if (tmpimg.width > $xmax) {
		img.style.width = $xmax + 'px';
		img.style.height = (tmpimg.height * ($xmax / tmpimg.width)) + 'px';
	} else {
		img.style.width = tmpimg.width + 'px';
		img.style.height = tmpimg.height + 'px';
	}

	if (img.height > $ymax) {
		img.style.height = $ymax + 'px';
		img.style.width = (img.width * ($ymax / img.height)) + 'px';
	}

}


