/***********************************************************************

			dim variables

***********************************************************************/

//var navSpeed=100;

//var firstTime=0;

var speed=15;

var loop, timer;

var initialised;

var bw;

var width, height;

var objControlTop, objControlLeft, objScrollerTop, objScrollerLeft;

var strScroll;



/***********************************************************************

			URL Stripper

***********************************************************************/

var qs = new QuerystringObject();



function QuerystringObject(){



	// get the query string, ignore the ? at the front.

	var querystring=location.search.substring(1,location.search.length);



	// parse out name/value pairs separated via &

	var args = querystring.split('&');



	// split out each name = value pair

	for (var i=0;i<args.length;i++){



		var pair = args[i].split('=');

		// Fix broken unescaping

		temp = unescape(pair[0]).split('+');

		temp0 = temp.join(' ');

		

		temp = unescape(pair[1]).split('+');

		temp1 = temp.join(' ');

		

		this[temp0]=temp1;

	}



	this.get=Querystring_get;

}



function Querystring_get(strKey,strDefault){

	var value=this[strKey];

	if (value==null){value=strDefault;}

	

	return value;

}


//new code
if (qs.get('page')=='Home' || qs.get('page')=='General Enquiries' || qs.get('page')=='Executive Management' || qs.get('page')=='Advertising Sales' || qs.get('page')=='Marketing and Circulation' || qs.get('page')=='Production' || qs.get('page')=='Finance' || qs.get('page')=='IT Services' || qs.get('page')=='Media Information' || qs.get('page')=='Promotions' || qs.get('page')=='Human Resources' || qs.get('page')=='Subscriptions' || qs.get('page')=='ELLE' || qs.get('page')=='ELLE Decoration' || qs.get('page')=='Crime Confidential' || qs.get('page')=='Red' || qs.get('page')=='B' || qs.get('page')=='Sugar' || qs.get('page')=='Psychologies' || qs.get('page')=='All About Soap' || qs.get('page')=='Inside Soap' || qs.get('page')=='Digital Spy') valueOfPage = qs.get('page');

if(qs.get('page')==null) valueOfPage = 'Home';

//old code commeted out
//valueOfPage = qs.get('page');
//if(valueOfPage==null) valueOfPage = 'Home';


switch(valueOfPage){



	case 'Home':

		strScroll = strScrollHome;

		break;

	

	case 'General Enquiries':

		strScroll = strScrollGenEnquiries;

		break;



	case 'Executive Management':	

		strScroll = strScrollExecManagement;

		break;

		

	case 'Advertising Sales':	

		strScroll = strScrollAdSales;

		break;



	case 'Marketing and Circulation':	

		strScroll = strScrollMarketing;

		break;



	case 'Production':	

		strScroll = strScrollProduction;

		break;

			

	case 'Finance':	

		strScroll = strScrollFinance;

		break;



	case 'IT Services':	

		strScroll = strScrollIT;

		break;

		

	case 'Media Information':	

		strScroll = strScrollMediaInfo;

		break;

		

	case 'Promotions':

		strScroll = strScrollPromotions;

		break;



	case 'Human Resources':

		strScroll = strScrollHumanResources;

		break;

	

	case 'Subscriptions':

		strScroll = strScrollSubscriptions;

		break;

		

	case 'ELLE':

		strScroll = strScrollELLE;

		break;		

		

	case 'ELLE Decoration':

		strScroll = strScrollELLEDeco;

		break;



	case 'Crime Confidential':

		strScroll = strScrollCrimeConf;

		break;



	case 'Red':

		strScroll = strScrollRed;

		break;

		

	case 'B':

		strScroll = strScrollB;

		break;



	case 'Sugar':

		strScroll = strScrollSugar;

		break;

		

	case 'Psychologies':

		strScroll = strScrollPsychologies;

		break;

		

	case 'All About Soap':

		strScroll = strScrollAas;

		break;

		

	case 'Inside Soap':

		strScroll = strScrollInsideSoap;

		break;

		

	case 'Digital Spy':

		strScroll = strScrollDigitalSpy;

		break;

		

}



function setScrolls(){



	objScroller.moveArea(0,0);



	switch(valueOfPage){

	



		case 'Home':

			objControl.css.visibility='hidden';

			objScroller.scrollHeight=0;

			break;



		case 'General Enquiries':

			objControl.css.visibility='hidden';

			objScroller.scrollHeight=0;

			break;

	

		case 'Executive Management':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=580;

			break;



		case 'Advertising Sales':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=785;

			break;	



		case 'Marketing and Circulation':

			objControl.css.visibility='hidden';

			objScroller.scrollHeight=0;

			break;	



		case 'Production':

			objControl.css.visibility='hidden';

			objScroller.scrollHeight=0;

			break;

	

		case 'Finance':

			objControl.css.visibility='hidden';

			objScroller.scrollHeight=0;

			break;



		case 'IT Service and Facilities':

			objControl.css.visibility='hidden';

			objScroller.scrollHeight=0;

			break;



		case 'Syndication':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=490;

			break;

	

		case 'Promotions':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=520;

			break;



		case 'Human Resources':

			objControl.css.visibility='hidden';

			objScroller.scrollHeight=0;

			break;



		case 'Subscriptions':

			objControl.css.visibility='hidden';

			objScroller.scrollHeight=0;

			break;

			

		case 'ELLE':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=490;

			break;			

	

		case 'ELLE Decoration':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=470;

			break;

			

		case 'Crime Confidential':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=420;

			break;

	

		case 'Red':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=650;

			break;	



		case 'B':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=490;

			break;

			

		case 'Sugar':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=420;

			break;

	

		case 'Psychologies':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=500;

			break;



		case 'All About Soap':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=330;

			break;

			

		case 'Inside Soap':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=330;

			break;



		case 'Digital Spy':

			objControl.css.visibility='visible';

			objScroller.scrollHeight=500;

			break;



	}







}



/***********************************************************************

			Browser test

***********************************************************************/



function verifyCompatibleBrowser(){ 



    this.ver=navigator.appVersion 

    this.dom=document.getElementById?1:0 

    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 

	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0; 	

    this.ie4=(document.all && !this.dom)?1:0; 

    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 

    this.ns4=(document.layers && !this.dom)?1:0; 

    this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns5) 



    return this 



}



bw=new verifyCompatibleBrowser();



/***********************************************************************

			initialise objects

***********************************************************************/



function initialiseCommonObjects(){

	

	objContainer=new createScrollObject('divContainer'); 

	objScroller=new createScrollObject('divContent','divContainer');   //--objScroller refers to both layers as one object--//

	objControl=new createControlObject('divControl');

	objPageName=new createControlObject('divPageName');

}





/***********************************************************************

			Control funnctions - not specific to objects

***********************************************************************/



function initialisePage(){		//		define what gets initialised on page load



	initialiseCommonObjects();	//common stuff

	positionObjects();

	rewriteLayer('divPageName','<span class=blueHeader>' + valueOfPage + '</span>');

	setScrolls();

	setPageVisibility();



}



function setPageVisibility(){		//	turn on visiblity of initial page objects

	

	objPageName.css.visibility='visible';

	objScroller.css.visibility='visible';

	initialised = true;

}



function objectPositions(){		//find object positions



	if(document.all){

		width = document.body.scrollWidth ;

		height = document.body.scrollHeight;

	}

	else{

		width = document.width;

		height = document.height;

	}



	objScrollerTop = (height/2)-150;

	objScrollerLeft = (width/2)-100;

	

	objPageNameTop = (height/2)-182;

	

	objControlTop = (height/2)+56;

	objControlLeft = (width/2)-95;	



}



function positionObjects(){		//position objects



	objectPositions();

	objContainer.moveObject(objScrollerTop,objScrollerLeft);	

	objControl.moveObject(objControlTop,objControlLeft);

	objPageName.moveObject(objPageNameTop,objScrollerLeft+145);

	objScroller.moveArea(0,0);

}





function rewriteLayer(id,html){	// rewrites the html inside a layer



       if (document.all){document.all[id].innerHTML = html;return;}

        else if(document.layers && arguments.length==2) {var lay= eval(document.layers[id]);}

		else if(document.layers && arguments.length==3) {var lay= eval(document.layers[nn4Parent].document.layers[id]);}

            if(document.layers){

				lay.document.open();

	            lay.document.write(html);

	            lay.document.close();

		  		return;

				}

	  	else if(document.getElementById){

	  	document.getElementById(id).innerHTML = html;

	  	}

	return;

}



/***********************************************************************

			scroll object creator

***********************************************************************/



function createControlObject(obj){      //--used to recognise divContainer and divContent layers as a single object--//

    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;

    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 

	this.visible=showHideObject;		//	show hide object method

	this.moveObject=moveObject;

	this.x; 

	this.y;

	 

    this.obj = obj + "Object" 

    eval(this.obj + "=this") 

    return this 

	

} 



/***********************************************************************

			scroll object creator

***********************************************************************/



function createScrollObject(obj,nest){      //--used to recognise divContainer and divContent layers as a single object--//

    nest=(!nest) ? '':'document.'+nest+'.' 

    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;

    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 

    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 

    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight 

	this.visible=showHideObject;		//	show hide object method

	this.moveObject=moveObject;

    this.up=moveAreaUp;             //--gives scrolling method to object--//

	this.down=moveAreaDown; 

    this.moveArea=moveArea; 

	this.x; 

	this.y;



    this.obj = obj + "Object" 

    eval(this.obj + "=this") 

    return this 

	

} 



/********************************************************

		Scroller object Methods

***********************************************************/



function moveArea(x,y){ 	//	moves the scroll

    this.x=x;this.y=y 

    this.css.left=this.x 

    this.css.top=this.y 

} 

 

function moveAreaDown(move){ 	// Loop to move scroll down

	if(this.y>-this.scrollHeight+eval('objContainer').clipHeight){   //--stops scrolling at end of layer--//

    this.moveArea(0,this.y-move) 

    if(loop) setTimeout(this.obj+".down("+move+")",speed) 

	} 

} 



function moveAreaUp(move){ 	// loop to move scroll up

	if(this.y<0){ 

    this.moveArea(0,this.y-move) 

    if(loop) setTimeout(this.obj+".up("+move+")",speed) 

	} 

} 

 

function performScroll(speed){ 	//	starts scroll



	if(initialised){ 

		loop=true; 

		if(speed<0) eval('objScroller').up(speed) 

		else eval('objScroller').down(speed) 

	} 

} 

 

function ceaseScroll(){ 	//	stops scroll

    loop=false 

    if(timer) clearTimeout(timer) 

} 





/***********************************************************************

	Commom object methods

***********************************************************************/	



function moveObject(toppos,leftpos){	// Move object around the screen

	this.css.top=toppos;

	this.css.left=leftpos;	

}



function showHideObject(status){		//	Set object visibilty

	this.css.visibility = status;

}



