// Some utilities developed for styleslodge.co.uk
// Copyrite Jeff Allen(2009) - JTS Developments
// ---------------------------------------------------------------------------------------------------------------

// First of all some system variables and constants...
var baseSize;
var baseColor;
var newColor;

var backGroundColour_1 = "#008080"		// green				current selection...
var backGroundColour_2 = "#006699"		// dark blue
var backGroundColour_3 = "#0066FF";		// light blue

var baseFrameWidthFactor = 0.95, baseFrameHeightFactor = 0.75;
var baseFrameWidth,baseFrameHeight;

var fontType = 'Verdana';
var bigSize = 12;
var smallSize = 10;
var fontColour_0 = '#666666';
var fontColour_1 = '#FFFFFF';
// ---------------------------------------------------------------------------------------------------------------

function setHighlightColour(theNewColor) {
	newColor = theNewColor;
}

function getBaseSizeColor(text) {
	baseSize = document.getElementById(text).style.fontSize;
	baseColor = document.getElementById(text).style.color;	
}

function increaseText(text,newSize) {
	getBaseSizeColor(text);
	elem = document.getElementById(text);
 	elem.style.color = newColor; 	
 	elem.style.fontSize = newSize;
 	elem.style.textDecoration = "underline";
}

function decreaseText(text) {
	elem = document.getElementById(text);
 	elem.style.fontSize = baseSize;
 	elem.style.color = baseColor;
 	elem.style.textDecoration = "none";
}
// ---------------------------------------------------------------------------------------------------------------

function getClientScreenWidth() {
	return screen.availWidth;
}

function getClientScreenHeight() {
	return screen.availHeight;
}	

function calcBaseFrameWidthHeight() {
	baseFrameWidth = baseFrameWidthFactor * getClientScreenWidth();
	baseFrameHeight = baseFrameHeightFactor * getClientScreenHeight();
}

function setFrameSize(theFrameID) {
	var theFrame;
	this.calcBaseFrameWidthHeight();
	//theFrame = top.document.getElementById(theFrameID);
	theFrame = document.getElementById(theFrameID);
	theFrame.width = parseInt(baseFrameWidth);
	theFrame.height = parseInt(baseFrameHeight);
	//alert('From setFrameSize - theFrameId = ' + theFrameID);
}
// ---------------------------------------------------------------------------------------------------------------

// Use this function to set... the 4 main horizontal rows (header row,contents row,view row,footer row
// It is called from homeHeaderPage.html 
function setHomePageTopLevelFrameset(theFramesetID,header,top,bottom,footer) {
  var headerStr = parseInt(header);
  var topStr = parseInt(top);
  var bottomStr = parseInt(bottom);
  var footerStr = parseInt(footer);
  
  var paramStr = headerStr + "%," + topStr + "%," + bottomStr + "%," + footerStr + "%";
  parent.document.getElementById(theFramesetID).rows = paramStr;
}

// Use this function to set...the frames in the contents row (contents col,top welcome col, house picture col
// It is called from homeHeaderPage.html
function setHomePageTripleFrameset(theFramesetID,left,centre,right) {
  var leftStr = parseInt(left);
  var centreStr = parseInt(centre);
  var rightStr = parseInt(right);
  var paramStr = leftStr + "%," + centreStr + "%," + rightStr + "%";
  parent.document.getElementById(theFramesetID).cols = paramStr;
}

// Use this function to set... the 2 frames in the view row (the view picture col, the bottom welcome col)
// It is called from homeHeaderPage.html
function setHomePageDoubleFrameset(theFramesetID,left,right) {
  var leftStr = parseInt(left);
  var rightStr = parseInt(right);
  var paramStr = leftStr + "%," + rightStr + "%";
  parent.document.getElementById(theFramesetID).cols = paramStr;
} 

// Use this function to set... the 3 main horizontal rows (header row, contents row, thumbnails row) 
// It is called from tariff.html
function setAccommodationFrameset(theFramesetID,header,middle,thumbnail) {
	var headerStr = parseInt(header);
  var middleStr = parseInt(middle);
  var thumbnailStr = parseInt(thumbnail);
  
  var paramStr = headerStr + "%," + middleStr + "%," + thumbnailStr + "%";
  parent.document.getElementById(theFramesetID).rows = paramStr;
}

// Use this function to set... to set the 3 vertical frames in the centre contents row (contents col, picture col, tariff col) 
// It is called from tariff.html
function setAccommodationTopFrameset(theFramesetID,left,centre,right) {
	this.setHomePageTripleFrameset(theFramesetID,left,centre,right);
} 
// ---------------------------------------------------------------------------------------------------------------

function changeImageSize(imageID,option,width,height) {	
	this.calcBaseFrameWidthHeight()
	document.getElementById(imageID).width = width * baseFrameWidth;
	document.getElementById(imageID).height = height * baseFrameHeight;
}
// ---------------------------------------------------------------------------------------------------------------

function setBackground() {
	document.body.style.background = backGroundColour_1;
}

function setBannerText() {
	this.setBackground();
	if (this.getClientScreenWidth() <= 800) {
		document.write('<p style="margin-top: 0; margin-bottom: 0" align="center"><font face="Times New Roman"><i><font size="5">Styles Lodge Guest House</font>&nbsp;&nbsp;&nbsp; <font size="4">&nbsp;&nbsp;01536 713202</font></i></font></p>');
	}
	else {
		document.write('<p style="margin-top: 0; margin-bottom: 0" align="center"><font face="Times New Roman"><i><font size="7">Styles Lodge Guest House</font>&nbsp;&nbsp;&nbsp; <font size="6">&nbsp;&nbsp;01536 713202</font></i></font></p>');
	}
}

function setStylesLodgeFont(option) {
	if (this.getClientScreenWidth() <= 800) {
		this.setFont(smallSize,option);
	}
	else {
		this.setFont(bigSize,option);
	}
}

function setFont(size,option) {
	for (i = 0; i < document.all.length; i++) {
		document.all[i].style.fontFamily = fontType;
		document.all[i].style.fontSize = size;
		if (option == 0) document.all[i].style.color = fontColour_0;
		else document.all[i].style.color = fontColour_1;
	}
}

// ---------------------------------------------------------------------------------------------------------------

function doSlideShow() {
	var myWidth, myHeight, whichDir;
	var theImagesStr = "";
	
	if (this.getClientScreenWidth() <= 800) {
		myWidth = 400; myHeight = 300;
		whichDir = "smallGalleryImages";	
	}
	else {
		myWidth = 600; myHeight = 450;
		whichDir = "galleryImages";
	}
	
	document.write('<div id="contents" style="width: ' + myWidth + '; height: ' + myHeight + '">');    
 		document.write('<table width="' + myWidth + '" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111" height="' + myHeight + '">');
 		document.write('<tr>');
 			document.write('<td width="' + myWidth + '" valign="top" class="main-content" height="' + myHeight +'">');
			document.write('<center>');
 			document.write('<div style="border: 1px solid white; height:auto;width:' + myWidth + 'px">');
				document.write('<div id="placeHolder" style="background-image: url("' + whichDir + '/Scotland-100.jpg"); background-repeat: no-repeat">');
 					document.write('<img src="' + whichDir + '/Scotland-100.jpg" alt="slide show" name="theImage" width="' + myWidth + '" id="theImage" style="opacity: 0;" height="' + myHeight + '"/>');
 					document.write('<p style="margin-top: 0; margin-bottom: 0">');
 				document.write('</div>');
 			document.write('</div>');
			document.write('</center>');    
 		document.write('</tr>');
 		document.write('</table>');
	document.write('</div>');
		
	for (i = 100; i < 109; i++)
		theImagesStr = theImagesStr + whichDir + '/Scotland-' + parseInt(i) + '.jpg;';

	RunSlideShow("theImage","placeHolder",theImagesStr,5);
}
// ---------------------------------------------------------------------------------------------------------------

function loadPlatform() {
	location.href = '../platformPage.html';
}

function setMainPage() {
	var page = getParam();
	if (page != null)  {//alert(page);
		setFrameSource(page);
	}
}

function setFrameSource(srcDocument) {
	var theFrameID = 'mainPlatformFrame';
	document.getElementById(theFrameID).src = srcDocument;
	//alert('From setFrameSource() - theFrameID = ' + theFrameID);
}

function setPlatformPage(thePage) {
	setFrameSource(thePage);
} 

var qsParm = new Array();
function getParam() {
	//alert("jeff");
	var queryStr = window.location.search.substring(1);
	var parms = queryStr.split('&');
	//alert(parms.length);
	for (var i = 0; i < parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
      qsParm[key] = val;
    	qsParm[i] = val;
		}
	}
	return qsParm[0];
}
