// Scripted by Adam Fletcher 15-04-03
// Create a random number between one and <the total number of images used>
// Simply use the total number of images minus one because the random num will start at 0
// Put this value in the equation below after the *
// An easy way to calculate this to add the value after the * and 1. The result should equal your total number of images
//Some of you may be curious as to why Math.floor(), instead of Math.round(), is used in the above code. While both successfully round off its containing parameter to an integer within the designated range, Math.floor does so more "evenly", so the resulting integer isn't lopsided towards either end of the number spectrum. In other words, a more random number is returned using Math.floor()
var random_num; 
random_num = (Math.floor((Math.random()*8)+1));
//
function largePic(sPicURL) { 
window.open("popup.php?"+sPicURL, "", "resizable=1,height=200,width=200");
}
/*
var iMyWidth;
var iMyHeight;
//gets top and left positions based on user's resolution so hint window is centered.
iMyWidth = (window.screen.width/2) - (100+4); //half the screen width minus half the new window width (plus 2 pixel edge).
iMyHeight = (window.screen.height/2) - (100+4); //half the screen height minus half the new window height (plus 2 pixel edge).
window.open("popup.php?"+sPicURL,"Agigi Design Salon Furniture","directories=0,status=yes,width=400,height=300,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");
//var popupwindow = window.open("popup.php?" + sPicURL + "","Agigi Design Salon Furniture","directories=0,status=yes,width=200,height=200,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",resizable=no,scrollbars=no");
//popupwindow.focus();
//window.parent.close();
}
*/

//
var isNS = (navigator.appName == "Netscape") ? 1 : 0;

if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);

function mischandler(){
  return false;
}

function mousehandler(e){
	var myevent = (isNS) ? e : event;
	var eventbutton = (isNS) ? myevent.which : myevent.button;
   if((eventbutton==2)||(eventbutton==3)){ return false; }
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;

//

//
<!-- Original:  Martin Webb (martin@irt.org) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function right(e) {
if (navigator.appName == 'Netscape' && 
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && 
(event.button == 2 || event.button == 3)) {
alert("Sorry, you do not have permission to right click.");
return false;
}
return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;
//  End -->
//

//alert('Boo');
//
// FUNCTION FOR THE PRODUCT POPUPS
function popitup(url) {
	newwindow=window.open(url,'name','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=615,height=615');
	if (window.focus) {newwindow.focus()}
	return false;
}
//

function PopupPic(sPicURL) { 
window.open("popup.php?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200");
}
//
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//
// Script Source: CodeLifter.com
// Copyright 2003
// Set the horizontal and vertical position for the popup - centered on the screen
var PositionX;
var PositionY;
//gets top and left positions based on user's resolution so hint window is centered.
PositionX = (window.screen.width/2) - (320+4); //half the screen width minus half the new window width (plus 2 pixel edge).
PositionY = (window.screen.height/2) - (240+4); //half the screen height minus half the new window height (plus 2 pixel edge).
//PositionX = 15;
//PositionY = 15;
// Set these value approximately 20 pixels greater than the size of the largest image to be used (needed for Netscape)
defaultWidth  = 640;
defaultHeight = 480;
// Set autoclose true to have the window close automatically. Set autoclose false to allow multiple popup windows
var AutoClose = false;
// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=640,height=480,left='+PositionX+',top='+PositionY;

function popImage(imageURL,imageTitle){
if (isNN){
imgWin=window.open('about:blank','',optNN);
}
if (isIE){
imgWin=window.open('about:blank','',optIE);
}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
writeln('<sc'+'ript>');
writeln('var isNN,isIE;');
writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');
writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');
writeln('if (isIE){');
writeln('window.resizeTo(640,480);');
writeln('width=640-(document.body.clientWidth-document.images[0].width);');
writeln('height=480-(document.body.clientHeight-document.images[0].height)+25;');
writeln('window.resizeTo(width,height);}');
writeln('if (isNN){');       
writeln('window.innerWidth=document.images["Retail"].width;');
writeln('window.innerHeight=document.images["Retail"].height;}}');
writeln('function doTitle(){');
writeln('document.title="' + imageTitle + '";}');
writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=584B41 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onClick="self.close()">')
else writeln('</head><body bgcolor=584B41 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onClick="self.close()">');
writeln('<a href="#" onClick="javascript:self.close();"><img name="Retail" src="' + imageURL + '" border="0" style="display:block" alt="Click To Close"></a><center><img src="images/shim.gif" width="100" height="7" border="0"><br><font color="#FFFFFF" face="Arial" size="-2">Click image to close</font></center>');
writeln('<script type="text/javascript">');
writeln('var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");');
writeln('document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));');
writeln('</script>');
writeln('<script type="text/javascript">');
writeln('var pageTracker = _gat._getTracker("UA-5224282-1");');
writeln('pageTracker._trackPageview();');
writeln('</script>');
writeln('</body>');
writeln('</html>');
close();		
}
}
//
function sendURL(){
//get location
var thisUrl=String(this.location);
alert(thisUrl);
return thisUrl;
}
/*
//get location
var loc=String(this.location);  
path=unescape(document.location);
loc=loc.split("/");  
loc=loc[loc.length-1].split(".");  
loc=loc[loc.length-2]; 
//alert(loc);
*/
//Popup Window Script
function popUp(url){
window.open(url,name,"width=640,height=500,toolbars=no,status=yes,scrollbars=yes,left=160,top=80");
}
//
function selfFocus(){
self.focus();
}
//
// Centre popups on screen for Home Page Ads //
function openWindow1(){
var iMyWidth;
var iMyHeight;
//gets top and left positions based on user's resolution so hint window is centered.
iMyWidth = (window.screen.width/2) - (194+4); //half the screen width minus half the new window width (plus 2 pixel edge).
iMyHeight = (window.screen.height/2) - (250+4); //half the screen height minus half the new window height (plus 2 pixel edge).
var popupwindow = window.open("images/agigiTrolleyAdvert500d.jpg","Advert","directories=0,status=yes,width=387,height=500,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",resizable=no,scrollbars=no");
popupwindow.focus();
//window.parent.close();
}

// Centre popups on screen for Home Page Ads //
function openWindow2(){
var iMyWidth;
var iMyHeight;
//gets top and left positions based on user's resolution so hint window is centered.
iMyWidth = (window.screen.width/2) - (194+4); //half the screen width minus half the new window width (plus 2 pixel edge).
iMyHeight = (window.screen.height/2) - (250+4); //half the screen height minus half the new window height (plus 2 pixel edge).
var popupwindow = window.open("images/agigiFabFourAd500d.jpg","Advert","directories=0,status=yes,width=387,height=500,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",resizable=no,scrollbars=no");
popupwindow.focus();
//window.parent.close();
}
//
function openWindow600x420(url,name) {
	var iMyWidth;
	var iMyHeight;
	//gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/2) - (300+4); //half the screen width minus half the new window width (plus 2 pixel edge).
	iMyHeight = (window.screen.height/2) - (225+4); //half the screen height minus half the new window height (plus 2 pixel edge).
	var popupwindow = window.open(url,name,"directories=0,status=yes,width=600,height=450,resizable=no,scrollbars=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + "");
	popupwindow.focus();
		}
//	
function openWindow480x540(url,name) {
	var iMyWidth;
	var iMyHeight;
	//gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/2) - (240+4); //half the screen width minus half the new window width (plus 2 pixel edge).
	iMyHeight = (window.screen.height/2) - (270+4); //half the screen height minus half the new window height (plus 2 pixel edge).
	var popupwindow = window.open(url,name,"directories=0,status=yes,width=480,height=540,resizable=no,scrollbars=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + "");
	popupwindow.focus();
		}
//
function pagePrint() {
var platform="";
var version=""; 
if (navigator.appVersion.indexOf("Mac")!=-1) platform = "mac";
if (navigator.userAgent.indexOf("Mozilla/4") != -1) version = "moz_valid"; 
else if (navigator.userAgent.indexOf("Mozilla/5") != -1) version = "moz_valid"; 
else if (navigator.userAgent.indexOf("Mozilla/6") != -1) version = "moz_valid"; 
else if (navigator.userAgent.indexOf("Mozilla/7") != -1) version = "moz_valid"; 
if (navigator.userAgent.indexOf("MSIE 5") != -1) version = "ms_valid"; 
else if (navigator.userAgent.indexOf("MSIE 6") != -1) version = "ms_valid"; 
else if (navigator.userAgent.indexOf("MSIE 7") != -1) version = "ms_valid"; 
else if (navigator.userAgent.indexOf("MSIE 4") != -1) version = "ms_valid"; 

if (platform == "mac" && version == "moz_valid") {
print_moz(); 
// alert('You are on an Apple Mac using Netscape. In order to print, press (Apple P)!');
}
else if (platform == "mac" && version == "ms_valid") {
alert('You are on an Apple Mac using Internet Explorer. In order to print, press (Apple P)!');
}
else if (platform != "mac" && version == "moz_valid") { 
print_moz(); 
} 
else if (platform != "mac" && version == "ms_valid") { 
print_ms();
} 
version = "" ; 
}

function print_moz() 
{window.print() ; 
print() ;} 
function print_ms() { 
var OLECMDID_PRINT = 6; 
var OLECMDEXECOPT_DONTPROMPTUSER = 2; 
var OLECMDEXECOPT_PROMPTUSER = 1; 
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
oldHandler = window.onerror; 
window.onerror = deal; 
WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER); 
WebBrowser1.outerHTML = ""; 
window.onerror = oldHandler;} 

function deal() { 
WebBrowser1.outerHTML = ""; 
window.onerror = oldHandler; 
return true; 
} 
// this.mac = (agt.indexOf("mac")!=-1) 
// this.mac68k = this.mac && ((agt.indexOf("68k")!=-1) || (agt.indexOf("68000")!=-1)) 
// this.macppc = this.mac && ((agt.indexOf("ppc")!=-1) || (agt.indexOf("powerpc")!=-1)) 

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; 
	}
	}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//
function CheckRequiredFields() {
var errormessage = new String();
// Put field checks below this point.
if(WithoutContent(document.Contact.First_Name.value))
	{ errormessage += "\n\nPlease enter your first name.";}
if(WithoutContent(document.Contact.Last_Name.value))
	{ errormessage += "\n\nPlease enter your last name.";}
if(WithoutContent(document.Contact.email.value))
	{ errormessage += "\n\nPlease enter your email address.";}
if(WithoutContent(document.Contact.address.value))
	{ errormessage += "\n\nPlease enter your address number.";}
if(WithoutContent(document.Contact.city.value))
	{ errormessage += "\n\nPlease enter your city number.";}
if(WithoutContent(document.Contact.state.value))
	{ errormessage += "\n\nPlease enter your state number.";}
if(WithoutContent(document.Contact.phone.value))
	{ errormessage += "\n\nPlease enter your telephone number.";}
//if(WithoutContent(document.Contact.Comments.value))
//	{ errormessage += "\n\nPlease enter your email address.";}
//if(WithoutSelectionValue(document.Register.YourPosition))
//	{ errormessage += "\n\nPlease select your position from the dropdown list.";}
//if(WithoutContent(document.Register.CompanyName.value))
//	{ errormessage += "\n\nPlease enter your company name.";}
//if(WithoutSelectionValue(document.Register.IndustryType))
//	{ errormessage += "\n\nPlease select your industry type from the dropdown list.";}
//if(WithoutContent(document.Register.CompanyAddress.value))
//	{ errormessage += "\n\nPlease enter your company address.";}
//if(WithoutContent(document.Register.CitySuburb.value))
//	{ errormessage += "\n\nPlease enter your company city or suburb.";}
//if(WithoutSelectionValue(document.Register.StateTerritory))
//	{ errormessage += "\n\nPlease select your state or territory from the dropdown list.";}
//if(WithoutContent(document.Register.PostCode.value))
//	{ errormessage += "\n\nPlease enter your postcode.";}
//if(WithoutContent(document.Register.Telephone.value))
//	{ errormessage += "\n\nPlease enter your telephone number.";}
//if(NoneWithCheck(document.Register.TravelManagement))
//	{ errormessage += "\n\nPlease click a radio button. \"Do you currently use a travel management company\?\"";}
//if(WithoutSelectionValue(document.Register.TravelBooking))
//	{ errormessage += "\n\nPlease select how you currently book your travel from the dropdown list.";}

// Put field checks above this point.
if(errormessage.length > 2) {
	alert('NOTE:' + errormessage);
	return false;
	}
// THIS IS THE CATALOGUE DOWNLOAD LINK
//window.open("download/AgigiCatalogue300506.pdf","Download","width=300,height=400");
window.open("catalogue_download.php","Download","width=450,height=550");
/*
var answer = confirm("Our catalogue is being redesigned at the moment with the latest range of products!\n\nWe do not have a catalogue for you to download.\nIf you would like us to contact you when our new catalogue is ready\n please press the 'OK' button\n otherwise press 'Cancel'.");
	if(answer){
	document.Contact.submit();
	return true;
	} else {
	return false;
	}
*/
} // end of function CheckRequiredFields()


function WithoutContent(ss) {
if(ss.length > 0) { 
return false; 
}
return true;
}

function NoneWithContent(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].value.length > 0) { return false; }
	}
return true;
}

function NoneWithCheck(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].checked) { return false; }
	}
return true;
}

function WithoutCheck(ss) {
if(ss.checked) { return false; }
return true;
}

function WithoutSelectionValue(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].selected) {
//		if(ss[i].value != 'Select' || ss[i].value.length) { 
		if(ss[i].value.length) { 
		return false; 
		}
		} 
	} 
return true;
}
