/*

*	jQuery plugins

*

*				www.senzatie.com

*/



function setMood(){

	datetoday = new Date(); 

	timenow = datetoday.getTime(); 

	datetoday.setTime(timenow); 

	thehour = datetoday.getHours(); 

	document.body.className += (thehour > 6 && thehour < 18) ? ' day' : ' night';

}







(function($) { 



	//	logging function

	$.fn.log = function (msg) {

		if(window.console) window.console.log("%s: %o", msg, this);

		return this;

	};



	//	add a spinner to element / $('element').spin()

	$.fn.spin = function(append) {

		if (append)

			$(this).append('<img src="/static/default/site/images/spinner.gif" class="spinner" alt="" />')

		else

			$(this).after('<img src="/static/default/site/images/spinner.gif" class="spinner" alt="" />')

	};

	

	//	pause

	$.fn.pause = function (n) {

		return this.queue(function () {

			var el = this;

			setTimeout(function () {

				return $(el).dequeue();

			}, n);

		});

	};



	//	Age validation

	$.fn.ageValidation = function(age){

		var t = $(this);

		

		var day = $("#av-day", t).val();

		var month = $("#av-month", t).val();

		var year = $("#av-year", t).val();

		var age = age || 18;

					

		var mydate = new Date();

		mydate.setFullYear(year, month-1, day);

					

		var currdate = new Date();

		currdate.setFullYear(currdate.getFullYear() - age);

		

		if ((currdate - mydate) < 0)

			return false;

		else

			return true;

	}



	// MSDropDown - jquery.dd.js

	// author: Marghoob Suleman

	// Date: 12th Aug, 2009

	// Version: 2.1 {date: 3rd Sep 2009}

	// Revision: 25

	// web: www.giftlelo.com | www.marghoobsuleman.com

	var oldDiv = "";

	$.fn.dd = function(options) {

		$this =  this;

		options = $.extend({

			height:120,

			visibleRows:7,

			rowHeight:23,

			showIcon:true,

			zIndex:9999,

			style:''

		}, options);

		var selectedValue = "";

		var actionSettings ={};

		actionSettings.insideWindow = true;

		actionSettings.keyboardAction = false;

		actionSettings.currentKey = null;

		var ddList = false;

		config = {postElementHolder:'_msddHolder', postID:'_msdd', postTitleID:'_title',postTitleTextID:'_titletext',postChildID:'_child',postAID:'_msa',postOPTAID:'_msopta',postInputID:'_msinput', postArrowID:'_arrow', postInputhidden:'_inp'};

		styles = {dd:'dd', ddTitle:'ddTitle', arrow:'arrow', ddChild:'ddChild', disbaled:.30};

		attributes = {actions:"onfocus,onblur,onchange,onclick,ondblclick,onmousedown,onmouseup,onmouseover,onmousemove,onmouseout,onkeypress,onkeydown,onkeyup", prop:"size,multiple,disabled,tabindex"};

		var elementid = $(this).attr("id");

		var inlineCSS = $(this).attr("style");

		options.style += (inlineCSS==undefined) ? "" : inlineCSS;

		var allOptions = $(this).children();

		ddList = ($(this).attr("size")>0 || $(this).attr("multiple")==true) ? true : false;

		if(ddList) {options.visibleRows = $(this).attr("size");};

		var a_array = {};//stores id, html & value etc

		//create wrapper

		createDropDown();

	

	function getPostID(id) {

		return elementid+config[id];

	};

	function getOptionsProperties(option) {

		var currentOption = option;

		var styles = $(currentOption).attr("style");

		return styles;

	};

	function matchIndex(index) {

		var selectedIndex = $("#"+elementid+" option:selected");

		if(selectedIndex.length>1) {

			for(var i=0;i<selectedIndex.length;i++) {

				if(index == selectedIndex[i].index) {

					return true;

				};

			};

		} else if(selectedIndex.length==1) {

			if(selectedIndex[0].index==index) {

				return true;

			};

		};

		return false;

	}

	function createATags() {

		var childnodes = allOptions;

		var aTag = "";

		var aidfix = getPostID("postAID");

		var aidoptfix = getPostID("postOPTAID");

		childnodes.each(function(current){

								 var currentOption = childnodes[current];

								 //OPTGROUP

								 if(currentOption.nodeName == "OPTGROUP") {

								  	aTag += "<div class='opta'>";

									 aTag += "<span style='font-weight:bold;font-style:italic; clear:both;'>"+$(currentOption).attr("label")+"</span>";

									 var optChild = $(currentOption).children();

									 optChild.each(function(currentopt){

															var currentOptOption = optChild[currentopt];

															 var aid = aidoptfix+"_"+(current)+"_"+(currentopt);

															 var arrow = $(currentOptOption).attr("title");

															 arrow = (arrow.length==0) ? "" : '<img src="'+arrow+'" align="left" /> ';

															 var sText = $(currentOptOption).text();

															 var sValue = $(currentOptOption).val();

															 var sEnabledClass = ($(currentOptOption).attr("disabled")==true) ? "disabled" : "enabled";

															 a_array[aid] = {html:arrow + sText, value:sValue, text:sText, index:currentOptOption.index, id:aid};

															 var innerStyle = getOptionsProperties(currentOptOption);

															 if(matchIndex(currentOptOption.index)==true) {

																 aTag += '<a href="javascript:void(0);" class="selected '+sEnabledClass+'"';

															 } else {

															 	aTag += '<a  href="javascript:void(0);" class="'+sEnabledClass+'"';

															 };

															 if(innerStyle!=false)

															 aTag +=  ' style="'+innerStyle+'"';

															 aTag +=  ' id="'+aid+'">';

															 aTag += arrow + sText+'</a>';															 

															});

									 aTag += "</div>";

									 

								 } else {

									 var aid = aidfix+"_"+(current);

									 var arrow = $(currentOption).attr("title");

									 arrow = (arrow.length==0) ? "" : '<img src="'+arrow+'" align="left" /> ';									 

									 var sText = $(currentOption).text();

									 var sValue = $(currentOption).val();

									 var sEnabledClass = ($(currentOption).attr("disabled")==true) ? "disabled" : "enabled";

									 a_array[aid] = {html:arrow + sText, value:sValue, text:sText, index:currentOption.index, id:aid};

									 var innerStyle = getOptionsProperties(currentOption);

									 if(matchIndex(currentOption.index)==true) {

										 aTag += '<a href="javascript:void(0);" class="selected '+sEnabledClass+'"';

									 } else {

										aTag += '<a  href="javascript:void(0);" class="'+sEnabledClass+'"';

									 };

									 if(innerStyle!=false)

									 aTag +=  ' style="'+innerStyle+'"';

									 aTag +=  ' id="'+aid+'">';

									 aTag += arrow + sText+'</a>';															 

								 };

								 });

		return aTag;

	};

	function createChildDiv() {

		var id = getPostID("postID");

		var childid = getPostID("postChildID");

		var sStyle = options.style;

		sDiv = "";

		sDiv += '<div id="'+childid+'" class="'+styles.ddChild+'"';

		if(!ddList) {

			sDiv += (sStyle!="") ? ' style="'+sStyle+'"' : ''; 

		} else {

			sDiv += (sStyle!="") ? ' style="border-top:1px solid #c3c3c3;display:block;position:relative;'+sStyle+'"' : ''; 

		}

		sDiv += '>';		

		return sDiv;

	};



	function createTitleDiv() {

		var titleid = getPostID("postTitleID");

		var arrowid = getPostID("postArrowID");

		var titletextid = getPostID("postTitleTextID");

		var inputhidden = getPostID("postInputhidden");

		var sText = $("#"+elementid+" option:selected").text();

		var arrow = $("#"+elementid+" option:selected").attr("title");

		arrow = (arrow.length==0 || arrow==undefined || options.showIcon==false) ? "" : '<img src="'+arrow+'" align="left" /> ';

		var sDiv = '<div id="'+titleid+'" class="'+styles.ddTitle+'"';

		sDiv += '>';

		sDiv += '<span id="'+arrowid+'" class="'+styles.arrow+'"></span><span class="textTitle" id="'+titletextid+'">'+arrow + sText+'</span></div>';

		return sDiv;

	};

	function createDropDown() {

		var changeInsertionPoint = false;

		var id = getPostID("postID");

		var titleid = getPostID("postTitleID");

		var titletextid = getPostID("postTitleTextID");

		var childid = getPostID("postChildID");

		var arrowid = getPostID("postArrowID");

		//var iWidth = $("#"+elementid).width();

		var iWidth = $("#"+elementid).parent().width()-10;

		var sStyle = options.style;

		if($("#"+id).length>0) {

			$("#"+id).remove();

			changeInsertionPoint = true;

		}

		var sDiv = '<div id="'+id+'" class="'+styles.dd+'"';

		sDiv += (sStyle!="") ? ' style="'+sStyle+'"' : '';

		sDiv += '>';

		//create title bar

		if(!ddList)

		sDiv += createTitleDiv();

		//create child

		sDiv += createChildDiv();

		sDiv += createATags();

		sDiv += "</div>";

		sDiv += "</div>";

		if(changeInsertionPoint==true) {

			var sid =getPostID("postElementHolder");

			$("#"+sid).after(sDiv);

		} else {

			$("#"+elementid).after(sDiv);

		}

		$("#"+id).css("width", iWidth+"px");

		$("#"+childid).css("width", (iWidth-2)+"px");

		if(allOptions.length>options.visibleRows) {

			var margin = parseInt($("#"+childid+" a:first").css("padding-bottom")) + parseInt($("#"+childid+" a:first").css("padding-top"));

			var iHeight = ((options.rowHeight)*options.visibleRows) - margin;

			$("#"+childid).css("height", iHeight+"px");

		}

		//set out of vision

		if(changeInsertionPoint==false) {

			setOutOfVision();

			addNewEvents(elementid);

		}

		if($("#"+elementid).attr("disabled")==true) {

			$("#"+id).css("opacity", styles.disbaled);

		} else {

			applyEvents();

			//add events

			//arrow hightlight

			if(!ddList) {

				$("#"+titleid).bind("mouseover", function(event) {

														  hightlightArrow(1);

														  });

				$("#"+titleid).bind("mouseout", function(event) {

														  hightlightArrow(0);

														  });

			};

			//open close events

			$("#"+childid+ " a.enabled").bind("click", function(event) {

														 event.preventDefault();

														 manageSelection(this);

														 if(!ddList) {

															 $("#"+childid).unbind("mouseover");

															 setInsideWindow(false);															 

															 var sText = (options.showIcon==false) ? $(this).text() : $(this).html();

															  setTitleText(sText);

															  closeMe();

														 };

														 setValue();

														 //actionSettings.oldIndex = a_array[$(this).attr("id")].index;

														 });

			$("#"+childid+ " a.disabled").css("opacity", styles.disbaled);

			if(ddList) {

				$("#"+childid).bind("mouseover", function(event) {if(!actionSettings.keyboardAction) {

																	 actionSettings.keyboardAction = true;

																	 $(document).bind("keydown", function(event) {

																										var keyCode = event.keyCode;	

																										actionSettings.currentKey = keyCode;

																										if(keyCode==39 || keyCode==40) {

																											//move to next

																											event.preventDefault(); event.stopPropagation();

																											next();

																											setValue();

																										};

																										if(keyCode==37 || keyCode==38) {

																											event.preventDefault(); event.stopPropagation();

																											//move to previous

																											previous();

																											setValue();

																										};

																										  });

																	 

																	 }});

			};

			$("#"+childid).bind("mouseout", function(event) {setInsideWindow(false);$(document).unbind("keydown");actionSettings.keyboardAction = false;actionSettings.currentKey=null;});

			if(!ddList) {

				$("#"+titleid).bind("click", function(event) {

													  setInsideWindow(false);

														if($("#"+childid+":visible").length==1) {

															$("#"+childid).unbind("mouseover");

														} else {

															$("#"+childid).bind("mouseover", function(event) {setInsideWindow(true);});

															openMe();

														};

													  });

			};

			$("#"+titleid).bind("mouseout", function(evt) {

													 setInsideWindow(false);

													 })

		};

	};

	function getByIndex(index) {

		for(var i in a_array) {

			if(a_array[i].index==index) {

				return a_array[i];

			}

		}

	}

	function manageSelection(obj) {

		var childid = getPostID("postChildID");

		if(!ddList) {

			$("#"+childid+ " a.selected").removeClass("selected");

		} 

		var selectedA = $("#"+childid + " a.selected").attr("id");

		if(selectedA!=undefined) {

			var oldIndex = (actionSettings.oldIndex==undefined || actionSettings.oldIndex==null) ? a_array[selectedA].index : actionSettings.oldIndex;

		};

		if(obj && !ddList) {

			$(obj).addClass("selected");

		};				

		if(ddList) {

			var keyCode = actionSettings.currentKey;

			if($("#"+elementid).attr("multiple")==true) {

				if(keyCode == 17) {

					//control

						actionSettings.oldIndex = a_array[$(obj).attr("id")].index;

						$(obj).toggleClass("selected");

					//multiple

				} else if(keyCode==16) {

					$("#"+childid+ " a.selected").removeClass("selected");

					$(obj).addClass("selected");

					//shift

					var currentSelected = $(obj).attr("id");

					var currentIndex = a_array[currentSelected].index;

					for(var i=Math.min(oldIndex, currentIndex);i<=Math.max(oldIndex, currentIndex);i++) {

						$("#"+getByIndex(i).id).addClass("selected");

					}

				} else {

					$("#"+childid+ " a.selected").removeClass("selected");

					$(obj).addClass("selected");

					actionSettings.oldIndex = a_array[$(obj).attr("id")].index;

				};

			} else {

					$("#"+childid+ " a.selected").removeClass("selected");

					$(obj).addClass("selected");

					actionSettings.oldIndex = a_array[$(obj).attr("id")].index;				

			};

		};		

	};

	function addNewEvents(id) {

		document.getElementById(id).refresh = function(e) {

			$("#"+this.id).dd(options);

		};

	};

	function setInsideWindow(val) {

		actionSettings.insideWindow = val;

	};

	function getInsideWindow() {

		return actionSettings.insideWindow;

	};

	function applyEvents() {

		var mainid = getPostID("postID");

		var actions_array = attributes.actions.split(",");

		for(var iCount=0;iCount<actions_array.length;iCount++) {

			var action = actions_array[iCount];

			var actionFound = $("#"+elementid).attr(action);

			if(actionFound!=undefined) {

				switch(action) {

					case "onfocus": 

					$("#"+mainid).bind("mouseenter", function(event) {

													   document.getElementById(elementid).focus();

													   });

					break;

					case "onclick": 

					$("#"+mainid).bind("click", function(event) {

													   document.getElementById(elementid).onclick();

													   });

					break;

					case "ondblclick": 

					$("#"+mainid).bind("dblclick", function(event) {

													   document.getElementById(elementid).ondblclick();

													   });

					break;

					case "onmousedown": 

					$("#"+mainid).bind("mousedown", function(event) {

													   document.getElementById(elementid).onmousedown();

													   });

					break;

					case "onmouseup": 

					//has in closeMe mthod

					$("#"+mainid).bind("mouseup", function(event) {

													   document.getElementById(elementid).onmouseup();

													   //setValue();

													   });

					break;

					case "onmouseover": 

					$("#"+mainid).bind("mouseover", function(event) {

													   document.getElementById(elementid).onmouseover();

													   });

					break;

					case "onmousemove": 

					$("#"+mainid).bind("mousemove", function(event) {

													   document.getElementById(elementid).onmousemove();

													   });

					break;

					case "onmouseout": 

					$("#"+mainid).bind("mouseout", function(event) {

													   document.getElementById(elementid).onmouseout();

													   });

					break;

				};

			};

		};

		

	};

	function setOutOfVision() {

		var sId = getPostID("postElementHolder");

		$("#"+elementid).after("<div style='height:0px;overflow:hidden;position:absolute;' id='"+sId+"'></div>");

		$("#"+elementid).appendTo($("#"+sId));

	};

	function setTitleText(sText) {

		var titletextid = getPostID("postTitleTextID");

		$("#"+titletextid).html(sText);

	};

	function next() {

		var titletextid = getPostID("postTitleTextID");

		var childid = getPostID("postChildID");

		var allAs = $("#"+childid + " a.enabled");

		for(var current=0;current<allAs.length;current++) {

			var currentA = allAs[current];

			var id = $(currentA).attr("id");

			if($(currentA).hasClass("selected") && current<allAs.length-1) {

				$("#"+childid + " a.selected").removeClass("selected");

				$(allAs[current+1]).addClass("selected");

				//manageSelection(allAs[current+1]);

				var selectedA = $("#"+childid + " a.selected").attr("id");

				if(!ddList) {

					var sText = (options.showIcon==false) ? a_array[selectedA].text : a_array[selectedA].html;

					setTitleText(sText);

				}

				if(parseInt(($("#"+selectedA).position().top+$("#"+selectedA).height()))>=parseInt($("#"+childid).height())) {

					$("#"+childid).scrollTop(($("#"+childid).scrollTop())+$("#"+selectedA).height()+$("#"+selectedA).height());

				};

				break;

			};

		};

	};

	function previous() {

		var titletextid = getPostID("postTitleTextID");

		var childid = getPostID("postChildID");

		var allAs = $("#"+childid + " a.enabled");

		for(var current=0;current<allAs.length;current++) {

			var currentA = allAs[current];

			var id = $(currentA).attr("id");

			if($(currentA).hasClass("selected") && current!=0) {

				$("#"+childid + " a.selected").removeClass("selected");

				$(allAs[current-1]).addClass("selected");				

				//manageSelection(allAs[current-1]);

				var selectedA = $("#"+childid + " a.selected").attr("id");

				if(!ddList) {

					var sText = (options.showIcon==false) ? a_array[selectedA].text : a_array[selectedA].html;

					setTitleText(sText);

				}

				if(parseInt(($("#"+selectedA).position().top+$("#"+selectedA).height())) <=0) {

					$("#"+childid).scrollTop(($("#"+childid).scrollTop()-$("#"+childid).height())-$("#"+selectedA).height());

				};

				break;

			};

		};

	};

	function setValue() {

		var childid = getPostID("postChildID");

		var allSelected = $("#"+childid + " a.selected");

		if(allSelected.length==1) {

			var sText = $("#"+childid + " a.selected").text();

			var selectedA = $("#"+childid + " a.selected").attr("id");

			if(selectedA!=undefined) {

				var sValue = a_array[selectedA].value;

				document.getElementById(elementid).selectedIndex = a_array[selectedA].index;

			};

		} else if(allSelected.length>1) { 

			var alls = $("#"+elementid +" > option:selected").removeAttr("selected");

			for(var i=0;i<allSelected.length;i++) {

				var selectedA = $(allSelected[i]).attr("id");

				var index = a_array[selectedA].index;

				document.getElementById(elementid).options[index].selected = "selected";

			};

		};

	};

	function openMe() {

		var childid = getPostID("postChildID");

		if(oldDiv!="" && childid!=oldDiv) { 

			$("#"+oldDiv).slideUp("fast");

			$("#"+oldDiv).css({zIndex:'0'});

		};

		if($("#"+childid).css("display")=="none") {

			selectedValue = a_array[$("#"+childid +" a.selected").attr("id")].text;

			$(document).bind("keydown", function(event) {

													var keyCode = event.keyCode;											

													if(keyCode==39 || keyCode==40) {

														//move to next

														event.preventDefault(); event.stopPropagation();

														next();

													};

													if(keyCode==37 || keyCode==38) {

														event.preventDefault(); event.stopPropagation();

														//move to previous

														previous();

													};

													if(keyCode==27 || keyCode==13) {

														closeMe();

														setValue();

													};

													if($("#"+elementid).attr("onkeydown")!=undefined) {

															document.getElementById(elementid).onkeydown();

														};														

													   });

			$(document).bind("keyup", function(event) {

													if($("#"+elementid).attr("onkeyup")!=undefined) {

														//$("#"+elementid).keyup();

														document.getElementById(elementid).onkeyup();

													};												 

												 });



					$(document).bind("mouseup", function(evt){

															if(getInsideWindow()==false) {

															 closeMe();

															}

														 });													  

			$("#"+childid).css({zIndex:options.zIndex});

			$("#"+childid).slideDown("fast");

		if(childid!=oldDiv) {

			oldDiv = childid;

		}

		};

	};

	function closeMe() {

				var childid = getPostID("postChildID");

				$(document).unbind("keydown");

				$(document).unbind("keyup");

				$(document).unbind("mouseup");

				$("#"+childid).slideUp("fast", function(event) {

															checkMethodAndApply();

															$("#"+childid).css({zIndex:'0'});

															});

		

	};

	function checkMethodAndApply() {

		var childid = getPostID("postChildID");

		if($("#"+elementid).attr("onchange")!=undefined) {

			var currentSelectedValue = a_array[$("#"+childid +" a.selected").attr("id")].text;

			if(selectedValue!=currentSelectedValue){document.getElementById(elementid).onchange();};

		}

		if($("#"+elementid).attr("onmouseup")!=undefined) {

			document.getElementById(elementid).onmouseup();

		}

		if($("#"+elementid).attr("onblur")!=undefined) { 

			$(document).bind("mouseup", function(evt) {

												   $("#"+elementid).focus();

												   $("#"+elementid)[0].blur();

												   setValue();

												   $(document).unbind("mouseup");

												});

		};

	};

	function hightlightArrow(ison) {

		var arrowid = getPostID("postArrowID");

		if(ison==1)

			$("#"+arrowid).css({backgroundPosition:'0 100%'});

		else 

			$("#"+arrowid).css({backgroundPosition:'0 0'});

	};

	};

	$.fn.msDropDown = function(properties) {

		var dds = $(this);

		for(var iCount=0;iCount<dds.length;iCount++) {

			var id = $(dds[iCount]).attr("id");

			if(properties==undefined) {

				$("#"+id).dd();

			} else {

				$("#"+id).dd(properties);

			};

		};		

	};



	/*

	 * SimpleModal 1.3.3 - jQuery Plugin

	 * http://www.ericmmartin.com/projects/simplemodal/

	 * Copyright (c) 2009 Eric Martin (http://twitter.com/EricMMartin)

	 * Dual licensed under the MIT and GPL licenses

	 * Revision: $Id: jquery.simplemodal.js 228 2009-10-30 13:34:27Z emartin24 $

	 */

	var ie6 = $.browser.msie && parseInt($.browser.version) == 6 && typeof window['XMLHttpRequest'] != "object",

		ieQuirks = null,

		w = [];



	/*

	 * Stand-alone function to create a modal dialog.

	 * 

	 * @param {string, object} data A string, jQuery object or DOM object

	 * @param {object} [options] An optional object containing options overrides

	 */

	$.modal = function (data, options) {

		return $.modal.impl.init(data, options);

	};



	/*

	 * Stand-alone close function to close the modal dialog

	 */

	$.modal.close = function () {

		$.modal.impl.close();

	};



	/*

	 * Chained function to create a modal dialog.

	 * 

	 * @param {object} [options] An optional object containing options overrides

	 */

	$.fn.modal = function (options) {

		return $.modal.impl.init(this, options);

	};



	/*

	 * SimpleModal default options

	 * 

	 * appendTo:		(String:'body') The jQuery selector to append the elements to. For ASP.NET, use 'form'.

	 * focus:			(Boolean:true) Forces focus to remain on the modal dialog

	 * opacity:			(Number:50) The opacity value for the overlay div, from 0 - 100

	 * overlayId:		(String:'simplemodal-overlay') The DOM element id for the overlay div

	 * overlayCss:		(Object:{}) The CSS styling for the overlay div

	 * containerId:		(String:'simplemodal-container') The DOM element id for the container div

	 * containerCss:	(Object:{}) The CSS styling for the container div

	 * dataId:			(String:'simplemodal-data') The DOM element id for the data div

	 * dataCss:			(Object:{}) The CSS styling for the data div

	 * minHeight:		(Number:200) The minimum height for the container

	 * minWidth:		(Number:200) The minimum width for the container

	 * maxHeight:		(Number:null) The maximum height for the container. If not specified, the window height is used.

	 * maxWidth:		(Number:null) The maximum width for the container. If not specified, the window width is used.

	 * autoResize:		(Boolean:false) Resize container on window resize? Use with caution - this may have undesirable side-effects.

	 * autoPosition:	(Boolean:true) Reposition container on window resize?

	 * zIndex:			(Number: 1000) Starting z-index value

	 * close:			(Boolean:true) If true, closeHTML, escClose and overClose will be used if set.

	 							If false, none of them will be used.

	 * closeHTML:		(String:'<a class="modalCloseImg" title="Close"></a>') The HTML for the 

							default close link. SimpleModal will automatically add the closeClass to this element.

	 * closeClass:		(String:'simplemodal-close') The CSS class used to bind to the close event

	 * escClose:		(Boolean:true) Allow Esc keypress to close the dialog? 

	 * overlayClose:	(Boolean:false) Allow click on overlay to close the dialog?

	 * position:		(Array:null) Position of container [top, left]. Can be number of pixels or percentage

	 * persist:			(Boolean:false) Persist the data across modal calls? Only used for existing

								DOM elements. If true, the data will be maintained across modal calls, if false,

								the data will be reverted to its original state.

	 * onOpen:			(Function:null) The callback function used in place of SimpleModal's open

	 * onShow:			(Function:null) The callback function used after the modal dialog has opened

	 * onClose:			(Function:null) The callback function used in place of SimpleModal's close

	 */

	$.modal.defaults = {

		appendTo: 'body',

		focus: true,

		opacity: 50,

		overlayId: 'simplemodal-overlay',

		overlayCss: {},

		containerId: 'simplemodal-container',

		containerCss: {},

		dataId: 'simplemodal-data',

		dataCss: {},

		minHeight: 200,

		minWidth: 300,

		maxHeight: null,

		maxWidth: null,

		autoResize: false,

		autoPosition: true,

		zIndex: 1000,

		close: true,

		closeHTML: '<a class="modalCloseImg" title="Close"></a>',

		closeClass: 'simplemodal-close',

		escClose: true,

		overlayClose: false,

		position: null,

		persist: false,

		onOpen: null,

		onShow: null,

		onClose: null

	};



	/*

	 * Main modal object

	 */

	$.modal.impl = {

		/*

		 * Modal dialog options

		 */

		o: null,

		/*

		 * Contains the modal dialog elements and is the object passed 

		 * back to the callback (onOpen, onShow, onClose) functions

		 */

		d: {},

		/*

		 * Initialize the modal dialog

		 */

		init: function (data, options) {

			var s = this;



			// don't allow multiple calls

			if (s.d.data) {

				return false;

			}



			// $.boxModel is undefined if checked earlier

			ieQuirks = $.browser.msie && !$.boxModel;



			// merge defaults and user options

			s.o = $.extend({}, $.modal.defaults, options);



			// keep track of z-index

			s.zIndex = s.o.zIndex;



			// set the onClose callback flag

			s.occb = false;



			// determine how to handle the data based on its type

			if (typeof data == 'object') {

				// convert DOM object to a jQuery object

				data = data instanceof jQuery ? data : $(data);



				// if the object came from the DOM, keep track of its parent

				if (data.parent().parent().size() > 0) {

					s.d.parentNode = data.parent();



					// persist changes? if not, make a clone of the element

					if (!s.o.persist) {

						s.d.orig = data.clone(true);

					}

				}

			}

			else if (typeof data == 'string' || typeof data == 'number') {

				// just insert the data as innerHTML

				data = $('<div></div>').html(data);

			}

			else {

				// unsupported data type!

				alert('SimpleModal Error: Unsupported data type: ' + typeof data);

				return s;

			}



			// create the modal overlay, container and, if necessary, iframe

			s.create(data);

			data = null;



			// display the modal dialog

			s.open();



			// useful for adding events/manipulating data in the modal dialog

			if ($.isFunction(s.o.onShow)) {

				s.o.onShow.apply(s, [s.d]);

			}



			// don't break the chain =)

			return s;

		},

		/*

		 * Create and add the modal overlay and container to the page

		 */

		create: function (data) {

			var s = this;



			// get the window properties

			w = s.getDimensions();



			// add an iframe to prevent select options from bleeding through

			if (ie6) {

				s.d.iframe = $('<iframe src="javascript:false;"></iframe>')

					.css($.extend(s.o.iframeCss, {

						display: 'none',

						opacity: 0, 

						position: 'fixed',

						height: w[0],

						width: w[1],

						zIndex: s.o.zIndex,

						top: 0,

						left: 0

					}))

					.appendTo(s.o.appendTo);

			}



			// create the overlay

			s.d.overlay = $('<div></div>')

				.attr('id', s.o.overlayId)

				.addClass('simplemodal-overlay')

				.css($.extend(s.o.overlayCss, {

					display: 'none',

					opacity: s.o.opacity / 100,

					height: w[0],

					width: w[1],

					position: 'fixed',

					left: 0,

					top: 0,

					zIndex: s.o.zIndex + 1

				}))

				.appendTo(s.o.appendTo);

		

			// create the container

			s.d.container = $('<div></div>')

				.attr('id', s.o.containerId)

				.addClass('simplemodal-container')

				.css($.extend(s.o.containerCss, {

					display: 'none',

					position: 'fixed', 

					zIndex: s.o.zIndex + 2

				}))

				.append(s.o.close && s.o.closeHTML

					? $(s.o.closeHTML).addClass(s.o.closeClass)

					: '')

				.appendTo(s.o.appendTo);

				

			s.d.wrap = $('<div></div>')

				.attr('tabIndex', -1)

				.addClass('simplemodal-wrap')

				.css({height: '100%', outline: 0, width: '100%'})

				.appendTo(s.d.container);

				

			// add styling and attributes to the data

			// append to body to get correct dimensions, then move to wrap

			s.d.data = data

				.attr('id', data.attr('id') || s.o.dataId)

				.addClass('simplemodal-data')

				.css($.extend(s.o.dataCss, {

						display: 'none'

				}))

				.appendTo('body');

			data = null;



			s.setContainerDimensions();

			s.d.data.appendTo(s.d.wrap);



			// fix issues with IE

			if (ie6 || ieQuirks) {

				s.fixIE();

			}

		},

		/*

		 * Bind events

		 */

		bindEvents: function () {

			var s = this;



			// bind the close event to any element with the closeClass class

			$('.' + s.o.closeClass).bind('click.simplemodal', function (e) {

				e.preventDefault();

				s.close();

			});

			

			// bind the overlay click to the close function, if enabled

			if (s.o.close && s.o.overlayClose) {

				s.d.overlay.bind('click.simplemodal', function (e) {

					e.preventDefault();

					s.close();

				});

			}

	

			// bind keydown events

			$(document).bind('keydown.simplemodal', function (e) {

				if (s.o.focus && e.keyCode == 9) { // TAB

					s.watchTab(e);

				}

				else if ((s.o.close && s.o.escClose) && e.keyCode == 27) { // ESC

					e.preventDefault();

					s.close();

				}

			});



			// update window size

			$(window).bind('resize.simplemodal', function () {

				// redetermine the window width/height

				w = s.getDimensions();



				// reposition the dialog

				s.setContainerDimensions(true);

	

				if (ie6 || ieQuirks) {

					s.fixIE();

				}

				else {

					// update the iframe & overlay

					s.d.iframe && s.d.iframe.css({height: w[0], width: w[1]});

					s.d.overlay.css({height: w[0], width: w[1]});

				}

			});

		},

		/*

		 * Unbind events

		 */

		unbindEvents: function () {

			$('.' + this.o.closeClass).unbind('click.simplemodal');

			$(document).unbind('keydown.simplemodal');

			$(window).unbind('resize.simplemodal');

			this.d.overlay.unbind('click.simplemodal');

		},

		/*

		 * Fix issues in IE6 and IE7 in quirks mode

		 */

		fixIE: function () {

			var s=this, p = s.o.position;



			// simulate fixed position - adapted from BlockUI

			$.each([s.d.iframe || null, s.d.overlay, s.d.container], function (i, el) {

				if (el) {

					var bch = 'document.body.clientHeight', bcw = 'document.body.clientWidth',

						bsh = 'document.body.scrollHeight', bsl = 'document.body.scrollLeft',

						bst = 'document.body.scrollTop', bsw = 'document.body.scrollWidth',

						ch = 'document.documentElement.clientHeight', cw = 'document.documentElement.clientWidth',

						sl = 'document.documentElement.scrollLeft', st = 'document.documentElement.scrollTop',

						s = el[0].style;



					s.position = 'absolute';

					if (i < 2) {

						s.removeExpression('height');

						s.removeExpression('width');

						s.setExpression('height','' + bsh + ' > ' + bch + ' ? ' + bsh + ' : ' + bch + ' + "px"');

						s.setExpression('width','' + bsw + ' > ' + bcw + ' ? ' + bsw + ' : ' + bcw + ' + "px"');

					}

					else {

						var te, le;

						if (p && p.constructor == Array) {

							var top = p[0] 

								? typeof p[0] == 'number' ? p[0].toString() : p[0].replace(/px/, '')

								: el.css('top').replace(/px/, '');

							te = top.indexOf('%') == -1 

								? top + ' + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"'

								: parseInt(top.replace(/%/, '')) + ' * ((' + ch + ' || ' + bch + ') / 100) + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"';



							if (p[1]) {

								var left = typeof p[1] == 'number' ? p[1].toString() : p[1].replace(/px/, '');

								le = left.indexOf('%') == -1 

									? left + ' + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"'

									: parseInt(left.replace(/%/, '')) + ' * ((' + cw + ' || ' + bcw + ') / 100) + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"';

							}

						}

						else {

							te = '(' + ch + ' || ' + bch + ') / 2 - (this.offsetHeight / 2) + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"';

							le = '(' + cw + ' || ' + bcw + ') / 2 - (this.offsetWidth / 2) + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"';

						}

						s.removeExpression('top');

						s.removeExpression('left');

						s.setExpression('top', te);

						s.setExpression('left', le);

					}

				}

			});

		},

		focus: function (pos) {

			var s = this, p = pos || 'first';



			// focus on dialog or the first visible/enabled input element

			var input = $(':input:enabled:visible:' + p, s.d.wrap);

			input.length > 0 ? input.focus() : s.d.wrap.focus();

		},

		getDimensions: function () {

			var el = $(window);



			// fix a jQuery/Opera bug with determining the window height

			var h = $.browser.opera && $.browser.version > '9.5' && $.fn.jquery <= '1.2.6' ? document.documentElement['clientHeight'] :

				$.browser.opera && $.browser.version < '9.5' && $.fn.jquery > '1.2.6' ? window.innerHeight :

				el.height();



			return [h, el.width()];

		},

		getVal: function (v) {

			return v == 'auto' ? 0 

				: v.indexOf('%') > 0 ? v 

					: parseInt(v.replace(/px/, ''));

		},

		setContainerDimensions: function (resize) {

			var s = this;



			if (!resize || (resize && s.o.autoResize)) {

				// get the dimensions for the container and data

				var ch = s.getVal(s.d.container.css('height')), cw = s.getVal(s.d.container.css('width')),

					dh = s.d.data.outerHeight(true), dw = s.d.data.outerWidth(true);



				var mh = s.o.maxHeight && s.o.maxHeight < w[0] ? s.o.maxHeight : w[0],

					mw = s.o.maxWidth && s.o.maxWidth < w[1] ? s.o.maxWidth : w[1];



				// height

				if (!ch) {

					if (!dh) {ch = s.o.minHeight;}

					else {

						if (dh > mh) {ch = mh;}

						else if (dh < s.o.minHeight) {ch = s.o.minHeight;}

						else {ch = dh;}

					}

				}

				else {

					ch = ch > mh ? mh : ch;

				}



				// width

				if (!cw) {

					if (!dw) {cw = s.o.minWidth;}

					else {

						if (dw > mw) {cw = mw;}

						else if (dw < s.o.minWidth) {cw = s.o.minWidth;}

						else {cw = dw;}

					}

				}

				else {

					cw = cw > mw ? mw : cw;

				}



				s.d.container.css({height: ch, width: cw});

				if (dh > ch || dw > cw) {

					s.d.wrap.css({overflow:'auto'});

				}

			}

			

			if (s.o.autoPosition) {

				s.setPosition();

			}

		},

		setPosition: function () {

			var s = this, top, left,

				hc = (w[0]/2) - (s.d.container.outerHeight(true)/2),

				vc = (w[1]/2) - (s.d.container.outerWidth(true)/2);



			if (s.o.position && Object.prototype.toString.call(s.o.position) === "[object Array]") {

				top = s.o.position[0] || hc;

				left = s.o.position[1] || vc;

			} else {

				top = hc;

				left = vc;

			}

			s.d.container.css({left: left, top: top});

		},

		watchTab: function (e) {

			var s = this;



			if ($(e.target).parents('.simplemodal-container').length > 0) {

				// save the list of inputs

				s.inputs = $(':input:enabled:visible:first, :input:enabled:visible:last', s.d.data[0]);



				// if it's the first or last tabbable element, refocus

				if ((!e.shiftKey && e.target == s.inputs[s.inputs.length -1]) ||

						(e.shiftKey && e.target == s.inputs[0]) ||

						s.inputs.length == 0) {

					e.preventDefault();

					var pos = e.shiftKey ? 'last' : 'first';

					setTimeout(function () {s.focus(pos);}, 10);

				}

			}

			else {

				// might be necessary when custom onShow callback is used

				e.preventDefault();

				setTimeout(function () {s.focus();}, 10);

			}

		},

		/*

		 * Open the modal dialog elements

		 * - Note: If you use the onOpen callback, you must "show" the 

		 *	        overlay and container elements manually 

		 *         (the iframe will be handled by SimpleModal)

		 */

		open: function () {

			var s = this;

			// display the iframe

			s.d.iframe && s.d.iframe.show();



			if ($.isFunction(s.o.onOpen)) {

				// execute the onOpen callback 

				s.o.onOpen.apply(s, [s.d]);

			}

			else {

				// display the remaining elements

				s.d.overlay.show();

				s.d.container.show();

				s.d.data.show();

			}

			

			s.focus();



			// bind default events

			s.bindEvents();

		},

		/*

		 * Close the modal dialog

		 * - Note: If you use an onClose callback, you must remove the 

		 *         overlay, container and iframe elements manually

		 *

		 * @param {boolean} external Indicates whether the call to this

		 *     function was internal or external. If it was external, the

		 *     onClose callback will be ignored

		 */

		close: function () {

			var s = this;



			// prevent close when dialog does not exist

			if (!s.d.data) {

				return false;

			}



			// remove the default events

			s.unbindEvents();



			if ($.isFunction(s.o.onClose) && !s.occb) {

				// set the onClose callback flag

				s.occb = true;



				// execute the onClose callback

				s.o.onClose.apply(s, [s.d]);

			}

			else {

				// if the data came from the DOM, put it back

				if (s.d.parentNode) {

					// save changes to the data?

					if (s.o.persist) {

						// insert the (possibly) modified data back into the DOM

						s.d.data.hide().appendTo(s.d.parentNode);

					}

					else {

						// remove the current and insert the original, 

						// unmodified data back into the DOM

						s.d.data.hide().remove();

						s.d.orig.appendTo(s.d.parentNode);

					}

				}

				else {

					// otherwise, remove it

					s.d.data.hide().remove();

				}



				// remove the remaining elements

				s.d.container.hide().remove();

				s.d.overlay.hide().remove();

				s.d.iframe && s.d.iframe.hide().remove();



				// reset the dialog object

				s.d = {};

			}

		}

	};

	

	$.fn.scrollbar = function (l) {

		var o = {

			autoHide: true

		};

		var p = $.extend(o, l);

		var n;

		var k;

		var b;

		var i;

		var e;

		var g;

		var h = false;

		return this.each(function () {

			p.el = this;

			n = $("div.content", p.el);

			k = $("div.contentWrapper", p.el);

			b = $("div.scrollbar", p.el);

			i = $("div.scrubber", p.el);

			r()

		});

	

		function r() {

			$(n).hover(s, d);

			i.hover(function (u) {

				i.addClass("over")

			},function (u) {

				i.removeClass("over")

			});

			i.mousedown(function (u) {

				i.addClass("down")

			});

			b.bind("mousedown", function (u) {

				if (!$(u.target).hasClass("scrubber")) {

					i.css("top", u.pageY - b.offset().top - (i.height() * 0.5))

				}

				e = u.pageY - i.position().top;

				$(document).bind("mousemove", f);

				$(document).bind("mouseup", m);

				f(u);

				if ($.browser.mozilla) {

					$("iframe", n).css("visibility", "hidden")

				}

				return false

			});

			b.css("height", k.height()-2);

			g = setInterval(q, 1000);

			q()

		}

		function q() {

			if (n.height() < k.height()) {

				h = true;

				b.addClass("disabled")

			} else {

				h = false;

				b.removeClass("disabled");

				var u = (k.height() / n.height()) * b.height();

				u = Math.min(u, b.height());

				u = Math.max(u, 21);

				u = Math.round(u);

				if (u != i.height()) {

					var v = $(".middle .grab", i);

					i.css("height", u);

					v.css("top", (u / 2) - (v.height() / 2))

				}

			}

		}

		function s(u) {

			if (window.addEventListener) {

				if ($.browser.safari) {

					window.addEventListener("mousewheel", j, false)

				} else {

					window.addEventListener("DOMMouseScroll", j, false)

				}

			} else {

				window.mousewheel = document.mousewheel = j

			}

		}

		function d(u) {

			if (window.addEventListener) {

				if ($.browser.safari) {

					window.removeEventListener("mousewheel", j, false)

				} else {

					window.removeEventListener("DOMMouseScroll", j, false)

				}

			} else {

				window.onmousewheel = document.onmousewheel = null

			}

		}

		function j(u) {

			if (h) {

				return

			}

			e = u.pageY - i.position().top;

			var w = 0;

			if (!u) {

				u = window.event

			}

			if (u.wheelDelta) {

				w = u.wheelDelta / 120;

				if (window.opera) {

					w = -w

				}

			}

			if (u.detail) {

				w = -u.detail / 3

			}

			if (w) {

				var v = w > 0 ? -50 : 50;

				c(u.pageY + v)

			}

			if (u.stopPropagation) {

				u.stopPropagation()

			}

			if (u.preventDefault) {

				u.preventDefault()

			}

			if (u.returnValue) {

				u.returnValue = false

			}

			return false

		}

		function f(u) {

			c(u.pageY)

		}

		function c(y) {

			var u = b.height() - 2;

			var x = Math.max(Math.min(y - e, u - i.height()), 0);

			var v = x / (u - i.height());

			var w = -v * (n.height() - k.height());

			if (x === 0) {

				w = 0

			}

			i.css("top", x);

			n.css("top", w)

		}

		function m(u) {

			i.removeClass("down");

			$(document).unbind("mousemove", f);

			$(document).unbind("mouseup", f);

			if ($.browser.mozilla) {

				$("iframe", n).css("visibility", "visible")

			}

		}

	}



})(jQuery);





/**

 * Cookie plugin

 *

 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)

 * Dual licensed under the MIT and GPL licenses:

 * http://www.opensource.org/licenses/mit-license.php

 * http://www.gnu.org/licenses/gpl.html

 *

 */



/**

 * Create a ` with the given name and value and other optional parameters.

 *

 * @example $.cookie('the_cookie', 'the_value');

 * @desc Set the value of a cookie.

 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });

 * @desc Create a cookie with all available options.

 * @example $.cookie('the_cookie', 'the_value');

 * @desc Create a session cookie.

 * @example $.cookie('the_cookie', null);

 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain

 *       used when the cookie was set.

 *

 * @param String name The name of the cookie.

 * @param String value The value of the cookie.

 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.

 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.

 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.

 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained

 *                             when the the browser exits.

 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).

 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).

 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will

 *                        require a secure protocol (like HTTPS).

 * @type undefined

 *

 * @name $.cookie

 * @cat Plugins/Cookie

 * @author Klaus Hartl/klaus.hartl@stilbuero.de

 */



/**

 * Get the value of a cookie with the given name.

 *

 * @example $.cookie('the_cookie');

 * @desc Get the value of a cookie.

 *

 * @param String name The name of the cookie.

 * @return The value of the cookie.

 * @type String

 *

 * @name $.cookie

 * @cat Plugins/Cookie

 * @author Klaus Hartl/klaus.hartl@stilbuero.de

 */

$.cookie = function(name, value, options) {

    if (typeof value != 'undefined') { // name and value given, set cookie

        options = options || {};

        if (value === null) {

            value = '';

            options = $.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed

            options.expires = -1;

        }

        var expires = '';

        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {

            var date;

            if (typeof options.expires == 'number') {

                date = new Date();

                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));

            } else {

                date = options.expires;

            }

            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE

        }

        // NOTE Needed to parenthesize options.path and options.domain

        // in the following expressions, otherwise they evaluate to undefined

        // in the packed version for some reason...

        var path = options.path ? '; path=' + (options.path) : '';

        var domain = options.domain ? '; domain=' + (options.domain) : '';

        var secure = options.secure ? '; secure' : '';

        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');

    } else { // only name given, get cookie

        var cookieValue = null;

        if (document.cookie && document.cookie != '') {

            var cookies = document.cookie.split(';');

            for (var i = 0; i < cookies.length; i++) {

                var cookie = $.trim(cookies[i]);

                // Does this cookie string begin with the name we want?

                if (cookie.substring(0, name.length + 1) == (name + '=')) {

                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));

                    break;

                }

            }

        }

        return cookieValue;

    }

};





/*

 * Metadata - jQuery plugin for parsing metadata from elements

 *

 * Copyright (c) 2006 John Resig, Yehuda Katz, Jörn Zaefferer, Paul McLanahan

 *

 * Dual licensed under the MIT and GPL licenses:

 *   http://www.opensource.org/licenses/mit-license.php

 *   http://www.gnu.org/licenses/gpl.html

 *

 * Revision: $Id: jquery.metadata.js 3640 2007-10-11 18:34:38Z pmclanahan $

 *

 */

(function($) {



$.extend({

  metadata : {

    defaults : {

      type: 'class',

      name: 'metadata',

      cre: /({.*})/,

      single: 'metadata'

    },

    setType: function( type, name ){

      this.defaults.type = type;

      this.defaults.name = name;

    },

    get: function( elem, opts ){

      var settings = $.extend({},this.defaults,opts);

      // check for empty string in single property

      if ( !settings.single.length ) settings.single = 'metadata';

      

      var data = $.data(elem, settings.single);

      // returned cached data if it already exists

      if ( data ) return data;

      

      data = "{}";

      

      var getData = function(data) {

        if(typeof data != "string") return data;

        

        if( data.indexOf('{') < 0 ) {

          data = eval("(" + data + ")");

        }

      }

      

      var getObject = function(data) {

        if(typeof data != "string") return data;

        

        data = eval("(" + data + ")");

        return data;

      }

      

      if ( settings.type == "html5" ) {

        var object = {};

        $( elem.attributes ).each(function() {

          var name = this.nodeName;

          if(name.match(/^data-/)) name = name.replace(/^data-/, '');

          else return true;

          object[name] = getObject(this.nodeValue);

        });

      } else {

        if ( settings.type == "class" ) {

          var m = settings.cre.exec( elem.className );

          if ( m )

            data = m[1];

        } else if ( settings.type == "elem" ) {

          if( !elem.getElementsByTagName ) return;

          var e = elem.getElementsByTagName(settings.name);

          if ( e.length )

            data = $.trim(e[0].innerHTML);

        } else if ( elem.getAttribute != undefined ) {

          var attr = elem.getAttribute( settings.name );

          if ( attr )

            data = attr;

        }

        object = getObject(data.indexOf("{") < 0 ? "{" + data + "}" : data);

      }

      

      $.data( elem, settings.single, object );

      return object;

    }

  }

});



/**

 * Returns the metadata object for the first member of the jQuery object.

 *

 * @name metadata

 * @descr Returns element's metadata object

 * @param Object opts An object contianing settings to override the defaults

 * @type jQuery

 * @cat Plugins/Metadata

 */

$.fn.metadata = function( opts ){

  return $.metadata.get( this[0], opts );

};



})(jQuery);





/*

 * jQuery validation plug-in 1.6

 *

 * 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);else if(element.parentNode.name in this.submitted)this.element(element.parentNode)},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).",number:"Please enter a valid number.",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, select, option",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.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",e);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),theregex=/\$?\{(\d+)\}/g;if(typeof message=="function"){message=message.call(this,rule.parameters,element);}else if(theregex.test(message)){message=jQuery.format(message.replace(theregex,'{$1}'),rule.parameters);}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){var name=this.idOrName(element);return this.errors().filter(function(){return $(this).attr('for')==name});},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();this.formSubmitted=false;}else if(!valid&&this.pendingRequest==0&&this.formSubmitted){$(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=false;}},previousValue:function(element){return $.data(element,"previousValue")||$.data(element,"previousValue",{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!=undefined?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 val=$(element).val();return val&&val.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]={};previous.originalMessage=this.settings.messages[element.name].remote;this.settings.messages[element.name].remote=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){validator.settings.messages[element.name].remote=previous.originalMessage;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={};var message=(previous.message=response||validator.defaultMessage(element,"remote"));errors[element.name]=$.isFunction(message)?message(value):message;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);},number: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(var 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){var target=$(param).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){$(element).valid();});return value==target.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);



/*

CUSTOM FORM ELEMENTS

Created by Ryan Fait (www.ryanfait.com)



The only things you may need to change in this file are the following

variables: checkboxHeight, radioHeight and selectWidth (lines 24, 25, 26)



The numbers you set for checkboxHeight and radioHeight should be one quarter

of the total height of the image want to use for checkboxes and radio

buttons. Both images should contain the four stages of both inputs stacked

on top of each other in this order: unchecked, unchecked-clicked,

checked, checked-clicked.

*/

var checkboxHeight = "25";

var radioHeight = "25";

var selectWidth = "190";



document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; } .disabled { opacity: 0.5; filter: alpha(opacity=50); }</style>');

var Custom = {

	init: function() {

		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;

		for(a = 0; a < inputs.length; a++) {

			if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className.indexOf("styled") != -1) {

				span[a] = document.createElement("span");

				span[a].className = inputs[a].type;



				if(inputs[a].checked == true) {

					if(inputs[a].type == "checkbox") {

						position = "0 -" + (checkboxHeight*2) + "px";

						span[a].style.backgroundPosition = position;

					} else {

						position = "0 -" + (radioHeight*2) + "px";

						span[a].style.backgroundPosition = position;

					}

				}

				inputs[a].parentNode.insertBefore(span[a], inputs[a]);

				inputs[a].onchange = Custom.clear;

				if(!inputs[a].getAttribute("disabled")) {

					span[a].onmousedown = Custom.pushed;

					span[a].onmouseup = Custom.check;

				} else {

					span[a].className = span[a].className += " disabled";

				}

			}

		}

		inputs = document.getElementsByTagName("select");

		for(a = 0; a < inputs.length; a++) {

			if(inputs[a].className.indexOf("styled") != -1) {

				option = inputs[a].getElementsByTagName("option");

				active = option[0].childNodes[0].nodeValue;

				textnode = document.createTextNode(active);

				for(b = 0; b < option.length; b++) {

					if(option[b].selected == true) {

						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);

					}

				}

				span[a] = document.createElement("span");

				span[a].className = "select";

				span[a].id = "select" + inputs[a].name;

				span[a].appendChild(textnode);

				inputs[a].parentNode.insertBefore(span[a], inputs[a]);

				if(!inputs[a].getAttribute("disabled")) {

					inputs[a].onchange = Custom.choose;

				} else {

					inputs[a].previousSibling.className = inputs[a].previousSibling.className += " disabled";

				}

			}

		}

		document.onmouseup = Custom.clear;

	},

	pushed: function() {

		element = this.nextSibling;

		if(element.checked == true && element.type == "checkbox") {

			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";

		} else if(element.checked == true && element.type == "radio") {

			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";

		} else if(element.checked != true && element.type == "checkbox") {

			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";

		} else {

			this.style.backgroundPosition = "0 -" + radioHeight + "px";

		}

	},

	check: function() {

		element = this.nextSibling;

		if(element.checked == true && element.type == "checkbox") {

			this.style.backgroundPosition = "0 0";

			element.checked = false;

		} else {

			if(element.type == "checkbox") {

				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";

			} else {

				this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";

				group = this.nextSibling.name;

				inputs = document.getElementsByTagName("input");

				for(a = 0; a < inputs.length; a++) {

					if(inputs[a].name == group && inputs[a] != this.nextSibling) {

						inputs[a].previousSibling.style.backgroundPosition = "0 0";

					}

				}

			}

			element.checked = true;

		}

	},

	clear: function() {

		inputs = document.getElementsByTagName("input");

		for(var b = 0; b < inputs.length; b++) {

			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className.indexOf("styled") != -1) {

				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";

			} else if(inputs[b].type == "checkbox" && inputs[b].className.indexOf("styled") != -1) {

				inputs[b].previousSibling.style.backgroundPosition = "0 0";

			} else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className.indexOf("styled") != -1) {

				inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";

			} else if(inputs[b].type == "radio" && inputs[b].className.indexOf("styled") != -1) {

				inputs[b].previousSibling.style.backgroundPosition = "0 0";

			}

		}

	},

	choose: function() {

		option = this.getElementsByTagName("option");

		for(d = 0; d < option.length; d++) {

			if(option[d].selected == true) {

				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;

			}

		}

	}

}





var BRK = new(function($){

	var ie 				= $.browser.msie;

	var ie6 			= ie && parseInt($.browser.version) == 6;

	var brk 			= this;

	brk.debugging 		= false;

	brk.logging 		= false;

	brk.cacheBust 		= false;

	brk.time 			= (new Date()).getTime();

	brk.language		= PHPVars.DefaultLanguage;

	brk.loader			= $('#ajax_loader');

	brk.COOKIE_name		= '__s_agevalidator';

	brk.COOKIE_options 	= { path: '/', expires: 10 };



	

	brk.info = function (msg) {

		if(window.console && brk.debugging) 

			//window.console.log("%s: %o", (typeof(msg) == "string") ? ("INFO: " + msg) : (msg), this);

			window.console.log((typeof(msg) == "string") ? ("INFO: " + msg) : (msg));

	};

	

	brk.showLoader = function(t) {

		if(!t) {

			t = {};

		}

		var f;

		if (!t.load_text) {

            var a = ["wondering", "thinking", "pondering", "debating", "speculating", "introspecting", "dreaming", "contemplating"];

            var i = Math.floor(Math.random() * a.length);

            f = a[i];

		} else {

			f = t.load_text;

		}

		$(brk.loader).show().text(f);

		

		return brk.loader;

	};

	

	brk.hideLoader = function() {

		brk.loader.hide();

	}

	

	brk.loadifyText = function(o){

		return $(o).each(function(){

			$(o).append('<span></span>');

			setInterval(function(){

				$('span', o)

					.empty()

					.animate({opacity: 1.0}, 300, function(){ $(this).html('.') })

					.animate({opacity: 1.0}, 300, function(){ $(this).html('..') })

					.animate({opacity: 1.0}, 300, function(){ $(this).html('...') })

			}, 1200);

		})

	};

	

	

	brk.showAgeValidator = function(){

		if ($.cookie(brk.COOKIE_name) === null) {

			brk.showModalAgeValidator($('#modal-age-validator'));

			brk.info('BRK.showAgeValidator (NO cookie found)');	

		} else {

			brk.hideModalAgeValidator;

			brk.info('BRK.hideAgeValidator (Cookie FOUND)');

		}

	};

	

	brk.hideAgeValidator = function(){

		//$.cookie('__s_agevalidator', true, { expires: 30, path: '/', domain: 'senzatie.com', secure: true });

		$.cookie(brk.COOKIE_name, true, brk.COOKIE_options);

		

		brk.loadifyText(brk.showLoader());

		$('<p class="ok"></p>').appendTo('#form-results').text('Bine ati venit!');

		setTimeout(brk.hideModalAgeValidator, 1000);

		brk.info('BRK.hideAgeValidator (Cookie SET)');

	}

	

	brk.showModalAgeValidator = function(o){

		if($.fn.modal)

			o.modal({

				close: false, 

				opacity: 85, 

				maxWidth: 650, 

				minHeight: 415,

				onShow: function(){

					//	customize dropdowns

					if($.fn.msDropDown)

						$('select', o).msDropDown({showIcon:false, rowHeight: 27, visibleRows: 3});

					

					//	custom checkbox

					window.onload = Custom.init;

					

					//	checker button hover state

					$('input[type="submit"]', o).bind("mouseenter",function(){

						$(this).addClass('hvr');

					}).bind("mouseleave",function(){

						$(this).removeClass('hvr');

					});

					

					//	form validator

					$.validator.addMethod("ageValidator", function(v, e, p) { 

						return $(o).ageValidation(p); 

					}, $.validator.format("Ne pare rau, trebuie sa ai peste <span>{0}</span> ani.")); 



					$('#agevalidator').validate({

						meta: 'validate',

						errorPlacement: function(error, element) {

							var results = $('#form-results');

							$("p.error", results).siblings().remove(); 

							error.prependTo(results); 

						},

						errorElement: 'p class="no-label error"',

						errorClass: "warning",

						success: "removed",

						submitHandler: function(form) {

							brk.hideAgeValidator();

							return false;

						}

					});

				}

			});

	};

	

	brk.hideModalAgeValidator = function(){

		brk.hideLoader();

		if($.fn.modal)

			$.modal.close();

		$('#modal-age-validator').remove();

	}

	

	brk.happyValentinesDay = function(o){

		if($.fn.modal)

			o.modal({

				opacity: 90, 

				maxWidth: 500, 

				minHeight: 579,

				onShow: function(){

					$('a.closing', o).click(function(){

						$.modal.close();

						return false;

					})

				}

			});

	}



	brk.firstMarch = function(o){

		if($.fn.modal)

			o.modal({

				opacity: 90, 

				maxWidth: 305, 

				minHeight: 405,

				onShow: function(){

					$('a.closing', o).click(function(){

						$.modal.close();

						return false;

					})

				}

			});

	}



	brk.defaultSettings = function(){

		//	info

		brk.info('BRK.defaultSettings');



		//	sets links with the rel of "blank" to open in a new window

		$('a[rel$="blank"]').attr('target', '_blank'); 

		

		//	site mood

		//setMood(); setInterval('setMood()', 5*60*1000)

	};



	brk.initWebChat = function(){

		//	info

		brk.info('BRK.initWebChat');

		

		//	tic tac

		var start = new Date();

		

		//	init webchat

		var flashvars = {

		  host: 						'hardcore.6667.eu',

		  accessKey: 					'0457e76304aa98ac5d68fee31d17d9cb',

		  rtmp: 						'rtmp.senzatie.com',

		  webcam: 						'yes',

		  nickselect: 					'yes',

		  nickServAuth: 				'yes',

		  //styleURL: 					'/webchat/yahoo.swf',

		  styleURL: 					'http://www.lightirc.com/styles/yahoo.swf',

		  showListButton: 				'no',

		  perform: 						'/ns set enforce on',

		  showRegisterNicknameButton: 	'yes',

		  showJoinPartMessages:			'no',
		  doubleClickForQuery: 			'yes',
		  showServerWindowButton: 		'yes',

		  language: 					'ro',

		  autojoin: 					'#Romania,#Trivia',

		  ident: 						start.getTime(),

		  realname: 					'senzatie.com chat client',

		  quitmsg:						'Chat online romanesc, www.senzatie.com'

		};

		var params = {

		  menu: 'false',

		  wmode: 'transparent'

		};

		var attributes = {};

		if( $('#webchat').length )

			//swfobject.embedSWF('/webchat/webchat.swf', 'webchat', '100%', '410', '9.0.0', '/temp/expressInstall.swf', flashvars, params, attributes);

			swfobject.embedSWF('http://www.lightirc.com/start/lightIRC.swf', 'webchat', '100%', '410', '9.0.0', '/temp/expressInstall.swf', flashvars, params, attributes);

			

	};



	brk.initWebChatXAT = function(){

		//	info

		brk.info('BRK.initWebChatXAT');

		

		//	init webchat

		var flashvars = {

		  id: '34037747',

		  gn: 'Senzatie',

		  rl: 'Romanian'

		};

		var params = {

		  menu: 'false',

		  wmode: 'transparent'

		};

		var attributes = {};

		if( $('#webchat').length )

			swfobject.embedSWF('http://www.xatech.com/web_gear/chat/chat.swf', 'webchat', '100%', '410', '9.0.0', '/temp/expressInstall.swf', flashvars, params, attributes);

	};

	

	brk.initWebRadio = function(){

		//	info

		brk.info('BRK.initWebRadio');

		

		//	init radioplayer

		var flashvars = {

		  repeat:		true,

		  autostart: 	true,

		  displayheight:0,

		  type:			'rtmp',

		  streamer:		'rtmp://80.86.106.136/live',

		  file:			'stream',

		  skin:			'http://www.kissfm.ro/player/kissfm_audio.swf',

		  bufferlength:	6

		};

		var params = {

		  menu:	'false',

		  wmode:'transparent'

		};

		var attributes = {};

		if( $('#webradio').length )

			swfobject.embedSWF('http://www.kissfm.ro/player/player_new.swf', 'webradio', '180', '26', '9.0.0', '/temp/expressInstall.swf', flashvars, params, attributes);

	};

	

	brk.switchLights = function(){

		//	info

		brk.info('BRK.switchLights');

		

		//	switching light

		$('strong', '#switcher').text('stinge lumina');

		$('#switcher').bind('click',function(){

			$('body').toggleClass('lightson');

			if($('body').hasClass('lightson'))

				$('strong',this).text('stinge lumina');

			else

				$('strong',this).text('aprinde lumina');

			return false;

		});

	};



	brk.Initialize = function(){

		brk.defaultSettings();

		brk.info('BRK.Initialize');

		brk.initWebChat();

		brk.switchLights();

		brk.initWebRadio();

		//brk.happyValentinesDay($('#modal-happy-valetines-day'));

		//brk.firstMarch($('#modal-march'));

		

		//brk.showAgeValidator();

	};

})(jQuery);





