// JavaScript Document
function switchSite(site, classname) {
$('text').style.display = "none";
$('close').style.display = "none";
changeBg();
$('text').className = classname;
var url = Gurl + '/~thesalty/actionHandler.php';
var params = 'site=' + site;
var ajax = new Ajax.Updater($('text'),
url,
{method: 'post', parameters: params, onComplete:function() {finalize()}});
}

function Close() {
$('text').fade();
$('close').fade();
return false;
}

function finalize() {
$('text').appear();
$('close').appear();
if( $('contactForm') ) {
var contactForm = new VarienForm('contactForm', true);
}
return false;	
}

function Nsignup() {
	window.open("newsletter.html", "newsle","width=320, height=220");
	return false;
}

function changeBg() {
var bg = new Array();
bg[0] = "main";
bg[1] = "main1";
bg[2] = "main2";
bg[3] = "main3";

var randno = Math.floor ( Math.random() * bg.length );
$('main').className = bg[randno];
}

function contactSend() {
var url = Gurl + '/~thesalty/sendMail.php';
var params = 'send=1' + '&name=' + $('name').value + '&email=' + $('email').value + '&telephone=' + $('telephone').value + '&comment=' + $('comment').value;
var ajax = new Ajax.Updater($('msg'),
url,
{method: 'post', parameters: params, onComplete:function() {finish()}});
}

function finish() {
$('name').value = '';
$('email').value = '';
$('telephone').value = '';
$('comment').value = '';
}

function PageDisplay(p, site) {
if(p!='')
{
var url = Gurl + '/~thesalty/actionHandler.php';
var params = 'site='+site+'&page=' + p;
var ajax = new Ajax.Updater($('text'),
url,
{method: 'post', parameters: params});	
}
return false;
}

function ShowNews(id, site) {
var url = Gurl + '/~thesalty/actionHandler.php';
var params = 'site='+site+'&id='+id;
var ajax = new Ajax.Updater($('text'),
url,
{method: 'post', parameters: params});
return false;
}

function BoxActivate(id1,id2)
		{
		var block1=document.getElementById(id1);
		var block2=document.getElementById(id2);
		if(block1.style.display=='block')
		{
		block1.style.display='none';
		block2.style.display='none';
		}
		else
		{
		block1.style.display='block';
		block2.style.display='block';
		var arrayPageSize = getPageSize();
		document.getElementById(id1).style.height=arrayPageSize[1] + "px";
		document.getElementById(id1).style.width=arrayPageSize[0] + "px";
		}
		}
function getPageSize(){
	
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
	//	console.log(self.innerWidth);
	//	console.log(document.documentElement.clientWidth);
	
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
	//	console.log("xScroll " + xScroll)
	//	console.log("windowWidth " + windowWidth)
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
	//	console.log("pageWidth " + pageWidth)
	
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
}

function openwindow()
{
var centerWidth = (window.screen.width - 770) / 2;
var centerHeight = (window.screen.height - 550) / 2;

window.open("https://secure92.nocdirect.com/~thesalty/booking/beds_available.php","mywindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1, width=770,height=550, left="+ centerWidth +", top="+centerHeight);
return false;
}
