$(document).ready(function() {
	 $('a[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
	$('#cLogin').attr('href','javascript:void(0);');
	$('#rLoginClick').attr('href','javascript:void(0);');
	$('#PostClickT').html('<a href="javascript:void(0);" onclick="Register_1();"><img src="/gfx/btns/continue.gif" width="157" height="42" id="btnCont" alt="Continue" /></a>');
	$('#PostClickT2').html('<a href="javascript:void(0);" onclick="Register_2();"><img src="/gfx/btns/register.gif" width="157" height="42" id="btnTrade" alt="Register" /></a>');
	$('#searchBtn').html('<a href="javascript:void(0);" onclick="doSearch();"><img src="/gfx/btns/search.gif" width="127" height="34" id="btnSearch" alt="Search" /></a>');
	$('#btnLogin').hover( function(){ $(this).attr('src','/gfx/btns/loginover.gif'); }, function() { $(this).attr('src','/gfx/btns/login.gif'); } );
	$('#News img').hover( function(){ $(this).attr('src','/gfx/btns/newsover.gif'); }, function() { $(this).attr('src','/gfx/btns/news.gif'); } );
	$('#BtnRegLogin').hover( function(){ $(this).attr('src','/gfx/btns/clientloginover.gif'); }, function() { $(this).attr('src','/gfx/btns/clientlogin.gif'); } );
	$('#BtnRegLogin2').hover( function(){ $(this).attr('src','/gfx/btns/clientloginover.gif'); }, function() { $(this).attr('src','/gfx/btns/clientlogin.gif'); } );
	$('#btnCont').hover( function(){ $(this).attr('src','/gfx/btns/continueover.gif'); }, function() { $(this).attr('src','/gfx/btns/continue.gif'); } );
	$('#btnTrade').hover( function(){ $(this).attr('src','/gfx/btns/registerover.gif'); }, function() { $(this).attr('src','/gfx/btns/register.gif'); } );
	$('#btnSearch').hover( function(){ $(this).attr('src','/gfx/btns/searchover.gif'); }, function() { $(this).attr('src','/gfx/btns/search.gif'); } );
	$('#Navigation li').hover( function(){ $(this).find('div.SubMenu').slideDown('fast'); }, function() { $(this).find('div.SubMenu').slideUp('fast'); } );
	$(".Overlay").fancybox();
	$("#Pwd").keypress(function(e){
        if(e.which==13) doLogin();
    });
});
function FeatureJob(JobID,v) {
	var params = 'action=JobFeature&JobID='+JobID+'&v='+v;
	$.post('/ajax/class.ajax-functions.php',params,function(d) {
		$('#jFeature').attr('class','');
		$('#jFeature').html(d);
	});
}
function PayOptions(d) {
	var Prices = {1:'12.00',3:'32.40',6:'63.60',12:'120.00'};
	$('.ppBtnText a').html('£'+Prices[d]);
	$('.PaySelectedMonths').hide();
	$('.PayOptionMonths').show();
	$('#SelectMonths'+d).hide();
	$('#Months'+d).show();
	$('#DiscountMonths').val(d);
	goToByScroll('ppBtn2');
}
function DiscountPay(v) {
	$('#ddDiscount').val(v);
	if ($('#DiscountMonths').val()=="") { alert('Please select a monthly payment term first'); return; }
	$('#Paypal').submit();
}
function jFormStep(step,UserID) {
	var e=false;
	$('.TipWrapper, .absRight, .jError').hide();
	$('input, select, textarea').css('border','2px solid #91C0F3');
	if (step=="1") {
		if ($('#Category').val()=="0") { $('#e-Category').show().html('Please select a category'); $('#Category').css('border','2px solid #fd602d'); e=true; }
		var t=$('#Title').val();
		if (t.length<5) { $('#e-Title').show().html('Enter a title of 4-50 characters'); $('#Title').css('border','2px solid #fd602d'); e=true; }
		var t=$('#Details').val();
		if (t.length<5) { $('#e-Details').show().html('Enter a description using a minimum 20 of characters'); $('#Details').css('border','2px solid #fd602d'); e=true; }
		if (e) { return; }
		$("#Step-1").effect("slide", { direction: "left", mode : "hide"}, 300);
		$("#Step-2").effect("slide", { direction: "right", mode : "show"}, 300);
	}
	if (step=="2") {
		if ($('#MaxCalls').val()=="") { $('#e-MaxCalls').show().html('Select how many tradesmen you would like to hear from.'); $('#MaxCalls').css('border','2px solid #fd602d'); e=true; }
		if ($('#ContactVia').val()=="") { $('#e-ContactVia').show().html('Please select your prefered method of contact.'); $('#ContactVia').css('border','2px solid #fd602d'); e=true; }
		if (($('#ContactVia').val()=="2")&&($('#Tel').val()=="")&&($('#Mobile').val()=="")) { $('#e-ContactPhones').show().html('Enter a tel and or mobile number'); $('#Tel').css('border','2px solid #fd602d'); e=true; }
		if (e) { return; }
		$("#Step-2").effect("slide", { direction: "left", mode : "hide"}, 300);
		$("#Step-3").effect("slide", { direction: "right", mode : "show"}, 300);
	}
	if (step=="3") {
		if ($('#Postcode').val()=="") { $('#e-Town').show().html('Please enter your postcode.'); $('#Postcode').css('border','2px solid #fd602d'); e=true; }
		if ($('#Town').val()=="") { $('#e-Town').show().html('Please enter your town.'); $('#Town').css('border','2px solid #fd602d'); e=true; }
		if (UserID==0) {
		if ($('#Username').val()=="") { $('#e-Username').show().html('Please enter a username.'); $('#Username').css('border','2px solid #fd602d'); e=true; }
		if ($('#Password').val()=="") { $('#e-Password').show().html('Please enter a password.'); $('#Password').css('border','2px solid #fd602d'); e=true; }
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		if (!emailPattern.test($('#pEmail').val())) { $('#e-Email').show().html('Please enter a valid email.'); $('#pEmail').css('border','2px solid #fd602d'); e=true; }
		}
		if (e) { return; }
		var params = $('#jForm').serialize()+'&action=PostJobSteps';
		$.post('/ajax/postajob.php',params,function(d) { 
			if (d=="x") { $('#e-Password').show().html('Enter correct password please'); return; }
			if (d=="") { alert('There was an error please try again'); return; }
			location.href='/Members/MyJob/'+d+'/NewMember';
		});
	}
}
function StepBack(step) {
	if (step=="1") {
		$("#Step-2").effect("slide", { direction: "right", mode : "hide"}, 300);
		$("#Step-1").effect("slide", { direction: "left", mode : "show"}, 300);
	}
	if (step=="2") {
		$("#Step-3").effect("slide", { direction: "right", mode : "hide"}, 300);
		$("#Step-2").effect("slide", { direction: "left", mode : "show"}, 300);
	}
}
function goToByScroll(id){
	$('html,body').animate({scrollTop: $("#"+id).offset().top},600);
}
var xopen = false;
function openLogin() {
	$('#Login').slideToggle('fast');
	if (xopen==false) {
		$('#cLogin').css('background','#d8dadb');
		xopen = true;
	} else {
		$('#cLogin').css('background','#fff');
		xopen = false;
	}
}
var ropen = false;
function OpenRegLogin() {
	$('#RegLoginForm').slideToggle('fast');
	if (ropen==false) {
		$('#BtnRegLogin').hide();
		$('.BoxClose').show();
		ropen = true;
	} else {
		$('#BtnRegLogin').show();
		$('.BoxClose').hide();
		ropen = false;
	}
}
function doLogin() {
	$('.Error').hide();
	var error = '';
	if ($('#Pwd').val()=="") { error+= 'Invalid password.<br />'; $('#PwdError').show(); }
	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if (!CheckEmail('#Email')) { error+= 'Invalid email.'; $('#EmailError').show(); }
	if (error=="") { $('#LoginForm').submit(); return; }
	$('#ErrorMsg').html(error).show();
}
function doLoginR() {
	$('.FormElement img').hide();
	$('.FormElement').css('background-color','#c6e0fc').next().css('color','#2071c8');
	$('.FormError').hide();
	var error=false;
	if (!checkrPwd()) { error=true; }
	if (!CheckEmail('#rEmail')) { $('#rEmailError').html('Invalid email address'); doError('#rEmailError'); error=true; }
	if (error) { bindLogin(); return; } else { 
	$.post('/ajax/login.php',{Email: $('#rEmail').val(), Pwd: $('#rPwd').val(), action:'RegJobLogin'}, function(data) { $('#rErrorFail').html(data); });
	}
}
function doLoginQ(JobID) {
	$('.FormError').hide();
	var error=false;
	if (!checkrPwd()) { $('#qMsg').html('Please enter your password'); error=true; }
	if (!CheckEmail('#qEmail')) { $('#qMsg').html('Invalid email address'); error=true; }
	if (error) { $('#qError').css('padding-left','25px').slideDown('fast'); return false; }
	$.post('/ajax/login.php',{Email: $('#qEmail').val(), Pwd: $('#qPassword').val(), action:'qLogin', JobID: JobID}, function(data) {
		if ((data=="")||(data=="05")) { $('#qMsg').html('Invalid login details.'); $('#qError').css('padding-left','25px').slideDown('fast'); } 
		if (data=="102") { $('#qMsg').html('Please sign up as a tradesman using the button "Sign Up Now" on the right to quote.'); $('#qError').css('margin-left','-35px').slideDown('fast'); } 
		if (data=="103") { $('#qMsg').html('You have already quoted for this job. Please contact the user via your members area.'); $('#qError').css('margin-left','-35px').slideDown('fast'); } 
		if (data=="104") { $('#qLogin').slideUp('fast');$('#qSignup').hide();$('#Renew').slideDown('fast'); }
		if (data=="105") { $('#qLogin').slideUp('fast');$('#qSignup').hide();$('#Activate').slideDown('fast'); }
		if (data=="1"){ $('#qLogin').slideUp('fast'); $('#qSignup').slideUp('fast'); $('#QuoteThisJob').slideDown('fast'); getQuoteForm(JobID); }
	});
}
function getQuoteForm(JobID) {
	$.post('/ajax/class.ajax-functions.php',{action:'getQuoteForm', JobID: JobID}, function(d) { $('#QuoteThisJob').html(d); });
}
function bindLogin() {
	$('#rPwd').keyup(function() { checkrPwd(); });
	$('#rPwd').blur(function() { checkrPwd(); });
	$('#rEmail').keyup(function() { checkrEmail(); });
	$('#rEmail').blur(function() { checkrEmail(); });
}
function showTip(id) {
	$('.TipWrapper, .testlower, .jError').hide();
	$('#'+id).fadeIn('fast');
}
function regContactVia() {
	$('#ContactPhones').hide();
	if ($('#ContactVia').val()==1) { $('#Tel').val('');$('#Mobile').val(''); }
	if ($('#ContactVia').val()==2) { $('#ContactPhones').slideDown('fast'); }
}
function checkrPwd() {
	if ($('#rPwd').val()=="") { $('#rPwdError').html('Please enter your password'); doError('#rPwdError'); return false; }
	unDoError('#rPwdError'); return true;
}
function checkrEmail() {
	if (!CheckEmail('#rEmail')) { $('#rEmailError').html('Invalid email address'); doError('#rEmailError'); return false; }
	unDoError('#rEmailError'); return true;
}
function doError(id) {
	$(id).slideDown().prev().fadeIn().prev().prev().css('color','#ff4300').parent().css('background-color','#fddcbe');
}
function unDoError(id) {
	$(id).html(' ').slideUp().prev().fadeOut().prev().prev().css('color','#2071c8').parent().css('background-color','#c6e0fc');
}
function Register_1() {
	var error=false;
	$('.FormError').hide();
	$('.FormElement img').hide();
	$('.FormElement').css('background-color','#c6e0fc').next().css('color','#0a4788');
	$('#oops').hide('fast');
	checkPostcode();
	if ($('#NewUser').length>0) {
		checkUsername();
		checkRegEmail();
		if (!checkPassword()) { error=true; }
		if (!checkPassword2()) { error=true; }
	}
	if (!checkTown()) { error=true; }
	if (!checkTel()) { error=true; }
	if (!checkDistance()) { error=true; }
	if (error) { bindValidation(); $('#oops').show('fast'); return; } else { $('#RegForm1').submit(); }
}
function Register_2() {
	var error=false;
	var msg = '';
	$('#oops').hide('fast');
	if ($('#Insured').val()=="1") {
		var n=/^[0-9]+$/.test($('#InsuredValue').val());
		if (!n) { doError('#InsuredValueError'); $('#InsuredValueError').html('Please enter number only (0-9)'); error=true; } else { unDoError('#InsuredValueError'); }
	}
	if (!checkAccept()) { error=true; }
	if ($('input:checkbox:checked.trades').length==0) { alert('Please select at least one trade catery from the list.'); $('#oops').show('fast'); error=true; }
	if (error) { $('#oops').show('fast');return; } else { $('#TradeForm').submit(); }

}
function doInsured() {
	$('#InsuredV').slideUp('fast');
	if ($('#Insured').val()==1) { $('#InsuredV').slideDown('fast'); }
}
function checkContactVia() {
	if ($('#ContactVia').val()=="") {
		if (($('#Tel').val()=="")&&($('#Mobile').val()=="")) { doError('#ContactViaError'); $('#ContactViaError').html('Please select your prefered method of contact.'); return false; } else { unDoError('#ContactViaError'); return true; }
	}
	if ($('#ContactVia').val()==2) {
		if (($('#Tel').val()=="")&&($('#Mobile').val()=="")) { doError('#ContactViaError'); $('#ContactViaError').html('You have selected contact via phone. Please either change your selection above or enter your telephone or mobile number below.'); return false; } else { unDoError('#ContactViaError'); return true; }
	}
	if ($('#ContactVia').val()==1) {
		unDoError('#ContactViaError'); return true;
	}
	return true;
}
function EditContactVia() {
	if (!checkContactVia()) { return; } else { $('#JobForm').submit(); }
}
function getPhoneNos(JobID) {
	var params = 'action=getPhoneNos&JobID='+JobID;
	$.post('/ajax/class.ajax-functions.php',params, function(data) { $('#PhoneNos').html(data); });
}
function PostAndReg() {
	var error=false;
	$('.FormError').hide();
	$('.FormElement img').hide();
	$('.FormElement').css('background-color','#c6e0fc').next().css('color','#0a4788');
	$('#oops').hide('fast');
	if (!checkContactVia()) { error=true; }
	if (!checkCat()) { error=true; }
	if (!checkTitle()) { error=true; }
	if (!checkDetails()) { error=true; }
	if ($('#NewUser').length>0) {
		checkPostcode();
		checkRegEmail()
		if (!checkTown()) { error=true; }
		checkUsername();
		if (!checkPassword()) { error=true; }
		if (!checkPassword2()) { error=true; }
	}
	if ($('#MaxCalls').val()=="") { doError('#MaxCallsError'); $('#MaxCallsError').html('Please select how many tradesmen you would like to hear from.'); } else { unDoError('#MaxCallsError'); }
	if (!checkAccept()) { error=true; }
	if (error) { bindValidation(); $('#oops').show('fast'); return; } else { $('#JobForm').submit(); }
}
function CloseJob(JobID,JobStatus) {
	var params = 'JobID='+JobID+'&JobStatus='+JobStatus+'&action=CloseJob';
	if (JobStatus=="1") {
		var Trader = $('#Trader').val();
		if (Trader=="") { alert('Please select a trademan'); return false; }
		params += '&Trader='+Trader;
	}
	$.post('/ajax/class.ajax-functions.php',params, function(data) { $('#CloseJobContent').html(data); });
}
function EditJob() {
	var error=false;
	$('.FormError').hide();
	$('.FormElement img').hide();
	$('.FormElement').css('background-color','#c6e0fc').next().css('color','#0a4788');
	if (!checkCat()) { error=true; }
	if (!checkTitle()) { error=true; }
	if (!checkDetails()) { error=true; }
	checkPostcode();
	if (!checkTown()) { error=true; }
	if (error) { return; } else { $('#JobForm').submit(); }
}
function EditLogin() {
	var error=false;
	$('.FormError').hide();
	$('.FormElement img').hide();
	$('.FormElement').css('background-color','#c6e0fc').next().css('color','#0a4788');
	if (!CheckEmail('#pEmail')) { $('#pEmailError').html('Invalid email address'); doError('#pEmailError'); error=true; }
	if (!checkPassword()) { error=true; }
	if(!error) { $('#JobForm').submit(); }
}
function EditProfile() {
	var error=false;
	$('.FormError').hide();
	$('.FormElement img').hide();
	$('.FormElement').css('background-color','#c6e0fc').next().css('color','#0a4788');
	if ($('input:checkbox:checked.trades').length==0) { alert('Please select at least one trade catery from the list.'); return false; }
	checkPostcode();
	if (!checkTown()) { error=true; }
	if (!checkTel()) { error=true; }
	if (!checkDistance()) { error=true; }
	if (error) { bindValidation(); return; } else { $('#TradeForm').submit(); }
}
function EditBilling() {
	var error=false;
	$('.FormError').hide();
	$('.FormElement img').hide();
	$('.FormElement').css('background-color','#c6e0fc').next().css('color','#0a4788');
	$('#RegForm1').submit();
}
function preBindValidation() {
	$('#Category').blur(function() { checkCat(); });
	$('#Title').focus(function() { checkCat(); });
	$('#Title').blur(function() { checkTitle(); });
	$('#Details').blur(function() { checkDetails(); });
	$('#Postcode').blur(function() { checkPostcode(); doGeo(); });
	$('#Town').blur(function() { checkTown(); });
	$('#Username').blur(function() { checkUsername(); });
	$('#Password').blur(function() { checkPassword(); });
	$('#Password2').blur(function() { checkPassword2(); });
	$('#pEmail').blur(function() { checkRegEmail(); });
	$('#FirstName').blur(function() { checkFirstName(); });
	$('#Surname').blur(function() { checkSurname(); });
	$('#Tel').blur(function() { checkTel(); });
	$('#Distance').blur(function() { checkDistance(); });
}
function preBindValidation2() {
	$('#AboutMe').blur(function() { check4Domain('AboutMe'); });
	$('#Qualifications').blur(function() { check4Domain('Qualifications'); });
	$('#MyHistory').blur(function() { check4Domain('MyHistory'); });
}
function bindValidation() {
	$('#Category').change(function() { checkCat(); });
	$('#Title').keyup(function() { checkTitle(); });
	$('#Details').keyup(function() { checkDetails(); });
	$('#Postcode').keyup(function() { checkPostcode(); });
	$('#Town').keyup(function() { checkTown(); });
	$('#Username').keyup(function() { checkUsername(); });
	$('#Password').keyup(function() { checkPassword(); });
	$('#Password2').keyup(function() { checkPassword2(); });
	$('#pEmail').keyup(function() { checkRegEmail(); });
	$('#Accept').click(function() { checkAccept(); });
	$('#Tel').keyup(function() { checkTel(); });
	$('#Distance').change(function() { checkDistance(); });
}
function checkFirstName() {
	if ($('#FirstName').val()=="") { $('#FirstNameError').html('Please enter your first name'); doError('#FirstNameError'); return false } else {
		unDoError('#FirstNameError'); return true;
	}
}
function checkSurname() {
	if ($('#Surname').val()=="") { $('#SurnameError').html('Please enter your surname'); doError('#SurnameError'); return false } else {
		unDoError('#SurnameError'); return true;
	}
}
function checkTel() {
	if ($('#Tel').val()=="") { $('#TelError').html('Please enter your telephone number'); doError('#TelError'); return false } else {
		unDoError('#TelError'); return true;
	}
}
function checkDistance() {
	if ($('#Distance').val()=="0") { $('#DistanceError').html('Please select how far you are willing to travel').slideDown().parent().css('background-color','#fddcbe'); $('#DistanceLabel').css('color','#ff4300'); $('#DistanceIcon').fadeIn(); return false; } else {
		$('#DistanceError').html(' ').slideUp().parent().css('background-color','#c6e0fc'); $('#DistanceLabel').css('color','#2071c8'); $('#DistanceIcon').fadeOut(); return true;
	}
}
function checkCat() {
	if ($('#Category').val()=="0") { $('#CatError').html('Please select a category').slideDown().parent().css('background-color','#fddcbe'); $('#CatLabel').css('color','#ff4300'); $('#CatIcon').fadeIn(); return false; } else {
		$('#CatError').html(' ').slideUp().parent().css('background-color','#c6e0fc'); $('#CatLabel').css('color','#2071c8'); $('#CatIcon').fadeOut(); return true;
	}
}
function checkTitle() {
	if (($('#Title').val().length<5)||($('#Title').val().length>50)) { $('#TitleError').html('Please enter a short description, between 4 & 50 characters'); doError('#TitleError'); return false } else {
		unDoError('#TitleError'); return true;
	}
}
function checkDetails() {
	if ($('#Details').val().length<20) { $('#DetailsError').html('Please describe the job giving as much information as possible <br /> and using a minimum of 20 characters').slideDown().prev().prev().fadeIn().prev().prev().css('color','#ff4300').parent().css('background-color','#fddcbe'); return false; } else {
		$('#DetailsError').slideUp(' ').hide().prev().prev().fadeOut().prev().prev().css('color','#2071c8').parent().css('background-color','#c6e0fc');; return true;
	}
}
function checkPostcode() {
	if ($('#Postcode').val()=="") { $('#PostcodeError').html('Please enter your postcode so we can find tradesmen in your area'); doError('#PostcodeError'); error=false } else {
		$.post('/ajax/postajob.php',{Postcode: $('#Postcode').val(), action:'checkpostcode'}, function(data) {
			if (data==1) { $('#PostcodeError').html('Please enter a valid UK postcode'); doError('#PostcodeError'); error=false; } else { unDoError('#PostcodeError'); error=true; }
		});
	}
}
function checkTown() {
	if ($('#Town').val()=="") { $('#TownError').html('Please enter your town or city'); doError('#TownError'); return false } else {
		unDoError('#TownError'); return true;
	}
}
function checkUsername() {
	var TooShort = 'Please choose a public username between 3 &amp; 20 characters, this is the name you will be referred to publicly throughout this website';
	var username = $('#Username').val();
	if ((username.length<3)||(username.length>25)) { $('#UsernameError').html(TooShort); doError('#UsernameError'); error=false; } else {
		$.post('/ajax/postajob.php',{Username: username,action:'checkusername'},function(data) {
			switch(data) {
				case "1": $('#UsernameError').html(TooShort); doError('#UsernameError'); error=false; break;
				case "2": $('#UsernameError').html('This username has been taken, please choose another'); doError('#UsernameError'); error=false; break;
				case "3": $('#UsernameError').html(TooShort); doError('#UsernameError'); error=false; break;
				case "4": $('#UsernameError').html('Username must only contain Numbers, Letters, a Space or an Underscore'); doError('#UsernameError'); error=false; break;
				case "5": $('#UsernameError').html('You can not use a web address as your username'); doError('#UsernameError'); error=false; break;
				case "6": $('#UsernameError').html('This is not a valid username'); doError('#UsernameError'); error=false; break;
				default: unDoError('#UsernameError'); error=true; break;
			}
		});
	}
}
function checkPassword() {
	var pwd = $('#Password').val();
	if ((pwd.length<3)||(pwd.length>20)) { $('#PasswordError').html('Please choose a password between 3 &amp; 20 characters'); doError('#PasswordError'); return false } else {
		unDoError('#PasswordError'); return true;
	}
}
function checkPassword2() {
	if ($('#Password').val()!=$('#Password2').val()) { $('#Password2Error').html('Your password does not match'); doError('#Password2Error'); return false } else {
		unDoError('#Password2Error'); return true;
	}
}
function checkRegEmail() {
	var pemail = $('#pEmail').val();
	if (pemail=="") { $('#pEmailError').html('Please enter your email address'); doError('#pEmailError'); return true; }
	if (!CheckEmail('#pEmail')) { $('#pEmailError').html('Invalid email address'); doError('#pEmailError'); return true; }
	$.post('/ajax/postajob.php',{Email: pemail,action:'checkemail'},function(data) {
		switch(data) { 
			case "1": $('#pEmailError').html('Invalid email address'); doError('#pEmailError'); return true; break;
			case "2": $('#pEmailError').html('This email address is already registered, please login'); doError('#pEmailError'); return true; break;
			case "0": unDoError('#pEmailError'); return false; break;
		}
	});
}
function checkAccept() {
	if (!$('#Accept').prop("checked")) { $('#AcceptError').html('You must accept the terms & conditions').slideDown().prev().fadeIn().prev().css('color','#ff4300').parent().css('background-color','#fddcbe'); return false; } else {
		$('#AcceptError').html(' ').slideUp().prev().fadeOut().prev().css('color','#0a4788').parent().css('background-color','#c6e0fc'); return true;
	}
}
function check4Domain(id) {
	$.post('/ajax/postajob.php',{elem: $('#'+id).val(),action:'check4domain'},function(data) {
		if (data=="1") { $('#'+id+'Error').html('Domain names are not allowed here!'); doError('#'+id+'Error'); return false; } else { unDoError('#'+id+'Error'); return true; }
	});
}
function CheckEmail(id) {
	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if (!emailPattern.test($(id).val())) { return false; }
	return true;
}
function doSearch() {
	$('#SearchForm').submit();return;
	var postcode = $('#Postcode').val();
	$('#PostcodeError').hide();
	if (!postcode=="") {
		doGeo();
		setTimeout('$("#SearchForm").submit();',500);
	} else {
		$('#SearchForm').submit();
	}
}
function doGeo() {
	if ($('#Postcode').val()=="") { $('#PostcodeOverlay').show(); return; }
	geoPostcode($('#Postcode').val(),
    function (point) {
	  $('#xLat').val(point.lat());
	  $('#xLon').val(point.lng());
      })
}
function geoPostcode(postcode, callbackFunction) {
  localSearch.setSearchCompleteCallback(null, 
    function() {
      if (localSearch.results[0]) {    
        //console.log(localSearch.results);
		var resultLat = localSearch.results[0].lat;
        var resultLng = localSearch.results[0].lng;
        var point = new google.maps.LatLng(resultLat,resultLng);
		
		var geocoder;
		geocoder = new google.maps.Geocoder();
		geocoder.geocode({'latLng': point,region:'GB'}, function(results, status) {
		//console.log(results);
		var address = results[0].address_components;
		//var A = address.split(', ');
		var city = address[6].short_name;
		//var county = A[3];
		//console.log(city+'#'+county);
		$('#Town').val(city);
		});
        callbackFunction(point);
      }
    });
  localSearch.execute(postcode + ", UK");
}
function getReviews(id,type) {
	$('.mFeedback a').removeClass('OnPage');
	$('#R'+type).addClass('OnPage');
	$('#MyProfile').slideUp('fast');$('#MyFeedback').slideDown('fast');
	$.post('/ajax/reviews.php',{UserID: id, action: 'getreview', Type: type }, function(data) {
		$('#Feedback').html(data);
	});
}
function AddReview(id) {
	var d = $('#Details').val();
	unDoError('#DetailsError');
	$('#TraderError').html(' ');
	if ($('#Trader').val()=="") { $('#TraderError').html('Please select your tradesman'); doError('#TraderError'); return }
	if (d=="") { $('#DetailsError').html('Please add your review in the box above'); doError('#DetailsError'); return }
	$.post('/ajax/reviews.php',$('#RatingForm').serialize()+'&JobID='+id+'&action=addreview', function(data) {
		switch(data) {
			case "2": $('#DetailsError').html('Please check your spelling'); doError('#DetailsError'); break;
			case "3": $('#DetailsError').html('Swear words are not allowed!'); doError('#DetailsError'); break;
			default: $('.AddReview').html(data); $('#RatingForm').hide(); break;
		}
	});
}
function Respond(id) {
	var d = $('#ReviewRsponse'+id).val();
	unDoError('#Response'+id+'Error');
	if (d=="") { $('#Response'+id+'Error').html('Please add your response in the box above'); doError('#Response'+id+'Error'); return }
	$.post('/ajax/reviews.php','Response='+d+'&ReviewID='+id+'&action=respond', function(data) {
		switch(data) {
			case "2": $('#Response'+id+'Error').html('Please check your spelling'); doError('#Response'+id+'Error'); break;
			case "3": $('#Response'+id+'Error').html('Swear words are not allowed!'); doError('#Response'+id+'Error'); break;
			default: $('#Response'+id).html(data); $('#Resp'+id).hide(); break;
		}
	});
}
function OpenResponse(id) {
	$('#Response'+id).slideDown('fast');
	$('#Resp'+id+' img').slideDown('fast');
}
function SendQuote(id) {
	$('.FormError').hide();
	$('.FormElement img').hide(); $('#pound').show();
	$('.FormElement').css('background-color','#c6e0fc').next().css('color','#0a4788');
	if ($('#Quote').val()=="x") { alert('Please select if you want to give a price now!'); return; }
	if ($('#Details').val()=="") { $('#DetailsError').html('Please write your comments in the box above.'); $('#DetailsError').slideDown('fast'); return; }
	$('#btnSQ').html('<img src="/gfx/ajax.gif" /> ... SENDING YOUR QUOTE').css('color','#2279e8');
	$.post('/ajax/quote.php',$('#QuoteForm').serialize()+'&JobID='+id, function(data) {
		switch(data) {
			case "1": $('#QuoteThisJob').slideUp('fast').html('<div style="padding:10px 40px 30px 40px; color:#2279e8; font-weight:bold;">Thank you, your email has been sent.<br />We will notify you when you get a reply.</div>').slideDown('fast'); break;
			case "2": $('#DetailsError').html('No swearing allowed.'); doError('#DetailsError'); break;
			case "3": $('#PriceError').html('Numbers only please.'); doError('#PriceError'); break;
			case "4": $('#DetailsError').html('Phone numbers or Prices are not allowed in your emails!. If you want to quote then please use the box above.'); doError('#DetailsError'); break;
			case "5": $('#PriceError').html('You selected to quote now, please enter your quote in the box above.'); doError('#PriceError'); break;
			default: $('#DetailsError').html('There was an error please try again.'); doError('#DetailsError'); break;
		}
		$('#btnSQ').html('<a href="javascript:void(0);" onclick="SendQuote('+id+');"><img src="/gfx/btns/sendquote.gif" id="btnSendQuote" width="199" height="50" alt="Send Quote" /></a>');
	});
}
function getMail(type,owner) {
	$('#MessagePane').html('<img src="/gfx/ajax.gif" />');
	$('#Mail img').removeClass('MailOn');
	$('#inbox').attr('src','/gfx/btns/inbox'+owner+'.gif');
	$('#sent').attr('src','/gfx/btns/sent'+owner+'.gif');
	$('#deleted').attr('src','/gfx/btns/deleted'+owner+'.gif');
	$('#'+type).addClass('MailOn').attr('src','/gfx/btns/'+type+owner+'over.gif');
	$.post('/ajax/quote.php','action='+type, function(data) {
		$('#MessagePane').html(data);
	});
}
function ViewEmail(id) {
	$('.Open').each(function(i,e) { var id=$(e).attr('id');id=id.replace('e','');CloseEmail(id) });
	$('#e'+id+' a[class="view"]').removeAttr('href');
	$('#e'+id).addClass('Open').removeClass('EmailNotRead').hover(function() { $(this).css('background','#e0eefc'); }, function() { $(this).css('background','#e0eefc'); });
	$('#e'+id+' td').each(function() { $(this).css({'border-bottom':'none','font-weight':'bold'}); });
	$('#r'+id).html('<td colspan="5"><img src="/gfx/ajax.gif" /></td>').show().css('background','#e0eefc');
	$.post('/ajax/quote.php','action=view&id='+id, function(data) {
		$('#r'+id).html(data);
		$('#e'+id+' a[class="view"]').attr('href','javascript:ViewEmail('+id+')');
	});
	var x=$('#NewMail').css('display');
	if(x=="block") {
		var d=$('tr').filter('.EmailNotRead').size();
		if (d=="0") { $('#NewMail').slideUp('fast'); }
	}
}
function ReplyToEmail(id) {
	$('.Open').each(function(i,e) { var id=$(e).attr('id');id=id.replace('e','');CloseEmail(id) });
	$('#e'+id).addClass('Open').removeClass('EmailNotRead').hover(function() { $(this).css('background','#e0eefc'); }, function() { $(this).css('background','#e0eefc'); });
	$('#e'+id+' td').each(function() { $(this).css({'border-bottom':'none','font-weight':'bold'}); });
	$('#r'+id).html('<td colspan="5"><img src="/gfx/ajax.gif" /></td>').show().css('background','#e0eefc');
	$('#e'+id).removeClass('EmailNotRead');
	$.post('/ajax/quote.php','action=view&id='+id, function(data) {
		$('#r'+id).html(data);
		$('#xReply'+id).slideDown('fast');
	});
}
function EmailReply(id) {
	$('#MailSend').html('<img src="/gfx/ajax.gif" /> .. Sending reply');
	$.post('/ajax/quote.php',$('#eDetails'+id).serialize()+'&'+$('#Price'+id).serialize()+'&action=reply&id='+id, function(data) {
		$('#MailSend').html('<a href="javascript:EmailReply('+id+')"><img id="btnsendemail" src="/gfx/btns/sendemail.gif" /></a>');
		switch(data) {
			case "2": alert('Please check your spelling!'); break;
			case "3": alert('You can only enter Numbers in the quote box'); break;
			case "4": alert('Phone numbers or Prices are not allowed in your emails!'); break;
			case "5": alert('Please type your reply in the box above.'); break;
			default: $('#xReply'+id).slideUp('fast');$('#MessageSent').html(data).slideDown('fast'); break;
		}
	});
}
function CloseEmail(id) {
	$('#e'+id).removeClass('Open').css('background','#fff').hover(function() { $(this).css('background','#d7e6fb'); }, function() { $(this).css('background','#fff'); });
	$('#e'+id+' td').each(function() { $(this).css({'border-bottom':'1px solid #9dc6e2','font-weight':'normal'}); });
	$('#r'+id).hide();
}
function DeleteEmail(id) {
	if (confirm('Are you sure you wish to delete this email ?')) {
		$('#r'+id).hide();
		$('#e'+id).slideUp('fast');
		$.post('/ajax/quote.php','action=delete&id='+id);
	}
}
function FlagEmail(x,id) {
	$('#f'+id).removeAttr('href');
	var y=1; if(x==1) { y=0; }
	$.post('/ajax/quote.php','action=flagemail&id='+id+'&Flag='+x, function(data) {
		$('#f'+id+' img').attr('src','/gfx/icons/'+data+'.png');
		$('#f'+id).attr('href','javascript:FlagEmail('+y+','+id+')');
	});
}
function ClearText(id) {
	if ($('#eDetails'+id).val()=="Type your message in here.") { $('#eDetails'+id).val(''); }
}
function AcceptQuote(id) {
	if (confirm('Click OK to confirm you accept this quote.')) {
		$('#r'+id).html('<td colspan="5"><img src="/gfx/ajax.gif" /></td>')
		$.post('/ajax/quote.php','&action=accept&id='+id, function(data) {
			$('#r'+id).html('<td colspan="5">'+data+'</td>');
		});
	}
}
function QuoteToggle() {
	if ($('#Quote').val()=="1") { $('#xPrice').slideDown('fast'); } else { $('#xPrice').slideUp('fast'); }
}
function CancelAccount() {
	if (!confirm('Are You Sure?')) { return; }
	$.post('/ajax/payments.php','action=CancelAccount',function(data) {
		$('#CancelM').html(data);
	});
}
function doAjax(action,id,elem) {
	$.post('/ajax/class.ajax-functions.php','action='+action+'&id='+id+'&elem='+elem,function(d) { $('#'+elem).html(d)});
}
function SendBug() {
	var Problem = $('#Problem').val();
	if (Problem=="") {
		return alert('Please tell us what kind of problems you are experiencing');
	}
	$.post('/ajax/class.ajax-functions.php','action=SendBug&Problem='+Problem+'&Email='+$('#BugEmail').val(),function(d) { $('#ReportBugForm').html(d)});
}
function SessionAlive() {
	$.ajax({
	method: 'get',
	url : '/ajax/sessionalive.php',
	dataType : 'text',
	success: function (d) { $('#ajax').html(d); }
	});
}

/*
 * OVERLAY
*/
(function(a){a.fn.fixPNG=function(){return this.each(function(){var b=a(this).css("backgroundImage");if(b.match(/^url\(["']?(.*\.png)["']?\)$/i)){b=RegExp.$1;a(this).css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod="+(a(this).css("backgroundRepeat")=="no-repeat"?"crop":"scale")+", src='"+b+"')"}).each(function(){var b=a(this).css("position");if(b!="absolute"&&b!="relative")a(this).css("position","relative")})}})};var b,c,d=false,e=new Image,f,g=1,h=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i;var i=null,j=a.browser.msie&&a.browser.version.substr(0,1)==6&&!window.XMLHttpRequest,k=j||a.browser.msie&&a.browser.version.substr(0,1)==7;a.fn.fancybox=function(f){function t(){if(a.browser.msie){a("#fancy_content")[0].style.removeAttribute("filter");a("#fancy_outer")[0].style.removeAttribute("filter")}s();q();a(document).bind("keydown.fb",function(b){if(b.keyCode==27&&c.enableEscapeButton){a.fn.fancybox.close()}else if(b.keyCode==37&&c.itemCurrent!==0){a(document).unbind("keydown.fb");c.itemCurrent--;o()}else if(b.keyCode==39&&c.itemCurrent!=c.itemArray.length-1){a(document).unbind("keydown.fb");c.itemCurrent++;o()}});if(c.hideOnContentClick){a("#fancy_content").click(a.fn.fancybox.close)}if(c.overlayShow&&c.hideOnOverlayClick){a("#fancy_overlay").bind("click",a.fn.fancybox.close)}if(c.showCloseButton){a("#fancy_close").bind("click",a.fn.fancybox.close).show()}if(typeof c.itemArray[c.itemCurrent].title!=="undefined"&&c.itemArray[c.itemCurrent].title.length>0){var b=a("#fancy_outer").position();a("#fancy_title div").text(c.itemArray[c.itemCurrent].title).html();a("#fancy_title").css({top:b.top+a("#fancy_outer").outerHeight()-32,left:b.left+(a("#fancy_outer").outerWidth()*.5-a("#fancy_title").width()*.5)}).show()}if(c.overlayShow&&j){a("embed, object, select",a("#fancy_content")).css("visibility","visible")}if(a.isFunction(c.callbackOnShow)){c.callbackOnShow(c.itemArray[c.itemCurrent])}if(a.browser.msie){a("#fancy_outer")[0].style.removeAttribute("filter");a("#fancy_content")[0].style.removeAttribute("filter")}d=false}function s(){if(c.itemCurrent!==0){a("#fancy_left, #fancy_left_ico").unbind().bind("click",function(a){a.stopPropagation();c.itemCurrent--;o();return false});a("#fancy_left").show()}if(c.itemCurrent!=c.itemArray.length-1){a("#fancy_right, #fancy_right_ico").unbind().bind("click",function(a){a.stopPropagation();c.itemCurrent++;o();return false});a("#fancy_right").show()}}function r(b,e,f){d=true;var g=c.padding;if(k||i){a("#fancy_content")[0].style.removeExpression("height");a("#fancy_content")[0].style.removeExpression("width")}if(g>0){e+=g*2;f+=g*2;a("#fancy_content").css({top:g+"px",right:g+"px",bottom:g+"px",left:g+"px",width:"auto",height:"auto"});if(k||i){a("#fancy_content")[0].style.setExpression("height","(this.parentNode.clientHeight - "+g*2+")");a("#fancy_content")[0].style.setExpression("width","(this.parentNode.clientWidth - "+g*2+")")}}else{a("#fancy_content").css({top:0,right:0,bottom:0,left:0,width:"100%",height:"100%"})}if(a("#fancy_outer").is(":visible")&&e==a("#fancy_outer").width()&&f==a("#fancy_outer").height()){a("#fancy_content").fadeOut("fast",function(){a("#fancy_content").empty().append(a(b)).fadeIn("normal",function(){t()})});return}var h=a.fn.fancybox.getViewport();var j=f+60>h[1]?h[3]:h[3]+Math.round((h[1]-f-60)*.5);var l=e+40>h[0]?h[2]:h[2]+Math.round((h[0]-e-40)*.5);var m={left:l,top:j,width:e+"px",height:f+"px"};if(a("#fancy_outer").is(":visible")){a("#fancy_content").fadeOut("normal",function(){a("#fancy_content").empty();a("#fancy_outer").animate(m,c.zoomSpeedChange,c.easingChange,function(){a("#fancy_content").append(a(b)).fadeIn("normal",function(){t()})})})}else{if(c.zoomSpeedIn>0&&c.itemArray[c.itemCurrent].orig!==undefined){a("#fancy_content").empty().append(a(b));var n=c.itemArray[c.itemCurrent].orig;var o=a.fn.fancybox.getPosition(n);a("#fancy_outer").css({left:o.left-20-c.padding+"px",top:o.top-20-c.padding+"px",width:a(n).width()+c.padding*2,height:a(n).height()+c.padding*2});if(c.zoomOpacity){m.opacity="show"}a("#fancy_outer").animate(m,c.zoomSpeedIn,c.easingIn,function(){t()})}else{a("#fancy_content").hide().empty().append(a(b)).show();a("#fancy_outer").css(m).fadeIn("normal",function(){t()})}}}function q(){if(c.itemArray.length-1>c.itemCurrent){var a=c.itemArray[c.itemCurrent+1].href||false;if(a&&a.match(h)){objNext=new Image;objNext.src=a}}if(c.itemCurrent>0){var a=c.itemArray[c.itemCurrent-1].href||false;if(a&&a.match(h)){objNext=new Image;objNext.src=a}}}function p(){var b=e.width;var d=e.height;var f=c.padding*2+40;var g=c.padding*2+60;var h=a.fn.fancybox.getViewport();if(c.imageScale&&(b>h[0]-f||d>h[1]-g)){var i=Math.min(Math.min(h[0]-f,b)/b,Math.min(h[1]-g,d)/d);b=Math.round(i*b);d=Math.round(i*d)}r('<img alt="" id="fancy_img" src="'+e.src+'" />',b,d)}function o(){a("#fancy_right, #fancy_left, #fancy_close, #fancy_title").hide();var d=c.itemArray[c.itemCurrent].href;if(d.match("iframe")||b.className.indexOf("iframe")>=0){a.fn.fancybox.showLoading();r('<iframe id="fancy_frame" onload="jQuery.fn.fancybox.showIframe()" name="fancy_iframe'+Math.round(Math.random()*1e3)+'" frameborder="0" hspace="0" src="'+d+'"></iframe>',c.frameWidth,c.frameHeight)}else if(d.match(/#/)){var f=window.location.href.split("#")[0];f=d.replace(f,"");f=f.substr(f.indexOf("#"));r('<div id="fancy_div">'+a(f).html()+"</div>",c.frameWidth,c.frameHeight)}else if(d.match(h)){e=new Image;e.src=d;if(e.complete){p()}else{a.fn.fancybox.showLoading();a(e).unbind().bind("load",function(){a("#fancy_loading").hide();p()})}}else{a.fn.fancybox.showLoading();a.get(d,function(b){a("#fancy_loading").hide();r('<div id="fancy_ajax">'+b+"</div>",c.frameWidth,c.frameHeight)})}}function n(){if(d)return;if(a.isFunction(c.callbackOnStart)){c.callbackOnStart()}c.itemArray=[];c.itemCurrent=0;if(g.itemArray.length>0){c.itemArray=g.itemArray}else{var e={};if(!b.rel||b.rel==""){var e={href:b.href,title:b.title};if(a(b).children("img:first").length){e.orig=a(b).children("img:first")}else{e.orig=a(b)}if(e.title==""||typeof e.title=="undefined"){e.title=e.orig.attr("alt")}c.itemArray.push(e)}else{var f=a(l).filter("a[rel="+b.rel+"]");var e={};for(var h=0;h<f.length;h++){e={href:f[h].href,title:f[h].title};if(a(f[h]).children("img:first").length){e.orig=a(f[h]).children("img:first")}else{e.orig=a(f[h])}if(e.title==""||typeof e.title=="undefined"){e.title=e.orig.attr("alt")}c.itemArray.push(e)}}}while(c.itemArray[c.itemCurrent].href!=b.href){c.itemCurrent++}if(c.overlayShow){if(j){a("embed, object, select").css("visibility","hidden");a("#fancy_overlay").css("height",a(document).height())}a("#fancy_overlay").css({"background-color":c.overlayColor,opacity:c.overlayOpacity}).show()}a(window).bind("resize.fb scroll.fb",a.fn.fancybox.scrollBox);o()}function m(){b=this;c=a.extend({},g);n();return false}var g=a.extend({},a.fn.fancybox.defaults,f);var l=this;return this.unbind("click.fb").bind("click.fb",m)};a.fn.fancybox.scrollBox=function(){var b=a.fn.fancybox.getViewport();if(c.centerOnScroll&&a("#fancy_outer").is(":visible")){var d=a("#fancy_outer").outerWidth();var e=a("#fancy_outer").outerHeight();var f={top:e>b[1]?b[3]:b[3]+Math.round((b[1]-e)*.5),left:d>b[0]?b[2]:b[2]+Math.round((b[0]-d)*.5)};a("#fancy_outer").css(f);a("#fancy_title").css({top:f.top+e-32,left:f.left+(d*.5-a("#fancy_title").width()*.5)})}if(j&&a("#fancy_overlay").is(":visible")){a("#fancy_overlay").css({height:a(document).height()})}if(a("#fancy_loading").is(":visible")){a("#fancy_loading").css({left:(b[0]-40)*.5+b[2],top:(b[1]-40)*.5+b[3]})}};a.fn.fancybox.getNumeric=function(b,c){return parseInt(a.curCSS(b.jquery?b[0]:b,c,true))||0};a.fn.fancybox.getPosition=function(b){var c=b.offset();c.top+=a.fn.fancybox.getNumeric(b,"paddingTop");c.top+=a.fn.fancybox.getNumeric(b,"borderTopWidth");c.left+=a.fn.fancybox.getNumeric(b,"paddingLeft");c.left+=a.fn.fancybox.getNumeric(b,"borderLeftWidth");return c};a.fn.fancybox.showIframe=function(){a("#fancy_loading").hide();a("#fancy_frame").show()};a.fn.fancybox.getViewport=function(){return[a(window).width(),a(window).height(),a(document).scrollLeft(),a(document).scrollTop()]};a.fn.fancybox.animateLoading=function(){if(!a("#fancy_loading").is(":visible")){clearInterval(f);return}a("#fancy_loading > div").css("top",g*-40+"px");g=(g+1)%12};a.fn.fancybox.showLoading=function(){clearInterval(f);var b=a.fn.fancybox.getViewport();a("#fancy_loading").css({left:(b[0]-40)*.5+b[2],top:(b[1]-40)*.5+b[3]}).show();a("#fancy_loading").bind("click",a.fn.fancybox.close);f=setInterval(a.fn.fancybox.animateLoading,66)};a.fn.fancybox.close=function(){d=true;a(e).unbind();a(document).unbind("keydown.fb");a(window).unbind("resize.fb scroll.fb");a("#fancy_overlay, #fancy_content, #fancy_close").unbind();a("#fancy_close, #fancy_loading, #fancy_left, #fancy_right, #fancy_title").hide();__cleanup=function(){if(a("#fancy_overlay").is(":visible")){a("#fancy_overlay").fadeOut("fast")}a("#fancy_content").empty();if(c.centerOnScroll){a(window).unbind("resize.fb scroll.fb")}if(j){a("embed, object, select").css("visibility","visible")}if(a.isFunction(c.callbackOnClose)){c.callbackOnClose()}d=false};if(a("#fancy_outer").is(":visible")!==false){if(c.zoomSpeedOut>0&&c.itemArray[c.itemCurrent].orig!==undefined){var b=c.itemArray[c.itemCurrent].orig;var f=a.fn.fancybox.getPosition(b);var g={left:f.left-20-c.padding+"px",top:f.top-20-c.padding+"px",width:a(b).width()+c.padding*2,height:a(b).height()+c.padding*2};if(c.zoomOpacity){g.opacity="hide"}a("#fancy_outer").stop(false,true).animate(g,c.zoomSpeedOut,c.easingOut,__cleanup)}else{a("#fancy_outer").stop(false,true).fadeOut("fast",__cleanup)}}else{__cleanup()}return false};a.fn.fancybox.build=function(){var b="";b+='<div id="fancy_overlay"></div>';b+='<div id="fancy_loading"><div></div></div>';b+='<div id="fancy_outer">';b+='<div id="fancy_inner">';b+='<div id="fancy_close"></div>';b+='<div id="fancy_bg"><div class="fancy_bg" id="fancy_bg_n"></div><div class="fancy_bg" id="fancy_bg_ne"></div><div class="fancy_bg" id="fancy_bg_e"></div><div class="fancy_bg" id="fancy_bg_se"></div><div class="fancy_bg" id="fancy_bg_s"></div><div class="fancy_bg" id="fancy_bg_sw"></div><div class="fancy_bg" id="fancy_bg_w"></div><div class="fancy_bg" id="fancy_bg_nw"></div></div>';b+='<a href="javascript:;" id="fancy_left"><span class="fancy_ico" id="fancy_left_ico"></span></a><a href="javascript:;" id="fancy_right"><span class="fancy_ico" id="fancy_right_ico"></span></a>';b+='<div id="fancy_content"></div>';b+="</div>";b+="</div>";b+='<div id="fancy_title"></div>';a(b).appendTo("body");a('<table cellspacing="0" cellpadding="0" border="0"><tr><td class="fancy_title" id="fancy_title_left"></td><td class="fancy_title" id="fancy_title_main"><div></div></td><td class="fancy_title" id="fancy_title_right"></td></tr></table>').appendTo("#fancy_title");if(a.browser.msie){a(".fancy_bg").fixPNG()}if(j){a("div#fancy_overlay").css("position","absolute");a("#fancy_loading div, #fancy_close, .fancy_title, .fancy_ico").fixPNG();a("#fancy_inner").prepend('<iframe id="fancy_bigIframe" src="javascript:false;" scrolling="no" frameborder="0"></iframe>');var c=a("#fancy_bigIframe")[0].contentWindow.document;c.open();c.close()}};a.fn.fancybox.defaults={padding:10,imageScale:true,zoomOpacity:true,zoomSpeedIn:0,zoomSpeedOut:0,zoomSpeedChange:300,easingIn:"swing",easingOut:"swing",easingChange:"swing",frameWidth:562,frameHeight:550,overlayShow:true,overlayOpacity:.71,overlayColor:"#3073B1",enableEscapeButton:true,showCloseButton:true,hideOnOverlayClick:true,hideOnContentClick:true,centerOnScroll:true,itemArray:[],callbackOnStart:null,callbackOnShow:null,callbackOnClose:null};a(document).ready(function(){i=a.browser.msie&&!a.boxModel;if(a("#fancy_outer").length<1){a.fn.fancybox.build()}})})(jQuery)
/*
 * jQuery UI Effects 1.8.16
 */
jQuery.effects||function(f,j){function m(c){var a;if(c&&c.constructor==Array&&c.length==3)return c;if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10)];if(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))return[parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55];if(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))return[parseInt(a[1],
16),parseInt(a[2],16),parseInt(a[3],16)];if(a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c))return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)];if(/rgba\(0, 0, 0, 0\)/.exec(c))return n.transparent;return n[f.trim(c).toLowerCase()]}function s(c,a){var b;do{b=f.curCSS(c,a);if(b!=""&&b!="transparent"||f.nodeName(c,"body"))break;a="backgroundColor"}while(c=c.parentNode);return m(b)}function o(){var c=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,
a={},b,d;if(c&&c.length&&c[0]&&c[c[0]])for(var e=c.length;e--;){b=c[e];if(typeof c[b]=="string"){d=b.replace(/\-(\w)/g,function(g,h){return h.toUpperCase()});a[d]=c[b]}}else for(b in c)if(typeof c[b]==="string")a[b]=c[b];return a}function p(c){var a,b;for(a in c){b=c[a];if(b==null||f.isFunction(b)||a in t||/scrollbar/.test(a)||!/color/i.test(a)&&isNaN(parseFloat(b)))delete c[a]}return c}function u(c,a){var b={_:0},d;for(d in a)if(c[d]!=a[d])b[d]=a[d];return b}function k(c,a,b,d){if(typeof c=="object"){d=
a;b=null;a=c;c=a.effect}if(f.isFunction(a)){d=a;b=null;a={}}if(typeof a=="number"||f.fx.speeds[a]){d=b;b=a;a={}}if(f.isFunction(b)){d=b;b=null}a=a||{};b=b||a.duration;b=f.fx.off?0:typeof b=="number"?b:b in f.fx.speeds?f.fx.speeds[b]:f.fx.speeds._default;d=d||a.complete;return[c,a,b,d]}function l(c){if(!c||typeof c==="number"||f.fx.speeds[c])return true;if(typeof c==="string"&&!f.effects[c])return true;return false}f.effects={};f.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor",
"borderTopColor","borderColor","color","outlineColor"],function(c,a){f.fx.step[a]=function(b){if(!b.colorInit){b.start=s(b.elem,a);b.end=m(b.end);b.colorInit=true}b.elem.style[a]="rgb("+Math.max(Math.min(parseInt(b.pos*(b.end[0]-b.start[0])+b.start[0],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[1]-b.start[1])+b.start[1],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[2]-b.start[2])+b.start[2],10),255),0)+")"}});var n={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,
0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,
211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},q=["add","remove","toggle"],t={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};f.effects.animateClass=function(c,a,b,
d){if(f.isFunction(b)){d=b;b=null}return this.queue(function(){var e=f(this),g=e.attr("style")||" ",h=p(o.call(this)),r,v=e.attr("class");f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});r=p(o.call(this));e.attr("class",v);e.animate(u(h,r),{queue:false,duration:a,easing:b,complete:function(){f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});if(typeof e.attr("style")=="object"){e.attr("style").cssText="";e.attr("style").cssText=g}else e.attr("style",g);d&&d.apply(this,arguments);f.dequeue(this)}})})};
f.fn.extend({_addClass:f.fn.addClass,addClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{add:c},a,b,d]):this._addClass(c)},_removeClass:f.fn.removeClass,removeClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{remove:c},a,b,d]):this._removeClass(c)},_toggleClass:f.fn.toggleClass,toggleClass:function(c,a,b,d,e){return typeof a=="boolean"||a===j?b?f.effects.animateClass.apply(this,[a?{add:c}:{remove:c},b,d,e]):this._toggleClass(c,a):f.effects.animateClass.apply(this,
[{toggle:c},a,b,d])},switchClass:function(c,a,b,d,e){return f.effects.animateClass.apply(this,[{add:a,remove:c},b,d,e])}});f.extend(f.effects,{version:"1.8.16",save:function(c,a){for(var b=0;b<a.length;b++)a[b]!==null&&c.data("ec.storage."+a[b],c[0].style[a[b]])},restore:function(c,a){for(var b=0;b<a.length;b++)a[b]!==null&&c.css(a[b],c.data("ec.storage."+a[b]))},setMode:function(c,a){if(a=="toggle")a=c.is(":hidden")?"show":"hide";return a},getBaseline:function(c,a){var b;switch(c[0]){case "top":b=
0;break;case "middle":b=0.5;break;case "bottom":b=1;break;default:b=c[0]/a.height}switch(c[1]){case "left":c=0;break;case "center":c=0.5;break;case "right":c=1;break;default:c=c[1]/a.width}return{x:c,y:b}},createWrapper:function(c){if(c.parent().is(".ui-effects-wrapper"))return c.parent();var a={width:c.outerWidth(true),height:c.outerHeight(true),"float":c.css("float")},b=f("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),
d=document.activeElement;c.wrap(b);if(c[0]===d||f.contains(c[0],d))f(d).focus();b=c.parent();if(c.css("position")=="static"){b.css({position:"relative"});c.css({position:"relative"})}else{f.extend(a,{position:c.css("position"),zIndex:c.css("z-index")});f.each(["top","left","bottom","right"],function(e,g){a[g]=c.css(g);if(isNaN(parseInt(a[g],10)))a[g]="auto"});c.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})}return b.css(a).show()},removeWrapper:function(c){var a,b=document.activeElement;
if(c.parent().is(".ui-effects-wrapper")){a=c.parent().replaceWith(c);if(c[0]===b||f.contains(c[0],b))f(b).focus();return a}return c},setTransition:function(c,a,b,d){d=d||{};f.each(a,function(e,g){unit=c.cssUnit(g);if(unit[0]>0)d[g]=unit[0]*b+unit[1]});return d}});f.fn.extend({effect:function(c){var a=k.apply(this,arguments),b={options:a[1],duration:a[2],callback:a[3]};a=b.options.mode;var d=f.effects[c];if(f.fx.off||!d)return a?this[a](b.duration,b.callback):this.each(function(){b.callback&&b.callback.call(this)});
return d.call(this,b)},_show:f.fn.show,show:function(c){if(l(c))return this._show.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="show";return this.effect.apply(this,a)}},_hide:f.fn.hide,hide:function(c){if(l(c))return this._hide.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="hide";return this.effect.apply(this,a)}},__toggle:f.fn.toggle,toggle:function(c){if(l(c)||typeof c==="boolean"||f.isFunction(c))return this.__toggle.apply(this,arguments);else{var a=k.apply(this,
arguments);a[1].mode="toggle";return this.effect.apply(this,a)}},cssUnit:function(c){var a=this.css(c),b=[];f.each(["em","px","%","pt"],function(d,e){if(a.indexOf(e)>0)b=[parseFloat(a),e]});return b}});f.easing.jswing=f.easing.swing;f.extend(f.easing,{def:"easeOutQuad",swing:function(c,a,b,d,e){return f.easing[f.easing.def](c,a,b,d,e)},easeInQuad:function(c,a,b,d,e){return d*(a/=e)*a+b},easeOutQuad:function(c,a,b,d,e){return-d*(a/=e)*(a-2)+b},easeInOutQuad:function(c,a,b,d,e){if((a/=e/2)<1)return d/
2*a*a+b;return-d/2*(--a*(a-2)-1)+b},easeInCubic:function(c,a,b,d,e){return d*(a/=e)*a*a+b},easeOutCubic:function(c,a,b,d,e){return d*((a=a/e-1)*a*a+1)+b},easeInOutCubic:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a+b;return d/2*((a-=2)*a*a+2)+b},easeInQuart:function(c,a,b,d,e){return d*(a/=e)*a*a*a+b},easeOutQuart:function(c,a,b,d,e){return-d*((a=a/e-1)*a*a*a-1)+b},easeInOutQuart:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a+b;return-d/2*((a-=2)*a*a*a-2)+b},easeInQuint:function(c,a,b,
d,e){return d*(a/=e)*a*a*a*a+b},easeOutQuint:function(c,a,b,d,e){return d*((a=a/e-1)*a*a*a*a+1)+b},easeInOutQuint:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a*a+b;return d/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(c,a,b,d,e){return-d*Math.cos(a/e*(Math.PI/2))+d+b},easeOutSine:function(c,a,b,d,e){return d*Math.sin(a/e*(Math.PI/2))+b},easeInOutSine:function(c,a,b,d,e){return-d/2*(Math.cos(Math.PI*a/e)-1)+b},easeInExpo:function(c,a,b,d,e){return a==0?b:d*Math.pow(2,10*(a/e-1))+b},easeOutExpo:function(c,
a,b,d,e){return a==e?b+d:d*(-Math.pow(2,-10*a/e)+1)+b},easeInOutExpo:function(c,a,b,d,e){if(a==0)return b;if(a==e)return b+d;if((a/=e/2)<1)return d/2*Math.pow(2,10*(a-1))+b;return d/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(c,a,b,d,e){return-d*(Math.sqrt(1-(a/=e)*a)-1)+b},easeOutCirc:function(c,a,b,d,e){return d*Math.sqrt(1-(a=a/e-1)*a)+b},easeInOutCirc:function(c,a,b,d,e){if((a/=e/2)<1)return-d/2*(Math.sqrt(1-a*a)-1)+b;return d/2*(Math.sqrt(1-(a-=2)*a)+1)+b},easeInElastic:function(c,a,b,
d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);return-(h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g))+b},easeOutElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);return h*Math.pow(2,-10*a)*Math.sin((a*e-c)*2*Math.PI/g)+d+b},easeInOutElastic:function(c,a,b,d,e){c=1.70158;var g=
0,h=d;if(a==0)return b;if((a/=e/2)==2)return b+d;g||(g=e*0.3*1.5);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);if(a<1)return-0.5*h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)+b;return h*Math.pow(2,-10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)*0.5+d+b},easeInBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;return d*(a/=e)*a*((g+1)*a-g)+b},easeOutBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;return d*((a=a/e-1)*a*((g+1)*a+g)+1)+b},easeInOutBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;
if((a/=e/2)<1)return d/2*a*a*(((g*=1.525)+1)*a-g)+b;return d/2*((a-=2)*a*(((g*=1.525)+1)*a+g)+2)+b},easeInBounce:function(c,a,b,d,e){return d-f.easing.easeOutBounce(c,e-a,0,d,e)+b},easeOutBounce:function(c,a,b,d,e){return(a/=e)<1/2.75?d*7.5625*a*a+b:a<2/2.75?d*(7.5625*(a-=1.5/2.75)*a+0.75)+b:a<2.5/2.75?d*(7.5625*(a-=2.25/2.75)*a+0.9375)+b:d*(7.5625*(a-=2.625/2.75)*a+0.984375)+b},easeInOutBounce:function(c,a,b,d,e){if(a<e/2)return f.easing.easeInBounce(c,a*2,0,d,e)*0.5+b;return f.easing.easeOutBounce(c,
a*2-e,0,d,e)*0.5+d*0.5+b}})}(jQuery);
/*
 * jQuery UI Effects Slide 1.8.16
 */
(function(c){c.effects.slide=function(d){return this.queue(function(){var a=c(this),h=["position","top","bottom","left","right"],f=c.effects.setMode(a,d.options.mode||"show"),b=d.options.direction||"left";c.effects.save(a,h);a.show();c.effects.createWrapper(a).css({overflow:"hidden"});var g=b=="up"||b=="down"?"top":"left";b=b=="up"||b=="left"?"pos":"neg";var e=d.options.distance||(g=="top"?a.outerHeight({margin:true}):a.outerWidth({margin:true}));if(f=="show")a.css(g,b=="pos"?isNaN(e)?"-"+e:-e:e);
var i={};i[g]=(f=="show"?b=="pos"?"+=":"-=":b=="pos"?"-=":"+=")+e;a.animate(i,{queue:false,duration:d.duration,easing:d.options.easing,complete:function(){f=="hide"&&a.hide();c.effects.restore(a,h);c.effects.removeWrapper(a);d.callback&&d.callback.apply(this,arguments);a.dequeue()}})})}})(jQuery);

