

var newwindow='';
function myVoid(){ ; } // do nothing
function trim(sStr){while(sStr.substring(0,1)== ' '){sStr=sStr.substring(1,sStr.length);}while(sStr.substring(sStr.length-1, sStr.length)==' '){sStr=sStr.substring(0,sStr.length-1);}return sStr;}
function rollover(doc_name,img_name,img_src){if(isString(img_name)){doc_name.getElementById(img_name).src=img_src;}else if(isObject(img_name)){img_name.src=img_src;}else{return -1;}}
function pngrollover(doc_name,img_name,img_src){if(document.all){doc_name.getElementById(img_name+'div').style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader (src=\''+img_src+'\', sizing Method=\'scale\')';}else{doc_name.getElementById(img_name + 'img').src=img_src;}}
function bannerRotate(banners,anchor_target_id,image_target_id,myIndex,image_target_attribute){var d=document;var n;if(!myIndex){n=Math.floor(Math.random()*banners.length);}else{n=myIndex}switch(image_target_attribute){case'backgroundImage':d.getElementById(image_target_id).style.backgroundImage = "url(" + banners[n][0] + ")";break;default:if(d.getElementById(image_target_id)){d.getElementById(image_target_id).src=banners[n][0];}if(anchor_target_id!=null){if(d.getElementById(anchor_target_id)){d.getElementById(anchor_target_id).href=banners[n][1];}}}return n;}
function bannerTextRotate (banners, div_target_id) {var n;n=Math.floor(Math.random() * banners.length);document.getElementById(div_target_id).innerHTML=banners[n];return 0;}
/*Code for fixing Internet Explorer!!!*/
/*Fortunately, can use some DOM1 methods with IE5 but still have to resort to IE5 DHTML to retrieve objects.
/*IE4, like NS4, does not support the DOM model at all and therefore the help elements probably won't disappear, anyway... i think*/
function fixIERender(doc_name) {var imgs=document.body.all.tags("img");for(i=0;i<imgs.length;i++){if(imgs[i].getAttributeNode('class').value=='infoBubbleDiv'){imgs[i].style.visibility='inherit';}}}
/*more code for fixing ie redraw bugs*/
function forceIERedraw(){if (document.all){var cn=document.body.className;document.body.className="nodisplay";document.body.className=cn;return 0;}}
window.onload=function(){if(document.getElementById('quoteDiv')){}if(document.all&&document.getElementById){window.event.cancelBubble=true;myMenus=document.getElementsByClass("menu");myId=document.getElementById("menu");if(myId)myMenus[myMenus.length]=myId;for(i=0;i<myMenus.length;i++){sfHover(myMenus[i]);}}forceIERedraw();}
document.getElementsByClass=function(needle){var my_array=document.getElementsByTagName("*");var retvalue=new Array();var i=0;var j=0;for(i=0,j=0;i<my_array.length;i++){var c=" "+my_array[i].className+" ";if(c.indexOf(" "+needle+" ")!=-1)retvalue[j++]=my_array[i];}return retvalue;}
/*menu gubbins*/
/*son of suckerfish: http://www.htmldog.com/articles/suckerfish/dropdowns/*/
sfHover= function(menuElement) {var sfEls=menuElement.getElementsByTagName("LI");
   for ( var i=0; i<sfEls.length; i++) { 
      sfEls[i].onmouseover=function() {this.className+=" sfhover";}
      sfEls[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" sfhover\\b"),"");}
   }
}
/*font size  From:http://www.dynamicdrive.com/dynamicindex9/textsizer.js */
//Specify tags. Add or remove from list: //var tgs = new Array( 'div','td','tr');
var tgs = new Array( 'body');
//Specify spectrum of different font sizes:
//var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var szs = new Array( 'x-small','small','medium','large','x-large');
//var startSz = 1;
function setFontSize(trgt,inc,mode) {
   if (!document.getElementById) return
   var d = document,cEl = null,sz = startSz,i,j,cTags;
   //alert('Start Size is '+startSz);
   cookieSize = '';
   if ( mode == 'ABS' ) {
      cookieSize = inc;
   }
   else {
      sz += inc;
      if ( sz < 0 ) sz = 0;
      if ( sz > 3 ) sz = 3;
      startSz = sz;
      cookieSize = szs[ sz ];
   } 
   // Store in cookie
   var now = new Date();
   var expires = new Date(now.getTime() + ( 1000 * 60 * 60 * 24) );

   if (!cookieSize) {
        expires = new Date(now.getTime() - 1000 * 60 * 60 * 24);
   }
   setCookie('fontSize', cookieSize, expires, '/');
   if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
   if (mode == 'relative' || mode == 'ABS') {
      cEl.style.fontSize = cookieSize;
      for ( i = 0 ; i < tgs.length ; i++ ) {
	   cTags = cEl.getElementsByTagName( tgs[ i ] );
   	   for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = cookieSize;
	}
    } else {
	cEl.style.fontSize = parseInt(cEl.style.fontSize) + inc + "em";
	for ( i = 0 ; i < tgs.length ; i++ ) {
	   cTags = cEl.getElementsByTagName( tgs[ i ] );
	   for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = inc + "em";
	}
   }
}
/*popup window           */
/* this is the old style inline javascript window. Has been superceded by superPopUp which is called automagically using the article_popup uri*/
function newPopUp (url, name, options) {
	//assume for the time being it is 3 characters 
	var myWidth = options.substr(options.indexOf("width=") + 6, 3);
	var myHeight = options.substr(options.indexOf("height=") + 7, 3);
	if (!newwindow.closed && newwindow.location){
		newwindow.location.href = url;
		newwindow.resizeTo(myWidth, myHeight);
		newwindow.focus();
	}
	else{
		newwindow=window.open(url,name,options);
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
}
/*popup window           */
function superPopUp(myWindow,myWidth,myHeight,options){myWindow.resizeTo(myWidth, myHeight);return;}
/*kev's pagination script          */
function pagination(anchor,current_page,maxpage,thisURI){var work_str='';if(current_page==0&&maxpage==1){return '';}for(i=0;i<maxpage;i++){if(i==current_page){work_str=work_str+' '+(i+1);}else{if(!thisURI){thisURI='';}work_str=work_str+' <a href="'+thisURI+'?pa='+i+'#'+anchor+'">'+(i+1)+'</a>';}}return work_str;}
/*kev's 'new' and 'updated' flags  */
function newFlag(dateStr,createdStr,startStr){
   var today=new Date();
   var one_day=1000*60*60*24;
   var dFmt='yyyy-MM-dd HH:mm';
   var pubDt=new Date(getDateFromFormat(dateStr,dFmt));  
   var crtDt=new Date(getDateFromFormat(createdStr,dFmt)); 
   var PubDysOld = Math.ceil((today.getTime()-pubDt.getTime())/(one_day)); 
   var CrtDysOld = Math.ceil((today.getTime()-crtDt.getTime())/(one_day)); 
   if(startStr){
      var strtDt = new Date(getDateFromFormat(startStr,'yyyy-MM-dd HH:mm')); 
      var SttDysOld=Math.ceil((today.getTime()-strtDt.getTime())/(one_day)); 
      if(SttDysOld<30){return '<span class="newarticle">New!</span>';}
      if(crtDt>=strtDt){
      if(PubDysOld<30&&(PubDysOld<SttDysOld)){return '<span class="newarticle">Updated!</span>';}}}if(PubDysOld<30){
      if(CrtdDysOld<30||(CrtDysOld<=PubDysOld)){return '<span class="newarticle">New!</span>';}
      else{return '<span class="newarticle">Updated!</span>';}}
      return ''; 
} 
/* date & time */
function getCalendarDate(){var months=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
  var days=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
  var now=new Date();
  var monthnumber=now.getMonth();
  var monthname=months[monthnumber];
  var monthday=now.getDate();
  var weekday=days[now.getDay()];
  var year=now.getYear();
  if(year<2000){year=year+1900;}
  var sp='&#xA0;'; 
  var dateString=weekday+sp+monthname+sp+monthday+sp+year;
  return dateString;
}
	
function getClockTime(){var now=new Date();
  var hour=now.getHours();
  var minute=now.getMinutes();
  var ap="AM";
  if(hour>11){ap="PM";}
  if(hour>12){hour=hour-12;}
  if(hour==0){hour=12;}
  if(minute<10){minute="0"+minute;}
  var timeString=hour+':'+minute+" "+ap;
  return timeString;
}
			
function doDate(dateString,dateFormat,nopadding) { 	
  var createdDate = new Date(getDateFromFormat(dateString,'yyyy-MM-dd HH:mm'));
  if(!(dateFormat)){dateFormat='d NNN y';}
    var spacer='&#xA0;';
  if(nopadding){spacer='';}
  return spacer+formatDate(createdDate,dateFormat)+spacer;
}
/* we're also going to need the tab objects we use everywhere for the lawgroup directory thingy */
//tab object
function initTab(objName) {
 this.obj = objName;
 this.aNodes = [];
};
//Node definition
function tabNode(id, name, url, title) {
 this.id = id;
 this.name = name;
 this.url = url;
 this.title = title;
};
//Add node
initTab.prototype.add = function(id, name, url, title) {
 this.aNodes[this.aNodes.length] = new tabNode(id, name, url, title);
};
//Function to dump tabs as linked list
initTab.prototype.dumpTabs = function () {
  var outputStr = "";
  for (n = 0; n < this.aNodes.length; n++) {
      outputStr = outputStr + '<li id=\"tab' + this.aNodes[n].id + 'l\"><a name=\"tab' + this.aNodes[n].id + '\" href=\"#\" id=\"tab' + this.aNodes[n].id + 'r\" onclick=\"' + this.aNodes[n].url + '\">' + this.aNodes[n].title + '</a></li>\n'
   }
  return outputStr;
}
//Function to write tabs to div
initTab.prototype.doTabs = function(myDiv) {
  outputStr = '<ul id="mb1" style="margin:0px;padding:0px;top:0px;left:0px;vertical-align:top;">' + initialTab.dumpTabs() + '</ul>';
  myDiv.innerHTML = outputStr;
  return;
}
function changePage(doc_name, page_name, tabclass) {
  var myPageIndex = -1;
  var dataPages = doc_name.getElementsByClass(tabclass);
  for (i = 0; i < dataPages.length; i++) {
      dataPages[i].style.display="none";
      if (dataPages[i].id == page_name) myPageIndex = i;
  }
 if (doc_name.getElementById("tab" + myPageIndex + "l")) {
     doc_name.getElementsByTagName("body").item(0).id = "body_tab" + myPageIndex;
 }
 doc_name.getElementById(page_name).style.display = "block";
 return false;
}
//this function allows us to dynamically add, remove, swap & check css classes for an object
function jscss(a,o,c1,c2){
  switch (a){
    case 'swap':
      o.className=!jscss('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
      break;
    case 'add':
      if(!jscss('check',o,c1)){o.className+=o.className?' '+c1:c1;}
      break;
    case 'remove':
      if(!jscss('check',o,c1)) return;
      var rep=o.className.match(' '+c1)?' '+c1:c1;
      o.className=o.className.replace(rep,'');
      break;
    case 'check':
      return new RegExp('\\b'+c1+'\\b').test(o.className)
      break;
  }
}

/***********************************************/
/* staffsearch profile switcher */
/***********************************************/
function profile_switch() {
   var d = document;
   var pb = d.getElementById('professional_biography');
   var prb = d.getElementById('personal_biography');
   var sP = d.getElementById('staffPhoto'); 
   var sPP = d.getElementById('staffPhotoPersonal');
   var sPI = d.getElementById('staff_professional_image');
   var sPRI = d.getElementById('staff_personal_image');
   var ps =  d.getElementById('profile_switcher');
   if (pb && pb.style.display != 'none') {
      if (sP && sPP) {
         sP.style.display='none';
      }
      if (sPP) {
         sPP.style.display='block';
      }
      pb.style.display = 'none';
      prb.style.display = 'block';
      if (sPI) {
         sPI.style.display = 'none';
         sPRI.style.display = 'block';
      }
      ps.value = 'View Professional Profile';
   } 
   else {
      if (sP) {
         sP.style.display='block';
      }
      if (sPP) {
         sPP.style.display='none';
      }
      pb.style.display = 'block';
      prb.style.display = 'none';
      if (sPI) {
	sPI.style.display = 'block';
        sPRI.style.display = 'none';
      }
      ps.value = 'View Personal Profile';
   }
}
/***********************************************/
/* show/hide faq function */
function skift(divId) { 
 var d = IDObject(divId);
 var Stat = d.style.display; 
 if (Stat != 'block') { 
	d.style.display = 'block'; 
 }else{ 
	d.style.display = 'none';
 }
}
function IDObject(id) {
 if (ie4) {
  return document.all[id]; 
 } else {
  return document.getElementById(id); 
 }
}
var ie4 = false;
if(document.all) {ie4=true;}
/***********************************************/
/* more show/hide faq function */
function expandFirst() {
document.getElementById(expandFirst.arguments[0]).style.display = "block";
for (var i=1; i<expandFirst.arguments.length; i++){document.getElementById(expandFirst.arguments[i]).style.display = "none";}}
function expandCollapse() {
for (var i=0; i<expandCollapse.arguments.length; i++) {var element = document.getElementById(expandCollapse.arguments[i]);element.style.display = (element.style.display == "none") ? "block" : "none";}
}

xMousePos=0;
yMousePos=0;
xMousePosMax=0;
yMousePosMax=0; 
function captureMousePosition(e) {
        if (document.layers) {
                // When the page scrolls in Netscape, the event's mouse position
                // reflects the absolute position on the screen. innerHight/Width
                // is the position from the top/left of the screen that the user is
                // looking at. pageX/YOffset is the amount that the user has
                // scrolled into the page. So the values will be in relation to
                // each other as the total offsets into the page, no matter if
                // the user has scrolled or not.
                xMousePos = e.pageX;
                yMousePos = e.pageY;
                xMousePosMax = window.innerWidth+window.pageXOffset;
                yMousePosMax = window.innerHeight+window.pageYOffset;
        } 
        else if (document.all) {
                // When the page scrolls in IE, the event's mouse position
                // reflects the position from the top/left of the screen the
                // user is looking at. scrollLeft/Top is the amount the user
                // has scrolled into the page. clientWidth/Height is the height/
                // width of the current page the user is looking at. So, to be
                // consistent with Netscape (above), add the scroll offsets to
                // both so we end up with an absolute value on the page, no
                // matter if the user has scrolled or not.
                //
                //NB. we are in standards compliant mode, so instead of using document.body, we must use document.body.parentNode, i.e. the HTML element
                if ( window.event && window.event.clientX ) {
                     if ( document.body ) {
                        xMousePos = window.event.clientX+document.body.parentNode.scrollLeft;
                        yMousePos = window.event.clientY+document.body.parentNode.scrollTop;
       
                        xMousePosMax = document.body.clientWidth+document.body.parentNode.scrollLeft;
                        yMousePosMax = document.body.clientHeight+document.body.parentNode.scrollTop;
                     }
                }
        } 
        else if (document.getElementById) {
                // Netscape 6 behaves the same as Netscape 4 in this regard
                xMousePos = e.pageX;
                yMousePos = e.pageY;
                xMousePosMax = window.innerWidth+window.pageXOffset;
                yMousePosMax = window.innerHeight+window.pageYOffset;
        }

}
//element geometry functions
function getElementLeft(myEl) {
        var parentLeft = 0;
        var total = 0;
        if (myEl.parentNode != null) {
                parentLeft = getElementLeft(myEl.parentNode);
                total = parentLeft + myEl.offsetLeft;
        } else {
                return 0;
        }
        return total;
}
function getElementTop(myEl) {
        var parentTop = 0;
        var total = 0;
        if (myEl.parentNode != null) {
                parentLeft = getElementTop(myEl.parentNode);
                total = parentTop + myEl.offsetTop;
        } else {
                return 0;
        }
        return total;
}
function myWidth() {
  var myWidth = 0
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if ( document.documentElement && document.documentElement.clientWidth ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if ( document.body && document.body.clientWidth ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}
function myHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}
function showPopUpAt(document, popup, el, x, y) {
   var s = el.style;
   document.getElementById(popup).style.left = x + "px";
   document.getElementById(popup).style.top = y + "px";
   document.getElementById(popup).style.display = 'block';
}
function showPopUpAtElement(document,popup, el, addOffSet) {
  var p = getAbsolutePos(el);
  var y_coord = p.y + el.offsetHeight;
  if ( addOffSet == 0 ) {
     y_coord = p.y;	      
  } 
  showPopUpAt(document, popup, el,p.x, y_coord);
}
function getAbsolutePos(el) {
  var r = { x: el.offsetLeft, y: el.offsetTop };
  if (el.offsetParent) {
     var tmp = getAbsolutePos(el.offsetParent);
     r.x += tmp.x;
     r.y += tmp.y;
  }
  return r;
}
function showPopOverHelp(doc_name, e, message) {
        if ( !doc_name.getElementById('popOverHelp') ) {
            return 0;
        }
	var x, y;
	if (doc_name.all) {
		x = window.event.clientX + document.body.scrollLeft;
		y = window.event.clientY + document.body.scrollTop;
	} else {
		x = e.pageX;
		y = e.pageY;
	}
	doc_name.getElementById('popOverHelp').style.left = (x + 15) + 'px';
	doc_name.getElementById('popOverHelp').style.top = (y + 15) + 'px';
	if (message != null) doc_name.getElementById('popOverHelp').innerHTML = message;
	doc_name.getElementById('popOverHelp').style.width = 'auto';
	if (myWidth() - parseInt(doc_name.getElementById('popOverHelp').style.left) < 100) {
		doc_name.getElementById('popOverHelp').style.left = (parseInt(doc_name.getElementById('popOverHelp').style.left) - 100) + 'px';
		doc_name.getElementById('popOverHelp').style.width = '50px';
	}
	if (myHeight() - parseInt(doc_name.getElementById('popOverHelp').style.top) < 100) {
		doc_name.getElementById('popOverHelp').style.top = (parseInt(doc_name.getElementById('popOverHelp').style.top) - 100) + 'px';
	}
	doc_name.getElementById('popOverHelp').style.display = 'block';
        if ( doc_name.getElementById('popupmenushadow') ) {
	doc_name.getElementById('popupmenushadow').style.left = (parseInt(doc_name.getElementById('popOverHelp').style.left) + 25) + 'px';
	doc_name.getElementById('popupmenushadow').style.top = (parseInt(doc_name.getElementById('popOverHelp').style.top) + 25) + 'px';
	if (myWidth() - parseInt(doc_name.getElementById('popupmenushadow').style.left) < 100) {
		doc_name.getElementById('popupmenushadow').style.left = (parseInt(doc_name.getElementById('popupmenushadow').style.left) - 100) + 'px';
		doc_name.getElementById('popupmenushadow').style.width = '15px';
	}
	if (myHeight() - parseInt(doc_name.getElementById('popupmenushadow').style.top) < 100) {
		doc_name.getElementById('popupmenushadow').style.top = (parseInt(doc_name.getElementById('popupmenushadow').style.top) - 100) + 'px';
	}
	doc_name.getElementById('popupmenushadow').style.display = 'block';
        }
	return true;
}
function editorPopOverHelp(doc_name, e, message) {
        captureMousePosition(e);
        doc_name.getElementById('popOverHelp').style.left = xMousePos - 10 + 'px'; 
        doc_name.getElementById('popOverHelp').style.top  = yMousePos - 10 + 'px';
        if (message != null) doc_name.getElementById('popOverHelp').innerHTML = message;
        var detect = navigator.userAgent.toLowerCase();
        if ( ( detect.indexOf('msie') + 1 ) == 0 ) {
           doc_name.getElementById('popOverHelp').style.width = 'auto';
        }
        doc_name.getElementById('popOverHelp').style.display = 'block';
        return true;
}
function hidePopOverHelp(doc_name) {
        if ( doc_name.getElementById('popOverHelp') ) {
	   doc_name.getElementById('popOverHelp').style.display = 'none';
	}		
        hideSubMenu(doc_name);
	return true;
}
function hideSubMenu(doc_name) {
        if ( doc_name.getElementById('submenu') ) {
           doc_name.getElementById('submenu').style.display = 'none';
        }         
                        return true;
}
function pageList(anchor, current_page, maxpage, thisURI, id ) {
   var work_str = '';
   if ( current_page == 0 && maxpage == 1 ) {
      return '';
   }
   var className = 'navNumber';
   for ( i=0; i<maxpage; i++) {
     className= 'navNumber';
     if ( i == current_page ) {
        className= 'navNumberOn';
     }
     if ( !thisURI ) {
        thisURI = '';
     }
     if ( anchor ) {
        work_str = work_str+' <a class="'+className+'" href="'+thisURI+'?id='+id+'&pa='+i+'#'+anchor+'">'+(i+1)+'</a>';
     }
     else {
        work_str = work_str+' <a class="'+className+'" href="'+thisURI+'?id='+id+'&pa='+i+'">'+(i+1)+'</a>';
     }
   }
   return work_str;
}
function e_de_code(e, v, q) {
     if ( q ) { 
        q = '?'+q;
     }
     else {
        q = '';
     }
     if ( e && e.length && v && v.length) {
        var stub = "\u006d\u0061\u0069\u006c\u0074\u006f\u003a";
        document.write("<a href="+'"'+stub+e+q+'"'+">"+v+"</a>");
     }
     else if ( e && e.length ) {
        return e;
     }
}
function leftAngletag() {
   var tag = "\u003c";
   return tag;
}
function rightAngletag() {
   var tag = "\u003e";
   return tag;  
}
function u_de_code(l, u, v) {
     if ( !l ) {
        l = '';
     } 
     if ( u && u.length ) {
        document.write("<a href="+'"'+l+u+'">'+v+"</a>");
     }
}
function elink(name,domain,phrase,asText) {
   var args = domain.split('/') // parse out domain parts
   var tmp = args.join(".");
   if ( !asText ) {
      document.write('<a href="mailto:'+name+'@'+tmp+'?subject=WWW-Email:">'+phrase+'</a>');
   }
   else {
      return name+'@'+tmp;
   }
}
function fos(fn,ln,em,oid,imgsrc,phrase){
   var d=document;
   var aref=d.createElement("a");
   aref.style.border="none";
   var name=html_entity_decode(fn+' '+ln)
   var l = 'mailto:'+name+leftAngletag()+e_de_code(em)+rightAngletag()+'?subject=WWW-Email:';
   aref.setAttribute("href",l);
   if ( imgsrc && imgsrc !='') {
      var img=d.createElement("img");
      img.style.border="none";
      img.src=imgsrc;
      img.alt=e_de_code(em);
      img.title=img.alt;
      aref.appendChild(img);
   }
   else {
     if (phrase ) {
        if(phrase=='default'){phrase='send an email'}
        text1=d.createTextNode(phrase);
     }
     else {
        text1=d.createTextNode(name);
     }
     aref.appendChild(text1);
   }
   d.getElementById(oid).appendChild(aref);
}
function html_entity_decode(str) {
  var ta=document.createElement("textarea");
  ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
  return ta.value;
}
function ord(string){return (string+'').charCodeAt(0);}
function emailCheck (emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
/* Finally, let's start trying to figure out if the supplied address is
   valid. */
/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	//alert("Not a recognised form of email address.")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]
// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    //alert("Not a recognised form of email address.")
    return false
}
/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        //alert("Not a recognised form of email address.")
		return false
	    }
    }
    return true
}
// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	//alert("Not a recognised form of email address.")
    return false
}
/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */
/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   //alert("Not a recognised form of email address.")
   return false
}
// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="Not a recognised form of email address."
   //alert(errStr)
   return false
}
// If we've gotten this far, everything's valid!
return true;
}
clearCookie = function() {
	var now = new Date();
	var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
	this.setCookie('co'+this.obj, 'cookieValue', yesterday);
	this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
};
// [Cookie] Sets value in a cookie
setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
	document.cookie =
		escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; expires=' + expires.toGMTString() : '')
		+ (path ? '; path=' + path : '')
		+ (domain ? '; domain=' + domain : '')
		+ (secure ? '; secure' : '');

};
// [Cookie] Gets a value from a cookie
getCookie = function(cookieName) {
	var cookieValue = '';

	var posName = document.cookie.indexOf(escape(cookieName) + '=');
	if (posName != -1) {
		var posValue = posName + (escape(cookieName) + '=').length;
		var endPos = document.cookie.indexOf(';', posValue);
		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
		else cookieValue = unescape(document.cookie.substring(posValue));

	}

	return (cookieValue);
};
function highlight(thisObject,type) {
   var thisClassName = 'formInputMissing';
   if ( type == 'text' ) { 
      thisClassName = 'formInputMissingTxt';
   }	 
   if ( thisObject.className ) {	 
      var wrkClassName = thisObject.className;
     if ( wrkClassName.indexOf(thisClassName) == -1) {
         thisObject.className = thisObject.className+' '+thisClassName;
      }
   }   
   else {
      thisObject.className = thisClassName;
   }
}
function unhighlight(thisObject,type) {
   var myRegExp = /formInputMissing/;
   if ( type == 'text' ) { 
      myRegExp = /formInputMissingTxt/;
   }	 
    if ( thisObject.className ) {	 
      var wrkClassName = thisObject.className;
      wrkClassName = wrkClassName.replace(myRegExp,'');
      thisObject.className = wrkClassName;
   }
}
function highlightLabel(thisObject,type) {
   var thisClassName = 'formLabelError';
   if ( document.getElementById(thisObject.id+'Label') && document.getElementById(thisObject.id+'Label').className ) {
      var wrkClassName = document.getElementById(thisObject.id+'Label').className;
     if ( wrkClassName.indexOf(thisClassName) == -1) {
         document.getElementById(thisObject.id+'Label').className = thisObject.className+' '+thisClassName;
      }
   }
   else {
      if (document.getElementById(thisObject.id+'Label') ){document.getElementById(thisObject.id+'Label').className = thisClassName;}
   }
}
function unhighlightLabel(thisObject,type) {
   var myRegExp = /formLabelError/;
    if ( document.getElementById(thisObject.id+'Label') ) {
      var wrkClassName = document.getElementById(thisObject.id+'Label').className;
      wrkClassName = wrkClassName.replace(myRegExp,'');
      document.getElementById(thisObject.id+'Label').className = wrkClassName;
   }
}
// Generic form validation function.
// Expects to be called with an ARRAY of field objects to be validated
// We then check they have data, based upon the input control (text, radio, checkbox )
// All errors are hightlighted by;
// 1) The class name of the control/parentNode is modified to have an additional class added 
// 2) An error message is formatted. We look for a div with the same id as the form+'errorBox'
//    If we find no div we just pop up an alert window 
function validateForm(theForm,requiredFields,debug,noSubmit,modifier) {
    if ( !theForm ) {
       theForm = document.getElementById('thisForm');
       if ( !theForm ) {
          alert('Form Not Specified in call to validateForm');
          return 0;
       }
    }
    var fieldCount = requiredFields.length;
    if ( !fieldCount ) {
       return 1;
    }   
    if ( document.getElementById(theForm.id+'Errors') ) {
       document.getElementById(theForm.id+'Errors').style.display='none';
    }
    var indexCount = 0;
    var thisField;
    var errorFields = new Array();
    var errorMessages = new Array();
    for (indexCount = 0; indexCount < fieldCount; indexCount++) {
    	// Check the control id actually exists, if not we fail
	thisField = requiredFields[indexCount];
        var thisType = thisField.tagName;
	unhighlight(thisField);
        unhighlightLabel(thisField, thisType);
        if ( !thisType ) {
           thisType = '[object NodeList]';
        }

	switch ( thisType ) {
	   case 'TEXTAREA': {
             if (  thisField.value.length <= 0 ) {
	     	errorFields[errorFields.length] = thisField.id;
		highlight(thisField);
                
		if ( document.getElementById(thisField.id+'Label') ) {
		   errorMessages[errorMessages.length] = document.getElementById(thisField.id+'Label').innerHTML+' is a required field';
                   highlightLabel(thisField, thisType);
		}
		else {
		     errorMessages[errorMessages.length]  = thisField.id+' is a required field';
		}		
              }
	      continue;
           };	
	   case 'INPUT': {

	     // Is this an email field??

             if ( thisField.type && thisField.type == 'checkbox' ) {
	        unhighlight(thisField.parentNode);
	        if (  !thisField.checked ) {
	           errorFields[errorFields.length] = thisField;
		   highlight(thisField.parentNode);
		   if ( document.getElementById(thisField.id+'Label') ) {
                      highlightLabel(thisField, thisType);
		      errorMessages[errorMessages.length] = 'Please check '+document.getElementById(thisField.id+'Label').innerHTML;
		   }
		   else {
                      // Hack
		      // Get the parent Nodes innerHTML but strip out the checkbox
		      var thisHTML = thisField.parentNode.innerHTML;
		      var parts = thisHTML.split('<input ');
		      errorMessages[errorMessages.length] = 'Please check '+parts[0]; 
		   }
	        };	
		continue;	     	
	     
	     }

             if (  thisField.value.length <= 0 ) {
	     	errorFields[errorFields.length] = thisField.id;
		highlight(thisField);
		if ( document.getElementById(thisField.id+'Label') ) {
                   highlightLabel(thisField, thisType);
		   errorMessages[errorMessages.length] = document.getElementById(thisField.id+'Label').innerHTML+' is a required field';
		}
		else {
		     errorMessages[errorMessages.length]  = thisField.id+' is a required field';
		}		
              }
	      continue;
	     };	
              
	   case 'checkbox' : {
             if (  thisField.selectedIndex == 0 ) {
	     	errorFields[errorFields.length] = thisField;
		highlight(thisField);
		if ( document.getElementById(thisField.id+'Label') ) {
                   highlightLabel(thisField, thisType);
		   errorMessages[errorMessages.length] = document.getElementById(thisField.id+'Label').innerHTML;
		}
	     };	
	     continue;
             }
           case 'SELECT' : {
             if (  thisField.selectedIndex == -1 || thisField.options[thisField.selectedIndex].value=='') {
		highlight(thisField);
	     	errorFields[errorFields.length] = thisField;
		if ( document.getElementById(thisField.id+'Label') ) {
                   highlightLabel(thisField, thisType);
		   errorMessages[errorMessages.length] = document.getElementById(thisField.id+'Label').innerHTML+' is a required field';
		}
		else {
		   errorMessages[errorMessages.length] = thisField.id+' is a required field';
                }
	     };	
	     continue;
	     }
	       	    

	   case '[object NodeList]' : {
	      	     var radioItems = thisField.length;
		     if ( radioItems ) {
		     	var is_valid_rb=0;
			var workStr = '';
                        var separator = '/';
                    	unhighlight(thisField[0].parentNode);
                        for (i=0; i<radioItems; i++ ) {
        	 	   if ( thisField[i].checked ) {	
                             is_valid_rb = 1;
          		     continue;
                           }
			   if ( i > 0 ) {
			      workStr = workStr+'/';
                           }
    	                   workStr = workStr+thisField[i].value;

	                };
	                if ( !is_valid_rb ) {
                          highlight(thisField[0].parentNode);
                          errorFields[errorFields.length] = thisField;
                          if (modifier='survey') {
                             if ( document.getElementById(thisField.item(0).id)) {
                                var qStr = document.getElementById(thisField.item(0).id+'Label').innerHTML;
                                if ( qStr.length) {
                                   errorMessages[errorMessages.length] = qStr;
                                }
                             }
                             else if ( document.getElementById(thisField[0].id+'Label') ) {
                                var qStr = document.getElementById(thisField[0].id+'Label').innerHTML;
                                var qStrArray = qStr.split('.');
                                if ( qStrArray[0].length) {
                                   errorMessages[errorMessages.length] = 'Choose an option for question '+qStrArray[0];
                                }
                                else {errorMessages[errorMessages.length] = 'Choose an option for Question '+qStr};
                                document.getElementById(thisField[0].id+'Label').className+=' SurveyError';
                             }
                          }
                          else {
                             errorMessages[errorMessages.length] = 'Choose an option from the following '+workStr;
                          }
	                }
                    }
		    continue;
             }


        }

    }


    // We may also have some email fields on the form which are not mandatory
    // We therefore get an ARRAY of objects
    // and if we have not already validated them we do so here
    // className='emailAddressField'
    var myEmailFields = getFormElementsByClass(document,"emailAddressField",'input');
    if ( myEmailFields.length ) {
       var i=0;
       for (i = 0; i < myEmailFields.length; i++) {
    	// Check the control id actually exists, if not we fail
	thisField = myEmailFields[i];
        unhighlight(thisField);
        if ( thisField.value && !emailCheck( thisField.value ) ) {
	   errorFields[errorFields.length] = thisField.id;
	   highlight(thisField);
	   if ( document.getElementById(thisField.id+'Label') ) {
              highlightLabel(thisField, thisType);
	      errorMessages[errorMessages.length] = document.getElementById(thisField.id+'Label').innerHTML+' is not a valid email address';
	   }	   
	   else {
	      errorMessages[errorMessages.length]  = thisField.id+' is not a valid email address';
	   }		
	}
	}
     }


    if ( errorFields.length > 0 ) {
      var workStr = '';
      var separator = ""; 
      var separator1 = "\n"; 
      if ( document.getElementById(theForm.id+'Errors') ) {
         separator = '<li>';
         separator1 = '</li>';
      }
      for ( i=0; i<errorFields.length;i++ ) {
	  workStr += separator+errorMessages[i]+separator1;
      }
      if ( document.getElementById(theForm.id+'Errors') ) {
         document.getElementById(theForm.id+'Errors').innerHTML = '<br/><br/>Please check and fix the following problems with the information entered.</br><ul>'+workStr+'</ul>';
	 document.getElementById(theForm.id+'Errors').style.display='block';
      }   
      else {
         alert(workStr);
      }
      document.location="#thisFormErrors";
      return 0;
    }   

    if ( !noSubmit ) {
       theForm.submit();
    }	
    return 1;
}

function getFormElementsByClass(d,needle, tag) {
  if ( !tag ) { 
      tag = '*';
  } 

  var my_array = d.getElementsByTagName(tag);
  var retvalue = new Array();
  var i = 0;
  var j = 0;

  for (i = 0, j= 0; i < my_array.length; i++) {
    var c = " " + my_array[i].className + " ";
    if (c.indexOf(" " + needle + " ") != -1)
      retvalue[j++] = my_array[i];
  }
  return retvalue;
}

function add_tracking() {
   var qs = new Querystring();
   var d = document;
   var thisID = qs.get("qid");
   if ( thisID ) {
       var myLinks = d.getElementsByTagName("A");
       var id = '';
       for (i = 0, j= 0; i < myLinks.length; i++) {
        if ( myLinks[i].href.indexOf("/cms/billpay/") > 0 ) {
           if ( myLinks[i].href.substring(1,myLinks[i].href.length) == '/' ) {
               myLinks[i].href += '/';
           }
           myLinks[i].href += thisID;
            
        }
    }
   }
}

function print_quote() {
    var qs = new Querystring();
    var thisID = qs.get("print");
    if ( !thisID ) {
       alert('There was an error printing this page. Quote Reference Number is missing.');
       return 0;
    }
    var thisEmail = qs.get("email");
    if ( !thisEmail ) {
       alert('There was an error printing this page. Email address does not match.');
       return 0;
    }	  
    window.open('/cms/calculator/?print='+thisID+'&email='+thisEmail,'Print', 'top=160, left=20, width=540, height=550, scrollbars=no, resizable=yes');
}


function Querystring(qs) { // optionally pass a querystring to parse
   this.params = new Object()
   this.get=Querystring_get
   if (qs == null) qs=location.search.substring(1,location.search.length)
   if (qs.length == 0) return
// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
   qs = qs.replace(/\+/g, ' ')
   var args = qs.split('&') // parse out name/value pairs separated via &
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])
		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}
function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	var value=this.params[key]
	if (value==null) value=default_;
	return value
}
function popup_window(hrefObj,askUser) {
   if ( !hrefObj ) return;
   if ( askUser ) {
      var confirmed = confirm('The link you have followed belongs to an external website.'+"\n"+' and will open in a new window.'+"\n"+'We are not responsible for the content of external internet sites.'+"\n"+'Select OK to continue or Cancel to stop.'+"\n"); 
      if ( !confirmed ) return false;
   } 
   window.open(hrefObj.href,'_blank', 'top=160, left=20, width=700, height=550, scrollbars=yes, resizable=yes');   
   return false;
}
var startSz=1;
function initFontSize(){
 if (!document.getElementById) return;
 var trgt = 'body';
 var d = document,cEl = null,sz = startSz,i,j,cTags;
 if ( !( cEl = d.getElementById( trgt ) ) ) {cEl = d.getElementsByTagName( trgt )[ 0 ]};
 //cEl.style.display='none';
 var size=getCookie("fontSize");
 if ( size ) {
   //alert(size);
   switch ( size ) {
      case 'x-small': {startSz=0; break; };
      case 'small': {startSz=1; break;};
      case 'medium': {startSz=2;break;};
      case 'large': {startSz=3;break;};
   };

   var tgs = new Array( 'body');
   cEl.style.fontSize = size;
   for ( i = 0 ; i < tgs.length ; i++ ) {
      cTags = cEl.getElementsByTagName( tgs[ i ] );
      for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = size;
   }
 }
 //cEl.style.display='block';
}

if (window.attachEvent) { //attach load event
window.attachEvent("onload",initFontSize);}
else{window.addEventListener("load",initFontSize , true)}

// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
// ===================================================================

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x){return(x<0||x>9?"":"0")+x}
function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;}
function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0 || d2==0){return -1;}else if(d1 > d2){return 1;}return 0;}
function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length < 4){y=""+(y-0+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];value["NNN"]=MONTH_NAMES[M+11];value["d"]=d;value["dd"]=LZ(d);value["E"]=DAY_NAMES[E+7];value["EE"]=DAY_NAMES[E];value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;}else{value["K"]=H;}value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H > 11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(value[token] != null){result=result + value[token];}else{result=result + token;}}return result;}
function _isInteger(val){var digits="1234567890";for(var i=0;i < val.length;i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}return true;}
function _getInt(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length < minlength){return null;}if(_isInteger(token)){return token;}}return null;}
function getDateFromFormat(val,format){val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=1;var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm="";while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(token=="yyyy" || token=="yy" || token=="y"){if(token=="yyyy"){x=4;y=4;}if(token=="yy"){x=2;y=2;}if(token=="y"){x=2;y=4;}year=_getInt(val,i_val,x,y);if(year==null){return 0;}i_val += year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM"||token=="NNN"){month=0;for(var i=0;i<MONTH_NAMES.length;i++){var month_name=MONTH_NAMES[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){if(token=="MMM"||(token=="NNN"&&i>11)){month=i+1;if(month>12){month -= 12;}i_val += month_name.length;break;}}}if((month < 1)||(month>12)){return 0;}}else if(token=="EE"||token=="E"){for(var i=0;i<DAY_NAMES.length;i++){var day_name=DAY_NAMES[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=="MM"||token=="M"){month=_getInt(val,i_val,token.length,2);if(month==null||(month<1)||(month>12)){return 0;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return 0;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}i_val+=hh.length;}else if(token=="kk"||token=="k"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=_getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return 0;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return 0;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}else{i_val+=token.length;}}}if(i_val != val.length){return 0;}if(month==2){if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) ){if(date > 29){return 0;}}else{if(date > 28){return 0;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date > 30){return 0;}}if(hh<12 && ampm=="PM"){hh=hh-0+12;}else if(hh>11 && ampm=="AM"){hh-=12;}var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}
function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');var d=null;for(var i=0;i<checkList.length;i++){var l=window[checkList[i]];for(var j=0;j<l.length;j++){d=getDateFromFormat(val,l[j]);if(d!=0){return new Date(d);}}}return null;}

/*
 * DateFormat.js
 * Formats a Date object into a human-readable string
 *
 * Copyright (C) 2001 David A. Lindquist (http://www.gazingus.org)
 */

Date.MONTHS = [
  'January', 'February', 'March', 'April', 'May', 'June', 'July',
  'August', 'September', 'October', 'November', 'December'
];

Date.DAYS = [
  'Sunday', 'Monday', 'Tuesday', 'Wednesday',
  'Thursday', 'Friday', 'Saturday'
];

Date.SUFFIXES = [
  'st','nd','rd','th','th','th','th','th','th','th',
  'th','th','th','th','th','th','th','th','th','th',
  'st','nd','rd','th','th','th','th','th','th','th',
  'st'
];

Date.prototype.format = function( mask ) {
  var formatted     = ( mask != null ) ? mask : 'DD-MMM-YY';
  var letters       = 'DMYHdhmst'.split( '' );
  var temp          = new Array();
  var count         = 0;
  var regexA;
  var regexB        = /\[(\d+)\]/;

  var day           = this.getDay();
  var date          = this.getDate();
  var month         = this.getMonth();
  var year          = this.getFullYear().toString();
  var hours         = this.getHours();
  var minutes       = this.getMinutes();
  var seconds       = this.getSeconds();

  var formats       = new Object();
  formats[ 'D' ]    = date;
  formats[ 'd' ]    = date + Date.SUFFIXES[ date - 1 ];
  formats[ 'DD' ]   = ( date < 10 ) ? '0' + date : date;
  formats[ 'DDD' ]  = Date.DAYS[ day ].substring( 0, 3 );
  formats[ 'DDDD' ] = Date.DAYS[ day ];
  formats[ 'M' ]    = month + 1;
  formats[ 'MM' ]   = ( month + 1 < 10 ) ? '0' + ( month + 1 ) : month + 1;
  formats[ 'MMM' ]  = Date.MONTHS[ month ].substring( 0, 3 );
  formats[ 'MMMM' ] = Date.MONTHS[ month ];
  formats[ 'Y' ]    = ( year.charAt( 2 ) == '0' ) ? year.charAt( 3 ) : year.substring( 2, 4 );
  formats[ 'YY' ]   = year.substring( 2, 4 );
  formats[ 'YYYY' ] = year;
  formats[ 'H' ]    = hours;
  formats[ 'HH' ]   = ( hours < 10 ) ? '0' + hours : hours;  
  formats[ 'h' ]    = ( hours > 12 || hours == 0 ) ? Math.abs( hours - 12 ) : hours;
  formats[ 'hh' ]   = ( formats[ 'h' ] < 10 ) ? '0' + formats[ 'h' ] : formats[ 'h' ];
  formats[ 'm' ]    = minutes;
  formats[ 'mm' ]   = ( minutes < 10 ) ? '0' + minutes : minutes;
  formats[ 's' ]    = seconds;
  formats[ 'ss' ]   = ( seconds < 10 ) ? '0' + seconds : seconds;
  formats[ 't' ]    = ( hours < 12 ) ?  'A' : 'P';
  formats[ 'tt' ]   = ( hours < 12 ) ?  'AM' : 'PM';

  for ( var i = 0; i < letters.length; i++ ) {
    regexA = new RegExp( '(' + letters[ i ] + '+)' );
    while ( regexA.test( formatted ) ) {
      temp[ count ] = RegExp.$1;
      formatted = formatted.replace( RegExp.$1, '[' + count + ']' );
      count++;
    }
  }

  while ( regexB.test( formatted ) ) {
    formatted = formatted.replace( regexB, formats[ temp[ RegExp.$1 ] ] );
  }

  return formatted;
}

/*---------------------------------*/
/*date formatting  */
/*---------------------------------*/

	  function doDate(dateString,dateFormat,nopadding) { 
	  var createdDate = new Date(getDateFromFormat(dateString,'yyyy-MM-dd HH:mm'));
        if ( !(dateFormat) ) {
           dateFormat = 'd NNN y';
        }

	if (nopadding) {
        	return formatDate(createdDate,dateFormat);
	} else {
		return '&#xA0;'+formatDate(createdDate,dateFormat)+'&#xA0;';
	}
    }

/*Version $Id: domextension.js 1568 2006-01-09 18:33:41Z ray $*/

document.getElementsByClass = function (needle)
{
  var         my_array = document.getElementsByTagName("*");
  var         retvalue = new Array();
  var        i = 0;
  var        j = 0;

  for (i = 0, j= 0; i < my_array.length; i++)
  {
    var c = " " + my_array[i].className + " ";
    if (c.indexOf(" " + needle + " ") != -1)
      retvalue[j++] = my_array[i];
  }
  return retvalue;
}

function isChild(parentObj, testObj) {
	var i = 0;
	
	for (i = 0; i < parentObj.childNodes.length; i++) {
		if ((parentObj.childNodes[i] == testObj) || (isChild(parentObj.childNodes[i], testObj))) {
			return true;
		}
	}	
	return false;
}

function isParent(childObj, testObj) {
	
	if (testObj == childObj.parentNode) {
		return true;
	} else {
		if (childObj.parentNode.tagName == 'BODY') {
			return false;
		}
		return isParent(childObj.parentNode, testObj);
	}	
	return false;
}

function isSibling(first, second) {
	var i = 0;
	var parent = null;
	
	if (first == null || second == null) {
		return false;
	} else if (first.tagName == 'BODY' || second.tagName == 'BODY') {
		return false;
	} else {
		parent = first.parentNode;	
		for (i = 0; i < parent.childNodes.length; i++) {
			if (parent.childNodes[i] == second) return true;
		}		
		return false;
	}
}

 function isString(a)
 {
     return typeof a == 'string';
 }

 function isObject(a)
 {
     return (typeof a == 'object' && !!a) || isFunction(a);
 }

 function isNumber(a)
 {
      return typeof a == 'number' && isFinite(a);
 }

 function isNull(a)
 {
      return typeof a == 'object' && !a;
 }

/**********************************************/
/* nicked from: http://phrogz.net/JS/AttachEvent_js.txt*/
/**********************************************/

function AttachEvent(obj,evt,fnc,useCapture){
	if (!useCapture) useCapture=false;
	if (obj.addEventListener){
		obj.addEventListener(evt,fnc,useCapture);
		return true;
	} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
	else{
		MyAttachEvent(obj,evt,fnc);
		obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
	}
} 

//The following are for browsers like NS4 or IE5Mac which don't support either
//attachEvent or addEventListener
function MyAttachEvent(obj,evt,fnc){
	if (!obj.myEvents) obj.myEvents={};
	if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
	var evts = obj.myEvents[evt];
	evts[evts.length]=fnc;
}
function MyFireEvent(obj,evt){
	if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
	var evts = obj.myEvents[evt];
	for (var i=0,len=evts.length;i<len;i++) evts[i]();
}

	var slideDownInitHeight = new Array();
	var slidedown_direction = new Array();

        var activefaqID = '';
	var slidedownActive = false;
	var contentHeight = false;
	var slidedownSpeed = 40; 	// Higher value = faster script
	var slidedownTimer = 1;	// Lower value = faster script
	function slidedown_showHide(boxId,faqID) {

                if ( document.getElementById('footer') ) {
                  if (navigator.userAgent.indexOf('MSIE') != -1) {
                     document.getElementById('footer').style.zIndex = -1;
                  }
                } 

		if(!slidedown_direction[boxId])slidedown_direction[boxId] = 1;
		if(!slideDownInitHeight[boxId])slideDownInitHeight[boxId] = 0;
		
		if(slideDownInitHeight[boxId]==0)slidedown_direction[boxId]=slidedownSpeed; else slidedown_direction[boxId] = slidedownSpeed*-1;
                if ( activefaqID && document.getElementById(activefaqID) ) {
   	      	   document.getElementById(activefaqID).className = 'faqLink'; 
                }

		var visibleDivs = getElementsByClass(document,"faq_contentBox",'div');
		for(var no=0;no<visibleDivs.length;no++){
		   if ( visibleDivs[no].style.visibility == 'visible' &&
                      slidedownContentBox.id != boxId) {
		      visibleDivs[no].style.visibility="hidden";
		      slidedown_direction[visibleDivs[no].id] = 0;
		      slideDownInitHeight[visibleDivs[no].id] = 0;
                   }
		}
	
		slidedownContentBox = document.getElementById(boxId);
		var subDivs = slidedownContentBox.getElementsByTagName('DIV');
		for(var no=0;no<subDivs.length;no++){
			if(subDivs[no].className=='faq_content')slidedownContent = subDivs[no];	
		}

		contentHeight = slidedownContent.offsetHeight;
	
	        if ( document.getElementById(faqID) ) { 
                  activefaqID = faqID;
	       	  document.getElementById(faqID).className = 'faqLinkActive'; 
                }

		slidedownContentBox.style.visibility='visible';
		slidedownActive = true;
		slidedown_showHide_start(slidedownContentBox,slidedownContent);
	}

	function slidedown_showHide_start(slidedownContentBox,slidedownContent)	{

		if(!slidedownActive)return;
		slideDownInitHeight[slidedownContentBox.id] = slideDownInitHeight[slidedownContentBox.id]/1 + slidedown_direction[slidedownContentBox.id];
		if(slideDownInitHeight[slidedownContentBox.id] <= 0){
			slidedownActive = false;	
			slidedownContentBox.style.visibility='hidden';
			slideDownInitHeight[slidedownContentBox.id] = 0;
		}
		if(slideDownInitHeight[slidedownContentBox.id]>contentHeight){
			slidedownActive = false;	
		}
		slidedownContentBox.style.height = slideDownInitHeight[slidedownContentBox.id] + 'px';
		slidedownContent.style.top = slideDownInitHeight[slidedownContentBox.id] - contentHeight + 'px';

		setTimeout('slidedown_showHide_start(document.getElementById("' + slidedownContentBox.id + '"),document.getElementById("' + slidedownContent.id + '"))',slidedownTimer);	// Choose a lower value than 10 to make the script move faster
	}
	
	function setSlideDownSpeed(newSpeed) {
		slidedownSpeed = newSpeed;
		
	}

function getElementsByClass(d,needle, tag) {
  if ( !tag ) {
      tag = '*';
  }

  var my_array = d.getElementsByTagName('div');
  var retvalue = new Array();
  var i = 0;
  var j = 0;

  for (i = 0, j= 0; i < my_array.length; i++) {
    var c = " " + my_array[i].className + " ";
    if (c.indexOf(" " + needle + " ") != -1)
      retvalue[j++] = my_array[i];
  }
  return retvalue;
}





/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */

;(function($){
	$.fn.superfish = function(op){

		var sf = $.fn.superfish,
			c = sf.c,
			$arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),
			over = function(){
				var $$ = $(this), menu = getMenu($$);
				clearTimeout(menu.sfTimer);
				$$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function(){
				var $$ = $(this), menu = getMenu($$), o = sf.op;
				clearTimeout(menu.sfTimer);
				menu.sfTimer=setTimeout(function(){
					o.retainPath=($.inArray($$[0],o.$path)>-1);
					$$.hideSuperfishUl();
					if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
				},o.delay);	
			},
			getMenu = function($menu){
				var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
				sf.op = sf.o[menu.serial];
				return menu;
			},
			addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
			
		return this.each(function() {
			var s = this.serial = sf.o.length;
			var o = $.extend({},sf.defaults,op);
			o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
				$(this).addClass([o.hoverClass,c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
			});
			sf.o[s] = sf.op = o;
			
			$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
				if (o.autoArrows) addArrow( $('>a:first-child',this) );
			})
			.not('.'+c.bcClass)
				.hideSuperfishUl();
			
			var $a = $('a',this);
			$a.each(function(i){
				var $li = $a.eq(i).parents('li');
				$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
			});
			o.onInit.call(this);
			
		}).each(function() {
			menuClasses = [c.menuClass];
			if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
			$(this).addClass(menuClasses.join(' '));
		});
	};

	var sf = $.fn.superfish;
	sf.o = [];
	sf.op = {};
	sf.IE7fix = function(){
		var o = sf.op;
		if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
			this.toggleClass(sf.c.shadowClass+'-off');
		};
	sf.c = {
		bcClass     : 'sf-breadcrumb',
		menuClass   : 'sf-js-enabled',
		anchorClass : 'sf-with-ul',
		arrowClass  : 'sf-sub-indicator',
		shadowClass : 'sf-shadow'
	};
	sf.defaults = {
		hoverClass	: 'sfHover',
		pathClass	: 'overideThisToUse',
		pathLevels	: 1,
		delay		: 400,
		animation	: {opacity:'show'},
		speed		: 'normal',
		autoArrows	: true,
		dropShadows : false,
		disableHI	: false,		// true disables hoverIntent detection
		onInit		: function(){}, // callback functions
		onBeforeShow: function(){},
		onShow		: function(){},
		onHide		: function(){}
	};
	$.fn.extend({
		hideSuperfishUl : function(){
			var o = sf.op,
				not = (o.retainPath===true) ? o.$path : '';
			o.retainPath = false;
			var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility','hidden');
			o.onHide.call($ul);
			return this;
		},
		showSuperfishUl : function(){
			var o = sf.op,
				sh = sf.c.shadowClass+'-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility','visible');
			sf.IE7fix.call($ul);
			o.onBeforeShow.call($ul);
			$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
			return this;
		}
	});

})(jQuery);

(function($){
	/* hoverIntent by Brian Cherne */
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
	
})(jQuery);

/*
 * Supersubs v0.2b - jQuery plugin
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 *
 * This plugin automatically adjusts submenu widths of suckerfish-style menus to that of
 * their longest list item children. If you use this, please expect bugs and report them
 * to the jQuery Google Group with the word 'Superfish' in the subject line.
 *
 */

;(function($){ // $ will refer to jQuery within this closure

	$.fn.supersubs = function(options){
		var opts = $.extend({}, $.fn.supersubs.defaults, options);
		// return original object to support chaining
		return this.each(function() {
			// cache selections
			var $$ = $(this);
			// support metadata
			var o = $.meta ? $.extend({}, opts, $$.data()) : opts;
			// get the font size of menu.
			// .css('fontSize') returns various results cross-browser, so measure an em dash instead
			var fontsize = $('<li id="menu-fontsize">&#8212;</li>').css({
				'padding' : 0,
				'position' : 'absolute',
				'top' : '-999em',
				'width' : 'auto'
			}).appendTo($$).width(); //clientWidth is faster, but was incorrect here
			// remove em dash
			$('#menu-fontsize').remove();
			// cache all ul elements
			$ULs = $$.find('ul');
			// loop through each ul in menu
			$ULs.each(function(i) {	
				// cache this ul
				var $ul = $ULs.eq(i);
				// get all (li) children of this ul
				var $LIs = $ul.children();
				// get all anchor grand-children
				var $As = $LIs.children('a');
				// force content to one line and save current float property
				var liFloat = $LIs.css('white-space','nowrap').css('float');
				// remove width restrictions and floats so elements remain vertically stacked
				var emWidth = $ul.add($LIs).add($As).css({
					'float' : 'none',
					'width'	: 'auto'
				})
				// this ul will now be shrink-wrapped to longest li due to position:absolute
				// so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer
				.end().end()[0].clientWidth / fontsize;
				// add more width to ensure lines don't turn over at certain sizes in various browsers
				emWidth += o.extraWidth;
				// restrict to at least minWidth and at most maxWidth
				if (emWidth > o.maxWidth)		{ emWidth = o.maxWidth; }
				else if (emWidth < o.minWidth)	{ emWidth = o.minWidth; }
				emWidth += 'em';
				// set ul to width in ems
				$ul.css('width',emWidth);
				// restore li floats to avoid IE bugs
				// set li width to full width of this ul
				// revert white-space to normal
				$LIs.css({
					'float' : liFloat,
					'width' : '100%',
					'white-space' : 'normal'
				})
				// update offset position of descendant ul to reflect new width of parent
				.each(function(){
					var $childUl = $('>ul',this);
					var offsetDirection = $childUl.css('left')!==undefined ? 'left' : 'right';
					$childUl.css(offsetDirection,emWidth);
				});
			});
			
		});
	};
	// expose defaults
	$.fn.supersubs.defaults = {
		minWidth		: 9,		// requires em unit.
		maxWidth		: 25,		// requires em unit.
		extraWidth		: 0			// extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values
	};
	
})(jQuery); // plugin code ends





    $(document).ready(function() {
        $('ul.udm').superfish({
            delay:       1000,                            // one second delay on mouseout
            animation:   {opacity:'show'},  // fade-in and slide-down animation
            speed:       'normal',                          // faster animation speed
            autoArrows:  true,                           // disable generation of arrow mark-up
            dropShadows: true                            // disable drop shadows
        });

        $('ul.leftudm').superfish({
            delay:       1000,                            // one second delay on mouseout
            animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
            speed:       'normal',                          // faster animation speed
            autoArrows:  false,                           // disable generation of arrow mark-up
            dropShadows: false                            // disable drop shadows
        });
		
		var getTitle = $('#container-leftudm .title h2 a').html(); // Get the name of the page
		
		if (getTitle == "Individuals" || getTitle == "Businesses" || getTitle == "Sectors") {
			$('#container-leftudm .title').remove();
		} // If the name is any of these, remove the title.

		$('body#home .mwb_home_news .link a').html("read more news"); // Change the homepage news anchor link text.
		
		// Staff profile page
				
		$('.DDI').insertBefore('.office');
		
		$('.DDI').prepend("DD: ");
		
		// Meet the team
		$(".meetteam_main ").wrap('<div id="meet_team_holder"></div>');
		
		//Lead profile 
		$('div.centrenews .link a').html("Read More News");
		$('.single_document .icon').remove();
		$('.single_document .date').remove();
		
		//Dropdowns
		
		$('li#udm_menu_item_blankmm a').html('<img src="/images/mdot.gif" alt="dot"/>').css({"cursor" : "default"});
				
		
		// Events 
		
		eventTitle = $('.defaultTheme:nth-child(2) h1').html();
		
		if (eventTitle == "Event booking form") {
			$('.defaultTheme:nth-child(1)').remove();
		};

		$('.bookingformsubmit input.button').val("");
		
    });


	
	// Accordion //
	
	
var TINY={};function T$(i){return document.getElementById(i)}function T$$(e,p){return p.getElementsByTagName(e)}TINY.accordion=function(){function slider(n){this.n=n;this.a=[]}slider.prototype.init=function(t,e,m,o,k){var a=T$(t),i=s=0,n=a.childNodes,l=n.length;this.s=k||0;this.m=m||0;for(i;i<l;i++){var v=n[i];if(v.nodeType!=3){this.a[s]={};this.a[s].h=h=T$$(e,v)[0];this.a[s].c=c=T$$('div',v)[0];h.onclick=new Function(this.n+'.pr(0,'+s+')');if(o==s){h.className=this.s;c.style.height='auto';c.d=1}else{c.style.height=0;c.d=-1}s++}}this.l=s};slider.prototype.pr=function(f,d){for(var i=0;i<this.l;i++){var h=this.a[i].h,c=this.a[i].c,k=c.style.height;k=k=='auto'?1:parseInt(k);clearInterval(c.t);if((k!=1&&c.d==-1)&&(f==1||i==d)){c.style.height='';c.m=c.offsetHeight;c.style.height=k+'px';c.d=1;h.className=this.s;su(c,1)}else if(k>0&&(f==-1||this.m||i==d)){c.d=-1;h.className='';su(c,-1)}}};function su(c){c.t=setInterval(function(){sl(c)},20)};function sl(c){var h=c.offsetHeight,d=c.d==1?c.m-h:h;c.style.height=h+(Math.ceil(d/5)*c.d)+'px';c.style.opacity=h/c.m;c.style.filter='alpha(opacity='+h*100/c.m+')';if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'}clearInterval(c.t)}};return{slider:slider}}();

function showcaptcha(myElement) {
var myElement
document.getElementById(myElement).style.display='block';
}

jQuery.fn.DefaultValue = function(text){
    return this.each(function(){
		//Make sure we're dealing with text-based form fields
		if(this.type != 'text' && this.type != 'password' && this.type != 'textarea')
			return;
		
		//Store field reference
		var fld_current=this;
		
		//Set value initially if none are specified
        if(this.value=='') {
			this.value=text;
		} else {
			//Other value exists - ignore
			return;
		}
		
		//Remove values on focus
		$(this).focus(function() {
			if(this.value==text || this.value=='')
				this.value='';
		});
		
		//Place values back on blur
		$(this).blur(function() {
			if(this.value==text || this.value=='')
				this.value=text;
		});
		
		//Capture parent form submission
		//Remove field values that are still default
		$(this).parents("form").each(function() {
			//Bind parent form submit
			$(this).submit(function() {
				if(fld_current.value==text) {
					fld_current.value='';
				}
			});
		});
    });
};

(function($){ 		  
	$.fn.popupWindow = function(instanceSettings){
		
		return this.each(function(){
		
		$(this).click(function(){
		
		$.fn.popupWindow.defaultSettings = {
			centerBrowser:0, // center window over browser window? {1 (YES) or 0 (NO)}. overrides top and left
			centerScreen:0, // center window over entire screen? {1 (YES) or 0 (NO)}. overrides top and left
			height:500, // sets the height in pixels of the window.
			left:0, // left position when the window appears.
			location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
			menubar:0, // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
			resizable:0, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
			scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
			status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
			width:500, // sets the width in pixels of the window.
			windowName:null, // name of window set from the name attribute of the element that invokes the click
			windowURL:null, // url used for the popup
			top:0, // top position when the window appears.
			toolbar:0 // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
		};
		
		settings = $.extend({}, $.fn.popupWindow.defaultSettings, instanceSettings || {});
		
		var windowFeatures =    'height=' + settings.height +
								',width=' + settings.width +
								',toolbar=' + settings.toolbar +
								',scrollbars=' + settings.scrollbars +
								',status=' + settings.status + 
								',resizable=' + settings.resizable +
								',location=' + settings.location +
								',menuBar=' + settings.menubar;

				settings.windowName = this.name || settings.windowName;
				settings.windowURL = this.href || settings.windowURL;
				var centeredY,centeredX;
			
				if(settings.centerBrowser){
						
					if ($.browser.msie) {//hacked together for IE browsers
						centeredY = (window.screenTop - 120) + ((((document.documentElement.clientHeight + 120)/2) - (settings.height/2)));
						centeredX = window.screenLeft + ((((document.body.offsetWidth + 20)/2) - (settings.width/2)));
					}else{
						centeredY = window.screenY + (((window.outerHeight/2) - (settings.height/2)));
						centeredX = window.screenX + (((window.outerWidth/2) - (settings.width/2)));
					}
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
				}else if(settings.centerScreen){
					centeredY = (screen.height - settings.height)/2;
					centeredX = (screen.width - settings.width)/2;
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
				}else{
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + settings.left +',top=' + settings.top).focus();	
				}
				return false;
			});
			
		});	
	};
})(jQuery);


/*
 * jQuery validation plug-in 1.5.5
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.validate.js 6403 2009-06-17 14:27:16Z joern.zaefferer $
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function($){$.extend($.fn,{validate:function(options){if(!this.length){options&&options.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing");return;}var validator=$.data(this[0],'validator');if(validator){return validator;}validator=new $.validator(options,this[0]);$.data(this[0],'validator',validator);if(validator.settings.onsubmit){this.find("input, button").filter(".cancel").click(function(){validator.cancelSubmit=true;});if(validator.settings.submitHandler){this.find("input, button").filter(":submit").click(function(){validator.submitButton=this;});}this.submit(function(event){if(validator.settings.debug)event.preventDefault();function handle(){if(validator.settings.submitHandler){if(validator.submitButton){var hidden=$("<input type='hidden'/>").attr("name",validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);}validator.settings.submitHandler.call(validator,validator.currentForm);if(validator.submitButton){hidden.remove();}return false;}return true;}if(validator.cancelSubmit){validator.cancelSubmit=false;return handle();}if(validator.form()){if(validator.pendingRequest){validator.formSubmitted=true;return false;}return handle();}else{validator.focusInvalid();return false;}});}return validator;},valid:function(){if($(this[0]).is('form')){return this.validate().form();}else{var valid=true;var validator=$(this[0].form).validate();this.each(function(){valid&=validator.element(this);});return valid;}},removeAttrs:function(attributes){var result={},$element=this;$.each(attributes.split(/\s/),function(index,value){result[value]=$element.attr(value);$element.removeAttr(value);});return result;},rules:function(command,argument){var element=this[0];if(command){var settings=$.data(element.form,'validator').settings;var staticRules=settings.rules;var existingRules=$.validator.staticRules(element);switch(command){case"add":$.extend(existingRules,$.validator.normalizeRule(argument));staticRules[element.name]=existingRules;if(argument.messages)settings.messages[element.name]=$.extend(settings.messages[element.name],argument.messages);break;case"remove":if(!argument){delete staticRules[element.name];return existingRules;}var filtered={};$.each(argument.split(/\s/),function(index,method){filtered[method]=existingRules[method];delete existingRules[method];});return filtered;}}var data=$.validator.normalizeRules($.extend({},$.validator.metadataRules(element),$.validator.classRules(element),$.validator.attributeRules(element),$.validator.staticRules(element)),element);if(data.required){var param=data.required;delete data.required;data=$.extend({required:param},data);}return data;}});$.extend($.expr[":"],{blank:function(a){return!$.trim(a.value);},filled:function(a){return!!$.trim(a.value);},unchecked:function(a){return!a.checked;}});$.validator=function(options,form){this.settings=$.extend({},$.validator.defaults,options);this.currentForm=form;this.init();};$.validator.format=function(source,params){if(arguments.length==1)return function(){var args=$.makeArray(arguments);args.unshift(source);return $.validator.format.apply(this,args);};if(arguments.length>2&&params.constructor!=Array){params=$.makeArray(arguments).slice(1);}if(params.constructor!=Array){params=[params];}$.each(params,function(i,n){source=source.replace(new RegExp("\\{"+i+"\\}","g"),n);});return source;};$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:true,ignore:[],ignoreTitle:false,onfocusin:function(element){this.lastActive=element;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,element,this.settings.errorClass,this.settings.validClass);this.errorsFor(element).hide();}},onfocusout:function(element){if(!this.checkable(element)&&(element.name in this.submitted||!this.optional(element))){this.element(element);}},onkeyup:function(element){if(element.name in this.submitted||element==this.lastElement){this.element(element);}},onclick:function(element){if(element.name in this.submitted)this.element(element);},highlight:function(element,errorClass,validClass){$(element).addClass(errorClass).removeClass(validClass);},unhighlight:function(element,errorClass,validClass){$(element).removeClass(errorClass).addClass(validClass);}},setDefaults:function(settings){$.extend($.validator.defaults,settings);},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",dateDE:"Bitte geben Sie ein gültiges Datum ein.",number:"Please enter a valid number.",numberDE:"Bitte geben Sie eine Nummer ein.",digits:"Please enter only digits",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){this.labelContainer=$(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm);this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var groups=(this.groups={});$.each(this.settings.groups,function(key,value){$.each(value.split(/\s/),function(index,name){groups[name]=key;});});var rules=this.settings.rules;$.each(rules,function(key,value){rules[key]=$.validator.normalizeRule(value);});function delegate(event){var validator=$.data(this[0].form,"validator");validator.settings["on"+event.type]&&validator.settings["on"+event.type].call(validator,this[0]);}$(this.currentForm).delegate("focusin focusout keyup",":text, :password, :file, select, textarea",delegate).delegate("click",":radio, :checkbox",delegate);if(this.settings.invalidHandler)$(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler);},form:function(){this.checkForm();$.extend(this.submitted,this.errorMap);this.invalid=$.extend({},this.errorMap);if(!this.valid())$(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid();},checkForm:function(){this.prepareForm();for(var i=0,elements=(this.currentElements=this.elements());elements[i];i++){this.check(elements[i]);}return this.valid();},element:function(element){element=this.clean(element);this.lastElement=element;this.prepareElement(element);this.currentElements=$(element);var result=this.check(element);if(result){delete this.invalid[element.name];}else{this.invalid[element.name]=true;}if(!this.numberOfInvalids()){this.toHide=this.toHide.add(this.containers);}this.showErrors();return result;},showErrors:function(errors){if(errors){$.extend(this.errorMap,errors);this.errorList=[];for(var name in errors){this.errorList.push({message:errors[name],element:this.findByName(name)[0]});}this.successList=$.grep(this.successList,function(element){return!(element.name in errors);});}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors();},resetForm:function(){if($.fn.resetForm)$(this.currentForm).resetForm();this.submitted={};this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass);},numberOfInvalids:function(){return this.objectLength(this.invalid);},objectLength:function(obj){var count=0;for(var i in obj)count++;return count;},hideErrors:function(){this.addWrapper(this.toHide).hide();},valid:function(){return this.size()==0;},size:function(){return this.errorList.length;},focusInvalid:function(){if(this.settings.focusInvalid){try{$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus();}catch(e){}}},findLastActive:function(){var lastActive=this.lastActive;return lastActive&&$.grep(this.errorList,function(n){return n.element.name==lastActive.name;}).length==1&&lastActive;},elements:function(){var validator=this,rulesCache={};return $([]).add(this.currentForm.elements).filter(":input").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&validator.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in rulesCache||!validator.objectLength($(this).rules()))return false;rulesCache[this.name]=true;return true;});},clean:function(selector){return $(selector)[0];},errors:function(){return $(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext);},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=$([]);this.toHide=$([]);this.formSubmitted=false;this.currentElements=$([]);},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers);},prepareElement:function(element){this.reset();this.toHide=this.errorsFor(element);},check:function(element){element=this.clean(element);if(this.checkable(element)){element=this.findByName(element.name)[0];}var rules=$(element).rules();var dependencyMismatch=false;for(method in rules){var rule={method:method,parameters:rules[method]};try{var result=$.validator.methods[method].call(this,element.value.replace(/\r/g,""),element,rule.parameters);if(result=="dependency-mismatch"){dependencyMismatch=true;continue;}dependencyMismatch=false;if(result=="pending"){this.toHide=this.toHide.not(this.errorsFor(element));return;}if(!result){this.formatAndAdd(element,rule);return false;}}catch(e){this.settings.debug&&window.console&&console.log("exception occured when checking element "+element.id
+", check the '"+rule.method+"' method");throw e;}}if(dependencyMismatch)return;if(this.objectLength(rules))this.successList.push(element);return true;},customMetaMessage:function(element,method){if(!$.metadata)return;var meta=this.settings.meta?$(element).metadata()[this.settings.meta]:$(element).metadata();return meta&&meta.messages&&meta.messages[method];},customMessage:function(name,method){var m=this.settings.messages[name];return m&&(m.constructor==String?m:m[method]);},findDefined:function(){for(var i=0;i<arguments.length;i++){if(arguments[i]!==undefined)return arguments[i];}return undefined;},defaultMessage:function(element,method){return this.findDefined(this.customMessage(element.name,method),this.customMetaMessage(element,method),!this.settings.ignoreTitle&&element.title||undefined,$.validator.messages[method],"<strong>Warning: No message defined for "+element.name+"</strong>");},formatAndAdd:function(element,rule){var message=this.defaultMessage(element,rule.method);if(typeof message=="function")message=message.call(this,rule.parameters,element);this.errorList.push({message:message,element:element});this.errorMap[element.name]=message;this.submitted[element.name]=message;},addWrapper:function(toToggle){if(this.settings.wrapper)toToggle=toToggle.add(toToggle.parent(this.settings.wrapper));return toToggle;},defaultShowErrors:function(){for(var i=0;this.errorList[i];i++){var error=this.errorList[i];this.settings.highlight&&this.settings.highlight.call(this,error.element,this.settings.errorClass,this.settings.validClass);this.showLabel(error.element,error.message);}if(this.errorList.length){this.toShow=this.toShow.add(this.containers);}if(this.settings.success){for(var i=0;this.successList[i];i++){this.showLabel(this.successList[i]);}}if(this.settings.unhighlight){for(var i=0,elements=this.validElements();elements[i];i++){this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,this.settings.validClass);}}this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show();},validElements:function(){return this.currentElements.not(this.invalidElements());},invalidElements:function(){return $(this.errorList).map(function(){return this.element;});},showLabel:function(element,message){var label=this.errorsFor(element);if(label.length){label.removeClass().addClass(this.settings.errorClass);label.attr("generated")&&label.html(message);}else{label=$("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(element),generated:true}).addClass(this.settings.errorClass).html(message||"");if(this.settings.wrapper){label=label.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();}if(!this.labelContainer.append(label).length)this.settings.errorPlacement?this.settings.errorPlacement(label,$(element)):label.insertAfter(element);}if(!message&&this.settings.success){label.text("");typeof this.settings.success=="string"?label.addClass(this.settings.success):this.settings.success(label);}this.toShow=this.toShow.add(label);},errorsFor:function(element){return this.errors().filter("[for='"+this.idOrName(element)+"']");},idOrName:function(element){return this.groups[element.name]||(this.checkable(element)?element.name:element.id||element.name);},checkable:function(element){return/radio|checkbox/i.test(element.type);},findByName:function(name){var form=this.currentForm;return $(document.getElementsByName(name)).map(function(index,element){return element.form==form&&element.name==name&&element||null;});},getLength:function(value,element){switch(element.nodeName.toLowerCase()){case'select':return $("option:selected",element).length;case'input':if(this.checkable(element))return this.findByName(element.name).filter(':checked').length;}return value.length;},depend:function(param,element){return this.dependTypes[typeof param]?this.dependTypes[typeof param](param,element):true;},dependTypes:{"boolean":function(param,element){return param;},"string":function(param,element){return!!$(param,element.form).length;},"function":function(param,element){return param(element);}},optional:function(element){return!$.validator.methods.required.call(this,$.trim(element.value),element)&&"dependency-mismatch";},startRequest:function(element){if(!this.pending[element.name]){this.pendingRequest++;this.pending[element.name]=true;}},stopRequest:function(element,valid){this.pendingRequest--;if(this.pendingRequest<0)this.pendingRequest=0;delete this.pending[element.name];if(valid&&this.pendingRequest==0&&this.formSubmitted&&this.form()){$(this.currentForm).submit();}else if(!valid&&this.pendingRequest==0&&this.formSubmitted){$(this.currentForm).triggerHandler("invalid-form",[this]);}},previousValue:function(element){return $.data(element,"previousValue")||$.data(element,"previousValue",previous={old:null,valid:true,message:this.defaultMessage(element,"remote")});}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(className,rules){className.constructor==String?this.classRuleSettings[className]=rules:$.extend(this.classRuleSettings,className);},classRules:function(element){var rules={};var classes=$(element).attr('class');classes&&$.each(classes.split(' '),function(){if(this in $.validator.classRuleSettings){$.extend(rules,$.validator.classRuleSettings[this]);}});return rules;},attributeRules:function(element){var rules={};var $element=$(element);for(method in $.validator.methods){var value=$element.attr(method);if(value){rules[method]=value;}}if(rules.maxlength&&/-1|2147483647|524288/.test(rules.maxlength)){delete rules.maxlength;}return rules;},metadataRules:function(element){if(!$.metadata)return{};var meta=$.data(element.form,'validator').settings.meta;return meta?$(element).metadata()[meta]:$(element).metadata();},staticRules:function(element){var rules={};var validator=$.data(element.form,'validator');if(validator.settings.rules){rules=$.validator.normalizeRule(validator.settings.rules[element.name])||{};}return rules;},normalizeRules:function(rules,element){$.each(rules,function(prop,val){if(val===false){delete rules[prop];return;}if(val.param||val.depends){var keepRule=true;switch(typeof val.depends){case"string":keepRule=!!$(val.depends,element.form).length;break;case"function":keepRule=val.depends.call(element,element);break;}if(keepRule){rules[prop]=val.param!==undefined?val.param:true;}else{delete rules[prop];}}});$.each(rules,function(rule,parameter){rules[rule]=$.isFunction(parameter)?parameter(element):parameter;});$.each(['minlength','maxlength','min','max'],function(){if(rules[this]){rules[this]=Number(rules[this]);}});$.each(['rangelength','range'],function(){if(rules[this]){rules[this]=[Number(rules[this][0]),Number(rules[this][1])];}});if($.validator.autoCreateRanges){if(rules.min&&rules.max){rules.range=[rules.min,rules.max];delete rules.min;delete rules.max;}if(rules.minlength&&rules.maxlength){rules.rangelength=[rules.minlength,rules.maxlength];delete rules.minlength;delete rules.maxlength;}}if(rules.messages){delete rules.messages}return rules;},normalizeRule:function(data){if(typeof data=="string"){var transformed={};$.each(data.split(/\s/),function(){transformed[this]=true;});data=transformed;}return data;},addMethod:function(name,method,message){$.validator.methods[name]=method;$.validator.messages[name]=message||$.validator.messages[name];if(method.length<3){$.validator.addClassRules(name,$.validator.normalizeRule(name));}},methods:{required:function(value,element,param){if(!this.depend(param,element))return"dependency-mismatch";switch(element.nodeName.toLowerCase()){case'select':var options=$("option:selected",element);return options.length>0&&(element.type=="select-multiple"||($.browser.msie&&!(options[0].attributes['value'].specified)?options[0].text:options[0].value).length>0);case'input':if(this.checkable(element))return this.getLength(value,element)>0;default:return $.trim(value).length>0;}},remote:function(value,element,param){if(this.optional(element))return"dependency-mismatch";var previous=this.previousValue(element);if(!this.settings.messages[element.name])this.settings.messages[element.name]={};this.settings.messages[element.name].remote=typeof previous.message=="function"?previous.message(value):previous.message;param=typeof param=="string"&&{url:param}||param;if(previous.old!==value){previous.old=value;var validator=this;this.startRequest(element);var data={};data[element.name]=value;$.ajax($.extend(true,{url:param,mode:"abort",port:"validate"+element.name,dataType:"json",data:data,success:function(response){var valid=response===true;if(valid){var submitted=validator.formSubmitted;validator.prepareElement(element);validator.formSubmitted=submitted;validator.successList.push(element);validator.showErrors();}else{var errors={};errors[element.name]=previous.message=response||validator.defaultMessage(element,"remote");validator.showErrors(errors);}previous.valid=valid;validator.stopRequest(element,valid);}},param));return"pending";}else if(this.pending[element.name]){return"pending";}return previous.valid;},minlength:function(value,element,param){return this.optional(element)||this.getLength($.trim(value),element)>=param;},maxlength:function(value,element,param){return this.optional(element)||this.getLength($.trim(value),element)<=param;},rangelength:function(value,element,param){var length=this.getLength($.trim(value),element);return this.optional(element)||(length>=param[0]&&length<=param[1]);},min:function(value,element,param){return this.optional(element)||value>=param;},max:function(value,element,param){return this.optional(element)||value<=param;},range:function(value,element,param){return this.optional(element)||(value>=param[0]&&value<=param[1]);},email:function(value,element){return this.optional(element)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);},url:function(value,element){return this.optional(element)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);},date:function(value,element){return this.optional(element)||!/Invalid|NaN/.test(new Date(value));},dateISO:function(value,element){return this.optional(element)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);},dateDE:function(value,element){return this.optional(element)||/^\d\d?\.\d\d?\.\d\d\d?\d?$/.test(value);},number:function(value,element){return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);},numberDE:function(value,element){return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:,\d+)?$/.test(value);},digits:function(value,element){return this.optional(element)||/^\d+$/.test(value);},creditcard:function(value,element){if(this.optional(element))return"dependency-mismatch";if(/[^0-9-]+/.test(value))return false;var nCheck=0,nDigit=0,bEven=false;value=value.replace(/\D/g,"");for(n=value.length-1;n>=0;n--){var cDigit=value.charAt(n);var nDigit=parseInt(cDigit,10);if(bEven){if((nDigit*=2)>9)nDigit-=9;}nCheck+=nDigit;bEven=!bEven;}return(nCheck%10)==0;},accept:function(value,element,param){param=typeof param=="string"?param.replace(/,/g,'|'):"png|jpe?g|gif";return this.optional(element)||value.match(new RegExp(".("+param+")$","i"));},equalTo:function(value,element,param){return value==$(param).val();}}});$.format=$.validator.format;})(jQuery);;(function($){var ajax=$.ajax;var pendingRequests={};$.ajax=function(settings){settings=$.extend(settings,$.extend({},$.ajaxSettings,settings));var port=settings.port;if(settings.mode=="abort"){if(pendingRequests[port]){pendingRequests[port].abort();}return(pendingRequests[port]=ajax.apply(this,arguments));}return ajax.apply(this,arguments);};})(jQuery);;(function($){$.each({focus:'focusin',blur:'focusout'},function(original,fix){$.event.special[fix]={setup:function(){if($.browser.msie)return false;this.addEventListener(original,$.event.special[fix].handler,true);},teardown:function(){if($.browser.msie)return false;this.removeEventListener(original,$.event.special[fix].handler,true);},handler:function(e){arguments[0]=$.event.fix(e);arguments[0].type=fix;return $.event.handle.apply(this,arguments);}};});$.extend($.fn,{delegate:function(type,delegate,handler){return this.bind(type,function(event){var target=$(event.target);if(target.is(delegate)){return handler.apply(target,arguments);}});},triggerEvent:function(type,target){return this.triggerHandler(type,[$.event.fix({type:type,target:target})]);}})})(jQuery);
