	function changeNews(num) {
		incrementVal = num;
		clearTimeout(newsInterval);
		var linkCont = document.getElementById('newslinks');
		var allLinks = linkCont.getElementsByTagName('a');
		for(var i = 0; i < allLinks.length; i++ ) {
			//allLinks[i].setAttribute('class', 'inactive_link');
			allLinks[i].className = 'inactive_link';
		}
		var selectLink = document.getElementById('link_'+num);
		//selectLink.setAttribute('class', 'active_link');
		selectLink.className='active_link';
		
		var newsCont = document.getElementById('newscontent');
		var allDivs = newsCont.getElementsByTagName('div');
		for(var i = 0; i < allDivs.length; i++ ) {
			if (allDivs[i].className == "newsitem_active") {
				//allDivs[i].setAttribute('class', 'newsitem');
				allDivs[i].className = 'newsitem';
			}
		}
		var selectDiv = document.getElementById('news_'+num);
		//selectDiv.setAttribute('class', 'newsitem_active');
		selectDiv.className = 'newsitem_active';
		newsInterval = setTimeout("scrollNews()", 7000);
	}
	
	var incrementVal = 1;
	function scrollNews() {
		var maxVal = document.getElementById('maxnews').value;
		if (incrementVal < maxVal) {
			incrementVal++;
		}else {
			incrementVal = 1;
		}
		changeNews(incrementVal);
		
	}
	function HSAvailHeight() {
	  if (typeof window.innerHeight != 'undefined')
		return window.innerHeight;
	  if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientHeight != 'undefined' && document.documentElement.clientHeight !== 0)
		return document.documentElement.clientHeight;
	  return document.getElementsByTagName('body')[0].clientHeight;
	}
	
	
	function changeBackgroundHeight() {
		return true
		/*var theImage = document.getElementById('backholder1').getElementsByTagName('img')[0];
		var heightBanana = (HSAvailHeight() +30) +'px';
		theImage.style.height = heightBanana;*/
	}
	//window.onresize = changeBackgroundHeight;
	function setCountDown(timestamp) {
		var date = new Date();
		var time = date.getTime();
		time = time / 1000;
		var difference = timestamp - time;
		var days = Math.floor( difference / (60*60*24));
		var hours = Math.floor( (difference-days*(60*60*24)) / (60*60));
		var minutes = Math.floor( (difference-days*(60*60*24)-hours*(60*60)) / (60));
		var seconds =Math.floor(  difference-days*(60*60*24)-hours*(60*60)-minutes*60);
		
		
		document.getElementById("countdays").innerHTML = days;
		document.getElementById("counthours").innerHTML = hours;
		document.getElementById("countminutes").innerHTML = minutes;
		document.getElementById("countseconds").innerHTML = seconds;
	}
		var ns_marquee;
	var marqueewidth;
	var actualwidth;
	var pauseit = true;
	var copyspeed = 1;
	var lefttime;
	
	function scrollmarquee(){
		
		var iedom=document.all||document.getElementById
		if (iedom){
			if (parseInt(ns_marquee.style.left)>(actualwidth*(-1)+8)) {
				ns_marquee.style.left=parseInt(ns_marquee.style.left)-copyspeed+"px";
			} else {
				ns_marquee.style.left=parseInt(marqueewidth)+8+"px";
			}
		}else if (document.layers){
			if (ns_marquee.left>(actualwidth*(-1)+8)) {
				ns_marquee.left-=copyspeed;
			}else { 
				ns_marquee.left=parseInt(marqueewidth)+8;
			}
		}
	}
	function loadMarquee(marqueeId) {
		ns_marquee = document.getElementById(marqueeId);
		
		ns_marquee.style.left = '0px';
		var nodeWidth = 0;
		var marqueeNodes = ns_marquee.childNodes;
		for (var i = 0; i < marqueeNodes.length; i++ ) {
			if (!isNaN(marqueeNodes[i].offsetWidth)) {
				nodeWidth = nodeWidth + marqueeNodes[i].offsetWidth + 20;
			}
		}
		ns_marquee.style.width = nodeWidth + "px";
		marqueewidth= ns_marquee.clientWidth;
		actualwidth = ns_marquee.offsetWidth;
		if (pauseit) {
			ns_marquee.onmouseover = function () {
				clearInterval(lefttime);
			}
			ns_marquee.onmouseout = function () {
				lefttime = setInterval("scrollmarquee()", 20);
			}
		}
		lefttime = setInterval("scrollmarquee()", 20);
	}
	function changeGalleryPic(toWhat, theThumb, whatGallery) {
		if (document.getElementById('gallery_video')) {
			var galVid = document.getElementById('gallery_video');
			galVid.innerHTML = '';
			galVid.style.display = 'none';
		}		
		if (document.getElementById('loading_gif')) {
			var Loady = document.getElementById('loading_gif');
			Loady.parentNode.removeChild(Loady);
			loadingGif = false;
		}				
		var gallery = document.getElementById(whatGallery);
		
		var theFbookNo = theThumb.getAttribute('data-fbook');
		if ((theFbookNo)&&(theFbookNo != "")) {
			var fbookCont = document.getElementById('fbooks');
			var fbookers = fbookCont.childNodes;
			for (var i = 0; i < fbookers.length; i++) {
				if (fbookers[i].nodeName.toLowerCase() == "div") {
					fbookers[i].className = 'inactive';
				}
			}
			document.getElementById('fbook_'+theFbookNo).className = 'active';
		}
		
		var thumbImg = theThumb.getElementsByTagName('img')[0]; 
		//or however you get a handle to the IMG
		var thumb_width = thumbImg.clientWidth;
		var thumb_height = thumbImg.clientHeight;
		loadWPad = (thumb_width - 31) / 2;
		loadHPad = (thumb_height - 31) / 2;
				
		loadingGif = document.createElement('img');
		loadingGif.src = "http://www.propertypro.co.uk/websites/platinum/images/loading.gif";
		loadingGif.id = "loading_gif";
		loadingGif.style.padding = loadHPad + "px " + loadWPad + "px";
		loadingGif.style.marginLeft = "-" + (thumb_width + 10) + "px";
		loadingGif.onclick = function() {
			return false;
		}
		if (navigator.userAgent.search("MSIE") != -1) {
			theThumb.appendChild(loadingGif);
			var loadImg = document.createElement('img');
			loadImg.src = toWhat;
			gallery.style.backgroundImage = "url('"+toWhat+"')";
			if (document.getElementById('lightboximage')) {
				document.getElementById('lightboximage').src = toWhat;
			}
			if (loadingGif) {
				theThumb.removeChild(loadingGif);
				loadingGif = false;
			}
			theThumb.className = 'active';
		}else {
			loadingGif.onload = function() {
				theThumb.appendChild(loadingGif);
				var loadImg = document.createElement('img');
				loadImg.src = toWhat;
				loadImg.onload = function() {
					gallery.style.backgroundImage = "url('"+toWhat+"')";
					if (document.getElementById('lightboximage')) {
						document.getElementById('lightboximage').src = toWhat;
					}	
					if (loadingGif) {
						theThumb.removeChild(loadingGif);
						loadingGif = false;
					}
					theThumb.className = 'active';
				}
			}
		}
	}

	function destroyLightBox() {
		var theImage = document.getElementById('lightboximage');
		var gallery = document.getElementById('gallery');
		var galleryNav = document.getElementById('gallerynav');
		var theMask = document.getElementById('mask');
		var theCloseButton = document.getElementById('closebutton');
		gallery.removeChild(theImage);
		gallery.removeChild(theMask);
		gallery.removeChild(theCloseButton);
		galleryNav.setAttribute('style', false);
	}
	function getWindowWidth () {
		if( typeof( window.innerWidth ) == 'number' ) {
			var sWidth = window.innerWidth;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			var sWidth = document.documentElement.clientWidth;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			var sWidth = document.body.clientWidth;
		}
		return sWidth;
	}
	function getWindowHeight () {
		if( typeof( window.innerWidth ) == 'number' ) {
			var sHeight  = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			var sHeight  = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			var sHeight  = document.body.clientHeight;
		}
		return sHeight;
	}
	function getScaleImage(iHeight, iWidth, what) {
		var sWidth = getWindowWidth();
		var sHeight = getWindowHeight();
		var scale =  (iWidth / iHeight);		
		if ((sHeight-100) > iHeight) {
			if (sWidth > iWidth) {
				var imgHeight = iHeight;
				var imgWidth = iWidth;
			}else {
				var imgWidth = iWidth;
				var imgHeight = (imgWidth / scale);
			}
		}else {
			if (sWidth > (scale*(sHeight-100))) {
				var imgHeight = (sHeight-100);
				var imgWidth = (imgHeight*scale);
			}else {
				var imgWidth = sWidth;
				var imgHeight = (imgWidth / scale);
			}
		}
		if (what == "height" ){
			return imgHeight;
		}else {
			return imgWidth;
		}
	}
	function makeLightbox() {
		var sWidth = getWindowWidth();
		var sHeight = getWindowHeight();
		var gallery = document.getElementById('gallery');
		var galleryNav = document.getElementById('gallerynav');
		var theMask = document.createElement('div');
		theMask.style.height = sHeight + "px";
		theMask.style.width = sWidth + "px";
		theMask.id = "mask";
		theMask.onclick = destroyLightBox;
		gallery.appendChild(theMask);
		
		var theCloseButton = document.createElement('img');
		theCloseButton.id = "closebutton";
		theCloseButton.src = "http://www.akplatinum.co.uk/images/closebutton.png";
		theCloseButton.onclick = destroyLightBox;
		gallery.appendChild(theCloseButton);
		
		galleryNav.style.position = 'fixed';
		galleryNav.style.width = (sWidth - 40) + "px";
		galleryNav.style.bottom = 0;
		galleryNav.style.left = 0;
		
		var imgSrc = gallery.style.backgroundImage.replace("url(", "").replace(")", "").replace('"', '').replace('"', '');
		var theImage = document.createElement('img');
		theImage.src = imgSrc;
		var iHeight = theImage.height;
		var iWidth = theImage.width;
		var scale = (iWidth / iHeight);
		var imgHeight = getScaleImage(iHeight, iWidth, 'height');
		var imgWidth= getScaleImage(iHeight, iWidth, 'width');
		theImage.style.height = (imgHeight-10) + "px";
		theImage.style.width = (imgWidth - (10 / scale)) + "px";
		theImage.style.left = ((sWidth - (imgWidth - (10 / scale))) / 2) + "px";
		theImage.id = "lightboximage";
		if (navigator.userAgent.search("MSIE") != -1) {
			gallery.appendChild(theImage);
		}else {
			theImage.onload = function() {
				gallery.appendChild(theImage);
			}	
		}
	}
	function handleGalleryReszie() {
		if (document.getElementById('lightboximage')) {
			var theImage = document.getElementById('lightboximage');
			var gallery = document.getElementById('gallery');
			var galleryNav = document.getElementById('gallerynav');
			var theMask = document.getElementById('mask');
			
			var sWidth = getWindowWidth();
			var sHeight = getWindowHeight();
			
			galleryNav.style.width = (sWidth - 40) + "px";
			theMask.style.width = sWidth + "px";
			theMask.style.height = sHeight + "px";
			
			domImage = document.createElement('img');
			domImage.src = theImage.src;
			var iHeight = domImage.height;
			var iWidth = domImage.width;
			domImage = false;
			var scale = (iWidth / iHeight);	
			var imgHeight = getScaleImage(iHeight, iWidth, 'height');
			var imgWidth= getScaleImage(iHeight, iWidth, 'width');
			theImage.style.height = (imgHeight-20) + "px";
			theImage.style.width = (imgWidth - (20 / scale)) + "px";
			theImage.style.left = ((sWidth - (imgWidth - (20 / scale))) / 2) + "px";
		}
	}
		/******************************************
	* Scrollable content script II- © Dynamic Drive (www.dynamicdrive.com)
	* Visit http://www.dynamicdrive.com/ for full source code
	* This notice must stay intact for use
	******************************************/
	// modified 17-October-2011
	function move(id,spd){
		var obj=document.getElementById(id),max=-obj.offsetHeight+obj.parentNode.offsetHeight,top=parseInt(obj.style.top);
		if ((spd>0&&top<=0)||(spd<0&&top>=max)){
			obj.style.top=top+spd+"px";
			move.to=setTimeout(function(){ move(id,spd); },20);
		}
		else {
			obj.style.top=(spd>0?0:max)+"px";
		}
	}
	function moveLeft(id,spd){
		var obj=document.getElementById(id),max=-obj.offsetWidth+obj.parentNode.offsetWidth,left=parseInt(obj.style.left);
		if ((spd>0&&left<=0)||(spd<0&&left>=max)){
			obj.style.left=left+spd+"px";
			moveLeft.to=setTimeout(function(){ moveLeft(id,spd); },20);
		}
		else {
			obj.style.left=(spd>0?0:max)+"px";
		}
	}
	function handleFocus() {
		if (this.value == this.getAttribute('data-default')) {
			this.value = "";
		}
	}	
	function handleBlur() {
		if (this.value == "") {
			this.value = this.getAttribute('data-default');
		}
	}	
	function setFocusEvents(form) {
		allInputs = form.getElementsByTagName('input');
		for (var i = 0; i < allInputs.length; i++ ){
			if (allInputs[i].getAttribute('type') == "text" ) {
				allInputs[i].onfocus = this.handleFocus;
				allInputs[i].onblur = this.handleBlur;
				allInputs[i].focus(); 
				allInputs[i].blur(); 
			}
		}
		allTexts = form.getElementsByTagName('textarea');
		for (var i = 0; i < allTexts.length; i++ ){
			allTexts[i].onfocus = this.handleFocus;
			allTexts[i].onblur = this.handleBlur
			allTexts[i].focus(); 
			allTexts[i].blur(); 
		}
	}
	function checkHTML5() {
		var v = document.createElement('video');
		var supported = v.canPlayType('video/mp4; codecs="avc1.58A01E, mp4a.40.2"');
		if ( supported == 'probably') {
			return true;
		}else {
			return false;
		}
	}
	function createFlashVideo(source, vidWidth, vidHeight, destination){
			var videodata = '<object width="' + vidWidth + '" height="' + vidHeight + '">';
			videodata += '<param name="movie" value="strobemediaplayback.swf">';
			videodata += '</param><param name="flashvars" value="src=' + source + '">';
			videodata += '</param><param name="allowFullScreen" value="true"></param>';
			videodata += '<param name="allowscriptaccess" value="always"></param>';
			videodata += '<embed src="strobemediaplayback.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + vidWidth + '" height="' + vidHeight + '" flashvars="src=' + source + '"></embed>';
			videodata += '</object>';
			destination.innerHTML = videodata;
	}
	function createHTML5Video(source, vidWidth,vidHeight, destination) {
		video = document.createElement('video');
		video.height = vidHeight;
		video.width = vidWidth;
		video.id = 'video';
		video.setAttribute('controls', 'true');
		video.setAttribute('autobuffer', 'true');
		video.src = source;
		video.type = "video/m4v";
		destination.appendChild(video);
		video.load();
		video.play();
	}
	function insertVideo(flash_source, m4v_source, desinationId, vidWidth, vidHeight) {
		var destination = document.getElementById(desinationId);
		destination.style.display = 'block';
		var navvy = navigator.userAgent;
		if ((navvy.search('MSIE') != -1 ) ||((navvy.search('Safari') != -1 )&&(navvy.search('Windows') != -1 )&&(navvy.search('Chrome') == -1 ))){
			createFlashVideo(flash_source, vidWidth, vidHeight, destination);
		}else if (checkHTML5()==true) {
			createHTML5Video(m4v_source, vidWidth, vidHeight, destination);
		}else {
			createFlashVideo(flash_source, vidWidth, vidHeight, destination);
		}
	}
