
function $(id){
	return document.getElementById(id);
}

function href(link) {

	document.location.href = link;

}

function displayPopup(url, width, height) {

	var Win = window.open(url,"displayPopup",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=no,menubar=no');

}

function valPhone(obj){
	val = obj.value;
	id = obj.id;
	check = $(id).value.substr(($(id).value.length)-1,1);
	if(check!= '+' && check!= '(' && check!= ' ' && check!= ')' && isNaN(check)){
		$(id).value = $(id).value.substr(0, ($(id).value.length)-1);
	}
}

function valIntLimit(obj,limit) {
	val = obj.value;
	id = obj.id;
	check = $(id).value.substr(($(id).value.length)-1,1);
	if (isNaN(val) || $(id).value.length>limit) {
		$(id).value = $(id).value.substr(0, ($(id).value.length)-1);
	}
}

function tip(obj,tip_id) {
	if (obj.checked==true) {
		$(tip_id).style.display='block';
	}
	else {
		$(tip_id).style.display='none';
	}
}

function valNo(obj){
	val = obj.value;
	id = obj.id;
	check = $(id).value.substr(($(id).value.length)-1,1);
	if(isNaN(check)){
		$(id).value = $(id).value.substr(0, ($(id).value.length)-1);
	}
}

function clean(obj){

	obj.value='';
	obj.style.background = '#fff';
	obj.style.color = '#000';
}



function setInner(layer, url_to, message){
	
	advAJAX.setDefaultParameters({
	onInitialization : function(obj) { document.getElementById(obj.tag).innerHTML = message; },
	onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = message; },
	onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; },
	onError : function(obj) { document.getElementById(obj.tag).innerHTML = "error: Please press F5 "; }
	});
	advAJAX.get({ tag: layer, url: url_to });

}

function setCont(id,cont){
	$(id).innerHTML = cont;
}

function setVal(id,cont){
	$(id).value = cont;
}

function selectSubCat(id){

	setInner('subCat', 'http://estateagentoftheyear.com/plugs/ajax.php?getSubCat='+id, '<select name="subCat" disabled="disabled" ><option>Loading ...</option></select>');
	$('subCat').disabled=false;
	$('subSubCat').innerHTML = '<select name="subSubCat" id="subSubCat_select" disabled="disabled" ><option>Select text ...</option></select>';
	$('subSubCat').disabled = true;

}

function selectSubSubCat(id){

	setInner('subSubCat', 'http://estateagentoftheyear.com/plugs/ajax.php?getSubSubCat='+id, '<select name="subCat" disabled="disabled" ><option>Loading ...</option></select>');
	
	$('subSubCat').disabled=false;
	$("buttonSave").disabled=false;
	$("title").disabled=false;
	$("Tparent").value = id;

}

function getRegion(o){

	if(o.value == '0'){
		$('region_city').innerHTML = '<select disabled="disabled" id="region" name="search[region]" style="width:160px;margin-top:4px;margin-bottom:5px;"><option value="0">Please select country ...</option></select>';
	}else{
		setInner('region_city', 'http://estateagentoftheyear.com/plugs/ajax.php?getRegion='+o.value, '<select disabled="disabled" id="region" name="search[region]" style="width:160px;margin-top:4px;margin-bottom:5px;"><option value="0">Please wait ...</option></select>');
	}

}

function selectSector(o){

	setInner('SSD', 'http://estateagentoftheyear.com/plugs/ajax.php?getSector='+o.value, '<select disabled="disabled" id="Sector_Select" name="sector" style="margin-top:4px;margin-bottom:5px;"><option value="0">Please wait ...</option></select>');
	setCont('JSD','<select disabled="disabled" id="Job_Select" name="job" style="margin-top:4px;margin-bottom:5px;"><option value="0">Please wait ...</option></select>');

}

function deleteJob(id){

	advAJAX.get({
		url: "http://estateagentoftheyear.com/plugs/ajax.php?deleteJob="+id,
		onSuccess : function(obj) { void(0); }
	});

	$('JOB_'+id).style.display = 'none';

}

function getJobs(o){

	setInner('JSD', 'http://estateagentoftheyear.com/plugs/ajax.php?getJobs='+o.value, '<select disabled="disabled" id="Job_Select" name="job" style="margin-top:4px;margin-bottom:5px;"><option value="0">Please wait ...</option></select>');

}

function loadText(id){

	advAJAX.get({
		url: "http://estateagentoftheyear.com/plugs/ajax.php?getText="+id,
		onInitialization : function(obj) {tinyMCE.setContent("Please wait ...");},
		onLoading : function(obj) { tinyMCE.setContent("Please wait ..."); },
		onSuccess : function(obj) { tinyMCE.setContent(obj.responseText); },
		onError : function(obj) { tinyMCE.setContent("error: Please reload page (F5). "); }

	});

	advAJAX.get({
		url: "http://estateagentoftheyear.com/plugs/ajax.php?getTitle="+id,
		onInitialization : function(obj) {setVal("title","Please wait ...");},
		onLoading : function(obj) { setVal("title","Please wait ..."); },
		onSuccess : function(obj) { setVal("title",obj.responseText); },
		onError : function(obj) { setVal("title","error: Please reload page (F5). "); }

	});

	advAJAX.get({
		url: "http://estateagentoftheyear.com/plugs/ajax.php?getDate="+id,
		onInitialization : function(obj) {setCont("Text_DATE","");},
		onLoading : function(obj) { setCont("Text_DATE","..."); },
		onSuccess : function(obj) { setCont("Text_DATE",obj.responseText); },
		onError : function(obj) { setCont("Text_DATE","error: Please reload page (F5). "); }

	});


	$("saveAs").value = id;
	$("Text_ID").innerHTML = id;
	$("save_info").style.display = 'none';

}

function short_SUB(o){

	if(o.value != 0){
		selectSubSubCat(o.value);
		selectSubCat(o.value);
	}
	
		
	

}

function findPosition( oLink, xORy) {
	if( oLink.offsetParent ) {
		for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
			posX += oLink.offsetLeft;
			posY += oLink.offsetTop;
		}
		if(xORy == 'x'){
			return posX;
		}else{
			return posY;
		}
	} else {
		if(xORy == 'x'){
			return oLink.x;
		}else{
			return oLink.y;
		}
	}
}

function menuShow(id,a) {

	$(id).style.display = 'block';
	$(id).style.left = findPosition(a, 'x')+"px";
	$(id).style.top = (findPosition(a, 'y')+23)+"px";

}

function menuHide(id) {

	$(id).style.display = 'none';

}

function valid_CB(t) {

	if($('perm').checked == true && $('inter').checked == true){
		
		$('inter_select').disabled = true;
		$('inter_div').style.display = 'none';
		$('perm_select').disabled = false;
		$('perm_select').options[0].selected = true;
		$('perm_div').style.display = 'block';

	}
	
	if($('perm').checked == true && $('inter').checked == false){
		
		$('inter_select').disabled = true;
		$('inter_div').style.display = 'none';
		$('perm_select').disabled = false;
		$('perm_select').options[0].selected = true;
		$('perm_div').style.display = 'block';

	}

	if($('perm').checked == false && $('inter').checked == true){

		$('inter_select').disabled = false;
		$('inter_select').options[0].selected = true;
		$('inter_div').style.display = 'block';
		$('perm_select').disabled = true;
		$('perm_div').style.display = 'none';

	}

	if($('perm').checked == false && $('inter').checked == false){

		$('inter_select').disabled = true;
		$('inter_div').style.display = 'none';
		$('perm_select').disabled = true;
		$('perm_select').options[0].selected = true;
		$('perm_div').style.display = 'block';

	}

}

function bg(O, C){

	O.style.background = C;

}

function changeBox(a) {

	if(a == 'Tab_S'){
	
		$('Tab_I').style.background = 'url(tpl/Images/box/industry_c.png) top left';
		$('Tab_I').style.width = '70px';
		$('JobCat').style.display = 'none';
		

		$('Tab_S').style.background = 'url(tpl/Images/box/search_a.png) top left';
		$('Tab_S').style.width = '131px';
		$('searchTab_BOX').style.display = 'block';

	}

	if(a == 'Tab_I'){
	
		$('Tab_I').style.background = 'url(tpl/Images/box/industry_a.png) top left';
		$('Tab_I').style.width = '80px';
		$('JobCat').style.display = 'block';
		

		$('Tab_S').style.background = 'url(tpl/Images/box/search_c.png) top left';
		$('Tab_S').style.width = '121px';
		$('searchTab_BOX').style.display = 'none';

	}

								
}

function DDDM_show(a,b){
	$('DDDM_'+a).style.top = b+'px';
	$('DDDM_'+a).style.display = 'block';
}

function DDDM_hide(a){

	$('DDDM_'+a).style.display = 'none';
	$('parent_of_'+a).className = '';
}

function DDDM_show_OWN(a) {

	$('DDDM_'+a).style.display = 'block';
	$('parent_of_'+a).className = 'DDDM_hover';
	

}

function load(what) {
	
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("G_map"));
		map.addControl(new GSmallMapControl());
		
		if(what == ''){
			what = 'london';
		}
			if(what == 'brighton'){
			map.setCenter(new GLatLng(50.820713,-0.138788), 16);
			$('CITY_MAP').innerHTML = 'Brighton Map';
		}
			if(what == 'london'){
			map.setCenter(new GLatLng(51.515179,-0.081185), 16);
			$('CITY_MAP').innerHTML = 'London Map';
		}
		if(what == 'munchen'){
			map.setCenter(new GLatLng(48.137311,11.577358), 16);
			$('CITY_MAP').innerHTML = 'M&uuml;nchen Map';
		}
			map.addOverlay(new GMarker(map.getCenter()));
		var marker = new GMarker(map.getCenter());
		map.addOverlay(marker);
		
		}
}

function checkSelect(what, name) {

	if(what.value == 0){
		$(name).disabled = false;
	}else{
		$(name).disabled = true;
	}

}


/*

lukasg@demomedia.co.uk - additional scripts

*/


function fieldFocus(id,txt) {
	var fld = $(id);
	if (fld.value==txt) {
		fld.value='';
	}
}

function fieldBlur(id,txt) {
	var fld = $(id);
	if (fld.value=='') {
		fld.value = txt;
	}
}

function vote(score,id,pid) {
	$(id).value = score;
	$(pid).style.width = (score*16.6666) + "%";
	$('_submit').disabled = false;
}

function star_help(txt) {
	setCont('star_help',txt);
}
function _star_help(txt) {
	setVal('_star_help',txt);
}


function submit_question() {
	advAJAX.submit(document.getElementById('form_contact'), {
		onFinalization : function(obj) { 
			$('vote_questions').innerHTML = obj.responseText;
			$('star_help').innerHTML = '';
			$('_submit').disabled = true;
			if (obj.responseText == '') {
				$('vote_questions').innerHTML = 'Thank you for answering all the questions. Your form is now completed, please press the button below to submit your answers.<br /><br />';
                /*<input type="checkbox" name="noemail" id="noemail" style="width:20px;" checked/><label for="noemail">Please uncheck this box if you wish to receive confirmation of this registration by email.</label><br /><br />   */
				$('form_contact').action = 'vote,6.html';
				$('sbm_buttom').innerHTML = '<input type="submit" value="Submit your vote!" name="_submit" id="_submit" style="cursor:pointer"/>';
			}
		}
	});
}


function e_tab(tab) {
	if (tab=='e_review') {
		$('e_review').style.display='block';
		$('e_voters').style.display='none';
		$('e_moreinfo').style.display='none';

		$('btn_e_review').className='tab_selected';
		$('btn_e_voters').className='';
		$('btn_e_moreinfo').className='';
	}
	if (tab=='e_voters') {
		$('e_review').style.display='none';
		$('e_voters').style.display='block';
		$('e_moreinfo').style.display='none';

		$('btn_e_review').className='';
		$('btn_e_voters').className='tab_selected';
		$('btn_e_moreinfo').className='';
	}
	if (tab=='e_moreinfo') {
		$('e_review').style.display='none';
		$('e_voters').style.display='none';
		$('e_moreinfo').style.display='block';

		$('btn_e_review').className='';
		$('btn_e_voters').className='';
		$('btn_e_moreinfo').className='tab_selected';
	}
}


function select_checkbox(id) {
	$(id).checked = true;
}