//Enter domain of site to search.
var domainroot="www.iprjuristbyra.se"
function mysitesearch(curobj){
document.getElementById("hiddenquery").value="site:"+domainroot+" "+curobj.qfront.value
}
function epost(myarray) {var encryptedemail=''; //variable to contain encrypted email 
	for (var i=0; i<myarray.length; i++)
		encryptedemail+=String.fromCharCode(myarray[i]);
		encryptedemail='<a href="mailto:'+encryptedemail+'">'+encryptedemail+'</a>';
	 return encryptedemail;
	} 
var ipr = [105,110,102,111,64,105,112,114,106,117,114,105,115,116,98,121,114,97,46,115,101];
// jquery
$(function() {
	// alla sidor
	// ta bort test om javascript äv aktiverad
	$(".utanJs").hide();	
	// epost
	$("span#epost").html(epost(ipr));
	// lägg till uppdateringsdatum					 
	var datum = new Date(document.lastModified)
	datum= $.formatDate(datum,"d MMMM yyyy");
	$("li#datum span").html(datum);	
	// form lägg focus på första fältet													 
	var $inputTxt = $('#namn');
	if( $inputTxt.val() == '' ) {
		$inputTxt.focus(); // focus the username input by default
	}			
		// validera form on keyup and submit
	var mySida= $('body').hasClass('form');
	if (mySida) {
		var validator = $("#kontakt_form").validate();
		// ta bort validering vid reset
		$("#rensa").click(function() {
   	 validator.resetForm();
   	});
	}
		// contactsidan 
	$("#start").click(function() {
   	location.href='index.html'
   	});				 
});		// $ slut	
/*
$.formatDate(date,pattern) Formats the passed date according to the supplied pattern. The tokens that are substituted in the pattern are as follows:
yyyy: the 4-digit year, yy: the 2-digit year, MMMM: the full name of the month, MMM: the abbreviated name of the month, MM: the month number as a 0-filled, 2-character field, M: the month number, dd: the day in the month as a 0-filled, 2-character field, d: the day in the month
EEEE: the full name of the day of the week, EEE: the abbreviated name of the day of the week, a: the meridium (AM or PM), HH: the 24-hour clock hour in the day as a 2-character, 0-filled field, 
H: the 24-hour clock hour in the day, hh: the 12-hour clock hour in the day as a 2-character, 0-filled field, h: the 12-hour clock hour in the day, mm: the minutes in the hour as a 2-character, 0-filled field, m: the minutes in the hour, ss: the seconds in the minute as a 2-character, 0-filled field, s: the seconds in the minute, S: the milliseconds in the second as a 3-character, 0-filled field, Parameters, date (Date) The date to be formatted., pattern (String) The pattern to format the date into. Any characters not matching pattern, tokens are copied as-is to the result. ReturnsThe formatted date.
*/
(function($){$.toFixedWidth = function(value,length,fill) {var result = value.toString();if (!fill) fill = '0';var padding = length - result.length;if (padding < 0) {result = result.substr(-padding);}else {for (var n = 0; n < padding; n++)result = fill + result;}return result;};})(jQuery);(function($){$.formatDate = function(date,pattern) {var result = [];while (pattern.length > 0) {$.formatDate.patternParts.lastIndex = 0;var matched = $.formatDate.patternParts.exec(pattern);if (matched) {result.push($.formatDate.patternValue[matched[0]].call(this,date));pattern = pattern.slice(matched[0].length);} else {result.push(pattern.charAt(0));pattern = pattern.slice(1);}}return result.join('');};$.formatDate.patternParts =/^(yy(yy)?|M(M(M(M)?)?)?|d(d)?|EEE(E)?|a|H(H)?|h(h)?|m(m)?|s(s)?|S)/;$.formatDate.monthNames = [
'januari','februari','mars','april','maj','juni','juli','augusti','september','oktober','november','december'];$.formatDate.dayNames = ['Söndag','Måndag','Tisdag','Onsdag','Torsdag','Fredag','Lördag'];$.formatDate.patternValue = {yy: function(date) {return $.toFixedWidth(date.getFullYear(),2);},yyyy: function(date) {return date.getFullYear().toString();},MMMM: function(date) {return $.formatDate.monthNames[date.getMonth()];},MMM: function(date) {return $.formatDate.monthNames[date.getMonth()].substr(0,3);},MM: function(date) {return $.toFixedWidth(date.getMonth() + 1,2);},M: function(date) {return date.getMonth()+1;},dd: function(date) {return $.toFixedWidth(date.getDate(),2);},d: function(date) {return date.getDate();},EEEE: function(date) {return $.formatDate.dayNames[date.getDay()];},EEE: function(date) {return $.formatDate.dayNames[date.getDay()].substr(0,3);},HH: function(date) {return $.toFixedWidth(date.getHours(),2);},H: function(date) {return date.getHours();},hh: function(date) {var hours = date.getHours();return $.toFixedWidth(hours > 12 ? hours - 12 : hours,2);},h: function(date) {return date.getHours() % 12;},mm: function(date) {return $.toFixedWidth(date.getMinutes(),2);},m: function(date) {return date.getMinutes();},ss: function(date) {return $.toFixedWidth(date.getSeconds(),2);},s: function(date) {return date.getSeconds();},S: function(date) {return $.toFixedWidth(date.getMilliseconds(),3);},a: function(date) {return date.getHours() < 12 ? 'AM' : 'PM';}};})(jQuery);	


