/*  	
	Brown Paper Bab - Web Studio - Web Design - Web Creation - Web Hosting - Internet - Intranet
	Version 1.1
	Created: 19th Feb 2006
	By: info@brownpaperbag.com.au
	Modified: 
		23rd Feb 2006 RB Added HighlightNav function
*/
//<![CDATA[
function OpenModal(url){
	s = document.getElementById('greyout');
	s.style.width = '1024';
	s.style.height = '786';
	window.showModalDialog(url,'', 'dialogHeight:430px;dialogWidth:500px;center:yes;status:no')
	//s.style.width = '1';
	//s.style.height = '1';
	window.location.reload(true);
}
	
var current = null;

// Page load events
function WinLoad(func) {
	var oldonload = window.onload;
	if(typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() { 
			oldonload();
			func();
		}
	}
};
/*  Display Date and Time in the Cookie Trail */
function DateTime(){
	var thetime=new Date();
	var nhours=thetime.getHours();
	var nmins=thetime.getMinutes();
	var nsecn=thetime.getSeconds();
	var nday=thetime.getDay();
	var nmonth=thetime.getMonth();
	var ntoday=thetime.getDate();
	var nyear=thetime.getYear();
	var AorP=" ";
	
	if (nhours>=12) AorP="P.M.";
	   else AorP="A.M.";
	
	if (nhours>=13) nhours-=12;
	if (nhours==0) nhours=12;
	if (nsecn<10) nsecn="0"+nsecn;
	if (nmins<10) nmins="0"+nmins;
	
	if (nday==0) nday="Sunday";
	if (nday==1) nday="Monday";
	if (nday==2) nday="Tuesday";
	if (nday==3) nday="Wednesday";
	if (nday==4) nday="Thursday";
	if (nday==5) nday="Friday";
	if (nday==6) nday="Saturday";


	if (nmonth==0) nmonth="Jan";
	if (nmonth==1) nmonth="Feb";
	if (nmonth==2) nmonth="Mar";
	if (nmonth==3) nmonth="Apr";
	if (nmonth==4) nmonth="May";
	if (nmonth==5) nmonth="Jun";
	if (nmonth==6) nmonth="Jul";
	if (nmonth==7) nmonth="Aug";
	if (nmonth==8) nmonth="Sep";
	if (nmonth==9) nmonth="Oct";
	if (nmonth==10) nmonth="Nov";
	if (nmonth==11) nmonth="Dec";

	if (nyear<=99) nyear= "19"+nyear;
	if ((nyear>99) && (nyear<2000)) nyear+=1900;
	
	var clock = document.getElementById('Time');
	if (clock) clock.innerHTML=nhours+":"+nmins+":"+nsecn+" "+AorP+" "+nday+", "+ntoday+"-"+nmonth+"-"+nyear;
	setTimeout('DateTime()',1000);
};
WinLoad(DateTime);

/* Functions to fix on sreen messages */
function confirmDelete(){
	if(confirm("Are you sure you want to delete this item from the database?\n\nNote: If you select 'Ok' the action cannot be undone.")){return true;}else{return false;}
}

/* Image Swapper */
function ImgSwp(oButton) {  // Image swapper
	var ext = oButton.src.substring(oButton.src.lastIndexOf("."), oButton.src.length)
	var path = oButton.src.substring(0, oButton.src.lastIndexOf("/")+1)
	var file = oButton.src.substring(oButton.src.lastIndexOf("/")+1,oButton.src.lastIndexOf("."))
	if (oButton != current){
		oButton.src = (((i = file.indexOf("_ovr")) >= 0) || ((i = file.indexOf("_on")) >= 0)) ? path + file.substring(0, file.lastIndexOf("_")) + ext : path + file + "_ovr" + ext;
	}
};
/*  Opens the Main CSNet Window */
function ShowImage(el){
	var url = el.href;
	var sizeX = 500;
	var sizeY = 500;
	var posx = (screen.availWidth-sizeX)/2;
	var posy = (screen.availHeight-sizeY)/2;
	var windowString = 'toolbar=no,location=no,menubar=no,status=yes,titlebar=yes,resizable=no,directories=no,scrollbars=no,copyhistory=no,width='+sizeX+',height='+sizeY+',left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
	oWin = window.open(url, 'Adorne', windowString);
	oWin.focus();
	return false;
};

/*  Opens the Main CSNet Window */
function ShowOrder(OrderNum){
	var url = '/eshop/print_order.aspx?id=' + OrderNum;
	var sizeX = 560;
	var sizeY = 500;
	var posx = (screen.availWidth-sizeX)/2;
	var posy = (screen.availHeight-sizeY)/2;
	var windowString = 'toolbar=no,location=no,menubar=no,status=yes,titlebar=yes,resizable=no,directories=no,scrollbars=yes,copyhistory=no,width='+sizeX+',height='+sizeY+',left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
	oWin = window.open(url, 'Adorne', windowString);
	oWin.focus();
	return false;
};

function openWin( location, name, sizeX, sizeY ) {
  var posx = (screen.availWidth-sizeX)/2;
  var posy = (screen.availHeight-sizeY)/2;
  var windowString = 'toolbar=no,location=no,menubar=no,status=no,titlebar=no,resizable=no,directories=no,scrollbars=no,copyhistory=no,width='+sizeX+',height='+sizeY+',left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
  oWin = window.open(location, name, windowString);
  oWin.focus();
};
/* Right Click on images */

/*
    This script courtesy of Dynamicdrive.com ... thank you!
    Disable right click script II (on images)- By Dynamicdrive.com
    Visit http://www.dynamicdrive.com
*/

var clickmessage="Images are subject to copyright."

function disableclick(e) {
    if (document.all) {
        if (event.button==2||event.button==3) {
            if (event.srcElement.tagName=="IMG"){
                alert(clickmessage);
                return false;
            }
        }
    }
    else if (document.layers) {
        if (e.which == 3) { 
            alert(clickmessage);
            return false;
        }
    }
    else if (document.getElementById){
        if (e.which==3&&e.target.tagName=="IMG"){
            alert(clickmessage)
            return false
        }
    }
}

function associateimages(){
    for(i=0;i<document.images.length;i++)
    document.images[i].onmousedown=disableclick;
}

if (document.all)
    document.onmousedown=disableclick
else if (document.getElementById)
    document.onmouseup=disableclick
else if (document.layers)
    associateimages()

/* XMLPost */
function AJAXInteraction(url, callback) {
    var req = init();
    req.onreadystatechange = processRequest;
        
    function init() {
      if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
      } else if (window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
    
    function processRequest () {
      // readyState of 4 signifies request is complete
      if (req.readyState == 4) {
	// status of 200 signifies sucessful HTTP call
        if (req.status == 200) {
          if (callback) callback(req.responseText);
        }
      }
    }

    this.doGet = function() {
      // make a HTTP GET request to the URL asynchronously
      req.open("GET", url, true);
      req.send(null);
    }
}
//]]>