(function($) {  var cache = [];  $.preLoadImages = function() {    var args_len = arguments.length;    for (var i = args_len; i=i-1;) {      var cacheImage = document.createElement('img');      cacheImage.src = arguments[i];      cache.push(cacheImage);    }  }})(jQuery)$(document).ready(function() {	// Preload hover images.	jQuery.preLoadImages(websession.path + "onlineenq-h.png", websession.path + "mainqs-h.png",	websession.path + "btn-callback-h.gif", websession.path + "onlineenq-pl-h.png", websession.path + "mainqs-pl-h.png",	websession.path + "btn-callback-pl-h.gif", websession.path + "lpc-h.png", websession.path + "dialog-submit-h.png", websession.path + "visit-h.png",	websession.path + "whyqs-h.png", websession.path + "expert-h.png");	var timeout    = 500;	var closetimer = 0;	var ddmenuitem = 0;		function jsddm_open()	{  jsddm_canceltimer();	   jsddm_close();	   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}		function jsddm_close()	{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}		function jsddm_timer()	{  closetimer = window.setTimeout(jsddm_close, timeout);}		function jsddm_canceltimer()	{  if(closetimer)	   {  window.clearTimeout(closetimer);	      closetimer = null;}}		$(document).ready(function()	{  $('#main-nav > li').bind('mouseover', jsddm_open)	   $('#main-nav > li').bind('mouseout',  jsddm_timer)});		document.onclick = jsddm_close;	$(document).ready(function()	{  $('#main-nav2 > li').bind('mouseover', jsddm_open)	   $('#main-nav2 > li').bind('mouseout',  jsddm_timer)});	$("#my-location5").autocomplete(websession.path + "getplaces?openagent");			$("#location").autocomplete(websession.path + "getplaces?openagent");				$("#visitsite").hover(function() {  			$(this).attr("src", websession.path + "visit-h.png");  	}, function() {  		$(this).attr("src", websession.path + "visit.png");  	});		$("#expert").hover(function() {  			$(this).attr("src", websession.path + "expert-h.png");  	}, function() {  		$(this).attr("src", websession.path + "expert.png");  	});	$("#whyqs").hover(function() {  			$(this).attr("src", websession.path + "whyqs-h.png");  	}, function() {  		$(this).attr("src", websession.path + "whyqs.png");  	});	$("#fe-submit").hover(function() {  			$(this).attr("src", websession.path + "dialog-submit-h.png");  	}, function() {  		$(this).attr("src", websession.path + "dialog-submit.png");  	});	$("#fl-submit").hover(function() {  			$(this).attr("src", websession.path + "dialog-submit-h.png");  	}, function() {  		$(this).attr("src", websession.path + "dialog-submit.png");  	});	$("#fs-submit").hover(function() {  			$(this).attr("src", websession.path + "dialog-submit-h.png");  	}, function() {  		$(this).attr("src", websession.path + "dialog-submit.png");  	});	var rightenqValidator = $("#enquiry-right").validate({		submitHandler: function(form) {			}, 		onkeyup: false,		errorPlacement: function(error, element) {			if ( $("#" + element.name).hasClass("reinfo") ) {	     		$("#" + element.name).removeClass("reinfo").addClass("error");	     	}   		},   		unhighlight: function(element, errorClass, validClass) {			if ( $("#" + element.name).hasClass("error") ) {	     		$("#" + element.name).removeClass("error");	     	}   		},		rules: {		   	rename: {required: true}, 				   	reemail: {required: true, email: true}, 		   	rephone: {required: true},		   	repostcode: {required: true}		}	});		$("#fe-submit").click(function() {		$("#enquiry-right").validate().form();		if ($("#enquiry-right").validate().numberOfInvalids()==0) {					_gaq.push(['_trackEvent', 'Right Enquiry Form Submitted', websession.referrer, '']);							var postData = "Enquiry from www.qualitysolicitors.com|Name: " + $("#rename").val() + "~" + "Email: " + $("#reemail").val() + "~" + "Phone: " + $("#rephone").val() + "~" + "Postcode: " + $("#repostcode").val() + "~" + "Message: " + $("#remessage").val();			$("#rename").val(""); $("#reemail").val(""); $("#rephone").val(""); $("#remessage").val(""); $("#repostcode").val("");			$.post(websession.path + "feedback?openagent", postData, function() { location.href="/thankyou-enquiry.html"; } , "html");		} else {			alert("Please review the form and complete any missing information before submitting"); 		}	});		$("#fl-submit").click(function() {		$("#enquiry-right").validate().form();		if ($("#enquiry-right").validate().numberOfInvalids()==0) {					_gaq.push(['_trackEvent', 'Right Enquiry Form Submitted', websession.referrer, '']);							var postData = "Enquiry from www.qualitysolicitors.com|Name: " + $("#rename").val() + "~" + "Email: " + $("#reemail").val() + "~" + "Phone: " + $("#rephone").val() + "~" + "Postcode: " + $("#repostcode").val() + "~" + "Message: " + $("#remessage").val() + "|" + websession.profile;			$("#rename").val(""); $("#reemail").val(""); $("#rephone").val(""); $("#remessage").val(""); $("#repostcode").val("");			$.post(websession.path + "feedback?openagent", postData, function() { location.href="/thankyou-enquiry.html"; } , "html");		} else {			alert("Please review the form and complete any missing information before submitting"); 		}	});			var rightenqValidator2 = $("#fs-form").validate({		submitHandler: function(form) {			}, 		onkeyup: false,		errorPlacement: function(error, element) {			if ( $("#" + element.name).hasClass("field") ) {	     		$("#" + element.name).removeClass("field").addClass("error");	     	}   		},   		unhighlight: function(element, errorClass, validClass) {			if ( $("#" + element.name).hasClass("error") ) {	     		$("#" + element.name).removeClass("error");	     	}   		},		rules: {		   	"fs-name": {required: true}, 				   	"fs-email": {required: true, email: true}, 		   	"fs-phone": {required: true},		   	"fs-firm": {required: true},		   	"fs-postcode": {required: true}		}	});		$("#fs-submit").click(function() {		$("#fs-form").validate().form();		if ($("#fs-form").validate().numberOfInvalids()==0) {					_gaq.push(['_trackEvent', 'Solicitor Enquiry Form Submitted', websession.referrer, '']);							var postData = "Solicitor Enquiry from www.qualitysolicitors.com|Name: " + $("#fs-name").val() + "~" + "Email: " + $("#fs-email").val() + "~" + "Phone: " + $("#fs-phone").val() + "~" + "Mobile: " + $("#fs-mobile").val() + "~" + "Firm: " + $("#fs-firm").val() + "~" + "Postcode: " + $("#fs-postcode").val() + "~" + "Position: " + $("#fs-position").val();			$("#fs-name").val(""); $("#fs-email").val(""); $("#fs-phone").val(""); $("#fs-mobile").val(""); $("#fs-firm").val(""); $("#fs-postcode").val(""); $("#fs-position").val("")			$.post(websession.path + "solicitorfeedback?openagent", postData, function() { location.href="/for-solicitors/thank-you.html"; } , "html");		} else {			alert("Please review the form and complete any missing information before submitting"); 		}	});	// Handle the mainqs button hover	$("#mainqs").hover(function() {  			$(this).attr("src", websession.path + "mainqs-h.png");  		}, function() {  		$(this).attr("src", websession.path + "mainqs.png");   	});  	$("#mainqs-pl").hover(function() {  			$(this).attr("src", websession.path + "mainqs-pl-h.png");  		}, function() {  		$(this).attr("src", websession.path + "mainqs-pl.png");   	});  	// Legal Privilege card hover	$("#lpc-img").hover(function() {  			$(this).attr("src", websession.path + "lpc-h.png");  		}, function() {  		$(this).attr("src", websession.path + "lpc.png");   	});  	$("#callback2").hover(function() {  			$(this).attr("src", websession.path + "injury-h.png");  		}, function() {  		$(this).attr("src", websession.path + "injury.png");   	});  	// Handle the online enq button hover	$("#onlineenq").hover(function() {  			$(this).attr("src", websession.path + "onlineenq-h.png");  		}, function() {  		$(this).attr("src", websession.path + "onlineenq.png");   	});  	$("#onlineenq-pl").hover(function() {  			$(this).attr("src", websession.path + "onlineenq-pl-h.png");  		}, function() {  		$(this).attr("src", websession.path + "onlineenq-pl.png");   	});  	// Handle the callback button hover	$("#btn-callback").hover(function() {  			$(this).attr("src", websession.path + "btn-callback-h.gif");  		}, function() {  		$(this).attr("src", websession.path + "btn-callback.gif");   	});  	$("#btn-callback-pl").hover(function() {  			$(this).attr("src", websession.path + "btn-callback-pl-h.gif");  		}, function() {  		$(this).attr("src", websession.path + "btn-callback-pl.gif");   	});   	 	// Handle the polish button hover	$("#language-gfx-pl").hover(function() {  			$(this).attr("src", websession.path + "lang-en.png");  		}, function() {  		$(this).attr("src", websession.path + "lang-pl.png");   	});   	 	$("#language-gfx").hover(function() {  			$(this).attr("src", websession.path + "lang-pl.png");  		}, function() {  		$(this).attr("src", websession.path + "lang-en.png");   	});   		$("#more-news").hover(function() {  			$(this).attr("src", websession.path + "more-news-h.jpg");  		}, function() {  		$(this).attr("src", websession.path + "more-news.jpg");   	});   		// Read more function	$("#more").css("display", "none");	$("#read-more").click( function() { $("#read-more").hide(); $("#more").slideDown(1); } );	$("#read-less").click( function() { $("#read-more").show(); $("#more").slideUp(1); } );	 	$("#location-more").css("display", "none");	$("#location-read-more").click( function() { $("#location-read-more").hide(); $("#location-more").slideDown(); } )	$("#location-read-less").click( function() { $("#location-read-more").show(); $("#location-more").slideUp(); } ) 		 		var callbackValidator = $("#callback-form").validate({		submitHandler: function(form) {			}, 		onkeyup: false,		errorPlacement: function(error, element) {			if ( element.parent("td").hasClass("info") ) {	     		element.parent("td").removeClass("info").addClass("error");	     	}			if ( element.parent("td").hasClass("info-text") ) {	     		element.parent("td").removeClass("info-text").addClass("error-text");	     	}   		},   		unhighlight: function(element, errorClass, validClass) {			if ( $("#" + element.name).hasClass("error") ) {	     		$("#" + element.name).removeClass("error");	     	}			if ( $("#" + element.name).parent("td").hasClass("error-text") ) {	     		$("#" + element.name).parent("td").removeClass("error-text").addClass("info-text");	     	}   		},		rules: {		   	cname: {required: true}, 				   	cphone: {required: true},		   	cpostcode: {required: true}		}	});		$(".callbacklink").click(function() {		$("#callback_popup").dialog({ 			resizable: false,			title: "Call me back...",			closeText: "",			dialogClass: "callback-dialog",			bgiframe: true,			modal: true,			height: 360,			width: 721,			overlay: { 				opacity: 0.4, 				background: "black" 			}		});		$("#callback_popup").dialog("open");		if (document.getElementById("callback_popup").style.display!="block") {						document.getElementById("callback_popup").style.display="block"; 					$(".callback-submit").hover(function() {  					$(this).attr("src", websession.path + "dialog-submit-h.png");  			}, function() {  				$(this).attr("src", websession.path + "dialog-submit.png");  			});			$(".callback-submit-pl").hover(function() {  					$(this).attr("src", websession.path + "dialog-submit-pl-h.png");  			}, function() {  				$(this).attr("src", websession.path + "dialog-submit-pl.png");  			});			$("#callback-submit").click(function() {				$("#callback-form").validate().form();				if ($("#callback-form").validate().numberOfInvalids()==0) {							_gaq.push(['_trackEvent', 'Callback request from www.qualitysolicitors.com', websession.referrer, '']);									var postData = "Callback request from www.qualitysolicitors.com|Name: " + $("#cname").val() + "~" + "Phone: " + $("#cphone").val() + "~" + "Postcode: " + $("#cpostcode").val() + "~" + "Details: " + $("#cdetails").val();					$("#cname").val(""); $("#cphone").val(""); $("#cdetails").val(""); $("#cpostcode").val("")					$("#callback_popup").dialog("close"); 					$.post(websession.path + "feedback?openagent", postData, function() { location.href="/thankyou-callback.html"; } , "html");				} else {					alert("Please review the form and complete any missing information before submitting"); 				}			});			} 		$("#cname").focus();	});		var helpValidator = $("#help-form").validate({		submitHandler: function(form) {			}, 		onkeyup: false,		errorPlacement: function(error, element) {			if ( element.parent("td").hasClass("info") ) {	     		element.parent("td").removeClass("info").addClass("error");	     	}			if ( element.parent("td").hasClass("info-text") ) {	     		element.parent("td").removeClass("info-text").addClass("error-text");	     	}   		},   		unhighlight: function(element, errorClass, validClass) {			if ( $("#" + element.name).hasClass("error") ) {	     		$("#" + element.name).removeClass("error");	     	}			if ( $("#" + element.name).parent("td").hasClass("error-text") ) {	     		$("#" + element.name).parent("td").removeClass("error-text").addClass("info-text");	     	}   		},		rules: {		   	name: {required: true}, 				   	email: {required: true, email: true},				   	phone: {required: true},				   	mobile: {required: true},			   		postcode: {required: true}		}	});		$(".onlineenqlink").click(function() {		$("#help_popup").dialog({ 			title: "Just a few details please...",			closeText: "",			dialogClass: "enq-dialog",			bgiframe: true,			resizable: false,			modal: true,			height: 430,			width: 721,			overlay: { 				opacity: 0.4, 				background: "black" 			}		});		$("#help_popup").dialog("open");		if (document.getElementById("help_popup").style.display!="block") {						document.getElementById("help_popup").style.display="block"; 					$(".dialog-submit").hover(function() {  					$(this).attr("src", websession.path + "dialog-submit-h.png");  			}, function() {  				$(this).attr("src", websession.path + "dialog-submit.png");  			});			$(".dialog-submit-pl").hover(function() {  					$(this).attr("src", websession.path + "dialog-submit-pl-h.png");  			}, function() {  				$(this).attr("src", websession.path + "dialog-submit-pl.png");  			});			$("#dialog-submit").click(function() {				$("#help-form").validate().form();				if ($("#help-form").validate().numberOfInvalids()==0) {							_gaq.push(['_trackEvent', 'Enquiry Form Submitted', websession.referrer, '']);									var postData = "Enquiry form from www.qualitysolicitors.com|Name: " + $("#name").val() + "~" + "EMail: " + $("#email").val() + "~" + "Phone: " + $("#phone").val() + "~" + "Mobile: " + $("#mobile").val() + "~" + "Postcode: " + $("#postcode").val() + "~" + "Details: " + $("#details").val();					$("#name").val(""); $("#email").val(""); $("#phone").val(""); $("#mobile").val(""); $("#postcode").val(""); $("#details").val("");					$("#help_popup").dialog("close"); 					$.post(websession.path + "feedback?openagent", postData, function() { location.href="/thankyou-enquiry.html"; } , "html");				} else {					alert("Please review the form and complete any missing information before submitting"); 				}			});			} 		$("#name").focus();	});			$("#fs-submit").hover(function() {  			$(this).attr("src", websession.path + "dialog-submit-h.png");  	}, function() {  		$(this).attr("src", websession.path + "dialog-submit.png");  	});			//New Parents Query Form	$("#np-submit").hover(function() {  			$(this).attr("src", websession.path + "dialog-submit-h.png");  	}, function() {  		$(this).attr("src", websession.path + "dialog-submit.png");  	});	$("#np-form-terms").click(function() {		$("#new-parents-terms").height("400px");		$("#new-parents-ws").height("750px");	});		var newParentsValidator = $("#np-form").validate({		submitHandler: function(form) {			}, 		onkeyup: false,		errorPlacement: function(error, element) {			if ( $("#" + element.name).hasClass("reinfo") ) {	     		$("#" + element.name).removeClass("reinfo").addClass("error");	     	}   		},   		unhighlight: function(element, errorClass, validClass) {			if ( $("#" + element.name).hasClass("error") ) {	     		$("#" + element.name).removeClass("error");	     	}   		},		rules: {		   	npfirstname: {required: true}, 				   	nplastname: {required: true}, 				   	npemail: {required: true, email: true}, 		   	npphone: {required: true},		   	nppostcode: {required: true}		}	});		$("#np-submit").click(function() {		$("#np-form").validate().form();		if ($("#np-form").validate().numberOfInvalids()==0) {					_gaq.push(['_trackEvent', 'New Parents Form Submitted', websession.referrer, '']);							var postData = "Enquiry from www.qualitysolicitors.com|Name: " + $("#npfirstname").val() + " " + $("#nplastname").val() + "~" + "Email: " + $("#npemail").val() + "~" + "Phone: " + $("#npphone").val() + "~" + "Postcode: " + $("#nppostcode").val();			$("#npfirstname").val(""); $("#nplastname").val(""); $("#npemail").val(""); $("#npphone").val(""); $("#nppostcode").val("");			$.post(websession.path + "newparents?openagent", postData, function() { location.href="/thankyou-enquiry.html"; } , "html");		} else {			alert("Please review the form and complete any missing information before submitting"); 		}	});			});function toggle(id) {		if (document.getElementById(id).style.display == "none") {			document.getElementById(id).style.display = "block";		document.getElementById(id+"-toggle").className = "guide-service-open";	} else {		document.getElementById(id).style.display = "none";		document.getElementById(id+"-toggle").className = "guide-service";	}	}function loadPeople() {	$.post(websession.path + "peoplewall?openagent", "", function(data) { $("#people-wall").html(data); } , "html");	setTimeout(loadPeople2, 12000);	$.post(websession.path + "peoplewall?openagent", "", function(data) { $("#people-wall-h").html(data); } , "html");}function loadPeople2() {	$("#people-wall").fadeOut( function() { $("#people-wall").html($("#people-wall-h").html()).fadeIn(); } );	$.post(websession.path + "peoplewall?openagent", "", function(data) { $("#people-wall-h").html(data); } , "html");	setTimeout(loadPeople2, 12000);}function editContent(dialogtitle, fieldname, savefieldname) {	$("#contentedittext").val($("#" + fieldname).html());	if (CKEDITOR.instances) {		var editor = CKEDITOR.instances["contentedittext"];		if (editor)			editor.setData($("#contentedittext").val()); }	if (!editor) { 			         		editor = CKEDITOR.replace("contentedittext", {autoUpdateElement: true, height: "505px", resize_enabled: false, baseHref: websession.path + '/ckeditor/',				contentsCss: websession.path + "/ckeditor.css",			filebrowserUploadUrl: websession.path + '/imageupload?CreateDocument',			enterMode: CKEDITOR.ENTER_P,			autoUpdateElement: true, 			forcePasteAsPlainText: true, 			resize_enabled: false,			format_tags: 'p;h1;h2;h3',			font_names: 'Arial/Arial, Helvetica, sans-serif; Courier New/Courier New, Courier, Monospace;Times New Roman/Times New Roman, Times, serif',			font_defaultLabel: 'Arial',			fontSize_sizes: '16/16px;18/18px;/20/20px',			fontSize_defaultLabel: '16px',			toolbar: [['Source','-','Save','Preview'],    ['Cut','Copy','Paste','PasteText','-','Print', 'SpellChecker', 'Scayt'],    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],    '/',    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],    ['Link','Unlink','Anchor'],    ['Image','Table','HorizontalRule','SpecialChar','PageBreak'],    '/',    ['Format','Font','FontSize'],    ['TextColor','BGColor'],    ['Maximize', 'ShowBlocks']]							});			editor.on( 'afterCommandExec', renameCKUpload );	}			$("#contentedit-dialog").dialog({ 		title: dialogtitle,		resizable: false,		modal: true, 		height: 750,		width: 970,    		overlay: {         		opacity: 0.5,         		background: "black"     		},     	    	buttons: {         		"Ok": function() { 			     var textareas = $('textarea');			     $.each(textareas, function () {			         var idname = $(this).attr('id');			         var editor = CKEDITOR.instances[idname];			         if (editor) $(this).val(editor.getData());			     });   				var postData = escape($("#contentedittext").val());   				$.post(websession.path + "updateContent?openagent&unid=" + websession.unid + "&field=" + savefieldname + "&type=content", postData, function(data) { 					 window.location.reload() 				}, "html");            		$(this).dialog("close");   					        		},        		"Cancel": function() {             		$(this).dialog("close");         		}     		} 	});	$("#contentedit-dialog").show();}function renameCKUpload(eventObject) {	var eventType = eventObject.data.name;		var eventTypeCheck = eventType + ',';		if( 'image,link,imagebutton,flash,'.indexOf( eventTypeCheck ) === -1 ){ return }		renameFileUpload();			function renameFileUpload(){		//Poll for the upload-iframe/field		var iframes = document.getElementsByTagName( 'iframe' );		var dialogFrame, dialogDoc;		for( var i=0, len = iframes.length; i < len; i++ ){			if( iframes[i].id.indexOf( 'fileInput' ) > 0 ){				dialogFrame = iframes[i];				dialogDoc = dialogFrame.contentWindow.document;				break;			}		}						if( !(dialogFrame && dialogDoc.forms.length === 1) ){ setTimeout( renameFileUpload, 1000 ); return; }					dialogDoc.forms[0].upload.name = document.getElementById("txtUploadFile").name;	}}function sortListbox(listboxId) {	var $r = $("#" + listboxId + " option");	$r.sort(function(a, b) {		if (a.text < b.text) return -1;		if (a.text == b.text) return 0;		return 1;	});	$($r).remove();	$("#" + listboxId).append($($r));}(function($){  $.fn.fadeinout = function(options){    var container = this;    var index = 1;    var defaults =     {      speed : 7000,       id: "fadeinout"    }        var options = $.extend(defaults, options);           setInterval(changeQuote, options.speed);        container.html( $("#" + options.id + " li:nth-child(1)").html() );        function changeQuote() {      container.fadeOut( function() {        container.html(  $("#" + options.id + " li:nth-child(" + index + ")").html()  ).fadeIn();      });            if(index == $("#" + options.id + " li").length){        index = 1;      } else{        index++;      }	};	  return container;}})(jQuery);
