/* Exodus Library - Sunrise Villa 
   Base Functions loaded with every page
   Copyright (c) Exodus Enterprise Systems
   unless otherwise specified herein.
*/

// Empty initialization and termination functions
CONTACT = 0;
MANAGER = 1;
INFO = 2;
PAYMENTS = 3;
RENTALS = 4;
OWNERS = 5;
SALES = 6;
ES_Domain = 'sunrise-villa.com';
HostLogo = '<a href="http://www.meanbusiness.com" target="_blank"><img src="/graphics/logo.jpg" border="0"></a>'

function initPage()	{}
function exitPage()	{}

// Disable the right click button
function disableRightClick(e)
{
  var message = "Copyright © 2001-2005 Sunrise Villa";
  
  if(!document.rightClickDisabled) // initialize
  {
    if(document.layers) 
    {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = disableRightClick;
    }
    else document.oncontextmenu = disableRightClick;
    return document.rightClickDisabled = true;
  }
  if(document.layers || (document.getElementById && !document.all))
  {
    if (e.which==2||e.which==3)
    {
      alert(message);
      return false;
    }
  }
  else
  {
    alert(message);
    return false;
  }
}

function hasPopupBlocker() {
    /*  Function:      hasPopUpBlocker
        Creation Date: April 5, 2004
        Programmer:    Edmond Woychowsky
        Purpose:       The purpose of this function is to attempt to open
                       a popup window to determine if a popup blocker is
                       enabled.
        Update Date:            Programmer:         Description:
	*/
	var objChild;                           // Window
	var reWork = new RegExp('object','gi');	// Regular expression
	try {
		objChild = window.open('','child','width=50,height=50,status=no,resizable=yes'); 

		objChild.close();
	}
	catch(e) { }
	if(!reWork.test(String(objChild)))
		return true;
		// alert('Warning: A pop-up blocker is enabled for this site!');
	else
		return false;
		// alert('No pop-up blocker or pop-up blocker is disabled!');
}

// Get the arguments from either the active or passed location URL
function getURLArgs(theURL)	{
	var theArgs = new Object();						// Create a new object to hold the args
	var argv = getURLArgs.arguments;				// Get the function arguments
	if(argv.length == 0) {
		query = location.search.substring(1);		// Assume we are parsing the active location string
	} else {
		var queryLoc = theURL.indexOf('?');			// Or check to see if we have been passed one to parse
		if(queryLoc == -1) return;
		query = theURL.substr(queryLoc+1);
	}
	var arguments = query.split("&")				// Split into array arguments at the & symbol
	for(var i = 0; i < arguments.length; i++)	{
		var argLoc = arguments[i].indexOf('=');		// Look for name=value pair
		if (argLoc == -1) continue;					// Nothing found, go to next one
		var argName = arguments[i].substring(0,argLoc);		// Extract the name
		var argValue = arguments[i].substring(argLoc+1);	// Extract the value
		theArgs[argName] = unescape(argValue);				// Store in object as full string
		}
	return theArgs;
}

// IE bookmark
function bookmarkUs()	{
	if (document.all)	{
		window.external.AddFavorite('http://www.exodusventures.com', 'Exodus Island Ventures');
	}
}
// Reasonable attempt to get the basics about this session
function WhoIsIt() {
    var pform  = navigator.platform.toLowerCase();
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
	this.ie = (agent.indexOf("msie") != -1);
	this.op3 = (agent.indexOf("opera") != -1);
	this.pc  = (agent.indexOf("win") != -1);
	this.mac = (agent.indexOf("mac")!=-1); // Mac detect
	this.client = ( (navigator.userAgent.indexOf('AOL')!=-1) || (navigator.userAgent.indexOf('CS 2000')!=-1) )? 1 : 0;
	this.moz = ( this.ns && (agent.indexOf("netscape/") == -1) );
	if (this.moz) this.ns = 0;
	this.HIDDEN = (this.ns) ? 'hide' : 'hidden';
	this.VISIBLE = (this.ns) ? 'show' : 'visible';
}
var ES_BROWSERINFO = WhoIsIt();


/* 
	Copyright (c) Macromedia 
	Copied here for convenience
*/

// Restore an image that was previously swapped.
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;
}

// Preload images for this page.
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];}}
}

// Locate an object in the document.
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;
}

// Swap an image
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];}
}

// Write a message to the status area.
function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+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 MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function ES_showHideLayers()	{	//v1.0 - Lots of assumptions here!
	if(!document.layers) return;
	var i,args=ES_showHideLayers.arguments;
	for(i=0;i<(args.length-2);i+=3)	{
		v=(args[i+2]=='show')?'visible':'hidden';
		document.layers.args[i].style.visibility=v;
   }
}

// Copyright (c) Project VII
function P7_ShowPic(a,b) { //v2.0 by PVII
 var g,gg,d,dd,ic,im;if((g=MM_findObj(b))!=null){
 if(!document.P7ShowPic){document.P7ShowPic=true;}else{
 if((d=MM_findObj(document.P7SPlay))!=null){
  dd=(document.layers)?d:d.style;dd.visibility="hidden";}}
 document.P7SPlay=b;gg=(document.layers)?g:g.style;im=b+"im";
 if((ic=MM_findObj(im))!=null){ic.src=a;gg.visibility="visible";}}
}

// Copyright (c) aardwulf.com (encode64 and decode64)
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + 
             "abcdefghijklmnopqrstuvwxyz" + 
             "0123456789+/" + "=";

function encode64(input) {
	var output = "";
	var chr1, chr2, chr3 = "";
	var enc1, enc2, enc3, enc4 = "";
	var i = 0;

	do {
	   chr1 = input.charCodeAt(i++);
	   chr2 = input.charCodeAt(i++);
	   chr3 = input.charCodeAt(i++);

	   enc1 = chr1 >> 2;
	   enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
	   enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
	   enc4 = chr3 & 63;

	   if (isNaN(chr2)) {
		enc3 = enc4 = 64;
	   } else if (isNaN(chr3)) {
		enc4 = 64;
	   }

		output = output + 
		keyStr.charAt(enc1) + 
		keyStr.charAt(enc2) + 
		keyStr.charAt(enc3) + 
		keyStr.charAt(enc4);
		chr1 = chr2 = chr3 = "";
		enc1 = enc2 = enc3 = enc4 = "";
	} while (i < input.length);

	return output;
   }

function decode64(input) {
	var output = "";
	var chr1, chr2, chr3 = "";
	var enc1, enc2, enc3, enc4 = "";
	var i = 0;

	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	var base64test = /[^A-Za-z0-9\+\/\=]/g;
	if (base64test.exec(input)) {
	   alert("There were invalid base64 characters in the input text.\n" +
		   "Valid base64 characters are A-Z, a-z, 0-9, '+', '/', and '='\n" +
		   "Expect errors in decoding.");
	}
	input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	do {
		enc1 = keyStr.indexOf(input.charAt(i++));
		enc2 = keyStr.indexOf(input.charAt(i++));
		enc3 = keyStr.indexOf(input.charAt(i++));
		enc4 = keyStr.indexOf(input.charAt(i++));

		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;

		output = output + String.fromCharCode(chr1);

		if (enc3 != 64) {
			output = output + String.fromCharCode(chr2);
		}
		if (enc4 != 64) {
			output = output + String.fromCharCode(chr3);
		}

		chr1 = chr2 = chr3 = "";
		enc1 = enc2 = enc3 = enc4 = "";

	} while (i < input.length);

	return output;
   }

// Encode email address to prevent harvesting
var _esmailTo = decode64('Y29udGFjdHVzQCxtYW5hZ2VyQCxnZW5pbmZvQCxwYXltZW50c0AsdmlsbGFyZW50YWxzQCx2aWxsYW93bmVyc0AsdmlsbGFzYWxlc0A=').split(',');
function getMailTo(towhom)	{
	return _esmailTo[towhom] + location.hostname.substr(4);
}

function setRecipient(aVal)	{
	if((s = MM_findObj('recipient')) != null)	{
		s.value = aVal + '@' + ES_Domain;
	}
}

function ES_showHideBlocks() { //v6.0
	var i,p,v,obj,args=ES_showHideBlocks.arguments;
	for (i=0; i<(args.length-1); i+=2) 
  		if ((obj=MM_findObj(args[i]))!=null) { 
			v=args[i+1];
			if (obj.style) { 
				obj=obj.style; 
				v=(v=='show')?'block':(v=='hide')?'none':v; 
			}
		obj.display=v; }
	return true;
}

// Loads images in the 'background'
function EA_lazypreloadImages()	{	//v1.0
	var x,args=EA_lazypreloadImages.arguments
	var d=document;
	if(args.length>0)	{
		if(!d.EA_lazyFiles)	{
			d.EA_lazyFiles = new Array();
			d.EA_lazyImgs = new Array();
			d.EA_lazyStart = new Date();
		}
		for(x=0;x<args.length+1;x++)	{
			d.EA_lazyFiles.push(args[x]);
		}
	}
	if(!d.EA_preloader)	{
		d.EA_preloader = setInterval("EA_lazypreloadImages()", 250);
	}
	var i=new Image();
	i.src=d.EA_lazyFiles.pop();
	d.EA_lazyImgs.push(i);
	if(d.EA_lazyFiles.length==0)	{
		clearInterval(d.EA_preloader);
		d.EA_lazyFiles=new Array();
//		alert('Done in ' + (new Date()- d.EA_lazyStart)/1000 + " secs");
	}
}

// Create a simple popup ad, reized automatically.  Vars: 0=imgURL, 1=title, 2=top, 3=left
// Modified from original by CodeLifter (c) 2003
function autoSizeAd()	{
	var args=autoSizeAd.arguments;
	var x = (args[2] > 0) ? args[2] : (screen.availWidth / 2);
	var y = (args[3] > 0) ? args[3] : (screen.availHeight / 2);
	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='toolbar=no,scrollbars=no,resizable=no,width=500,height=500,left='+x+',screenX='+x+',top='+y+',screenY='+y;
	var optIE='toolbar=no,scrollbars=no,resizable=no,width=250,height=100,left='+x+',screenX='+x+',top='+y+',screenY='+y;
	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;padding: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(100,100);');
		writeln('width=120-(document.body.clientWidth-document.images[0].width);');
		writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		writeln('window.resizeTo(width,height);}');
		writeln('if (isNN){');       
		writeln('window.innerWidth=document.images[0].width;');
		writeln('window.innerHeight=document.images[0].height;');
		writeln('window.sizeToContent();');
		writeln('}}');
		writeln('function doTitle(){document.title="'+args[1]+'";}');
		writeln('</sc'+'ript>');
		writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
		writeln('<img name="SunriseAd" src='+args[0]+' style="display:block" border="0"></body></html>');
		close();
	}
}

function showSpecials()	{
	simplePopUp('/specials/index.html',435,265);
}

// Create a default popup window using the defined URL and optionally resize it to a single image.  
function simplePopUp() {
	var w,h,s,x,y,iw,ih,args=simplePopUp.arguments;
	w = (args[1] > 0) ? args[1] : (screen.availWidth / 2);
	h = (args[2] > 0) ? args[2] : (screen.availHeight / 2);
	x = (screen.availWidth) ? ((screen.availWidth / 2) - (w / 2)) : 0;
	y = (screen.availHeight) ? ((screen.availHeight / 2) - (h / 2)) : 0;
	window.open(args[0],'SunrisePopup','width=' + w + ',height=' + h + ',toolbar=no,scrollbars=no,resizable=no,left=' + x + ',screenX=' + x + ',top=' + y + ',screenY=' + y);
}
