// main.js
// Byde Heating & Plumbing Ltd

// Global Consts
var COMPANY_NAME = 'Byde Heating &amp; Plumbing Ltd.';
var W3CDOM = (document.getElementsByTagName && document.createElement);

// Finds an objects position
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curleft += obj.x;
	}
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}

// Returns the 4 digit year from a date (Works in all Browsers)
function takeYear(theDate) {
	x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}

// Rollover Image Object - CONSTRUCTOR
// Filename - complete filename, including path
// imgOut - Default Image
// imgOver - Appears onMouseOver event
function RolloverImg(Width, Height, Filename, FilenameOver) {
	this.imgOut = new Image(Width,Height);
	this.imgOut.src = Filename;
	this.imgOver = new Image(Width,Height);
	this.imgOver.src = FilenameOver;
}

// Called from the initialize() function from each page js
// Sets elements that are common to all pages (avoids code duplication)
function setCommonElements() {
	if (!W3CDOM) return;
	
	var obj;
	var today = new Date();
	var day = today.getDate();
	var month = today.getMonth() + 1;

	// Title text
	obj = document.getElementById('companyl');
	if (obj) { obj.innerHTML = COMPANY_NAME; }
	obj = document.getElementById('companyd');
	if (obj) { obj.innerHTML = COMPANY_NAME; }
	
	// Xmas (18th Dec .. 3rd Jan regardless of year!)
	//alert('month = ' + month + '\nday = ' + day);
	if (((month == 12) && (day >= 18)) || ((month == 1) && (day <= 3))) { 
	//if (month == 10) { 
		obj = document.getElementById('xmas_gsr_logo');
		if (obj) { obj.style.display = 'block'; }
		obj = document.getElementById('xmas_holly');
		if (obj) { obj.style.display = 'block'; }
	}
}

function privacyStatement() {
	alert('PRIVACY STATEMENT\n\nAny information submitted to this website via the contact form is for the sole communication between the sender and Byde Heating & Plumbing Ltd.  No part of this information will be passed on to any third parties.\n\nNames and specific contact details of private individuals mentioned on the customer feedback pages are obscured in the interests of those individuals in order to protect their privacy.\n\nByde Heating & Plumbing Ltd.');
}

