$(document).ready(function () {

    $('.login_btn').live('click', function () {
        $('.overlay').show();
        $('#table_holder').show();
        $('.login_box').fadeIn('slow');

        $('#table_holder').live('click', function () {
            $('.overlay').hide();
            $('#table_holder').hide();
            $('.login_box').hide();
        });

	$('#loginClose').live('click', function () {
            $('.overlay').hide();
            $('#table_holder').hide();
            $('.login_box').hide();
        });

        $('.login_box').live('click', function (e) {
            e.stopPropagation();
        });
    });

});

function changeSearchTabs(id) {

    if (id == 'ukSearch') {
		$('#intSearchHolder').css('display','none');
		$('#UKSearchHolder').css('display','block');
		$('#intSearch').attr('class','');
    }
    else {
		$('#UKSearchHolder').css('display','none');
		$('#intSearchHolder').css('display','block');
		$('#ukSearch').attr('class','');
    }

	$('#' + id).attr('class', 'active');
}

function changeTabs(id, archive) {
	
	if(archive == "archive")
	{	$('.archive_tab .menuTab').removeClass('active');
		$('.tab_container_archive .archive_tab_page').stop(true, true).hide();
	} else {
		$('.tab_menu .menuTab').removeClass('active');
		$('#tab_container .tab_content').stop(true, true).hide();
	}
	
	$('#' + id).addClass('active');
	$("div." + id).fadeIn('slow');
	
// to show the achive tab within the news tab, you pass the second var as the name of the tab you want to show	
	if(archive != "archive"){
		$('#' +archive).addClass('active');
		$('div.' + archive).fadeIn('slow');
	}
}

function changeNewsArchivePages(id, archive, tab) {
	
	if(archive == "archive_page") {
		$('.archiveMenu').removeClass('active');
		$('.' + tab + ' .archive_page').stop(true, true).hide();
	}
	
	$('.' + tab + ' .' + id).addClass('active');
	$('.' + tab + ' div.' + id).fadeIn('slow');
	
}

function changeFeatureArticle(id) {
	
	$('.our_features .feature').stop(true, true).hide();
	$('.our_features .' + id).fadeIn('slow');
	
}

function openBlock(id)
{
		$('#' + id + ' .block_content').toggle();
		$('#' + id +' h2').toggleClass("closed")
		$('#' + id +' h2').toggleClass("open")
}

function previousSlide() {

	$('.scroll').animate({   
	left: '+=310'
 	}, 400, function() {
	 
		 var pos = ($('.scroll').position().left -10);
		 var pos2 = ($('.slider_content:last').position().left)*-1;
		 
		 if(pos != pos2 ){
			 $('.right').show();
		} 
		
		if( $('.scroll').position().left == 0)
		{
			 $('.left').hide();
		}
	});
	 
	
}

function nextSlide() {

	$('.scroll').animate({   
	left: '-=310'
  	}, 300, function() {
		 
		 var pos = ($('.scroll').position().left -10);
		 var pos2 = ($('.slider_content:last').position().left)*-1;
	
		if(pos <= pos2 )
		{
		$('.right').hide();
		}	
		
		if( $('.scroll').position().left != 0)
		{
			$('.left').show();
		}			  
	});
		
}

function requestContent(file, variablesToPass, placeHolder) {
   
    // post(file, data, callback, type); (only "file" is required)
    $.post(file, variablesToPass, 
	function(data) {
		 $('#' + placeHolder).html(data); 
	}
    );
   
}


function SubmitLogin(form) {

	if ((form.user.value == '' || form.password.value == '') || (form.user.value == 'Username' || form.password.value == 'Password'))
	{
		$('#loginErr').text('Please Enter Username and Password');
		$('#loginErr').css('display','block');
		return false;
	}

    	$.post('/includes/login.aspx', {Type : form.loginType.value, Username : form.user.value, Password : form.password.value}, 
		function(data) {

			if (data == 'Invalid Login')
			{
				$('#loginErr').text(data);
				$('#loginErr').css('display','block');
			}
			else
			{
				window.location = data;
			}
		}
    	);
}

function EmailTo(url) {
	window.location = url;
}

/*function Subscribe(form) {
   
    	$.post('/Subscribe.aspx', {Email : form.subEmail.value}, 
		function(data) {
			$('#subscribeRes').text(data);
		}
    	);
   
}*/

function Subscribe(form) {
   
    	$.post('/Subscribe.aspx', {Email : form.subEmail.value}, 
		function(data) {
			$('#newsSubscribe').html(data);
		}
    	);
   
}

//Search Javascript

function LoadFeed(URL, ElementID, LoadingHTML, LoadCode) {
	var XMLObject;

	XMLObject = false;

	if (window.XMLHttpRequest && !(window.ActiveXObject))
	{
		try {
			XMLObject = new XMLHttpRequest();
		} catch (e) {
			XMLObject = false;
		}
	} else if (window.ActiveXObject) {
		
		try {
			XMLObject = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				XMLObject = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				XMLObject = false;
			}
		}

	}

	if (XMLObject) {
		if (ElementID != '') {
			document.getElementById(ElementID).innerHTML = LoadingHTML;
		}
			
		if (URL.indexOf('?') == -1) {
			XMLObject.open("GET", URL + '?Rndd=' + Math.floor(Math.random() * 99999999999999999), true);
		} else {
			XMLObject.open("GET", URL + '&Rndd=' + Math.floor(Math.random() * 99999999999999999), true);
		}
			
		XMLObject.onreadystatechange = function () {					
							if (XMLObject.readyState == 4 && XMLObject.status == 200) {
								if (ElementID != '') {
									document.getElementById(ElementID).innerHTML = XMLObject.responseText;
								}
								XMLObject = null;
								eval(LoadCode);
							}					
						};
		XMLObject.send("");
	} else {
		document.getElementById(ElementID).innerHTML = '<div class="errordiv">No LDAP detected</div>';
	}
		
}

function GotoArea(Menu) {
	if (Menu.value !== '' && Menu.value !== 'Type City or Town') {
		if (searchurl.length > 0) {
			document.location = searchurl;
		} else {
			document.location = '/SearchOffices.aspx?ST=FreeText&Location=' + Menu.value + '&ComPage=0';
		}
	} else {
		try {
			if (searchurl != '') {
				document.location = searchurl;
			} else {
				Menu = document.getElementById('home-txt');
				if (Menu.value !== ''  && Menu.value !== 'Type City or Town') {		
					document.location = '/SearchOffices.aspx?ST=FreeText&Location=' + Menu.value + '&ComPage=0';
				}
			}
		} catch (e) {

		}
	}
}

function GotoAreaDrp(Menu) {
	if (Menu.value !== 'na') {
		document.location = '/' + Menu.value + '_Office+Space+to+Rent_1.html?ST=DropDown';
	}
}

function globalSearch(MyTextValue) {
	if (MyTextValue != ''  && MyTextValue !== 'Type UK location') {		
		document.location = '/SearchOffices.aspx?ST=FreeText&Location=' + MyTextValue + '&ComPage=0';
	}		
}


function globalCheckEnter(e, MyTextValue) { //e is event object passed from function invocation
	var characterCode; //literal character code will be stored in this variable

	if (e && e.which) { //if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	} else {
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	if (characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)
		/*if (document.location != '') {
				document.location = searchurl;
		} else {
			globalSearch(MyTextValue); //submit the form
		} */
		
		globalSearch(MyTextValue);
		return false;
	} else {
		return true;
	}

}

var oldlength = 0;
var helperlink = 0;
var FoundResults = 0;
var tempurl = '';

var searchurl = '';
var VisableHelper = 'Head';

function UpdateSearchType(MyType, MyTextBox) {
	SearchType = MyType;
	TextBoxType =  MyTextBox;
}

function HideHelper() {
	if (DontHide === 0) {
		document.getElementById(SearchType + 'SearchHelper').style.display = 'none';

		tempurl = searchurl;
		searchurl = '';
	}
}

function showhelper(searchbox) {
	if (document.getElementById(SearchType + 'SearchHelper').innerHTML == '[POST CODE SEARCH]') {
		return false;
	}

	if (VisableHelper != SearchType) {
		document.getElementById(VisableHelper + 'SearchHelper').style.display = 'none';
		tempurl = '';
		searchurl = '';
	}

	if  ((FoundResults == 1) && (searchbox.value.length > 3) && (searchbox.value != 'UK office search' && searchbox.value != 'Type US location' && searchbox.value != 'Type City or Town')) {
		document.getElementById(SearchType + 'SearchHelper').style.display = 'block';

		VisableHelper = SearchType;
	}
}

function changeGlobal(MyBox, Typing, SearchType) {
	var searchbox = MyBox;	
		
	if (searchbox.value == '' && Typing === false) {
		searchbox.value = 'UK office search';
	} else if (Typing === true && searchbox.value == 'UK office search') {
		searchbox.value = '';
		searchbox.style.fontStyle = 'normal';
	}
}

function FocusHelp(e, forceme) {
	var characterCode; //literal character code will be stored in this variable

	if (e.which) { //if which property of event object is supported (NN4)
		characterCode = e.which; //character code is contained in NN4's which property
	} else {
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	if ((characterCode == 40) || (forceme)) {

		document.getElementById(SearchType.toLowerCase() + '-' + TextBoxType).blur();
		document.getElementById(SearchType + 'SearchHelper').focus();

		if (forceme === false) {
			changehelperlink(0);
			scrolldirection = 1;
			scrollnow();
		}
	}
}

function scrollnow() {
	if (scrolldirection)  {
		if (helperlink + 1 <= parseInt(document.getElementById(SearchType + 'totallinks').innerHTML)) {
			changehelperlink(helperlink + 1);
		} else {
			scrollme = 0;
		}
	} else {
		if (helperlink - 1 >= 0) {
			changehelperlink(helperlink - 1);
		} else {
			scrollme = 0;
		}
	}
	
	if (scrollme) {
		setTimeout('scrollnow', 500);
	}
}

function changehelperlink(newlink) {
	if ((document.getElementById(SearchType + 'SearchHelper').innerHTML == '[POST CODE SEARCH]') || (document.getElementById(SearchType + 'SearchHelper').innerHTML == '')) {
		DontHide = 0;
		HideHelper();
		return false;
	}

	if (document.getElementById(SearchType + 'SearchHelper').style.display != 'block') {
		DontHide = 1;
		document.getElementById(SearchType + 'SearchHelper').innerHTML = document.getElementById(SearchType + 'SearchHelper').innerHTML;
		document.getElementById(SearchType + 'SearchHelper').style.display = 'block';
	}

	var templink = helperlink;

	try {
		if (SearchType == 'Head') {
			document.getElementById(SearchType + 'HelperLink_' + helperlink).style.backgroundColor = '#FFFFFF';
		} else {
			document.getElementById(SearchType + 'HelperLink_' + helperlink).style.backgroundColor = '#FFFFFF';
		}
		helperlink = newlink;
		document.getElementById(SearchType + 'HelperLink_' + newlink).style.backgroundColor = '#D9E0FF';
		searchurl = document.getElementById(SearchType + 'HelperLink_l' + newlink).href;
	} catch (e) {
		helperlink = templink;
		scrollme = 0;
		document.getElementById(SearchType + 'HelperLink_' + helperlink).style.backgroundColor = '#D9E0FF';
		searchurl = document.getElementById(SearchType + 'HelperLink_l' + newlink).href;
	}
}

function findplaces(searchbox) {
	if ((searchbox.value.length > 3) && (document.getElementById(SearchType + 'SearchHelper').innerHTML != 'Loading...') && (searchbox.value.length != oldlength)) {
		LoadFeed('/includes/PredictSearch.aspx?Placename=' + searchbox.value + '&Helper=' + SearchType, SearchType + 'SearchHelper', 'Loading...', 'changehelperlink(0)');
		FoundResults = 1;
		searchurl = tempurl;
	} else if (searchbox.value.length <= 3) {
		document.getElementById(SearchType + 'SearchHelper').style.display = 'none';
		tempurl = searchurl;
		searchurl = '';
	}

	oldlength = searchbox.value.length;
}

function startscroll(e) {
	var characterCode; //literal character code will be stored in this variable

	if (e.which) { //if which property of event object is supported (NN4)	
		characterCode = e.which; //character code is contained in NN4's which property
	} else {
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	if (characterCode == 38) { //if generated character code is equal to ascii 13 (if enter key)
		scrolldirection = 0;
		scrollnow();
	} else if (characterCode == 40) {
		scrolldirection = 1;
		scrollnow();
	} else if (characterCode == 13) {
		document.location = searchurl;
	}
}

function stopscroll() {
	scrollme = 0;
}

function hide() {
	DontHide = 1;
}

function setSearchHelperEvents(searchHelper) {
	var temp = document.getElementById(searchHelper);
	temp.tabIndex = "1";

	if (document.addEventListener) {
		temp.addEventListener('focus', hide, false);
	} else if (document.attachEvent) {
		temp.attachEvent("onfocus", hide);
	}
}

function MapPop(LatCo, LongCo) {

	var mapwindow;
	var lat_co = LatCo;
	var long_co = LongCo;

	mapwindow = window.open("/Map.aspx?LatCo=" + lat_co + "&LongCo=" + long_co, "OfficeLocation", "scrollbars=no,resizable=no,toolbar=no,location=no,menubar=no,width=560,height=560");

}

function loadMap(lat, mylong) {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.setCenter(new GLatLng(lat, mylong), 14);
		map.setUIToDefault();

		var custicon = new GIcon();
		custicon.image = "/images/icons/office_marker_green.gif";
		custicon.iconSize = new GSize(47, 37);
		custicon.iconAnchor = new GPoint(13, 24);

		markerOptions = { icon: custicon };

		var point = new GLatLng(lat, mylong);

		map.addOverlay(new GMarker(point, markerOptions));

		GEvent.addListener(map, 'zoomend', function() {
			if (map.getZoom() > 14) {
				map.setZoom(14);
				document.getElementById('text-div').style.display = 'block';
			}
		});
	}
}

function checkFormError(element, html) {
	var splitElements = element.split(":");

	if (html === undefined) {
		html = false;
	}

	for (i = 0; i < splitElements.length; i++) {
		var temp = document.getElementById(splitElements[i]).value;
		if (html === true) {
			temp = temp.replace(/</g, "[LT]");
		}
		else
		{
			temp = temp.replace(/</g, "&lt;");
		}
		document.getElementById(splitElements[i]).value = temp;
		
	}
	return true;
}

// Review

var sMax;
var holder;
var preSet;
var rated;

function rating(num) {
	sMax = 0;
	for (n = 0; n < num.parentNode.childNodes.length; n++) {
		if (num.parentNode.childNodes[n].nodeName == "A") {
			sMax++;	
		}
	}
	
	if (!rated) {
		s = num.id.replace("_", '');
		a = 0;
		for (i = 1; i <= sMax; i++) {		
			if (i <= s) {
				document.getElementById("_" + i).className = "on";
				holder = a + 1;
				a++;
			} else {
				document.getElementById("_" + i).className = "";
			}
		}
	}
}

function off(me) {
	if (!rated) {
		if (!preSet) {	
			for (i = 1; i <= sMax; i++) {		
				document.getElementById("_" + i).className = "";
			}
		} else {
			rating(preSet);
		}
	}
}

function rateIt(me) {
	if (!rated) {
		preSet = me;
		//rated=1;
		applyRate(me);
		rating(me);
	}
}

function applyRate(sel) {
	document.getElementById("rating").value = sel.id.replace("_", "");
}

// Consultant

var consultantid;

function GetConsultant(searchlocation) {
	GetConsultantPost(searchlocation.value);
}

function GetConsultantPost(PostCode) {
	if (PostCode !== '') {
		LoadFeed('/consultants/findconsultant.aspx?ConsultantSearch=' + PostCode, 'PlaceSelection', '<b>Finding Area...</b>', 'TestConsultant()');
	} else {
		alert('Please Type A Location');
		document.location = '/consultants/';
	}
}

function TestConsultant() {
	try {
		Teststring = document.getElementById('consultantid').innerHTML;
		if (Teststring.indexOf('ID:') === 0) {
			var temp;

			temp = Teststring.split(":");
			document.location = '/consultants/consultantinfo.aspx?consultantid=' + temp[1];
		}
	} catch (e) {

	}
}

function checkConsultantEnter(e, Search) { //e is event object passed from function invocation
	var characterCode; //literal character code will be stored in this variable

	if (e && e.which) { //if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	} else {
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	if (characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)
		GetConsultant(Search); //submit the form
		return false;
	} else {
		return true;
	}

}

// Extra Info

function imgChange(ID, newImg) {
	var temp = document.getElementById(ID);
	temp.src = OffImages[newImg].src;
}

function OpenVid(url) {
	var mapwindow;

	mapwindow = window.open(url, "YouTube", "scrollbars=yes,resizable=yes,toolbar=yes,location=yes,menubar=yes,width=800,height=600");
}

function showReviews() {
	document.getElementById("otherRev").style.display = 'block';
	document.getElementById("showAllRevBot").style.display = 'none';
}

function OpenBCADoc() {
	window.open('/BCA.html', 'BusinessCentreAssociation', 'width=400, height=300, toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=no');
}

// Faq

function ShowQuestion(quest) {
	var answer;
    
	answer = document.getElementById('A' + quest);

	if (answer.style.display == '' | answer.style.display == 'none' | answer.style.display == 'hidden') {
		answer.style.display = 'block';
	} else {
		answer.style.display = 'none';
	}
}

// Forum

function openForm() {
	var tempdiv = document.getElementById('RegForm');
	
	if (tempdiv.style.display == 'none') {
		tempdiv.style.display = 'block';
		document.getElementById('RegFormLink').innerHTML = 'Register(Close)';
	} else {
		tempdiv.style.display = 'none';
		document.getElementById('RegFormLink').innerHTML = 'Register';
	}

}

function checkRegForm() {
	var uname = document.getElementById('Username').value;
	var pass = document.getElementById('Password').value;
	var pass2 = document.getElementById('PasswordTwo').value;
	var email = document.getElementById('EMail').value;
	var email2 = document.getElementById('EMailTwo').value;
		
	var url = 'Username=' + uname + '&Password=' + pass + '&PasswordTwo=' + pass2 + '&Email=' + email + '&EmailTwo=' + email2;
		
	LoadFeed('/forum/Forms/register/regsubmit.aspx?' + url , 'ErrorPara', '<b>Checking Registration</b>', 'completeRegistration()');
}
	
function completeRegistration() {
	var form = document.getElementById('RegisterForm');
	try {
		if (document.getElementById('ty-para').innerHTML == 'Thank you for registering with the officebroker.com forums, feel free to browse but to login you must activate your account via the email sent to the address you provided') {
			form.style.display = 'none';
		}
	} catch (e) {
		
	}
}
	
function checkform() {
	if (document.getElementById("replytxt").value == '') {
		return false;
	} else {
		var temp = document.getElementById("replytxt").value;
		temp = temp.replace(/</g, "&lt;");
		document.getElementById("replytxt").value = temp;
		return true;
	}

}

function changebgColor(id, position) {
	var tempthread = document.getElementById(id);
		
	if (position == 'over') {
		tempthread.style.backgroundColor = '#E1E9F4';
		tempthread.style.fontWeight = 'bold';
	} else if (position == 'out') {
		tempthread.style.backgroundColor = '#FFFFFF';
		tempthread.style.fontWeight = 'normal';
	}
}

// Int Search

function internationalSearch(country, city) {
	if (city != 'na') {
		document.location = '/Global/' + country.replace(/\s/g,'+') + '_' + city.replace(/\s/g,'+') + '_Office+Space+To+Rent_1.html';
	}
}

function intLoadDropDowns(country) {
	var globalSelect = document.getElementById('global-drop');
	var tempcountry;

	for (var i = 0; i < globalSelect.options.length; i++) {
		tempcountry = globalSelect.options[i].value;
		tempcountry = tempcountry.toLowerCase();

		if (tempcountry == country.toLowerCase()) {
			globalSelect.options[i].selected = true;
		}
	}

	LoadFeed('/includes/gl-city-drop.aspx?Country=' + document.getElementById('global-drop').value, 'glob-city', '&lt;p&gt;Loading Cities...&lt;/p&gt;', '');
}

//Office Right

var count = 0;
var pricecount = 0;
var usedprice = false;
var usedcompare = false;
var mycompare = [];

function CompareOffice(ID, Address, RemoveByList, Type, Services, ImgURL, OffURL) {
	if (Type == 'Comp') {
		LoadFeed('/includes/officecompare.aspx?OfficeID=' + ID + '&Address=' + Address + '&Services=' + Services + '&ImageUrl=' + ImgURL + '&OfficeURL=' + OffURL, '', '', 'window.location.reload()');
		return true;
	} else if (Type != 'Load' && Type != 'CompLoad') {
		LoadFeed('/includes/officecompare.aspx?OfficeID=' + ID + '&Address=' + Address + '&Services=' + Services + '&ImageUrl=' + ImgURL + '&OfficeURL=' + OffURL, '', '', '');
	}

	var checkbox = document.getElementById('chk' + ID);
	var officeList = document.getElementById('comp-list');

	if ((Type != 'Load' && Type != 'CompLoad') && (RemoveByList == 'True' || checkbox.checked === false)) {
		try {
			checkbox.checked = false;
		} catch (err) {
		
		}

		count--;

		try {
			document.getElementById("comp" + ID).innerHTML = 'Compare';
			document.getElementById("comp" + ID).style.textDecoration = 'none';
		} catch (err) {
		
		}

		for (i = 0; i < mycompare.length; i++) {
			if (mycompare[i] == ID) {
				mycompare.splice(i, 1);
			}
		}

		for (i = 0; i < mycompare.length; i++) {
			CompareText(mycompare[i], i + 1);
		}

		var templeft = 3 - count;
		var tempchose = 0 + count;

		if (count == 1) {
			document.getElementById('CompareBtn').style.display = 'none';
		}

		if (count === 0) {
			document.getElementById('compare-off').style.display = 'none';
			document.getElementById('comp-num').innerHTML = '';
			document.getElementById('comp-left').innerHTML = '';
		} else {
			document.getElementById('comp-num').innerHTML = tempchose + ' ';
			document.getElementById('comp-left').innerHTML = templeft + ' ';
		}

	} else {
		var x = document.getElementById('comp-num').innerHTML;

		if (x == 3 || x == '(3)') {
			alert("You Have Selected The Maximum Number Of Offices Allowed For Comparing");
			checkbox.checked = false;
		} else {
			if (x == 1 || x == '') {
				document.getElementById('compare-off').style.display = 'block';

				try {
					officeList.removeChild(document.getElementById('none-sel'));
				} catch (err) {
			
				}

				if (usedcompare === false) {
					ShowDiv('comp-help-div');
					usedcompare = true;
				}
			}

			if (Type != 'Load' && Type != 'CompLoad' && (x == 2 || x == '(2)')) {
				window.location = '/Compare.aspx';
			}

			count++;

			if (x == 2 || x == '(2)') {
				try {
					document.getElementById('AddComp').style.display = 'none';
				} catch (err) {
			
				}
			}

			try {
				CompareText(ID, count);
			} catch (err) {
			
			}

			mycompare[count - 1] = ID;

			var templeft = 3 - count;
			var tempchose = 0 + count;

			if (count > 1) {
				try {
					document.getElementById('CompareBtn').style.display = 'block';
				} catch (err) {
			
				}
			}

			document.getElementById('comp-num').innerHTML = tempchose + ' ';
			document.getElementById('comp-left').innerHTML = templeft + ' ';
		}
	}
}

function ClearCompare(ref) {
	var itemp;

	//The reason 0 is used in the for loop is because each item in the array will get spliced in the CompareOffice function
	//This will mean any rows will get reassigned to the correct array number. e.g 2 will become 1, 3 will become 2.
	for (itemp = 0; itemp <= 3; itemp++) {
		try {
			if (mycompare[0].replace(/\s/g, "") != '') {
				CompareOffice(mycompare[0], '', 'True', '', '', '', '');
			}
		} catch (err) {
		}
	}

	if (ref == "Compare") {window.location.reload()};
}

function AddOfficePrice(ID, Address, RemoveByList, Type, ImgURL, OffURL) {
	var ListItemExists = 'False';

	if (Type != 'Load') {
		if (Type == 'Comp') {
			try {
				document.getElementById(ID + "PRICELI").innerHTML;
				ListItemExists = 'True';
			} catch (err) {

			}
		}

		if (ListItemExists == 'False') {
			LoadFeed('/includes/officepricelist.aspx?OfficeID=' + ID + '&Address=' + Address + '&ImageUrl=' + ImgURL + '&OfficeURL=' + OffURL, '', '', '');
		}
	}

	var prices = document.getElementById('prices' + ID);
	var officeList = document.getElementById('price-list');
	var pricesimg;

	//pricesimg = '';
	//if (prices) {
	//	pricesimg = prices.src;
	//}

	if ((Type != 'Load' && Type != 'Comp') && ((RemoveByList == 'True') || (prices.className.indexOf("dark_btn") >= 0))) {
		var newLI = document.getElementById(ID + "PRICELI");
		
		officeList.removeChild(newLI);
		
		var x = 0;
		if (officeList.childNodes.length > 0) {
			for (var i = 0; i < officeList.childNodes.length; i++) {
				var child = officeList.childNodes[i];
				if (child.nodeName == "LI") {
					x++;
				}
			}
		}
					
		if (x == 0) {
			var noneLI = document.createElement("LI");
			
			noneLI.id = "price-none-sel";
			officeList.appendChild(noneLI);

			/*if (document.getElementById('off-price-selected').style.display == 'block') {
				closeDiv('off-price-selected');
			}*/
			document.getElementById('show-price-display').style.display = 'none';
			/*document.getElementById('price-para').style.display = 'none';
			document.getElementById('price-expand').style.display = 'none';*/
		}

		pricecount--;

		document.getElementById('list-number').innerHTML = pricecount;
		
		$(prices).removeClass('dark_btn');
		$(prices).addClass('light_btn');
		$(prices).text('Add to list');
		
		try {
			$('#pricesText' + ID).text('Like the look of this office space?');
			$('#pricesText' + ID + '_one').text('Like the look of this office space?');
			$('#pricesText' + ID + '_two').text('Like the look of this office space?');
			$('#pricesText' + ID + '_three').text('Like the look of this office space?');
		} catch (err) {
		}
		
		try {
			$('#prices' + ID + '_one').removeClass('dark_btn');
			$('#prices' + ID + '_two').removeClass('dark_btn');
			$('#prices' + ID + '_three').removeClass('dark_btn');
			$('#prices' + ID + '_four').removeClass('dark_btn');
			$('#prices' + ID + '_five').removeClass('dark_btn');
			$('#prices' + ID + '_six').removeClass('dark_btn');
			$('#prices' + ID + '_seven').removeClass('dark_btn');
			$('#prices' + ID + '_one').addClass('light_btn');
			$('#prices' + ID + '_two').addClass('light_btn');
			$('#prices' + ID + '_three').addClass('light_btn');
			$('#prices' + ID + '_four').addClass('light_btn');
			$('#prices' + ID + '_five').addClass('light_btn');
			$('#prices' + ID + '_six').addClass('light_btn');
			$('#prices' + ID + '_seven').removeClass('light_btn');
			
			$('#prices' + ID + '_one').text('Add to list');
			$('#prices' + ID + '_two').text('Add to list');
			$('#prices' + ID + '_three').text('Add to list');
			$('#prices' + ID + '_four').text('Add to list');
			$('#prices' + ID + '_five').text('Add to list');
			$('#prices' + ID + '_six').text('Add to list');
			$('#prices' + ID + '_seven').text('Add to list');
		} catch (err) {
		}
		
		/*if (pricesimg.indexOf("got_prices.gif") >= 0) {
			prices.src = "/images/results/buttons/prices.gif";
			try {
				document.getElementById('prices' + ID + '_bot').src = "/images/results/buttons/prices.gif";
			} catch (err) {
			}
		} else if (pricesimg.indexOf("ei_prices_ticked.jpg") >= 0) {
			prices.src = "/images/extrainfo/ei_prices_offices.gif";
			document.getElementById('prices' + ID + '_bot').src = "/images/extrainfo/ei_prices_offices.gif";
		} else if (pricesimg.indexOf("prices_compare.gif") >= 0) {
			prices.src = "/images/results/buttons/request_price.gif";
			document.getElementById('prices_bot' + ID).src = "/images/results/buttons/request_price.gif";
		} else if (pricesimg.indexOf("prices_st_tick.gif") >= 0) {
			prices.src = "/images/results/buttons/prices_st.gif";
		}*/

	} else {

		if (ListItemExists == 'False') {
			var newLI = document.createElement("LI");

			newLI.id = ID + "PRICELI";
			newLI.className = "price-office-list clearfix";
			newLI.innerHTML = "<img src='" + ImgURL + "' alt='' /><p>" + Address + "</span></p><a href='#' onclick=\"AddOfficePrice('" + ID + "', '', 'True', '', '', '');return false;\">Remove</a>";

			var x = 0;
			if (officeList.childNodes.length > 0) {
				for (var i = 0; i < officeList.childNodes.length; i++) {
					var child = officeList.childNodes[i];
					if (child.nodeName == "LI") {
						x++;
				   	}
				}		
			}

			if (x == 1) {
				document.getElementById('show-price-display').style.display = 'block';
				//document.getElementById('price-para').style.display = 'block';
				//document.getElementById('price-list').style.display = 'block';
				//document.getElementById('price-expand').style.display = 'block';

				try {
					officeList.removeChild(document.getElementById('price-none-sel'));
				} catch (err) {
		
				}

				/*if (usedprice === false) {
					ShowDiv('price-help-div');
					usedprice = true;
				}*/
			}

			officeList.appendChild(newLI);
		}

		pricecount++;

		document.getElementById('list-number').innerHTML = pricecount;

		if (Type != 'Load') {
			$(prices).removeClass('light_btn');
			$(prices).addClass('dark_btn');
			
			$(prices).text('Added to list');
			
			try {
				$('#pricesText' + ID).text('Add More or Complete Online Request');
				$('#pricesText' + ID + '_one').text('Add More or Complete Online Request');
				$('#pricesText' + ID + '_two').text('Add More or Complete Online Request');
				$('#pricesText' + ID + '_three').text('Add More or Complete Online Request');
			} catch (err) {
			}
			
			try {
				$('#prices' + ID + '_one').removeClass('light_btn');
				$('#prices' + ID + '_two').removeClass('light_btn');
				$('#prices' + ID + '_three').removeClass('light_btn');
				$('#prices' + ID + '_four').removeClass('light_btn');
				$('#prices' + ID + '_five').removeClass('light_btn');
				$('#prices' + ID + '_six').removeClass('light_btn');
				$('#prices' + ID + '_seven').removeClass('light_btn');
				$('#prices' + ID + '_one').addClass('dark_btn');
				$('#prices' + ID + '_two').addClass('dark_btn');
				$('#prices' + ID + '_three').addClass('dark_btn');
				$('#prices' + ID + '_four').addClass('dark_btn');
				$('#prices' + ID + '_five').addClass('dark_btn');
				$('#prices' + ID + '_six').addClass('dark_btn');
				$('#prices' + ID + '_seven').addClass('dark_btn');
				
				$('#prices' + ID + '_one').text('Added to list');
				$('#prices' + ID + '_two').text('Added to list');
				$('#prices' + ID + '_three').text('Added to list');
				$('#prices' + ID + '_four').text('Added to list');
				$('#prices' + ID + '_five').text('Added to list');
				$('#prices' + ID + '_six').text('Added to list');
				$('#prices' + ID + '_seven').text('Added to list');
			} catch (err) {
			}
				
		
			/*if (pricesimg.indexOf("prices.gif") >= 0) {
				prices.src = "/images/results/buttons/got_prices.gif";

				try {
					document.getElementById('prices' + ID + '_bot').src = "/images/results/buttons/got_prices.gif";
				} catch (err) {
				}
			} else if (pricesimg.indexOf("ei_prices_offices.gif") >= 0) {
				prices.src = "/images/extrainfo/ei_prices_ticked.jpg";
				document.getElementById('prices' + ID + '_bot').src = "/images/extrainfo/ei_prices_ticked.jpg";
			} else if (pricesimg.indexOf("request_price.gif") >= 0) {
				prices.src = "/images/results/buttons/prices_compare.gif";
				document.getElementById('prices_bot' + ID).src = "/images/results/buttons/prices_compare.gif";
			} else if (pricesimg.indexOf("prices_st.gif") >= 0) {
				prices.src = "/images/results/buttons/prices_st_tick.gif";
			}*/
		}
	}
}

function ShowDiv(div) {
	document.getElementById('clear-bg-ei').style.display = 'block';
	document.getElementById('table-holder-ei').style.display = 'block';
	document.getElementById(div).style.display = 'block';
}

function closeDiv(div) {
	document.getElementById(div).style.display = 'none';
	document.getElementById('table-holder-ei').style.display = 'none';
	document.getElementById('clear-bg-ei').style.display = 'none';
}

function showImg(ID, ImgURL) {
	var div = document.getElementById('side-pic-hold');

	div.style.display = 'block';
	div.innerHTML = '<img src="' + ImgURL + '" alt="" />';

	tempdivshown = 'side-pic-hold';
}

function hideImg() {
	document.getElementById('side-pic-hold').style.display = 'none';
}

function privacy() {
	var privacyWindow;
	privacywindow = window.open("/miniprivacy.aspx", "privacy", "scrollbars=yes,resizable=no,toolbar=no,location=no,menubar=no,width=600,height=500");
}

function changeTestimonialTabs(id) {
	
	$('.tab_menu_test .menuTab').removeClass('active');
	$('#tab_container_test .tab_content').stop(true, true).hide();
	
	$('#' + id).addClass('active');
	$("div." + id).fadeIn('slow');
	
// to show the achive tab within the news tab, you pass the second var as the name of the tab you want to show	
	if(archive != "archive"){
		$('#' +archive).addClass('active');
		$('div.' + archive).fadeIn('slow');
	}
}
