(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 + "dialog-submit-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;}}	function jsddm_tap(event) {		event.stopPropagation();		var mymenu = $(this).parent().find('ul');		if (mymenu.css('visibility')=='hidden') {			if(ddmenuitem) {				ddmenuitem.css('visibility', 'hidden');			}			ddmenuitem = mymenu.css('visibility', 'visible');			return false;		} else {			return true;		}	}/*		$(document).ready(function()	{  $('#main-nav > li').bind('mouseover', jsddm_open)	   $('#main-nav > li').bind('mouseout',  jsddm_timer)});*/	if (window.Touch) {		$('#main-nav > li > a').bind('click', jsddm_tap);		$(document).bind('click', jsddm_close);	} else {		$('#main-nav > li').bind('mouseover', jsddm_open);	   	$('#main-nav > li').bind('mouseout',  jsddm_timer);		$(document).bind('click', jsddm_close);	}/*	if (window.Touch) {		//$(document).bind('touchstart', jsddm_close);	} else {		$(document).bind('click', jsddm_close);	}*/		//$(document).bind('click', jsddm_close);	//document.onclick = jsddm_close;		$(document).ready(function()	{  $('#main-nav2 > li').bind('mouseover', jsddm_open)	   $('#main-nav2 > li').bind('mouseout',  jsddm_timer)	});	$("#t_disp").testimonials({    		speed : 7000	}); 	$("#fe-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}		}	});		$("#fe-submit").click(function() {		$("#enquiry-right").validate().form();		if ($("#enquiry-right").validate().numberOfInvalids()==0) {					_gaq.push(['_trackEvent', 'Partner Right Enquiry Form Submitted', websession.profile, websession.referrer]);							var postData = "Enquiry from www.qualitysolicitors.com/" + websession.profile + "|Name: " + $("#rename").val() + "~" + "Email: " + $("#reemail").val() + "~" + "Phone: " + $("#rephone").val() + "~" + "Message: " + $("#remessage").val() + "|" + websession.profile;			$("#rename").val(""); $("#reemail").val(""); $("#rephone").val(""); $("#remessage").val("");			$.post(websession.path + "feedback?openagent", escape(postData), function() { alert("Thank you for your enquiry."); } , "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");   	});  	// 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");   	});   	 	 	$("#peoplebysurname").click( function() { $.cookie("ops", "S"); window.location.reload(); }) 	$("#peoplebyfirstname").click( function() { $.cookie("ops", "F"); window.location.reload(); }) 	 	// Set the hover for claim go button	$("#page-search-go").hover(function() {  			$(this).attr("src", websession.path + "go-h.png");  		}, function() {  		$(this).attr("src", websession.path + "go.png");   	});  	// Handle the display for location field	$("#page-search-input").focusin(function() {if($("#page-search-input").val()==websession.searchstring) {$("#page-search-input").val("")}; $("#page-search-input").select()});	$("#page-search-input").focusout(function() {if($("#page-search-input").val()=="") {$("#page-search-input").val(websession.searchstring)} }); 	$("#page-search-input").val(websession.searchstring);	if (!websession.editmode) {		$('#page-search-input').keyup(function(e) { 			if(e.keyCode == 13)				if ($("#page-search-input").val() != "" & $("#page-search-input").val() != websession.searchstring) {					_gaq.push(['_trackEvent', 'Partner Site Search', websession.profile + " - " + $("#page-search-input").val(), websession.referrer]);									location.href = "/" + websession.profile + "-search.html?open&search=" + $("#page-search-input").val();				} 		});				$("#page-search-go").click(function() {			if ($("#page-search-input").val() != "" & $("#page-search-input").val() != websession.searchstring) {				_gaq.push(['_trackEvent', 'Partner Site Search', websession.profile + " - " + $("#page-search-input").val(), websession.referrer]);								location.href = "/" + websession.profile + "-search.html?open&search=" + $("#page-search-input").val(); 			}		});	} else {		$('#page-search-input').attr('disabled', true);	}	// 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); } );	 		var emailValidator = $("#email-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: {		   	ename: {required: true}, 				   	eemail: {required: true, email: true},		   	esubject: {required: true}		}	});		$("#email-person").click(function() {		$("#email_popup").dialog({ 			resizable: false,			title: websession.emailheading,			closeText: "",			dialogClass: "enq-dialog",			bgiframe: true,			modal: true,			height: 460,			width: 721,			overlay: { 				opacity: 0.4, 				background: "black" 			}		});		$("#email_popup").dialog("open");		if (document.getElementById("email_popup").style.display!="block") {						document.getElementById("email_popup").style.display="block"; 					$(".email-submit").hover(function() {  					$(this).attr("src", websession.path + "dialog-submit-h.png");  			}, function() {  				$(this).attr("src", websession.path + "dialog-submit.png");  			});			$(".email-submit-pl").hover(function() {  					$(this).attr("src", websession.path + "dialog-submit-pl-h.png");  			}, function() {  				$(this).attr("src", websession.path + "dialog-submit-pl.png");  			});			$("#email-submit").click(function() {				$("#email-form").validate().form();				if ($("#email-form").validate().numberOfInvalids()==0) {							_gaq.push(['_trackEvent', 'Partner Email Form Submitted', websession.profile, websession.referrer]);									var postData = $("#ename").val() + "~" + $("#eemail").val() + "~" + $("#esubject").val() + "~" + $("#ebody").val() + "~" + websession.unid + "~" + websession.profile;					$("#ename").val(""); $("#eemail").val(""); $("#esubject").val(""); $("#ebody").val("");					$("#email_popup").dialog("close"); 					$.post(websession.path + "emailperson?openagent", postData, function() { alert("Message sent.") } , "html");				} else {					alert("Please review the form and complete any missing information before submitting"); 				}			});			} 		$("#ename").focus();	});		 		 		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}		}	});		$(".callbacklink").click(function() {		$("#callback_popup").dialog({ 			resizable: false,			title: websession.callbackheading,			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', 'Partner Callback Form Submitted', websession.profile, websession.referrer]);									var postData = "Callback request from www.qualitysolicitors.com/" + websession.profile + "|Name: " + $("#cname").val() + "~" + "Phone: " + $("#cphone").val() + "~" + "Details: " + $("#cdetails").val() + "|" + websession.profile;					$("#cname").val(""); $("#cphone").val(""); $("#cdetails").val("");					$("#callback_popup").dialog("close"); 					$.post(websession.path + "feedback?openagent", escape(postData), function() {  } , "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: websession.enquiryheading,			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', 'Partner Enquiry Form Submitted', websession.profile, websession.referrer]);									var postData = "Enquiry form from www.qualitysolicitors.com/" + websession.profile + "|Name: " + $("#name").val() + "~" + "EMail: " + $("#email").val() + "~" + "Phone: " + $("#phone").val() + "~" + "Mobile: " + $("#mobile").val() + "~" + "PostCode: " + $("#postcode").val() + "~" + "Details: " + $("#details").val() + "|" + websession.profile;					$("#name").val(""); $("#email").val(""); $("#phone").val(""); $("#mobile").val(""); $("#postcode").val(""); $("#details").val("");					$("#help_popup").dialog("close"); 					$.post(websession.path + "feedback?openagent", escape(postData), function() { } , "html");				} else {					alert("Please review the form and complete any missing information before submitting"); 				}			});			} 		$("#name").focus();	});		});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 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&user=" + websession.username, 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.testimonials = function(options){    var container = this;    var index = 1;    var defaults =     {      speed : 7000,       tid: "testimonials"    }        var options = $.extend(defaults, options);           setInterval(changeQuote, options.speed);        container.html( $("#testimonials li:nth-child(1)").html() );        function changeQuote() {      container.fadeOut( function() {        container.html(  $("#testimonials li:nth-child(" + index + ")").html()  ).fadeIn();      });            if(index == $("#testimonials li").length){        index = 1;      } else{        index++;      }	};	  return container;}})(jQuery);
