// SAA Customer Center javascript include file

/*	checkRelation()
/	Called	: on every page in the body onload event
/	Used	: to ensure pages are called within the context of the frameset, e.g bookmarking a page within the frameset and then
/	attempting to access the page through the bookmark will result in the frameset not existing so browser is redirected
/	back to the proper start point.
*/

function checkRelation() {
	var objectTrueHome="/CustomerCentre/index.html";
	if ( ( parent.location.href.toUpperCase() ) == ( location.href.toUpperCase() ) ) {
		location.href=objectTrueHome
	} else {
		// within a frameset - but is it SAA's ?
		if  ( ( (parent.location.href.indexOf('http://www.reims.net/')==0) || (parent.location.href.indexOf('http://dobermann.saa-cons.co.uk')==0) || (parent.location.href.indexOf('http://saaweb')==0) ) && (((parent.location.href.toUpperCase()).indexOf('CUSTOMERCENTRE'))!=-1) ) {
			// It's OK, we're on the real site, but it could be a development server still
		} else {
			parent.location.href=objectTrueHome
		}
	}
}


function checkCWinRelation() {
	var objectTrueHome="/CustomerCentre/index.html";

	if (window.opener!=null) {
		//alert(window.opener.location.href)
		// Window has been opened in a child window, check the parent address
		if  ( (window.opener.location.href.indexOf('http://www.reims.net/')==0) || (window.opener.location.href.indexOf('http://dobermann.saa-cons.co.uk')==0) || (window.opener.location.href.indexOf('http://saaweb')==0) ) {
			// It's OK, we're on the real site, but it could be a development server still
		} else {
			window.opener.location.href=objectTrueHome
			self.close();
		}

	} else {
		if ( ( parent.location.href.toUpperCase() ) == ( location.href.toUpperCase() ) ) {
			location.href=objectTrueHome
		} else {
			// within a frameset - but is it SAA's ?
			if  ( ( (parent.location.href.indexOf('http://www.reims.net/')==0) || (parent.location.href.indexOf('http://dobermann.saa-cons.co.uk')==0) || (parent.location.href.indexOf('http://saaweb')==0) ) && (((parent.location.href.toUpperCase()).indexOf('CUSTOMERCENTRE'))!=-1) ) {
				// It's OK, we're on the real site, but it could be a development server still
			} else {
				parent.location.href=objectTrueHome
			}
		}
	}
}

function setBgColor(formEl){
	if(document.getElementById)formEl.style.backgroundColor  = '#99CCFF';
}

function resetBgColor(formEl){
	if(document.getElementById)formEl.style.backgroundColor  = '#FFFFFF';
}
