/**
 * FusionCharts: Flash Player detection and Chart embedding.
 * Version 1.2.3F ( 22 November 2008) - Specialized for FusionChartsFREE 
 * 					Checking Flash Version >=6 and added updateChartXML() for FREE Charts.
 * Version: 1.2.3 (1st September, 2008) - Added Fix for % and & characters, scaled dimensions, fixes in to properly handling of double quotes and single quotes in setDataXML() function.
 * Version: 1.2.2 (10th July, 2008) - Added Fix for % scaled dimensions, fixes in setDataXML() and setDataURL() functions
 * Version: 1.2.1 (21st December, 2007) - Added setting up Transparent/opaque mode: setTransparent() function 
 * Version: 1.2 (1st November, 2007) - Added FORM fixes for IE 
 * Version: 1.1 (29th June, 2007) - Added Player detection, New conditional fixes for IE
 *
 * Morphed from SWFObject (http://blog.deconcept.com/swfobject/) under MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof infosoftglobal == "undefined") var infosoftglobal = new Object();
if(typeof infosoftglobal.FusionChartsUtil == "undefined") infosoftglobal.FusionChartsUtil = new Object();
infosoftglobal.FusionCharts = function(swf, id, w, h, debugMode, registerWithJS, c, scaleMode, lang, detectFlashVersion, autoInstallRedirect){
	if (!document.getElementById) { return; }
	
	//Flag to see whether data has been set initially
	this.initialDataSet = false;
	
	//Create container objects
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	
	//Set attributes for the SWF
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }

	w=w.toString().replace(/\%$/,"%25");
	if(w) { this.setAttribute('width', w); }
	h=h.toString().replace(/\%$/,"%25");
	if(h) { this.setAttribute('height', h); }

	
	//Set background color
	if(c) { this.addParam('bgcolor', c); }
	
	//Set Quality	
	this.addParam('quality', 'high');
	
	//Add scripting access parameter
	this.addParam('allowScriptAccess', 'always');
	
	//Pass width and height to be appended as chartWidth and chartHeight
	this.addVariable('chartWidth', w);
	this.addVariable('chartHeight', h);

	//Whether in debug mode
	debugMode = debugMode ? debugMode : 0;
	this.addVariable('debugMode', debugMode);
	//Pass DOM ID to Chart
	this.addVariable('DOMId', id);
	//Whether to registed with JavaScript
	registerWithJS = registerWithJS ? registerWithJS : 0;
	this.addVariable('registerWithJS', registerWithJS);
	
	//Scale Mode of chart
	scaleMode = scaleMode ? scaleMode : 'noScale';
	this.addVariable('scaleMode', scaleMode);
	
	//Application Message Language
	lang = lang ? lang : 'EN';
	this.addVariable('lang', lang);
	
	//Whether to auto detect and re-direct to Flash Player installation
	this.detectFlashVersion = detectFlashVersion?detectFlashVersion:1;
	this.autoInstallRedirect = autoInstallRedirect?autoInstallRedirect:1;
	
	//Ger Flash Player version 
	this.installedVer = infosoftglobal.FusionChartsUtil.getPlayerVersion();
	
	if (!window.opera && document.all && this.installedVer.major > 7) {
		// Only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
		infosoftglobal.FusionCharts.doPrepUnload = true;
	}
}

infosoftglobal.FusionCharts.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs.push(key +"="+ variables[key]);
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { 
			// netscape plugin architecture			
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"  ';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE			
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");			
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	setDataURL: function(strDataURL){
		//This method sets the data URL for the chart.
		//If being set initially
		if (this.initialDataSet==false){
			this.addVariable('dataURL',strDataURL);
			//Update flag
			this.initialDataSet = true;
		}else{
			//Else, we update the chart data using External Interface
			//Get reference to chart object
			var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));
			
			if (!chartObj.setDataURL)
			{
				__flash__addCallback(chartObj, "setDataURL");
			}
			
			chartObj.setDataURL(strDataURL);
		}
	},
	//This function :
	//fixes the double quoted attributes to single quotes
	//Encodes all quotes inside attribute values
	//Encodes % to %25 and & to %26;
	encodeDataXML: function(strDataXML){
		
			var regExpReservedCharacters=["\\$","\\+"];
			var arrDQAtt=strDataXML.match(/=\s*\".*?\"/g);
			if (arrDQAtt){
				for(var i=0;i<arrDQAtt.length;i++){
					var repStr=arrDQAtt[i].replace(/^=\s*\"|\"$/g,"");
					repStr=repStr.replace(/\'/g,"%26apos;");
					var strTo=strDataXML.indexOf(arrDQAtt[i]);
					var repStrr="='"+repStr+"'";
					var strStart=strDataXML.substring(0,strTo);
					var strEnd=strDataXML.substring(strTo+arrDQAtt[i].length);
					var strDataXML=strStart+repStrr+strEnd;
				}
			}
			
			strDataXML=strDataXML.replace(/\"/g,"%26quot;");
			strDataXML=strDataXML.replace(/%(?![\da-f]{2}|[\da-f]{4})/ig,"%25");
			strDataXML=strDataXML.replace(/\&/g,"%26");

			return strDataXML;

	},
	setDataXML: function(strDataXML){
		//If being set initially
		if (this.initialDataSet==false){
			//This method sets the data XML for the chart INITIALLY.
			this.addVariable('dataXML',this.encodeDataXML(strDataXML));
			//Update flag
			this.initialDataSet = true;
		}else{
			//Else, we update the chart data using External Interface
			//Get reference to chart object
			var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));
			chartObj.setDataXML(strDataXML);
		}
	},
	setTransparent: function(isTransparent){
		//Sets chart to transparent mode when isTransparent is true (default)
		//When no parameter is passed, we assume transparent to be true.
		if(typeof isTransparent=="undefined") {
			isTransparent=true;
		}			
		//Set the property
		if(isTransparent)
			this.addParam('WMode', 'transparent');
		else
			this.addParam('WMode', 'Opaque');
	},
	
	render: function(elementId){
		//First check for installed version of Flash Player - we need a minimum of 6
		if((this.detectFlashVersion==1) && (this.installedVer.major < 6)){
			if (this.autoInstallRedirect==1){
				//If we can auto redirect to install the player?
				var installationConfirm = window.confirm("You need Adobe Flash Player 6 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. Please click on Ok to install the same.");
				if (installationConfirm){
					window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
				}else{
					return false;
				}
			}else{
				//Else, do not take an action. It means the developer has specified a message in the DIV (and probably a link).
				//So, expect the developers to provide a course of way to their end users.
				//window.alert("You need Adobe Flash Player 8 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. ");
				return false;
			}			
		}else{
			//Render the chart
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			
			//Added <FORM> compatibility
			//Check if it's added in Mozilla embed array or if already exits 
			if(!document.embeds[this.getAttribute('id')] && !window[this.getAttribute('id')])
		      	window[this.getAttribute('id')]=document.getElementById(this.getAttribute('id')); 
				//or else document.forms[formName/formIndex][chartId]			
			return true;		
		}
	}
}

/* ---- detection functions ---- */
infosoftglobal.FusionChartsUtil.getPlayerVersion = function(){
	var PlayerVersion = new infosoftglobal.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new infosoftglobal.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ 
		//If Windows CE
		var axo = 1;
		var counter = 3;
		while(axo) {
			try {
				counter++;
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
				PlayerVersion = new infosoftglobal.PlayerVersion([counter,0,0]);
			} catch (e) {
				axo = null;
			}
		}
	} else { 
		// Win IE (non mobile)
		// Do minor version lookup in IE, but avoid Flash Player 6 crashing issues
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new infosoftglobal.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new infosoftglobal.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
infosoftglobal.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
// ------------ Fix for Out of Memory Bug in IE in FP9 ---------------//
/* Fix for video streaming bug */
infosoftglobal.FusionChartsUtil.cleanupSWFs = function() {
	var objects = document.getElementsByTagName("OBJECT");
	for (var i = objects.length - 1; i >= 0; i--) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
// Fixes bug in fp9
if (infosoftglobal.FusionCharts.doPrepUnload) {
	if (!infosoftglobal.unloadSet) {
		infosoftglobal.FusionChartsUtil.prepUnload = function() {
			__flash_unloadHandler = function(){};
			__flash_savedUnloadHandler = function(){};
			window.attachEvent("onunload", infosoftglobal.FusionChartsUtil.cleanupSWFs);
		}
		window.attachEvent("onbeforeunload", infosoftglobal.FusionChartsUtil.prepUnload);
		infosoftglobal.unloadSet = true;
	}
}
/* Add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}
/* Add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* Function to return Flash Object from ID */
infosoftglobal.FusionChartsUtil.getChartObject = function(id)
{
  var chartRef=null;
  if (navigator.appName.indexOf("Microsoft Internet")==-1) {
    if (document.embeds && document.embeds[id])
      chartRef = document.embeds[id]; 
	else
	chartRef  = window.document[id];
  }
  else {
    chartRef = window[id];
  }
  if (!chartRef)
	chartRef  = document.getElementById(id);
  
  return chartRef;
}
/*
 Function to update chart's data at client side (FOR FusionCharts vFREE and 2.x
*/
infosoftglobal.FusionChartsUtil.updateChartXML = function(chartId, strXML){
	//Get reference to chart object				
	var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(chartId);		
	//Set dataURL to null
	chartObj.SetVariable("_root.dataURL","");
	//Set the flag
	chartObj.SetVariable("_root.isNewData","1");
	//Set the actual data
	chartObj.SetVariable("_root.newData",strXML);
	//Go to the required frame
	chartObj.TGotoLabel("/", "JavaScriptHandler"); 
}


/* Aliases for easy usage */
var getChartFromId = infosoftglobal.FusionChartsUtil.getChartObject;
var updateChartXML = infosoftglobal.FusionChartsUtil.updateChartXML;
var FusionCharts = infosoftglobal.FusionCharts;
function UpdateAreaMap(form_id,e){var eventObj=(e)?e:event;if(typeof(eventObj.offsetX)!="undefined"){var x=eventObj.offsetX;var y=eventObj.offsetY;}
else{var x=eventObj.pageX-document.getElementById(eventObj.target.id).offsetLeft;var y=eventObj.pageY-document.getElementById(eventObj.target.id).offsetTop;}
var area_type=null;var form_obj=document.getElementById(form_id+"_form");for(var i=0;i<form_obj.length;i++){if(form_obj.elements[i].name=='Edit[area_type]'){if(form_obj.elements[i].type=='select'){area_type=form_obj.elements[i].options[form_obj.elements[i].selectedIndex].value;}
else{area_type=form_obj.elements[i].value;}}}
for(var i=0;i<form_obj.length;i++){if(form_obj.elements[i].name=='Edit[coordinates]'){if(form_obj.elements[i].value==''){form_obj.elements[i].value=x+','+y;}
else{switch(parseInt(area_type)){case 0:case 4:case 5:var coord=form_obj.elements[i].value.split(',');if(coord.length==2){form_obj.elements[i].value+=','+x+','+y;}
else{form_obj.elements[i].value=x+','+y;}
break;case 1:var coord=form_obj.elements[i].value.split(',');if(coord.length==2){var r=Math.round(Math.sqrt(Math.pow(Math.abs(coord[0]-x),2)+Math.pow(Math.abs(coord[1]-y),2)));form_obj.elements[i].value+=','+r;}
else{form_obj.elements[i].value=x+','+y;}
break;case 3:case 2:form_obj.elements[i].value+=','+x+','+y;break;}}}}}
function UpdateAreaImage(image_id,script_name,id_name,id,form_id,mode){var args=new Array();var area_type=null;var select_transparency=null;var select_outline=null;var thickness=null;var coord_count=0;if(mode){args[args.length]="Mode="+mode;}
else{args[args.length]="Mode=FileShow";}
args[args.length]=id_name+"="+id;if(form_id){args[args.length]="AreaId=-1";var form_obj=document.getElementById(form_id+"_form");for(var i=0;i<form_obj.length;i++){if(form_obj.elements[i].name=='Edit[area_type]'){if(form_obj.elements[i].type=='select'){area_type=form_obj.elements[i].options[form_obj.elements[i].selectedIndex].value;}
else{area_type=form_obj.elements[i].value;}
args[args.length]="area_type="+area_type;}
if(form_obj.elements[i].name=='Edit[coordinates]'){coord_count=form_obj.elements[i].value.split(',').length;args[args.length]="coordinates="+encodeURIComponent(form_obj.elements[i].value);}
if(form_obj.elements[i].name=='Edit[select_color]'){args[args.length]="select_color="+encodeURIComponent(form_obj.elements[i].value);}
if(form_obj.elements[i].name=='Edit[select_transparency]'){if(form_obj.elements[i].type=='select'){select_transparency=form_obj.elements[i].options[form_obj.elements[i].selectedIndex].value;}
else{select_transparency=form_obj.elements[i].value;}
args[args.length]="select_transparency="+select_transparency;}
if(form_obj.elements[i].name=='Edit[select_outline]'){if(form_obj.elements[i].type=='select'){select_outline=form_obj.elements[i].options[form_obj.elements[i].selectedIndex].value;}
else{select_outline=form_obj.elements[i].value;}
args[args.length]="select_outline="+select_outline;}
if(form_obj.elements[i].name=='Edit[thickness]'){if(form_obj.elements[i].type=='select'){thickness=form_obj.elements[i].options[form_obj.elements[i].selectedIndex].value;}
else{thickness=form_obj.elements[i].value;}
args[args.length]="thickness="+thickness;}}
if((area_type==0&&coord_count>3)||(area_type==1&&coord_count>2)||(area_type==2&&coord_count>5)||(area_type==3&&coord_count>3)||(area_type==4&&coord_count>3)||(area_type==5&&coord_count>3)){var img_obj=document.getElementById(image_id);if(img_obj){img_obj.src=script_name+'?'+args.join('&');}}}
else{var img_obj=document.getElementById(image_id);if(img_obj){img_obj.src=script_name+'?'+args.join('&');}}}
function ClearAreaMap(form_id){var form_obj=document.getElementById(form_id+"_form");for(var i=0;i<form_obj.length;i++){if(form_obj.elements[i].name=='Edit[coordinates]'){form_obj.elements[i].value='';}}}
function UpdateSelection(img_id,URL){var obj=document.getElementById(img_id);if(obj){var d=new Date();obj.src=URL+'&T='+d.getTime();}}
function blogEditPost(BlogId,BlogPostId){var obj=document.getElementById("BlogButtons");if(obj){if(BlogPostId==-1){UpdateContent("BlogNewPost","blog.php?Mode=BlogPostEdit&BlogId="+BlogId+"&BlogPostId=-1");}
else{UpdateContent("blog_post_"+BlogPostId,"blog.php?Mode=BlogPostEdit&BlogId="+BlogId+"&BlogPostId="+BlogPostId);}}
else{alert("Element with id='BlogButtons' could not be found");}}
function blogPostDelete_callback(resp,xmlhttp){if(resp.match(/DONE/)){HideWorking(xmlhttp.params["working"]);var blog=$("#blog_"+xmlhttp.params["BlogId"]);if(blog){$("#blog_post_"+xmlhttp.params["BlogPostId"]).remove();}}
else{UpdateContent_callback(resp,xmlhttp);}}
function blogDeletePost(BlogId,BlogPostId){var params={"BlogId":BlogId,"BlogPostId":BlogPostId};UpdateContent("blog_post_"+BlogPostId,"blog.php?Mode=BlogPostDelete&BlogId="+BlogId+"&BlogPostId="+BlogPostId,blogPostDelete_callback,params);}
function blogCancelEdit(BlogId,BlogPostId){if(BlogPostId==-1){UpdateContent("BlogNewPost","blog.php?Mode=BlogButtons&BlogId="+BlogId);}
else{UpdateContent("blog_post_"+BlogPostId,"blog.php?Mode=BlogPost&BlogPostId="+BlogPostId);}}
function blogSaveOnLoad(iframe,UpdateTarget){var obj=document.getElementById(iframe);if(obj){if(obj.contentDocument){var d=obj.contentDocument;}
else if(obj.contentWindow){var d=obj.contentWindow.document;}
else{var d=window.frames[iframe].document;}
if(d.location.href=="about:blank"){return;}
if(d.body.innerHTML.match(/DONE/)){eval(d.body.innerHTML)
if(BlogPostId&&BlogId){if(UpdateTarget=="BlogNewPost"){UpdateContent(UpdateTarget,"blog.php?Mode=BlogButtons&BlogId="+BlogId);var new_post=document.createElement('div');new_post.id="blog_post_"+BlogPostId;$("#blog_"+BlogId).prepend(new_post);UpdateContent(new_post.id,"blog.php?Mode=BlogPost&BlogPostId="+BlogPostId);}
else{UpdateContent(UpdateTarget,"blog.php?Mode=BlogPost&BlogPostId="+BlogPostId);}}
if(post_working){HideWorking(post_working);post_working=null;}}}}
function blogPublishPost(BlogId,BlogPostId,HidePost){UpdateContent("blog_post_"+BlogPostId,"blog.php?Mode=PublishBlogPost&BlogPostId="+BlogPostId+"&HidePost="+HidePost);}
function blogScrollToTop(pane_id,speed){$('#'+pane_id).scrollTo(0,speed);}
function blogScrollTo(pane_id,target_id,speed){window.setTimeout(function(){$('#'+pane_id).scrollTo($('#'+target_id),speed);},500);}
function blogShowComments_callback(resp,xmlhttp){HideWorking(xmlhttp.params["working"]);$("#post_comments_"+xmlhttp.params["BlogPostId"]).hide().html(resp).slideToggle('def');}
function blogShowComments(BlogId,BlogPostId){var obj=document.getElementById("post_comments_"+BlogPostId);if(obj){if(obj.innerHTML==''){var params={"BlogPostId":BlogPostId};UpdateContent("post_comments_"+BlogPostId,"blog.php?Mode=CommentList&BlogId="+BlogId+"&BlogPostId="+BlogPostId,blogShowComments_callback,params);}
else{$("#post_comments_"+BlogPostId).slideToggle('def');}}}
function blogSubmitComment(BlogPostId,captcha){if(captcha){var value=$('#new_comment_'+BlogPostId+'_form #Edit_captcha').val();var HTTPobj=new XMLHttp();var CaptchaValid=HTTPobj.GetJSON('captcha.php?Validate='+value+'&CaptchaId='+BlogPostId);if(!CaptchaValid){MsgBox('\'CAPTCHA\': The entered value does not match the image','Input error');SetFocus('new_comment_'+BlogPostId+'_form','Edit_captcha');}
else{ValidateForm('post_comments_'+BlogPostId,'blog.php?Mode=CommentSave','new_comment_'+BlogPostId,false,null,null,null,true);}}
else{ValidateForm('post_comments_'+BlogPostId,'blog.php?Mode=CommentSave','new_comment_'+BlogPostId,false,null,null,null,true);}}
function blogPreviewComment(BlogPostId){var id='post_comments_preview_'+BlogPostId;var cp=CreatePopUp(id,"StandardPopUp","body",'Preview Comment');var params={"popup_id":id};ValidateForm(id+'_Body','blog.php?Mode=CommentPreview','new_comment_'+BlogPostId,false,AdminPopup_callback,params,null,true);}//
// $Id: br_case.js,v 1.341 2010/07/29 06:03:55 frank Exp $
//

function UpdateAge() {
	var dob = document.getElementById("Edit_dob");
	var session_date = document.getElementById("Edit_session_date");
	if (dob && session_date) {
		var d = CheckDate(dob.value);
		var n = CheckDate(session_date.value);
		if (n && d) {
			var diff = n - d;
			if (diff > 0) {
				var age = document.getElementById("Edit_age");
				age.value = Math.round(diff / 86400 / 365 / 1000 * 10) / 10;
			}
		}
	}
//	SetFocus('case', '[Edit[gender]');
}

function UpdateTotal() {
	var qty = document.getElementById("Edit_ordered");
	var price = document.getElementById("Edit_price");
	var rush_fee = document.getElementById("Edit_rush_fee");
	var discount = document.getElementById("Edit_discount");
	var total_price = document.getElementById("Edit_total_price");
	if (qty && price && discount && rush_fee && total_price) {
		var p = parseFloat(price.value);
		var r = parseFloat(rush_fee.value);
		var d = parseFloat(discount.value);
		if (isNaN(p)) {
			p = 0;
		}
		if (isNaN(r)) {
			r = 0;
		}
		if (isNaN(d)) {
			d = 0;
		}
		total_price.value = number_format((parseInt(qty.value) * (p - d) + r).toFixed(2));
	}
}

function PatientNew() {
	ClearSession();
	ClearBox('patient_box', 'Patient', 'CaseBoxInput');
	UpdateContent('patient_box', 'case.php?Mode=PatientSearch');
	UpdateContent('work_area', 'case.php?Mode=PatientEdit&PatientId=-1');
}

function PatientSearch() {
	ClearSession();
	ClearBox('patient_box', 'Patient', 'CaseBoxInput');
	UpdateContent('patient_box', 'case.php?Mode=PatientSearch');
	ClearElement('work_area', ' ');
}

function PatientDoSearch() {
	ValidateForm('work_area', 'case.php?Mode=PatientQueue', 'search');
}

function SelectPatient(PatientId) {
	ClearSession();
	UpdateContent('patient_box', 'case.php?Mode=PatientDetail&PatientId=' + PatientId);
	var SessionId = null;
	var SessionList = GetSessionList(PatientId);
	if (SessionList && SessionList.length == 1) {
		SessionId = SessionList[0]['node_xid'];
	}
	if (SessionId) {
		SelectSession(PatientId, SessionId);
	}
	else {
		UpdateContent('session_box', 'case.php?Mode=SessionList&PatientId=' + PatientId);
	}
}

function UpdatePatient_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	if (xmlhttp.params["PatientId"] == -1 || xmlhttp.params["SessionCount"] == 0) {
		ClearSession();
		ClearBox('session_box', 'Session', 'CaseBoxInput');
		UpdateContent('work_area', 'case.php?Mode=SessionEdit&PatientId=' + xmlhttp.params["PatientId"] + '&SessionId=-1');
	}
	else {
		UpdateContent('work_area', 'case.php?Mode=PatientQueue');
	}
}

function UpdatePatient(PatientId, SessionCount) {
	var params = {"PatientId":PatientId, "SessionCount":SessionCount}
	ValidateForm('patient_box', 'case.php?Mode=PatientSave', 'patient_edit', false, UpdatePatient_callback, params);
}

function ValidatePatient_callback(resp, xmlhttp) {
	HideWorking(xmlhttp.params["working"]);
	if (resp == "NEW") {
		var params = {"PatientId":-1, "SessionCount":0}
		ClearBox('patient_box', 'Patient', 'CaseBoxContent');
		ValidateForm('patient_box', 'case.php?Mode=PatientSave', 'patient_edit', false, UpdatePatient_callback, params);
	}
	else {
		var response = eval(resp);
		if (confirm("Another patient with that name and date of birth already exists. Do you want to use that record?")) {
			ClearSession();
			ClearBox('patient_box', 'Patient', 'CaseBoxContent');
			UpdateContent('patient_box', 'case.php?Mode=PatientDetail&PatientId=' + response[0]);
			ClearBox('session_box', 'Session', 'CaseBoxInput');
			UpdateContent('work_area', 'case.php?Mode=SessionEdit&PatientId=' + response[0] + '&SessionId=' + response[1]);
		}
		else {
			if (confirm("Are you sure you want to create a duplicate patient record?")) {
				var params = {"PatientId":-1, "SessionCount":0}
				ClearBox('patient_box', 'Patient', 'CaseBoxContent');
				ValidateForm('patient_box', 'case.php?Mode=PatientSave', 'patient_edit', false, UpdatePatient_callback, params);
			}
		}
	}
}

function ValidatePatient() {
	ValidateForm('patient_box', 'case.php?Mode=PatientValidate', 'patient_edit', false, ValidatePatient_callback);
}

function DeletePatient(PatientId) {
	ClearSession();
	UpdateContent('work_area', 'case.php?Mode=PatientDelete&PatientId=' + PatientId);
	UpdateContent('patient_box', 'case.php?Mode=PatientSearch');
} 

function RemovePatient(PatientId) {
	ClearSession();
	UpdateContent('work_area', 'case.php?Mode=PatientRemove&PatientId=' + PatientId);
	UpdateContent('patient_box', 'case.php?Mode=PatientSearch');
}

function ClearElement(id, new_value, new_class) {
	if (new_class) {
		$('#' + id).attr('className', new_class);
	}
	$('#' + id).html(new_value).fadeIn(250);
}

function ClearBox(id, Title, new_class) {
	ClearElement(id, '<div id="' + id + '_title" class="Title">' + Title + '</div><div id="' + id + '_body" class="Body"></div>', new_class);
}

function ClearSession() {
	ClearBox('session_box', 'Session', 'CaseBoxInactive');
	ClearBox('doctor_box', 'Referring Doctor', 'CaseBoxInactive');
	ClearBox('file_box', 'Files', 'CaseBoxInactive');
	ClearBox('report_box', 'Report Files', 'CaseBoxInactive');
	ClearBox('purpose_box', 'Study Purpose', 'CaseBoxInactive');
	ClearBox('service_box', 'Services', 'CaseBoxInactive');
}

// TODO: Make Async request
function GetSessionList(PatientId) {
	var HTTPobj = new XMLHttp();
	return HTTPobj.GetJSON('case.php?Mode=SessionCount&PatientId=' + PatientId);
}

function SessionList(PatientId) {
	ClearSession();
	UpdateContent('session_box', 'case.php?Mode=SessionList&PatientId=' + PatientId);
}

function SelectSession(PatientId, SessionId) {
	UpdateContent('process', 'case.php?Mode=SessionProcess&PatientId=' + PatientId + '&SessionId=' + SessionId);
}

function UpdateSession_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	if (xmlhttp.params["SessionId"] == -1) {
		var SessionList = GetSessionList(xmlhttp.params["PatientId"]);
		if (SessionList && SessionList.length > 0) {
			var SessionId = SessionList[0]['node_xid'];
			SelectSession(xmlhttp.params["PatientId"], SessionId);
			DoctorSearch(SessionId);
		}
		else {
			UpdateContent('work_area', 'case.php?Mode=PatientQueue');
		}
	}
	else {
		SelectSession(xmlhttp.params["PatientId"], xmlhttp.params["SessionId"]);
		UpdateContent('work_area', 'case.php?Mode=PatientQueue');
	}
}

function UpdateSession(PatientId, SessionId) {
	var params = {"PatientId":PatientId, "SessionId":SessionId}
	ValidateForm('session_box', 'case.php?Mode=SessionSave', 'session_edit', false, UpdateSession_callback, params);
}

function ValidateVoucher(Cupon, ServiceId) {
	var HTTPobj = new XMLHttp();
	if (ServiceId) {
		var tmp = HTTPobj.GetJSON('case.php?Mode=ValidateVoucher&Cupon=' + Cupon + '&ServiceId=' + ServiceId);
	}
	else {
		var tmp = HTTPobj.GetJSON('case.php?Mode=ValidateVoucher&Cupon=' + Cupon);
	}
	if (tmp == 'Valid') {
		return true;
	}
	else {
		return false;
	}
}

function SubmitSession_callback(resp, xmlhttp) {
	HideWorking(xmlhttp.params["working"]);
	if (resp == "Success") {
		SelectSession(xmlhttp.params["PatientId"], xmlhttp.params["SessionId"]);
		UpdateContent('work_area', 'case.php?Mode=ServiceConfirm&PatientId=' + xmlhttp.params["PatientId"] + '&SessionId=' + xmlhttp.params["SessionId"]);
	}
	else {
		alert('Unable to submitt the case. Please try again.');
	}
}

function SubmitSession(PatientId, SessionId) {
	var ServicesOrdered = 0;
	var form_obj = document.getElementById('service_select_form');
	if (form_obj){
		for(var i = 0; i < form_obj.length; i++) {
			if (form_obj.elements[i].id == 'Edit_cupon') {
				if (form_obj.elements[i].value.length) {
					if (!ValidateVoucher(form_obj.elements[i].value)) {
						alert("The entered cupon code '" + form_obj.elements[i].value + "' is not valid");
						$(form_obj.elements[i]).focus().select();
						return;
					}
				}
			}
			switch (form_obj.elements[i].type) {
				case 'checkbox' :
					if (form_obj.elements[i].checked) {
						ServicesOrdered++;
					}
					break;
				defaut :
					ServicesOrdered += parseInt(form_obj.elements[i].value);
					break;
			}
		}
	}
	if (ServicesOrdered) {
		var params = {"PatientId":PatientId, "SessionId":SessionId}
		ValidateForm('work_area', 'case.php?Mode=ServiceUpdate', 'service_select', false, SubmitSession_callback, params);
	}
	else {
		alert('Please select at least one service before submitting.');
	}
}

function DeleteSession(SessionId) {
	ClearSession();
	UpdateContent('work_area', 'case.php?Mode=SessionDelete&SessionId=' + SessionId);
} 

function RemoveSession(SessionId) {
	ClearSession();
	UpdateContent('work_area', 'case.php?Mode=SessionRemove&SessionId=' + SessionId);
}

function MoveSession_callback(resp, xmlhttp) {
		UpdateContent_callback(resp, xmlhttp);
		ClearSession();
		SelectPatient(xmlhttp.params['PatientId']);
}

function MoveSession(SessionId, PatientId) {
	if (confirm('Are you sure you want to move the session to this patient?')) {
		var params = {"PatientId":PatientId};
		UpdateContent('work_area', 'case.php?Mode=SessionMoveSave&SessionId=' + SessionId + '&PatientId=' + PatientId, MoveSession_callback, params);
	}
}

function UpdateDoctor_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	ClearBox('doctor_box', 'Referring Doctor', 'CaseBoxContent');
	UpdateContent('doctor_box', 'case.php?Mode=DoctorDetail&SessionId=' + xmlhttp.params["SessionId"]);
	UpdateContent('service_box', 'case.php?Mode=ServiceList&SessionId=' + xmlhttp.params["SessionId"]);
}

function UpdateDoctor(SessionId) {
	var params = {"SessionId":SessionId};
	ValidateForm('work_area', '/case.php?Mode=EntitySave', 'entity', false, UpdateDoctor_callback, params);
}

function UpdateFile_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	switch (xmlhttp.params["FileType"]) {
		case 0 :
			UpdateContent('file_box', xmlhttp.params["Application"] + '?Mode=FileList&SessionId=' + xmlhttp.params["SessionId"]);
			UpdateContent('service_box', xmlhttp.params["Application"] + '?Mode=ServiceList&SessionId=' + xmlhttp.params["SessionId"]);
			break;
		case 1 :
			UpdateContent('report_box', xmlhttp.params["Application"] + '?Mode=ReportFileList&SessionId=' + xmlhttp.params["SessionId"]);
			break;
	}
}

function UpdateFile(SessionId, FileType, Application) {
	var params = {"SessionId":SessionId, "FileType":FileType, "Application":Application};
	ValidateForm('work_area', Application + '?Mode=FileSave', 'file_edit', false, UpdateFile_callback, params);
}

function CreateReportPDF(SessionId, Application) {
	var params = {"SessionId":SessionId, "FileType":1, "Application":Application};
	ValidateForm('work_area', Application + '?Mode=ReportPDF', 'report_edit', false, UpdateFile_callback, params);
}

function UpdateFilesOnLoad(iframe, SessionId) {
	var obj = document.getElementById(iframe);
	if (obj) {
        if (obj.contentDocument) {   
            var d = obj.contentDocument;   
        }
        else if (obj.contentWindow) {   
            var d = obj.contentWindow.document;   
        }
        else {   
            var d = window.frames[iframe].document;   
        }   
        if (d.location.href == "about:blank") {   
            return;   
        }
        if (d.body.innerHTML.match(/DONE/)) {
			UpdateContent('file_box', 'case.php?Mode=FileList&SessionId=' + SessionId);
			UpdateContent('work_area', 'case.php?Mode=PatientQueue');
			UpdateContent('service_box', 'case.php?Mode=ServiceList&SessionId=' + SessionId);
		}
	}
}

function DeleteFile(SessionId, FileId, FileType) {
	if (FileType) {
		UpdateContent('work_area', 'case_admin.php?Mode=FileDelete&SessionId=' + SessionId + '&FileId=' + FileId);
		UpdateContent('report_box', 'case_admin.php?Mode=ReportFileList&SessionId=' + SessionId);
	}
	else {
		UpdateContent('work_area', 'case.php?Mode=FileDelete&SessionId=' + SessionId + '&FileId=' + FileId);
		UpdateContent('file_box', 'case.php?Mode=FileList&SessionId=' + SessionId);
	}
	UpdateContent('service_box', 'case.php?Mode=ServiceList&SessionId=' + SessionId);
}

function DoctorSearch(SessionId) {
	ClearBox('doctor_box', 'Referring Doctor', 'CaseBoxInput');
	UpdateContent('doctor_box', 'case.php?Mode=DoctorSearch&SessionId=' + SessionId);
	UpdateContent('work_area', 'case.php?Mode=DoctorList&SessionId=' + SessionId);
}

function DoctorDoSearch(SessionId) {
	ValidateForm('work_area', 'case.php?Mode=DoctorList&SessionId=' + SessionId, 'search');
}

function SelectDoctor(SessionId, DoctorId) {
	if (DoctorId == -1) {
		UpdateContent('work_area', '/case.php?Mode=EntityEdit&EntityId=-1&SessionId=' + SessionId);
	}
	else {
		ClearBox('doctor_box', 'Referring Doctor', 'CaseBoxContent');
		UpdateContent('doctor_box', 'case.php?Mode=DoctorUpdate&SessionId=' + SessionId + '&DoctorId=' + DoctorId);
		UpdateContent('service_box', 'case.php?Mode=ServiceList&SessionId=' + SessionId);
		UpdateContent('work_area', 'case.php?Mode=PatientQueue');
	}
}

function UpdatePurpose_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	UpdateContent('purpose_box', 'case.php?Mode=PurposeList&SessionId=' + xmlhttp.params["SessionId"]);
	UpdateContent('service_box', 'case.php?Mode=ServiceList&SessionId=' + xmlhttp.params["SessionId"]);
}

function UpdatePurpose(SessionId, PurposeId) {
	var params = {"SessionId":SessionId};
	ValidateForm('work_area', 'case.php?Mode=PurposeSave', 'purpose_edit', false, UpdatePurpose_callback, params);
}

function DeletePurpose(SessionId, PurposeId) {
	UpdateContent('work_area', 'case.php?Mode=PurposeDelete&SessionId=' + SessionId + '&PurposeId=' + PurposeId);
	UpdateContent('purpose_box', 'case.php?Mode=PurposeList&SessionId=' + SessionId);
	UpdateContent('service_box', 'case.php?Mode=ServiceList&SessionId=' + SessionId);
}

function QueuePatientSearch() {
	QueueClearSession();
	ClearBox('patient_box', 'Patient', 'CaseBoxInput');
	UpdateContent('patient_box', 'case_admin.php?Mode=PatientSearch');
	ClearElement('work_area', ' ');
}

function QueuePatientDoSearch() {
	ValidateForm('work_area', 'case_admin.php?Mode=PatientList', 'search');
}

function QueueSelectPatient(PatientId) {
	ClearSession();
	UpdateContent('patient_box', 'case_admin.php?Mode=PatientDetail&PatientId=' + PatientId);
	var SessionId = null;
	var SessionList = GetSessionList(PatientId);
	if (SessionList && SessionList.length == 1) {
		SessionId = SessionList[0]['node_xid'];
	}
	if (SessionId) {
		QueueSelectSession(PatientId, SessionId);
	}
	else {
		UpdateContent('work_area', '/case_admin.php?Mode=PatientSessionList&PatientId=' + PatientId);
	}
}

function QueueUpdateSession_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	UpdateContent('work_area', 'case_admin.php?Mode=SessionQueue');
	if (xmlhttp.params["NewPatientId"] && xmlhttp.params["PatientId"] != xmlhttp.params["NewPatientId"]) {
		QueueSelectSession(xmlhttp.params["NewPatientId"], xmlhttp.params["SessionId"]);
	}
}

function QueueUpdateSession(PatientId, SessionId) {
	var patient_xid = $('#Edit_patient_xid option:selected');
	var params = {"PatientId":PatientId, "SessionId":SessionId, "NewPatientId":patient_xid.val()}
	ValidateForm('session_box', 'case_admin.php?Mode=SessionSave', 'session_edit', false, QueueUpdateSession_callback, params);
}

function QueueRemoveSession(SessionId) {
	QueueClearSession();
	UpdateContent('work_area', 'case_admin.php?Mode=SessionRemove&SessionId=' + SessionId);
}

function QueueSelectSession(PatientId, SessionId) {
	UpdateContent('process', 'case_admin.php?Mode=SessionProcess&PatientId=' + PatientId + '&SessionId=' + SessionId);
}

function QueueSelectDoctor(SessionId, DoctorId) {
	UpdateContent('doctor_box', 'case_admin.php?Mode=DoctorUpdate&SessionId=' + SessionId + '&DoctorId=' + DoctorId);
	UpdateContent('work_area', 'case_admin.php?Mode=SessionQueue');
}

function UpdateReportsOnLoad(iframe, SessionId, FileType) {
	var obj = document.getElementById(iframe);
	if (obj) {
        if (obj.contentDocument) {   
            var d = obj.contentDocument;   
        }
        else if (obj.contentWindow) {   
            var d = obj.contentWindow.document;   
        }
        else {   
            var d = window.frames[iframe].document;   
        }   
        if (d.location.href == "about:blank") {   
            return;   
        }
		if (d.body.innerHTML.match(/DONE/)) {
			if (FileType) {
				UpdateContent('report_box', 'case_admin.php?Mode=ReportFileList&SessionId=' + SessionId);
				UpdateContent('service_box', 'case_admin.php?Mode=ServiceList&SessionId=' + SessionId);
			}
			else {
				UpdateContent('file_box', 'case_admin.php?Mode=FileList&SessionId=' + SessionId);
			}
			UpdateContent('work_area', 'case_admin.php?Mode=SessionQueue');
		}
	}
}

//
// Case Admin specific functions
//
function QueueClearSession() {
	ClearBox('patient_box', 'Patient', 'CaseBoxInactive');
	ClearBox('session_box', 'Session', 'CaseBoxInactive');
	ClearBox('comment_box', 'Session Comments', 'CaseBoxInactive');
	ClearBox('doctor_box', 'Referring Doctor', 'CaseBoxInactive');
	ClearBox('file_box', 'Files', 'CaseBoxInactive');
	ClearBox('report_box', 'Report Files', 'CaseBoxInactive');
	ClearBox('purpose_box', 'Study Purpose', 'CaseBoxInactive');
	ClearBox('service_box', 'Services', 'CaseBoxInactive');
	ClearBox('log_box', 'Session Log', 'CaseBoxInactive');
}

function CancelSession(SessionId) {
	QueueClearSession();
	UpdateContent('work_area', 'case_admin.php?Mode=SessionCancel&SessionId=' + SessionId);
}

function CancelService_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	UpdateContent('service_box', 'case_admin.php?Mode=ServiceList&SessionId=' + xmlhttp.params["SessionId"]);
}

function CancelService(SessionId, ServiceId) {
	var params = {"SessionId": SessionId};
	UpdateContent('work_area', 'case_admin.php?Mode=ServiceCancel&SessionId=' + SessionId + '&ServiceId=' + ServiceId, CancelService_callback, params);
}

function SessionAssign(SessionId) {
	if (!CheckLinkSelected('session_assign', 'Link')) {
		alert('Please assign the session to one or more entities');
	}
	else if (ValidateForm('work_area', 'case_admin.php?Mode=SessionAssignSave', 'session_assign', true)) {
		UpdateContent('service_box', 'case_admin.php?Mode=ServiceList&SessionId=' + SessionId);
	}
}

function SessionComplete(PatientId, SessionId, ServiceId) {
	UpdateContent('work_area', 'case_admin.php?Mode=SessionComplete&SessionId=' + SessionId + '&ServiceId=' + ServiceId);
	QueueSelectSession(PatientId, SessionId);
}

function SessionCompleteSelected() {
	QueueClearSession();
	ValidateForm('session_groups_8_d', 'case_admin.php?Mode=SessionCompleteSelected', 'complete');
}

function QueueUpdateComment_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	UpdateContent('work_area', 'case_admin.php?Mode=SessionQueue');
}

function QueueUpdateComment(SessionId, CommentId) {
	var params = {"SessionId":SessionId, "CommentId":CommentId}
	ValidateForm('comment_box', 'case_admin.php?Mode=SessionCommentSave', 'comment_edit', false, QueueUpdateComment_callback, params);
}

function SessionServiceSave_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	UpdateContent('work_area', 'case_admin.php?Mode=SessionQueue');
}

function SessionServiceSave(ServiceId) {
	var form_obj = document.getElementById('session_service_form');
	if (form_obj){
		for(var i = 0; i < form_obj.length; i++) {
			if (form_obj.elements[i].id == 'Edit_cupon') {
				if (form_obj.elements[i].value.length) {
					if (!ValidateVoucher(form_obj.elements[i].value, ServiceId)) {
						alert("The entered cupon code '" + form_obj.elements[i].value + "' is not valid");
						$(form_obj.elements[i]).focus().select();
						return;
					}
				}
			}
		}
	}
	ValidateForm('service_box', 'case_admin.php?Mode=SessionServiceSave', 'session_service', false, SessionServiceSave_callback);
}

function QueueValidatePatient() {
	if (ValidateForm('patient_box', 'case_admin.php?Mode=PatientSave', 'patient_edit', true)) {
		UpdateContent('work_area', 'case_admin.php?Mode=SessionQueue');
	}
}

//
// Reporting tool
//

function SelectAddress_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	BoxShow('BRPopUp', true);
}

function SelectAddress(SessionId) {
	var BRPopUp = CreatePopUp("BRPopUp", "StandardPopUp", "work_area", "Select Address");
	var params = {"SessionId": SessionId};
	UpdateContent('BRPopUp_Body', 'br_case_report.php?Mode=SelectAddress&SessionId=' + SessionId, SelectAddress_callback, params);
}

function UpdateSelectedAddress(AddressId) {
	var ReportAddress = document.getElementById("ReportAddress");
	var Address = document.getElementById("address_" + AddressId);
	if (ReportAddress && Address) {
		ReportAddress.innerHTML = Address.innerHTML;
		var HiddenAddress = document.getElementById("Edit[address]");
		if (HiddenAddress) {
			HiddenAddress.value = ReportAddress.innerHTML;
		}
	}
	BoxHide("BRPopUp");
}

function SaveAddress() {
	var ReportAddress = document.getElementById("ReportAddress");
	var EditAddress = document.getElementById("EditAddress");
	if (EditAddress && ReportAddress) {
		ReportAddress.innerHTML = EditAddress.value.replace(new RegExp('\n', 'img'), '<br />');
		var HiddenAddress = document.getElementById("Edit[address]");
		if (HiddenAddress) {
			HiddenAddress.value = ReportAddress.innerHTML;
		}
		BoxHide("BRPopUp");
	}
}

function AddressEdit() {
	var ReportAddress = document.getElementById("ReportAddress");
	var address = ReportAddress.innerHTML.replace(new RegExp('<br ?\/?>', 'img'), '\n');
	var txt = '<textarea id="EditAddress" class="EditInputText" onfocus="this.className=\'EditInputTextFocus\';" onblur="this.className=\'EditInputText\';">' + address + '</textarea>';
	txt += '<br /><br /><div class="ButtonRow">';
	txt += CreateButton('Cancel', "javascript:BoxHide(\'BRPopUp\');");
	txt += CreateButton('Save', "javascript:SaveAddress();");
	txt += '</div>';
	var BRPopUp = CreatePopUp("BRPopUp", "StandardPopUp", "work_area", "Edit Address");
	UpdateStaticContent("BRPopUp_Body", txt);
	DecisionTree_callback();
}

function DecisionTree_callback(resp, xmlhttp) {
	if (xmlhttp) {
		UpdateContent_callback(resp, xmlhttp);
	}
	var obj = document.getElementById("process");
	if (obj) {
		var pos = GetPosition(obj, true);
		MoveTo("BRPopUp", pos[0], pos[1]);
	}
	BoxShow('BRPopUp');
}

function ReportBuilder(ReportId, ServiceId) {
	var BRPopUp = CreatePopUp("BRPopUp", "StandardPopUp", "work_area", "Decision Trees");
	var params = {"ReportId": ReportId, "ServiceId": ServiceId};
	UpdateContent('BRPopUp_Body', 'br_case_report.php?Mode=DecisionTree&ReportId=' + ReportId + '&ServiceId=' + ServiceId, DecisionTree_callback, params);
}

function DiagnosticWizard() {
	var BRPopUp = CreatePopUp("BRWizard", "StandardPopUp", "work_area", "Diagnostic Wizard");
	var params = {"popup_id":"BRWizard"};
	UpdateContent('BRWizard_Body', '/diagnostic_wizard.php', AdminPopup_callback, params);
}

function ReportTextBuilder(decision_xid) {
	var target = 'service_question_' + decision_xid + '_n';
	var BRPopUp = CreatePopUp('BRPopUp_' + decision_xid, "StandardPopUp", target, "Report Text");
	ValidateForm('BRPopUp_' + decision_xid + '_Body', 'br_service_admin.php?Mode=ReportText', 'question_edit');
	BoxShow('BRPopUp_' + decision_xid, true);
}

function GetHiddenBody(BodyId) {
	if (BodyId == "ReportScannedArea") {
		var HiddenBody = document.getElementById("Edit[scanned_area]");
	}
	else if (BodyId == "ReportSessionComment") {
		var HiddenBody = document.getElementById("Edit[session_comment]");
	}
	else if (BodyId == "ReportPurposeComment") {
		var HiddenBody = document.getElementById("Edit[purpose_comment]");
	}
	else if (BodyId == "ReportObservations") {
		var HiddenBody = document.getElementById("Edit[observations]");
	}
	else if (BodyId == "ReportImpressions") {
		var HiddenBody = document.getElementById("Edit[impressions]");
	}
	return HiddenBody;
}

function GetTitle(BodyId) {
	if (BodyId == "ReportScannedArea") {
		return "Edit Scanned Area";
	}
	else if (BodyId == "ReportObservations") {
		return "Edit Observations";
	}
	else if (BodyId == "ReportImpressions") {
		return "Edit Impressions";
	}
}

function AddReportText(TextId, BodyId) {
	if (TextId) {
		var ReportText = document.getElementById("ReportText_" + TextId).innerHTML;
	}
	else {
		var ReportTarget = document.getElementById("Edit[report_target]");
		if (ReportTarget) {
			switch(ReportTarget.selectedIndex) {
				case 0 :
					BodyId = "ReportScannedArea";
					break;
				case 1 :
					BodyId = "ReportObservations";
					break;
				case 2 :
					BodyId = "ReportImpressions";
					break;
			}
			var ReportText = document.getElementById("Edit[report_text]").value.replace(new RegExp('\n', 'img'), '<br />');
		}
	}
	var ReportBody = document.getElementById(BodyId);
	if (ReportBody && ReportText) {
		if (BodyId == "ReportObservations") {
			ReportBody.innerHTML += ReportText + "<br />";
		} else {
			ReportBody.innerHTML += ReportText + " ";
		}
		var HiddenBody = GetHiddenBody(BodyId);
		if (HiddenBody) {
			HiddenBody.value = ReportBody.innerHTML;
		}
	}
}

function SaveReportText(BodyId) {
	var ReportBody = document.getElementById(BodyId);
	var EditReportText = document.getElementById("EditReportText");
	if (EditReportText && ReportBody) {
		ReportBody.innerHTML = nicEditors.findEditor('EditReportText').getContent().replace(new RegExp('\n', 'img'), '<br />').replace(new RegExp('<p>|</p>', 'img'), '');
//		ReportBody.innerHTML = EditReportText.value.replace(new RegExp('\n', 'img'), '<br />');
		var HiddenBody = GetHiddenBody(BodyId);
		if (HiddenBody) {
			HiddenBody.value = ReportBody.innerHTML;
		}
		BoxHide("BRPopUp");
	}
}

function ClearReportText(BodyId) {
	var ReportBody = document.getElementById(BodyId);
	var EditReportText = document.getElementById("EditReportText");
	if (EditReportText && ReportBody) {
		ReportBody.innerHTML = "";
		var HiddenBody = GetHiddenBody(BodyId);
		if (HiddenBody) {
			HiddenBody.value = "";
		}
		BoxHide("BRPopUp");
	}
}

function ReportTextEdit(BodyId) {
	var ReportBody = document.getElementById(BodyId);
//	var body = ReportBody.innerHTML.replace(new RegExp('<br ?\/?>', 'img'), '\n');
	var body = ReportBody.innerHTML;
	var txt = '<textarea id="EditReportText" class="EditInputText" onfocus="this.className=\'EditInputTextFocus\';" onblur="this.className=\'EditInputText\';">' + body + '</textarea>';
	txt += '<br /><br /><div class="ButtonRow">';
	txt += CreateButton('Cancel', "javascript:BoxHide(\'BRPopUp\');");
	txt += CreateButton('Save', "javascript:SaveReportText(\'" + BodyId + "\');");
	txt += CreateButton('Clear', "javascript:ClearReportText(\'" + BodyId + "\');", 'Are you sure you want to clear this text?');
	txt += '</div>';
	var title = GetTitle(BodyId);
	var BRPopUp = CreatePopUp("BRPopUp", "StandardPopUp", "work_area", title);
	UpdateStaticContent("BRPopUp_Body", txt);
	DecisionTree_callback();
}

function AssignCheck(ServiceId) {
	var assign = $('#assign_' + ServiceId);
	var rush = $('#rush_' + ServiceId);
	if (rush && assign) {
		if (!assign.attr('checked')) {
			rush.attr('checked', false);
		}
	}
}

function RushCheck(ServiceId) {
	var assign = $('#assign_' + ServiceId);
	var rush = $('#rush_' + ServiceId);
	if (rush && assign) {
		if (rush.attr('checked')) {
			assign.attr('checked', true);
		}
	}
}

function ChartPopup_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	BoxShow('ChartPopUp', true);
}

function ChartPopup(Period, Year, Month) {
	var ChartPopUp = CreatePopUp("ChartPopUp", "StandardPopUp", "work_area", "Statistics");
	var params = {};
	UpdateContent('ChartPopUp_Body', 'case_admin.php?Mode=Statistics&Chart=1&Period=' + Period + '&Year=' + Year + '&Month=' + Month, ChartPopup_callback, params);
}

function EmailInvoice(InvoiceId) {
	var HTTPobj = new XMLHttp();
	if (confirm("Are you sure you want to send a copy of this invoice to all subscribers?")) {
		var tmp = HTTPobj.GetJSON('case_payments.php?Mode=InvoiceEmail&InvoiceId=' + InvoiceId);
		if (tmp.length) {
			alert(tmp[1]);
		}
	}
}

function PurposeSelectChange(obj) {
	var arrInfo = window['purpose_edit_info'];
	if (!arrInfo) {
		return true;
	}
	if (obj.options[obj.selectedIndex].value) {
		if (StudyPurposeMandatory[obj.options[obj.selectedIndex].value]) {
			arrInfo['comments'][COLUMN_FORMAT] |= FORMAT_MANDATORY;
		}
		else {
			arrInfo['comments'][COLUMN_FORMAT] &= ~FORMAT_MANDATORY;
		}
	}
}

var start_image=null;var current_image=null;var gallery_data=null;var gallery_elements=null;var slideshow_timer=null;var gallery_base_url='gallery.php';function ShowGalleryImage(){openWindow(gallery_base_url+"?Mode=Show&Id="+gallery_elements[current_image]['id']);}
function UpdateText(index){var obj=document.getElementById('GalleryElementNumber');if(obj){obj.innerHTML=index+1;}
obj=document.getElementById('GalleryElementName');if(obj){if(gallery_elements[index]['element_name']){obj.innerHTML=gallery_elements[index]['element_name'];}
else{obj.innerHTML='';}}
obj=document.getElementById('GalleryElementDescription');if(obj){if(gallery_elements[index]['description']){obj.innerHTML=gallery_elements[index]['description'];}
else{obj.innerHTML='';}}}
function GalleryFadeImage(obj,index){if(document.all){obj.style.filter="blendTrans(duration=2)";obj.style.filter="blendTrans(duration=crossFadeDuration)";obj.filters.blendTrans.Apply();}
obj.src=gallery_elements[index]['pic'].src;if(obj.onload){obj.onload=UpdateText(index);}
if(document.all){obj.filters.blendTrans.Play();}
if(!obj.onload){UpdateText(index);}}
function GalleryLoadImage(index,slideshow){var obj=document.getElementById('GalleryImage');if(obj){current_image=index;if(gallery_elements[index]['pic']){GalleryFadeImage(obj,index);}
else{gallery_elements[index]['pic']=new Image();gallery_elements[index]['pic'].src=gallery_base_url+"?Mode=Show&Scale=1&Id="+gallery_elements[index]['id']+"&w="+gallery_data['image_width']+"&h="+gallery_data['image_height'];GalleryFadeImage(obj,index);}
if(slideshow){slideshow_timer=window.setTimeout(GalleryNextSlide,gallery_data['slideshow_duration']*1000);}}}
function GalleryShowImage(index){GallerySlideshowStop();GalleryLoadImage(index+start_image);}
function GalleryFirstSlide(){GallerySlideshowStop();current_image=0;GalleryLoadImage(current_image);}
function GalleryLastSlide(){GallerySlideshowStop();current_image=gallery_elements.length-1;GalleryLoadImage(current_image);}
function GalleryShowSlide(step){GallerySlideshowStop();do{current_image+=step;}while(current_image>=0&&current_image<gallery_elements.length&&gallery_elements[current_image]['file_name']==null);if(current_image==gallery_elements.length){current_image=0;}
if(current_image<0){current_image=gallery_elements.length-1;}
GalleryLoadImage(current_image);}
function GalleryNextSlide(){do{current_image++;}while(current_image<gallery_elements.length&&gallery_elements[current_image]['file_name']==null);if(current_image==gallery_elements.length){current_image=0;}
GalleryLoadImage(current_image,true);}
function GallerySlideshow(){if(slideshow_timer){GallerySlideshowStop();}
else{if(!gallery_data['slideshow_duration']){gallery_data['slideshow_duration']=1;}
slideshow_timer=window.setTimeout(GalleryNextSlide,gallery_data['slideshow_duration']*500);var obj=document.getElementById('GalleryStartStop_center');if(obj){obj.innerHTML=obj.innerHTML.replace("Start","Stop");$('#GalleryStartStop').removeClass('Start').addClass('Stop');}}}
function GallerySlideshowStop(){if(slideshow_timer){window.clearTimeout(slideshow_timer);slideshow_timer=null;}
var obj=document.getElementById('GalleryStartStop_center');if(obj){obj.innerHTML=obj.innerHTML.replace("Stop","Start");$('#GalleryStartStop').removeClass('Stop').addClass('Start');}}
function GalleryScrollImage(step){start_image+=step;if(start_image>gallery_elements.length-gallery_data['thumbs']){start_image=gallery_elements.length-gallery_data['thumbs'];}
if(start_image<0){start_image=0;}
for(var i=0;i<gallery_data['thumbs'];i++){if(start_image+i<gallery_elements.length){var id=gallery_elements[start_image+i]['id'];var obj=document.getElementById('thumb_'+i);if(obj){obj.src=gallery_base_url+'?Mode=Show&Id='+id+'&w='+gallery_data['thumb_width']+'&h='+gallery_data['thumb_height'];}}}}
function GalleryScrollFirst(){start_image=0;GalleryScrollImage(0);}
function GalleryScrollLast(){start_image=gallery_elements.length-gallery_data['thumbs'];GalleryScrollImage(0);}
function GalleryUpload_callback(resp,xmlhttp){UpdateContent_callback(resp,xmlhttp);BoxShow('GalleryPopUp',true);}
function GalleryUpload(GalleryId,ParentId,GalleryName){var GalleryPopUp=CreatePopUp("GalleryPopUp","StandardPopUp","Main","Upload to "+GalleryName);var params={"GalleryId":GalleryId,"ParentId":ParentId};UpdateContent('GalleryPopUp_Body',gallery_base_url+'?Mode=Upload&GalleryId='+GalleryId+"&ParentId="+ParentId,GalleryUpload_callback,params);}
if(window['google']){google.load("maps","2.x");}
function MapAddress(id,address){var map=new GMap2(document.getElementById(id));var geocoder=new GClientGeocoder();geocoder.getLatLng(address,function(point){if(!point){alert(address+" not found");}else{map.setCenter(point,13);var marker=new GMarker(point);map.addOverlay(marker);marker.openInfoWindowHtml(address);}});map.addControl(new GLargeMapControl());}
(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o<i;o++)e(a[o],b,f?d.call(a[o],o,e(a[o],b)):d,j);return a}return i?e(a[0],b):w}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function na(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function oa(a){var b,d=[],f=[],e=arguments,j,i,o,k,n,r;i=c.data(this,"events");if(!(a.liveFired===this||!i||!i.live||a.button&&a.type==="click")){a.liveFired=this;var u=i.live.slice(0);for(k=0;k<u.length;k++){i=u[k];i.origType.replace(O,"")===a.type?f.push(i.selector):u.splice(k--,1)}j=c(a.target).closest(f,a.currentTarget);n=0;for(r=j.length;n<r;n++)for(k=0;k<u.length;k++){i=u[k];if(j[n].selector===i.selector){o=j[n].elem;f=null;if(i.preType==="mouseenter"||i.preType==="mouseleave")f=c(a.relatedTarget).closest(i.selector)[0];if(!f||f!==o)d.push({elem:o,handleObj:i})}}n=0;for(r=d.length;n<r;n++){j=d[n];a.currentTarget=j.elem;a.data=j.handleObj.data;a.handleObj=j.handleObj;if(j.handleObj.origHandler.apply(j.elem,e)===false){b=false;break}}return b}}function pa(a,b){return"live."+(a&&a!=="*"?a+".":"")+b.replace(/\./g,"`").replace(/ /g,"&")}function qa(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function ra(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var j in f)for(var i in f[j])c.event.add(this,j,f[j][i],f[j][i].data)}}})}function sa(a,b,d){var f,e,j;b=b&&b[0]?b[0].ownerDocument||b[0]:s;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===s&&!ta.test(a[0])&&(c.support.checkClone||!ua.test(a[0]))){e=true;if(j=c.fragments[a[0]])if(j!==1)f=j}if(!f){f=b.createDocumentFragment();c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=j?f:1;return{fragment:f,cacheable:e}}function K(a,b){var d={};c.each(va.concat.apply([],va.slice(0,b)),function(){d[this]=a});return d}function wa(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Ra=A.jQuery,Sa=A.$,s=A.document,T,Ta=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/,Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&&(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this,a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b==="find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(j in e){i=a[j];o=e[j];if(a!==o)if(f&&o&&(c.isPlainObject(o)||c.isArray(o))){i=i&&(c.isPlainObject(i)||c.isArray(i))?i:c.isArray(o)?[]:{};a[j]=c.extend(f,i,o)}else if(o!==w)a[j]=o}return a};c.extend({noConflict:function(a){A.$=Sa;if(a)A.jQuery=Ra;return c},isReady:false,ready:function(){if(!c.isReady){if(!s.body)return setTimeout(c.ready,13);c.isReady=true;if(Q){for(var a,b=0;a=Q[b++];)a.call(s,c);Q=null}c.fn.triggerHandler&&c(s).triggerHandler("ready")}},bindReady:function(){if(!xa){xa=true;if(s.readyState==="complete")return c.ready();if(s.addEventListener){s.addEventListener("DOMContentLoaded",L,false);A.addEventListener("load",c.ready,false)}else if(s.attachEvent){s.attachEvent("onreadystatechange",L);A.attachEvent("onload",c.ready);var a=false;try{a=A.frameElement==null}catch(b){}s.documentElement.doScroll&&a&&ma()}}},isFunction:function(a){return $.call(a)==="[object Function]"},isArray:function(a){return $.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||$.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!aa.call(a,"constructor")&&!aa.call(a.constructor.prototype,"isPrototypeOf"))return false;var b;for(b in a);return b===w||aa.call(a,b)},isEmptyObject:function(a){for(var b in a)return false;return true},error:function(a){throw a;},parseJSON:function(a){if(typeof a!=="string"||!a)return null;a=c.trim(a);if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return A.JSON&&A.JSON.parse?A.JSON.parse(a):(new Function("return "+
a))();else c.error("Invalid JSON: "+a)},noop:function(){},globalEval:function(a){if(a&&Va.test(a)){var b=s.getElementsByTagName("head")[0]||s.documentElement,d=s.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(s.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,j=a.length,i=j===w||c.isFunction(a);if(d)if(i)for(f in a){if(b.apply(a[f],d)===false)break}else for(;e<j;){if(b.apply(a[e++],d)===false)break}else if(i)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=a[0];e<j&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Wa,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ba.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=0,f=b.length;d<f;d++)if(b[d]===a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==w;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,j=a.length;e<j;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,j=0,i=a.length;j<i;j++){e=b(a[j],j,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b==="string"){d=a;a=d[b];b=w}else if(b&&!c.isFunction(b)){d=b;b=w}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},uaMatch:function(a){a=a.toLowerCase();a=/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||!/compatible/.test(a)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},browser:{}});P=c.uaMatch(P);if(P.browser){c.browser[P.browser]=true;c.browser.version=P.version}if(c.browser.webkit)c.browser.safari=true;if(ya)c.inArray=function(a,b){return ya.call(b,a)};T=c(s);if(s.addEventListener)L=function(){s.removeEventListener("DOMContentLoaded",L,false);c.ready()};else if(s.attachEvent)L=function(){if(s.readyState==="complete"){s.detachEvent("onreadystatechange",L);c.ready()}};(function(){c.support={};var a=s.documentElement,b=s.createElement("script"),d=s.createElement("div"),f="script"+J();d.style.display="none";d.innerHTML="   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected,parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent=false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n=s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando];else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i,cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className){for(var j=" "+e.className+" ",i=e.className,o=0,k=b.length;o<k;o++)if(j.indexOf(" "+b[o]+" ")<0)i+=" "+b[o];e.className=c.trim(i)}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(k){var n=c(this);n.removeClass(a.call(this,k,n.attr("class")))});if(a&&typeof a==="string"||a===w)for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var j=(" "+e.className+" ").replace(Aa," "),i=0,o=b.length;i<o;i++)j=j.replace(" "+b[i]+" "," ");e.className=c.trim(j)}else e.className=""}return this},toggleClass:function(a,b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var j=c(this);j.toggleClass(a.call(this,e,j.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,j=0,i=c(this),o=b,k=a.split(ca);e=k[j++];){o=f?o:!i.hasClass(e);i[o?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(Aa," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j<d;j++){var i=e[j];if(i.selected){a=c(i).val();if(b)return a;f.push(a)}}return f}if(Ba.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Za,"")}return w}var o=c.isFunction(a);return this.each(function(k){var n=c(this),r=a;if(this.nodeType===1){if(o)r=a.call(this,k,n.val());if(typeof r==="number")r+="";if(c.isArray(r)&&Ba.test(this.type))this.checked=c.inArray(n.val(),r)>=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g,function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split(".");k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a),C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B<r.length;B++){u=r[B];if(d.guid===u.guid){if(i||k.test(u.namespace)){f==null&&r.splice(B--,1);n.remove&&n.remove.call(a,u)}if(f!=null)break}}if(r.length===0||f!=null&&r.length===1){if(!n.teardown||n.teardown.call(a,o)===false)Ca(a,e,z.handle);delete C[e]}}else for(var B=0;B<r.length;B++){u=r[B];if(i||k.test(u.namespace)){c.event.remove(a,n,u.handler,B);r.splice(B--,1)}}}if(c.isEmptyObject(C)){if(b=z.handle)b.elem=null;delete z.events;delete z.handle;c.isEmptyObject(z)&&c.removeData(a)}}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&&f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e<j;e++){var i=d[e];if(b||f.test(i.namespace)){a.handler=i.handler;a.data=i.data;a.handleObj=i;i=i.handler.apply(this,arguments);if(i!==w){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||s;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=s.documentElement;d=s.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==w)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a){c.event.add(this,a.origType,c.extend({},a,{handler:oa}))},remove:function(a){var b=true,d=a.origType.replace(O,"");c.each(c.data(this,"events").live||[],function(){if(d===this.origType.replace(O,""))return b=false});b&&c.event.remove(this,a.origType,oa)}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};var Ca=s.removeEventListener?function(a,b,d){a.removeEventListener(b,d,false)}:function(a,b,d){a.detachEvent("on"+b,d)};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,isImmediatePropagationStopped:Y};var Da=function(a){var b=a.relatedTarget;try{for(;b&&b!==this;)b=b.parentNode;if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}}catch(d){}},Ea=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ea:Da,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ea:Da)}}});if(!c.support.submitBubbles)c.event.special.submit={setup:function(){if(this.nodeName.toLowerCase()!=="form"){c.event.add(this,"click.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="submit"||d==="image")&&c(b).closest("form").length)return na("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="text"||d==="password")&&c(b).closest("form").length&&a.keyCode===13)return na("submit",this,arguments)})}else return false},teardown:function(){c.event.remove(this,".specialSubmit")}};if(!c.support.changeBubbles){var da=/textarea|input|select/i,ea,Fa=function(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j<o;j++)c.event.add(this[j],d,i,f)}return this}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&!a.preventDefault)for(var d in a)this.unbind(d,a[d]);else{d=0;for(var f=this.length;d<f;d++)c.event.remove(this[d],a,b)}return this},delegate:function(a,b,d,f){return this.live(b,d,f,a)},undelegate:function(a,b,d){return arguments.length===0?this.unbind("live"):this.die(b,null,d,a)},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var Ga={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};c.each(["live","die"],function(a,b){c.fn[b]=function(d,f,e,j){var i,o=0,k,n,r=j||this.selector,u=j?this:c(this.context);if(c.isFunction(f)){e=f;f=w}for(d=(d||"").split(" ");(i=d[o++])!=null;){j=O.exec(i);k="";if(j){k=j[0];i=i.replace(O,"")}if(i==="hover")d.push("mouseenter"+k,"mouseleave"+k);else{n=i;if(i==="focus"||i==="blur"){d.push(Ga[i]+k);i+=k}else i=(Ga[i]||i)+k;b==="live"?u.each(function(){c.event.add(this,pa(i,r),{data:f,selector:r,handler:e,origType:i,origHandler:e,preType:n})}):u.unbind(pa(i,r),e)}}return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){c.fn[b]=function(d){return d?this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});A.attachEvent&&!A.addEventListener&&A.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});(function(){function a(g){for(var h="",l,m=0;g[m];m++){l=g[m];if(l.nodeType===3||l.nodeType===4)h+=l.nodeValue;else if(l.nodeType!==8)h+=a(l.childNodes)}return h}function b(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1&&!p){t.sizcache=l;t.sizset=q}if(t.nodeName.toLowerCase()===h){y=t;break}t=t[g]}m[q]=y}}}function d(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1){if(!p){t.sizcache=l;t.sizset=q}if(typeof h!=="string"){if(t===h){y=true;break}}else if(k.filter(h,[t]).length>0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift();t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D||g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};k.matches=function(g,h){return k(g,null,null,h)};k.find=function(g,h,l){var m,q;if(!g)return[];for(var p=0,v=n.order.length;p<v;p++){var t=n.order[p];if(q=n.leftMatch[t].exec(g)){var y=q[1];q.splice(1,1);if(y.substr(y.length-1)!=="\\"){q[1]=(q[1]||"").replace(/\\/g,"");m=n.find[t](q,h,l);if(m!=null){g=g.replace(n.match[t],"");break}}}}m||(m=h.getElementsByTagName("*"));return{set:m,expr:g}};k.filter=function(g,h,l,m){for(var q=g,p=[],v=h,t,y,S=h&&h[0]&&x(h[0]);g&&h.length;){for(var H in n.filter)if((t=n.leftMatch[H].exec(g))!=null&&t[2]){var M=n.filter[H],I,D;D=t[1];y=false;t.splice(1,1);if(D.substr(D.length-
1)!=="\\"){if(v===p)p=[];if(n.preFilter[H])if(t=n.preFilter[H](t,v,l,p,m,S)){if(t===true)continue}else y=I=true;if(t)for(var U=0;(D=v[U])!=null;U++)if(D){I=M(D,t,U,v);var Ha=m^!!I;if(l&&I!=null)if(Ha)y=true;else v[U]=false;else if(Ha){p.push(D);y=true}}if(I!==w){l||(v=p);g=g.replace(n.match[H],"");if(!y)return[];break}}}if(g===q)if(y==null)k.error(g);else break;q=g}return v};k.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var n=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},relative:{"+":function(g,h){var l=typeof h==="string",m=l&&!/\W/.test(h);l=l&&!m;if(m)h=h.toLowerCase();m=0;for(var q=g.length,p;m<q;m++)if(p=g[m]){for(;(p=p.previousSibling)&&p.nodeType!==1;);g[m]=l||p&&p.nodeName.toLowerCase()===h?p||false:p===h}l&&k.filter(h,g,true)},">":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m<q;m++){var p=g[m];if(p){l=p.parentNode;g[m]=l.nodeName.toLowerCase()===h?l:false}}}else{m=0;for(q=g.length;m<q;m++)if(p=g[m])g[m]=l?p.parentNode:p.parentNode===h;l&&k.filter(h,g,true)}},"":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("parentNode",h,m,g,p,l)},"~":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("previousSibling",h,m,g,p,l)}},find:{ID:function(g,h,l){if(typeof h.getElementById!=="undefined"&&!l)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var l=[];h=h.getElementsByName(g[1]);for(var m=0,q=h.length;m<q;m++)h[m].getAttribute("name")===g[1]&&l.push(h[m]);return l.length===0?null:l}},TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,l,m,q,p){g=" "+g[1].replace(/\\/g,"")+" ";if(p)return g;p=0;for(var v;(v=h[p])!=null;p++)if(v)if(q^(v.className&&(" "+v.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m,g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return h<l[3]-0},gt:function(g,h,l){return h>l[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=h[3];l=0;for(m=h.length;l<m;l++)if(h[l]===g)return false;return true}else k.error("Syntax error, unrecognized expression: "+q)},CHILD:function(g,h){var l=h[1],m=g;switch(l){case"only":case"first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(l==="first")return true;m=g;case"last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case"nth":l=h[2];var q=h[3];if(l===1&&q===0)return true;h=h[0];var p=g.parentNode;if(p&&(p.sizcache!==h||!g.nodeIndex)){var v=0;for(m=p.firstChild;m;m=m.nextSibling)if(m.nodeType===1)m.nodeIndex=++v;p.sizcache=h}g=g.nodeIndex-q;return l===0?g===0:g%l===0&&g/l>=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m==="="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g,h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l<m;l++)h.push(g[l]);else for(l=0;g[l];l++)h.push(g[l]);return h}}var B;if(s.documentElement.compareDocumentPosition)B=function(g,h){if(!g.compareDocumentPosition||!h.compareDocumentPosition){if(g==h)i=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===h?0:1;if(g===0)i=true;return g};else if("sourceIndex"in s.documentElement)B=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)i=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)i=true;return g};else if(s.createRange)B=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)i=true;return g.ownerDocument?-1:1}var l=g.ownerDocument.createRange(),m=h.ownerDocument.createRange();l.setStart(g,0);l.setEnd(g,0);m.setStart(h,0);m.setEnd(h,0);g=l.compareBoundaryPoints(Range.START_TO_END,m);if(g===0)i=true;return g};(function(){var g=s.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&&q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML="<a href='#'></a>";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}();(function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}:function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q<p;q++)k(g,h[q],l);return k.filter(m,l)};c.find=k;c.expr=k.selectors;c.expr[":"]=c.expr.filters;c.unique=k.uniqueSort;c.text=a;c.isXMLDoc=x;c.contains=E})();var eb=/Until$/,fb=/^(?:parents|prevUntil|prevAll)/,gb=/,/;R=Array.prototype.slice;var Ia=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,j){return!!b.call(e,j,e)===d});else if(b.nodeType)return c.grep(a,function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Ua.test(b))return c.filter(b,f,!d);else b=c.filter(b,f)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;c.find(a,this[f],b);if(f>0)for(var j=d;j<b.length;j++)for(var i=0;i<d;i++)if(b[i]===b[j]){b.splice(j--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Ia(this,a,false),"not",a)},filter:function(a){return this.pushStack(Ia(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j={},i;if(f&&a.length){e=0;for(var o=a.length;e<o;e++){i=a[e];j[i]||(j[i]=c.expr.match.POS.test(i)?c(i,b||this.context):i)}for(;f&&f.ownerDocument&&f!==b;){for(i in j){e=j[i];if(e.jquery?e.index(f)>-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/<tbody/i,jb=/<|&#?\w+;/,ta=/<script|<object|<embed|<option|<style/i,ua=/checked\s*(?:[^=]|=\s*.checked.)/i,Ma=function(a,b,d){return hb.test(d)?a:b+"></"+d+">"},F={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja,""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}}else c.isFunction(a)?this.each(function(e){var j=c(this),i=j.html();j.empty().append(function(){return a.call(this,e,i)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=c(this),f=d.html();d.replaceWith(a.call(this,b,f))});if(typeof a!=="string")a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(u){return c.nodeName(u,"table")?u.getElementsByTagName("tbody")[0]||u.appendChild(u.ownerDocument.createElement("tbody")):u}var e,j,i=a[0],o=[],k;if(!c.support.checkClone&&arguments.length===3&&typeof i==="string"&&ua.test(i))return this.each(function(){c(this).domManip(a,b,d,true)});if(c.isFunction(i))return this.each(function(u){var z=c(this);a[0]=i.call(this,u,b?z.html():w);z.domManip(a,b,d)});if(this[0]){e=i&&i.parentNode;e=c.support.parentNode&&e&&e.nodeType===11&&e.childNodes.length===this.length?{fragment:e}:sa(a,this,o);k=e.fragment;if(j=k.childNodes.length===1?(k=k.firstChild):k.firstChild){b=b&&c.nodeName(j,"tr");for(var n=0,r=this.length;n<r;n++)d.call(b?f(this[n],j):this[n],n>0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{e=0;for(var j=d.length;e<j;e++){var i=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["",""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]==="<table>"&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e=c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]?c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=/<script(.|\s)*?\/script>/gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!=="string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("<div />").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)?"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B=false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since",c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E||d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x);g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(la[d])f=la[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a||a===0)return this.animate(K("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(K("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var j=c.extend({},e),i,o=this.nodeType===1&&c(this).is(":hidden"),k=this;for(i in a){var n=i.replace(ia,ja);if(i!==n){a[n]=a[i];delete a[i];i=n}if(a[i]==="hide"&&o||a[i]==="show"&&!o)return j.complete.call(this);if((i==="height"||i==="width")&&this.style){j.display=c.css(this,"display");j.overflow=this.style.overflow}if(c.isArray(a[i])){(j.specialEasing=j.specialEasing||{})[i]=a[i][1];a[i]=a[i][0]}}if(j.overflow!=null)this.style.overflow="hidden";j.curAnim=c.extend({},a);c.each(a,function(r,u){var z=new c.fx(k,j,r);if(Ab.test(u))z[u==="toggle"?o?"show":"hide":u](a);else{var C=Bb.exec(u),B=z.cur(true)||0;if(C){u=parseFloat(C[2]);var E=C[3]||"px";if(E!=="px"){k.style[r]=(u||1)+E;B=(u||1)/z.cur(true)*B;k.style[r]=B+E}if(C[1])u=(C[1]==="-="?-1:1)*u+B;z.custom(B,u,E)}else z.custom(B,u,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration==="number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||c.fx.stop()},stop:function(){clearInterval(W);W=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in s.documentElement?function(a){var b=this[0];if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=this[0];if(a)return this.each(function(r){c.offset.setOffset(this,a,r)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=b,e=b.ownerDocument,j,i=e.documentElement,o=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var k=b.offsetTop,n=b.offsetLeft;(b=b.parentNode)&&b!==o&&b!==i;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;j=e?e.getComputedStyle(b,null):b.currentStyle;k-=b.scrollTop;n-=b.scrollLeft;if(b===d){k+=b.offsetTop;n+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&j.overflow!=="visible"){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=j}if(f.position==="relative"||f.position==="static"){k+=o.offsetTop;n+=o.offsetLeft}if(c.offset.supportsFixedPosition&&f.position==="fixed"){k+=Math.max(i.scrollTop,o.scrollTop);n+=Math.max(i.scrollLeft,o.scrollLeft)}return{top:k,left:n}};c.offset={initialize:function(){var a=s.body,b=s.createElement("div"),d,f,e,j=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b);c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-
f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in
e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window);
var login_button=['',''];var default_page='';var body_class='';function keyListener(e){var keycode;if(window.event){keycode=window.event.keyCode;}
else if(e){keycode=e.which;}
else{return true;}
if(keycode==13){Validate();return false;}
else if(keycode==27){HideLogin();return false;}
return true;}
function SetLoginFocus(){SetFocus('login_form','login_user');}
function ShowLoginCallback(resp,xmlhttp){UpdateContent_callback(resp,xmlhttp);$('#Login').center().fadeIn();}
function ShowLogin(ParentId,ssl){if(ssl){setCookie("http_redirect_login",1);if(location.href.match(/http:/img)){location.href=location.href.replace(/http:\/\//,"https://");}}
else{var login_box=CreatePopUp('Login','StandardPopUp','body','Login',1);UpdateContent('Login_Body','login.php?Mode=Enter',ShowLoginCallback);login_box.onkeydown=keyListener;}}
function HideLogin(){var login_box=document.getElementById('Login');if(login_box){login_box.onkeydown=null;}
ClosePopup('Login');}
function Logout(){UpdateStaticContent('login_button',login_button[1]);var HTTPobj=new XMLHttp();HTTPobj.GetContent('login.php?Mode=Logout');UpdateContent('Menu',menu_app);if(body_class.length){$('body').attr('class',body_class);}
if(default_page){UpdateContent('Main',default_page);}}
function Validate_callback(resp){if(resp){if(resp!='Not Valid'){parts=eval(resp);if(parts[2]){UpdateContent('Main',parts[1]);}
else{UpdateContent('Menu',menu_app);if(parts[0]&&parts[0].length){$('body').attr('class',parts[0]);}
if(parts[1]&&parts[1].length){UpdateContent('Main',parts[1]);}}
UpdateStaticContent('login_button',login_button[0]);HideLogin();}
else{alert(resp);}}}
function Validate(){var submit=false;var login_user=document.getElementById('login_user');if(login_user){if(login_user.value==""){login_user.focus();}
else{var login_password=document.getElementById('login_password');if(login_password){if(login_password.value==""){login_password.focus();}
else{submit=true;}}}}
if(submit){var HTTPobj=new XMLHttp(Validate_callback);HTTPobj.PostContent('/login.php','login');}}
function SwitchTo_callback(resp){if(resp!='Not Valid'){UpdateContent('Menu',menu_app);UpdateContent('Main',resp);}
else{alert(resp);}}
function SwitchTo(UserId){var HTTPobj=new XMLHttp(SwitchTo_callback);HTTPobj.GetContent('/login.php?Mode=SwitchTo&UserId='+UserId);}
function SwitchBack_callback(resp){if(resp!='Not Valid'){UpdateContent('Menu',menu_app);UpdateContent('Main',resp);}
else{alert(resp);}}
function SwitchBack(){var HTTPobj=new XMLHttp(SwitchBack_callback);HTTPobj.GetContent('/login.php?Mode=SwitchBack');}
function UpdatePassword_callback(resp,xmlhttp){parts=eval(resp);if(parts[0]=='Ok'){var password_form=document.getElementById(xmlhttp.params['form_id']+'_form');password_form.reset();alert('Password was changed successfully.');if(parts[1]){Validate_callback(parts[1]);}}
else{alert(resp);}}
function UpdatePassword(form_id,update_url){var password_form=document.getElementById(form_id+'_form');if(password_form){if(password_form['Edit[old_password]']){if(password_form['Edit[old_password]'].value.length<3){alert('Old Password must be at least 3 characters long.');SetFocus(form_id+'_form','Edit[old_password]');return;}
if(password_form['Edit[old_password]'].value==password_form['Edit[new_password]'].value){alert('New password must be different from the old password');SetFocus(form_id+'_form','Edit[new_password]');return;}}
if(password_form['Edit[new_password]'].value.length<3){alert('New Password must be at least 3 characters long.');SetFocus(form_id+'_form','Edit[new_password]');return;}
if(password_form['Edit[confirm_password]'].value.length<3){alert('Confirm Password must be at least 3 characters long.');SetFocus(form_id+'_form','Edit[confirm_password]');return;}
if(password_form['Edit[new_password]'].value!=password_form['Edit[confirm_password]'].value){alert('New Password and Confirm Password must be the same.');SetFocus(form_id+'_form','Edit[new_password]');return;}}
var params={"form_id":form_id};var HTTPobj=new XMLHttp(UpdatePassword_callback,params);HTTPobj.PostContent(update_url,form_id);}
var hex_chr="0123456789abcdef";function rhex(num)
{str="";for(j=0;j<=3;j++)
str+=hex_chr.charAt((num>>(j*8+4))&0x0F)+
hex_chr.charAt((num>>(j*8))&0x0F);return str;}
function str2blks_MD5(str)
{nblk=((str.length+8)>>6)+1;blks=new Array(nblk*16);for(i=0;i<nblk*16;i++)blks[i]=0;for(i=0;i<str.length;i++)
blks[i>>2]|=str.charCodeAt(i)<<((i%4)*8);blks[i>>2]|=0x80<<((i%4)*8);blks[nblk*16-2]=str.length*8;return blks;}
function add(x,y)
{var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF);}
function rol(num,cnt)
{return(num<<cnt)|(num>>>(32-cnt));}
function cmn(q,a,b,x,s,t)
{return add(rol(add(add(a,q),add(x,t)),s),b);}
function ff(a,b,c,d,x,s,t)
{return cmn((b&c)|((~b)&d),a,b,x,s,t);}
function gg(a,b,c,d,x,s,t)
{return cmn((b&d)|(c&(~d)),a,b,x,s,t);}
function hh(a,b,c,d,x,s,t)
{return cmn(b^c^d,a,b,x,s,t);}
function ii(a,b,c,d,x,s,t)
{return cmn(c^(b|(~d)),a,b,x,s,t);}
function calcMD5(str)
{x=str2blks_MD5(str);a=1732584193;b=-271733879;c=-1732584194;d=271733878;for(i=0;i<x.length;i+=16)
{olda=a;oldb=b;oldc=c;oldd=d;a=ff(a,b,c,d,x[i+0],7,-680876936);d=ff(d,a,b,c,x[i+1],12,-389564586);c=ff(c,d,a,b,x[i+2],17,606105819);b=ff(b,c,d,a,x[i+3],22,-1044525330);a=ff(a,b,c,d,x[i+4],7,-176418897);d=ff(d,a,b,c,x[i+5],12,1200080426);c=ff(c,d,a,b,x[i+6],17,-1473231341);b=ff(b,c,d,a,x[i+7],22,-45705983);a=ff(a,b,c,d,x[i+8],7,1770035416);d=ff(d,a,b,c,x[i+9],12,-1958414417);c=ff(c,d,a,b,x[i+10],17,-42063);b=ff(b,c,d,a,x[i+11],22,-1990404162);a=ff(a,b,c,d,x[i+12],7,1804603682);d=ff(d,a,b,c,x[i+13],12,-40341101);c=ff(c,d,a,b,x[i+14],17,-1502002290);b=ff(b,c,d,a,x[i+15],22,1236535329);a=gg(a,b,c,d,x[i+1],5,-165796510);d=gg(d,a,b,c,x[i+6],9,-1069501632);c=gg(c,d,a,b,x[i+11],14,643717713);b=gg(b,c,d,a,x[i+0],20,-373897302);a=gg(a,b,c,d,x[i+5],5,-701558691);d=gg(d,a,b,c,x[i+10],9,38016083);c=gg(c,d,a,b,x[i+15],14,-660478335);b=gg(b,c,d,a,x[i+4],20,-405537848);a=gg(a,b,c,d,x[i+9],5,568446438);d=gg(d,a,b,c,x[i+14],9,-1019803690);c=gg(c,d,a,b,x[i+3],14,-187363961);b=gg(b,c,d,a,x[i+8],20,1163531501);a=gg(a,b,c,d,x[i+13],5,-1444681467);d=gg(d,a,b,c,x[i+2],9,-51403784);c=gg(c,d,a,b,x[i+7],14,1735328473);b=gg(b,c,d,a,x[i+12],20,-1926607734);a=hh(a,b,c,d,x[i+5],4,-378558);d=hh(d,a,b,c,x[i+8],11,-2022574463);c=hh(c,d,a,b,x[i+11],16,1839030562);b=hh(b,c,d,a,x[i+14],23,-35309556);a=hh(a,b,c,d,x[i+1],4,-1530992060);d=hh(d,a,b,c,x[i+4],11,1272893353);c=hh(c,d,a,b,x[i+7],16,-155497632);b=hh(b,c,d,a,x[i+10],23,-1094730640);a=hh(a,b,c,d,x[i+13],4,681279174);d=hh(d,a,b,c,x[i+0],11,-358537222);c=hh(c,d,a,b,x[i+3],16,-722521979);b=hh(b,c,d,a,x[i+6],23,76029189);a=hh(a,b,c,d,x[i+9],4,-640364487);d=hh(d,a,b,c,x[i+12],11,-421815835);c=hh(c,d,a,b,x[i+15],16,530742520);b=hh(b,c,d,a,x[i+2],23,-995338651);a=ii(a,b,c,d,x[i+0],6,-198630844);d=ii(d,a,b,c,x[i+7],10,1126891415);c=ii(c,d,a,b,x[i+14],15,-1416354905);b=ii(b,c,d,a,x[i+5],21,-57434055);a=ii(a,b,c,d,x[i+12],6,1700485571);d=ii(d,a,b,c,x[i+3],10,-1894986606);c=ii(c,d,a,b,x[i+10],15,-1051523);b=ii(b,c,d,a,x[i+1],21,-2054922799);a=ii(a,b,c,d,x[i+8],6,1873313359);d=ii(d,a,b,c,x[i+15],10,-30611744);c=ii(c,d,a,b,x[i+6],15,-1560198380);b=ii(b,c,d,a,x[i+13],21,1309151649);a=ii(a,b,c,d,x[i+4],6,-145523070);d=ii(d,a,b,c,x[i+11],10,-1120210379);c=ii(c,d,a,b,x[i+2],15,718787259);b=ii(b,c,d,a,x[i+9],21,-343485551);a=add(a,olda);b=add(b,oldb);c=add(c,oldc);d=add(d,oldd);}
return rhex(a)+rhex(b)+rhex(c)+rhex(d);}
var menu_app='menu_tree.php';var menu_type=1;var menu_effect=0;var current_menu_id=null;function UpdateMenuNode(Id,ParentId){UpdateTreeNode(Id,ParentId,null,null,null,menu_effect);}
function UpdateCurentMenu(id,active_class){if(!active_class){active_class="Active";}
if(current_menu_id){$('#m_'+current_menu_id[0]).removeClass(current_menu_id[1]);}
if(id){$('#m_'+id).addClass(active_class);current_menu_id=[id,active_class];}
else{current_menu_id=null;}}
var MenuPopup_timer=Array();function OpenMenuPopup(ParentId){ClearMenuTimer(ParentId);MenuPopup=CreatePopUp('MenuPopup'+ParentId,'Popup','Menu');if(MenuPopup&&MenuPopup.innerHTML==''){var obj=document.getElementById('m_'+ParentId);if(obj&&menu_data[ParentId]!=null){MenuPopup.onmouseover=function(){ClearMenuTimer(ParentId)};MenuPopup.onmouseout=function(){SetMenuTimer(ParentId)};MenuPopup.zIndex=100;$('#MenuPopup'+ParentId).html(menu_data[ParentId]);var pos=GetPosition(obj);switch(menu_type){case 0:switch(menu_effect){case 0:MoveTo('MenuPopup'+ParentId,pos[0],pos[1]+obj.offsetHeight);$('#MenuPopup'+ParentId).show();break;case 1:MoveTo('MenuPopup'+ParentId,pos[0],pos[1]+obj.offsetHeight);$('#MenuPopup'+ParentId).fadeIn();break;case 2:MoveTo('MenuPopup'+ParentId,pos[0],pos[1]+obj.offsetHeight);$('#MenuPopup'+ParentId).slideDown();break;case 3:MoveTo('MenuPopup'+ParentId,pos[0],pos[1]);$('#MenuPopup'+ParentId).show().animate({top:(pos[1]-$('#MenuPopup'+ParentId).height())+'px'},'def');break;}
break;case 2:MoveTo('MenuPopup'+ParentId,pos[0]+obj.offsetWidth,pos[1]);switch(menu_effect){case 0:$('#MenuPopup'+ParentId).show();break;case 1:$('#MenuPopup'+ParentId).fadeIn();break;case 2:case 3:$('#MenuPopup'+ParentId).toggle('def');break;}
break;}}}}
function CloseMenuPopup(id){ClearMenuTimer(id);switch(menu_type){case 0:switch(menu_effect){case 0:$('#MenuPopup'+id).hide(function(){$('#MenuPopup'+id).remove()});break;case 1:$('#MenuPopup'+id).fadeOut('def',function(){$('#MenuPopup'+id).remove()});break;case 2:$('#MenuPopup'+id).slideUp('def',function(){$('#MenuPopup'+id).remove()});break;case 3:var obj=document.getElementById('m_'+id);var pos=GetPosition(obj);$('#MenuPopup'+id).animate({top:(pos[1]+$('#MenuPopup'+id).height())+'px'},'def').slideUp('def',function(){$('#MenuPopup'+id).remove()});break;}
break;case 2:switch(menu_effect){case 0:$('#MenuPopup'+id).hide(function(){$('#MenuPopup'+id).remove()});break;case 1:$('#MenuPopup'+id).fadeOut('def',function(){$('#MenuPopup'+id).remove()});break;case 2:case 3:$('#MenuPopup'+id).toggle('def',function(){$('#MenuPopup'+id).remove()});break;}
break;}}
function ClearMenuTimer(id){if(MenuPopup_timer[id]){window.clearTimeout(MenuPopup_timer[id]);MenuPopup_timer[id]=null;}}
function SetMenuTimer(id){ClearMenuTimer(id);MenuPopup_timer[id]=window.setTimeout(function(){CloseMenuPopup(id);},500);}//
// $Id: payment.js,v 1.4 2009/07/26 04:26:04 frank Exp $
//

function ProcessCreditCard_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	BoxCenter('CreditCardData');
	$('#CreditCardData').fadeIn();
	SetFocus(focus_form, focus_field);
}

function ProcessCreditCard(InvoiceId, append_to) {
	if (!append_to) {
		append_to = "body";
	}
	var ccPopUp = CreatePopUp("CreditCardData", "StandardPopUp", append_to, "Credit Card Data");
	var params = {"InvoiceId": InvoiceId};
	UpdateContent('CreditCardData_Body', 'case_payments.php?Mode=CreditCard&InvoiceId=' + InvoiceId, ProcessCreditCard_callback, params);
}

COLUMN_TYPE=1;COLUMN_LENGTH=2;COLUMN_WIDTH=3;COLUMN_CAPTION=4;COLUMN_GROUP=5;COLUMN_SORT=6;COLUMN_ALIGN=7;COLUMN_FORMAT=8;COLUMN_DECIMALS=9;COLUMN_CASE=10;COLUMN_TOTAL=11;COLUMN_DATA=12;COLUMN_DESCRIPTION=13;COLUMN_EVENT=20;ELEMENT_HIDDEN=1;ELEMENT_CHAR=2;ELEMENT_TEXT=3;ELEMENT_PASSWORD=4;ELEMENT_INTEGER=5;ELEMENT_HEX=6;ELEMENT_FLOAT=7;ELEMENT_DATE=8;ELEMENT_TIME=9;ELEMENT_TIMESTAMP=10;ELEMENT_SELECT=11;ELEMENT_SELECT_MULTI=12;ELEMENT_CHECKBOX=13;ELEMENT_RADIOBUTTON=14;ELEMENT_LINK=15;ELEMENT_FILE=16;ELEMENT_BLOB=17;ELEMENT_BLOB_HANDLE=18;ELEMENT_IPADDRESS=19;ELEMENT_ELAPSED_TIME=20;ELEMENT_EMAIL=21;ELEMENT_CREDITCARD=22;ELEMENT_CHECKBOX_MULTI=23;ELEMENT_TEXTBOX=24;ELEMENT_CAPTCHA=25;ELEMENT_FILE_MULTI=26;ELEMENT_HTML=27;FORMAT_HIDDEN=0x0001;FORMAT_MANDATORY=0x0002;FORMAT_NOEDIT=0x0004;FORMAT_TOTAL_SUM=0x0100;FORMAT_TOTAL_AVG=0x0200;FORMAT_TOTAL_MIN=0x0400;FORMAT_TOTAL_MAX=0x0800;var date_format='m/d/Y';var time_format='H:i:s';var max_file_size='1 Mb';function UpdateMap(form_id,field_x,field_y,e){var eventObj=(e)?e:event;var x=eventObj.offsetX;var y=eventObj.offsetY;var form_obj=document.getElementById(form_id+"_form");for(var i=0;i<form_obj.length;i++){if(form_obj.elements[i].name==field_x){form_obj.elements[i].value=x;}
if(form_obj.elements[i].name==field_y){form_obj.elements[i].value=y;}}}
var ProgressUpdate=null;var update_timer=null;var post_working=null;function UploadProgressUpdate_callback(resp,xmlhttp){if(resp.length){eval(resp);if(ProgressUpdate&&ProgressUpdate[xmlhttp.params["upload_id"]]){var bar=document.getElementById(xmlhttp.params["id"]+'_bar');if(bar){bar.style.width=ProgressUpdate[xmlhttp.params["upload_id"]]['percent']+'%';}
var status=document.getElementById(xmlhttp.params["id"]+'_status');if(status){status.innerHTML=ProgressUpdate[xmlhttp.params["upload_id"]]['percent']+'%';}
var message=document.getElementById(xmlhttp.params["id"]+'_message');if(message){message.innerHTML='Estimated remaining time: '+ProgressUpdate[xmlhttp.params["upload_id"]]['time_left'];}
if(ProgressUpdate[xmlhttp.params["upload_id"]]['error']){alert(ProgressUpdate[xmlhttp.params["upload_id"]]['error']);if(post_working){HideWorking(post_working);post_working=null;}}
else{update_timer=setTimeout("UploadProgressUpdate('"+xmlhttp.params["id"]+"', '"+xmlhttp.params["upload_id"]+"')",1000);}}}}
function UploadProgressUpdate(id,upload_id){if(update_timer){clearTimeout(update_timer);update_timer=null;}
var bar=document.getElementById(id+'_bar');if(bar){var params={"id":id,"upload_id":upload_id};var HTTPobj=new XMLHttp(UploadProgressUpdate_callback,params);HTTPobj.GetJSON('upload_progress.php?upload_id='+upload_id);}}
function UploadProgressInit(form_id,id,mode){var form_obj=document.getElementById(form_id+'_form');if(form_obj){post_working=ShowWorking(form_obj);for(var i=0;i<form_obj.length;i++){if(mode&&form_obj.elements[i].id=="Mode"){form_obj.elements[i].value=mode;}
switch(form_obj.elements[i].type){case'hidden':if(form_obj.elements[i].name=="MAX_FILE_SIZE"){max_file_size=form_obj.elements[i].value;}
break;case'undefined':break;case'radio':break;case'select-one':break;case'select-multiple':break;case'checkbox':if(form_obj.elements[i].name.match(/Link\[/)){if(!form_obj.elements[i].checked){form_obj.elements[i].checked=true;form_obj.elements[i].value=0;}}
break;case'file':if(is.Gecko&&form_obj.elements[i].files[0]){var size=form_obj.elements[i].files[0].fileSize;if(size>max_file_size){alert('The file is too big! Please make sure each file is smaller than '+max_file_size+' bytes.');if(post_working){HideWorking(post_working);post_working=null;}
return;}}
break;default:if(!ValidateInput(form_id,form_obj.elements[i].id,form_obj.elements[i])){if(post_working){HideWorking(post_working);post_working=null;}
return;}
break;}}
ProgressUpdate=null;if(form_obj.UPLOAD_IDENTIFIER){var upload_id=form_obj.UPLOAD_IDENTIFIER.value;if(upload_id&&!update_timer){update_timer=setTimeout("UploadProgressUpdate('"+id+"', '"+upload_id+"')",1000);}}
form_obj.submit();}}
function UpdateContentOnLoad(iframe,id,URL){var obj=document.getElementById(iframe);if(obj){if(obj.contentDocument){var d=obj.contentDocument;}
else if(obj.contentWindow){var d=obj.contentWindow.document;}
else{var d=window.frames[iframe].document;}
if(d.location.href=="about:blank"){return;}
if(d.body.innerHTML.match(/DONE/)){if(post_working){HideWorking(post_working);post_working=null;}
UpdateContent(id,URL.replace('%Id%',d.body.innerHTML.replace('DONE;','')));}
var err_no=0;var err_code=null;if((err_no=d.body.innerHTML.match(/ERROR: (\d)/))){if(post_working){HideWorking(post_working);post_working=null;}
switch(parseInt(err_no[1])){case 1:err_code="The file exeeded the upload_max_filesize value in php.ini.";break;case 2:err_code="The file exeeded the max_file_size value in post form.";break;case 3:err_code="The file The uploaded file was only partially uploaded.";break;case 4:err_code="No file was uploaded.";break;case 6:err_code="Missing a temporary folder.";break;case 7:err_code="Failed to write file to disk.";break;case 8:err_code="File upload stopped by extension.";break;}
alert(err_code);}}}
function ParseDate(DateValue){var year;var month;var day;var hour=0;var min=0;var sec=0;var parts=DateValue.split(/ |-|\/|:/);if(parts.length>=3&&parts.length<=6){for(var i=0;i<parts.length;i++){if(parts[i].charAt(0)=='0'){parts[i]=parts[i].substring(1);}}
switch(date_format){case'd-m-Y':year=parseInt(parts[2]);month=parseInt(parts[1]);day=parseInt(parts[0]);break;case'Y/m/d':year=parseInt(parts[0]);month=parseInt(parts[1]);day=parseInt(parts[2]);break;default:case'm/d/Y':year=parseInt(parts[2]);month=parseInt(parts[0]);day=parseInt(parts[1]);break;}
if(parts.length>3){switch(time_format){case"H:i:s":hour=parseInt(parts[3]);min=parseInt(parts[4]);sec=parseInt(parts[5]);break;case"H:i":hour=parseInt(parts[3]);min=parseInt(parts[4]);break;}}
return{"year":year,"month":month,"day":day,"hour":hour,"min":min,"sec":sec};}
else{return null;}}
function CheckDate(DateValue){var parts=ParseDate(DateValue);if(parts){var d=new Date();if(parts["year"]<1902||parts["year"]>2038){return null;}
d.setFullYear(parts["year"],parts["month"]-1,parts["day"]);if(d.getFullYear()==parts["year"]&&d.getMonth()==parts["month"]-1&&d.getDate()==parts["day"]){return d;}
else{return null;}}
else{return null;}}
function CheckEmail(emailStr){var checkTLD=1;var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;var emailPat=/^(.+)@(.+)$/;var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";var validChars="\[^\\s"+specialChars+"\]";var quotedUser="(\"[^\"]*\")";var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;var atom=validChars+'+';var word="("+atom+"|"+quotedUser+")";var userPat=new RegExp("^"+word+"(\\."+word+")*$");var domainPat=new RegExp("^"+atom+"(\\."+atom+")*$");var matchArray=emailStr.trim().match(emailPat);if(matchArray==null){return false;}
var user=matchArray[1];var domain=matchArray[2];for(i=0;i<user.length;i++){if(user.charCodeAt(i)>127){return false;}}
for(i=0;i<domain.length;i++){if(domain.charCodeAt(i)>127){return false;}}
if(user.match(userPat)==null){return false;}
var IPArray=domain.match(ipDomainPat);if(IPArray!=null){for(var i=1;i<=4;i++){if(IPArray[i]>255){return false;}}
return true;}
var atomPat=new RegExp("^"+atom+"$");var domArr=domain.split(".");var len=domArr.length;for(i=0;i<len;i++){if(domArr[i].search(atomPat)==-1){return false;}}
if(checkTLD&&domArr[domArr.length-1].length!=2&&domArr[domArr.length-1].search(knownDomsPat)==-1){return false;}
if(len<2){return false;}
return true;}
function ValidateCreditCard(ccnum){var type=null;ccnum=ccnum.replace(/[ -]/g,"");var re=/^4\d{15}$/;if(re.test(ccnum)){type='Visa';}
var re=/^4\d{12}$/;if(!type&&re.test(ccnum)){type='Visa';}
var re=/^5[1-5]\d{14}$/;if(!type&&re.test(ccnum)){type='Mastercard';}
var re=/^6011\d{12}$/;if(!type&&re.test(ccnum)){type='Discover';}
var re=/^3[4,7]\d{13}$/;if(!type&&re.test(ccnum)){type='Amex';}
var re=/^3\d{15}$/;if(!type&&re.test(ccnum)){type='JCB';}
var re=/^[2131|1800]\d{11}$/;if(!type&&re.test(ccnum)){type='JCB';}
var re=/^3[0,6,8]\d{12}$/;if(!type&&re.test(ccnum)){type='Diners';}
if(type){var checksum=0;for(var i=(2-(ccnum.length%2));i<=ccnum.length;i+=2){checksum+=parseInt(ccnum.charAt(i-1));}
for(var i=(ccnum.length%2)+1;i<ccnum.length;i+=2){var digit=parseInt(ccnum.charAt(i-1))*2;if(digit<10){checksum+=digit;}
else{checksum+=(digit-9);}}
if((checksum%10)!=0){type=null;}}
return type;}
function ValidateInput(form_id,field_edit_id,form_obj,ignore_defaults){var form=form_id+'_form';var arrInfo=window[form_id+'_info'];if(!arrInfo){return true;}
var arrGroupIndex=window[form_id+'_groupindex'];if(field_edit_id.match(/Edit_/)){var field_name=field_edit_id.substring(5,field_edit_id.length);}
else if(field_edit_id.match(/Filter_/)){var field_name=field_edit_id.substring(7,field_edit_id.length);}
else{var field_name=field_edit_id;}
if(arrInfo&&arrInfo[field_name]){if((arrInfo[field_name][COLUMN_FORMAT]&FORMAT_MANDATORY)==FORMAT_MANDATORY){if(!form_obj.value||(form_obj.value==form_obj.defaultValue&&ignore_defaults)){MsgBox('\''+arrInfo[field_name][COLUMN_CAPTION]+'\' may not be blank','Input error');if(arrGroupIndex){TabSelect(form_id,arrGroupIndex[arrInfo[field_name][COLUMN_GROUP]]);}
SetFocus(form,field_edit_id);return false;}}
var invalid=false;switch(parseInt(arrInfo[field_name][COLUMN_TYPE])){case ELEMENT_INTEGER:if(form_obj.value.length){if(isNaN(parseInt(form_obj.value))||parseInt(form_obj.value)!=form_obj.value){MsgBox('\''+arrInfo[field_name][COLUMN_CAPTION]+'\': Please enter a valid integer value','Input error');invalid=true;}}
break;case ELEMENT_HEX:if(form_obj.value.length){if(isNaN(parseInt(form_obj.value,16))){MsgBox('\''+arrInfo[field_name][COLUMN_CAPTION]+'\': Please enter a valid hex value','Input error');invalid=true;}}
break;case ELEMENT_FLOAT:if(form_obj.value.length){if(isNaN(parseFloat(form_obj.value))||parseFloat(form_obj.value)!=form_obj.value){MsgBox('\''+arrInfo[field_name][COLUMN_CAPTION]+'\': Please enter a valid floating point value','Input error');invalid=true;}}
break;case ELEMENT_DATE:if(form_obj.value.length){var valid=CheckDate(form_obj.value);if(!valid){var expected_format='';switch(date_format){case'm/d/Y':expected_format=' MM/DD/YYYY';break;case'd-m-Y':expected_format=' DD-MM-YYYY';break;case'Y/m/d':expected_format=' YYYY/MM/DD';break;}
MsgBox('\''+arrInfo[field_name][COLUMN_CAPTION]+'\': Please enter a valid date'+expected_format,'Input error');invalid=true;}}
break;case ELEMENT_EMAIL:if(form_obj.value.length){if(!CheckEmail(form_obj.value)){MsgBox('\''+arrInfo[field_name][COLUMN_CAPTION]+'\': Please enter a valid email address','Input error');invalid=true;}}
break;case ELEMENT_PASSWORD:if((arrInfo[field_name][COLUMN_FORMAT]&FORMAT_MANDATORY)==FORMAT_MANDATORY&&form_obj.value.length<5){MsgBox('\''+arrInfo[field_name][COLUMN_CAPTION]+'\': Password must be at least 5 characters long','Input error');invalid=true;}
break;case ELEMENT_CREDITCARD:if(form_obj.value.length){var valid=ValidateCreditCard(form_obj.value);if(!valid){MsgBox('\''+arrInfo[field_name][COLUMN_CAPTION]+'\': Please enter a valid credit card number','Input error');invalid=true;}}
break;case ELEMENT_HTML:$('#'+field_edit_id).htmlarea('updateTextArea')
break;default:break;}
if(invalid){if(arrGroupIndex){TabSelect(form_id,arrGroupIndex[arrInfo[field_name][COLUMN_GROUP]]);}
SetFocus(form,field_edit_id);return false;}}
return true;}
function ValidateForm(id,URL,form_id,ret_value,callback,callback_params,timeout,ignore_defaults){var form_obj=document.getElementById(form_id+"_form");if(form_obj){var content='',r=[];for(var i=0;i<form_obj.length;i++){switch(form_obj.elements[i].type){case'undefined':break;case'radio':break;case'select-one':break;case'select-multiple':break;case'checkbox':break;default:if(!ValidateInput(form_id,form_obj.elements[i].id,form_obj.elements[i],ignore_defaults)){if(ret_value){return false;}
else{return;}}
break;}}}
PostContent(id,URL,form_id,callback,callback_params,timeout,ignore_defaults);if(ret_value){return true;}}
function ValidateSimpleForm(id,URL,form_id){ValidateForm(id,URL,form_id,false,null,null,null,true);}
function UpdateAllLinks(obj,name){var new_value=obj.checked;var all=document.getElementsByName(name);for(var i=0;i<all.length;i++){all[i].checked=new_value;}}
function CheckLinkSelected(form_id,link_name){var checked=false;var form_obj=document.getElementById(form_id+"_form");if(form_obj){var reg=new RegExp(link_name+"\[[0-9]*\]","im");for(var i=0;i<form_obj.length;i++){if(form_obj.elements[i].name.match(reg)&&form_obj.elements[i].checked){checked=true;break;}}}
return checked;}
function autoComplete(id,values,forcematch){var field=document.getElementById(id);if(field){var found=false;for(var i=0;i<values.length;i++){if(values[i].toUpperCase().indexOf(field.value.toUpperCase())==0){found=true;break;}}
if(field.createTextRange){if(forcematch&&!found){field.value=field.value.substring(0,field.value.length-1);return;}
var cursorKeys="8;46;37;38;39;40;33;34;35;36;45;";if(cursorKeys.indexOf(event.keyCode+";")==-1){var r1=field.createTextRange();var oldValue=r1.text;var newValue=found?values[i]:oldValue;if(newValue!=field.value){field.value=newValue;var rNew=field.createTextRange();rNew.moveStart('character',oldValue.length);rNew.select();}}}}}
function UpdateValue(id,value){var obj=document.getElementById(id);if(obj){if(obj.value==value){obj.value=null;}
else{obj.value=value;}}}
function ToggleValue(id,value){var obj=document.getElementById(id);if(obj){if(obj.value){obj.value='';}
else{obj.value=value;}}}
var CurrentDataField=null;function DateSelector_callback(resp,xmlhttp){UpdateContent_callback(resp,xmlhttp);var pos=GetPosition(xmlhttp.params["field"],true);MoveTo("DateSelector",pos[0],pos[1]);BoxShow('DateSelector');}
function ShowDateSelector(form_id,field_id){var form_obj=document.getElementById(form_id+"_form");if(form_obj){for(var i=0;i<form_obj.length;i++){if(form_obj.elements[i].id==field_id){var year;var month;var d=new Date();year=d.getFullYear();month=d.getMonth()+1;var parts=ParseDate(form_obj.elements[i].value);if(parts){if(parts["year"]>1902&&parts["year"]<2038){year=parts["year"];month=parts["month"];}}
var DateSelectorPopup=CreatePopUp("DateSelector","StandardPopUp","Main","Date Selector");CurrentDataField=form_obj.elements[i];var params={"field":form_obj.elements[i]};UpdateContent('DateSelector_Body','date_selector.php?Year='+year+'&Month='+month,DateSelector_callback,params);}}}}
function SelectDate(year,month,day){if(CurrentDataField){var datevalue=CurrentDataField.value.split(" ");if(month<10)month='0'+month;if(day<10)day='0'+day;switch(date_format){case'd-m-Y':datevalue[0]=day+'-'+month+'-'+year;break;case'Y/m/d':datevalue[0]=year+'/'+month+'/'+day;break;default:case'm/d/Y':datevalue[0]=month+'/'+day+'/'+year;break;}
CurrentDataField.value=datevalue.join(" ");CurrentDataField=null;}
BoxHide("DateSelector");}
function ShowRows(EditId,value){var e_all=EditId+'_all';var e_can_hide=EditId+'_can_hide';try{var selected_value=value;var edit_all=eval(e_all);var edit_can_hide=eval(e_can_hide);for(var i=0;i<edit_all.length;i++){var obj=document.getElementById(EditId+"_row_"+edit_all[i]);if(obj){if(edit_can_hide[selected_value].toString().indexOf(edit_all[i])!==-1){obj.style.display='block';}
else{obj.style.display='none';}}}}
catch(e){return;}}
function ClearForm(form_id,focus_field){var form=document.getElementById(form_id+'_form');form.reset();if(focus_field){SetFocus(form_id+'_form',focus_field);}}
function SubmitForm_callback(resp,xmlhttp){alert(resp);}
function SubmitForm(form_id,form_url,alert_text){var form=document.getElementById(form_id+'_form');var params={"form_id":form_id,"alert_text":alert_text};var HTTPobj=new XMLHttp(SubmitForm_callback,params);HTTPobj.PostContent(form_url,form_id);}
function AddSelectedFilter(filter_id){var column=$('#'+filter_id+'_add').val();var arrInfo=window[filter_id+'_info'];if(arrInfo&&arrInfo[column]){$('#'+filter_id+'_form').append(arrInfo[column][COLUMN_DATA]);}}
function UpdateLinkedDropdown(main_id,linked_id,url){var obj_main=document.getElementById(main_id);var obj_linked=document.getElementById(linked_id);if(obj_main&&obj_linked){var main_value=obj_main.options[obj_main.selectedIndex].value;if(main_value=="NULL"){obj_country.selectedIndex=0;}
else{UpdateContent(linked_id,url+main_value);}}}
var list_filter=[];function dechex(d){var hD="0123456789ABCDEF";var h=hD.substr(d&15,1);while(d>15){d>>=4;h=hD.substr(d&15,1)+h;}
return h;}
function number_format(number){x=String(number).split('.');x1=x[0];x2=x.length>1?'.'+x[1]:'';var rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2');}
return x1+x2;}
function Compare(val1,val2,desc){return(desc)?val1<val2:val1>val2;}
function GetValue(RowData,col,coltype,ignore_case){if(RowData&&RowData.childNodes[col]){switch(coltype){case ELEMENT_INTEGER:return parseInt(RowData.childNodes[col].innerHTML.replace(/[,\.]/img,""));break;case ELEMENT_HEX:return parseInt('0x'+RowData.childNodes[col].innerHTML.replace(/[,\.]/img,""),16);break;case ELEMENT_FLOAT:return parseFloat(RowData.childNodes[col].innerHTML.replace(/[,\.]/img,""));break;case ELEMENT_DATE:case ELEMENT_TIMESTAMP:return CheckDate(RowData.childNodes[col].innerHTML.replace(/[,\.]/img,""));break;case ELEMENT_ELAPSED_TIME:var elm=RowData.childNodes[col].innerHTML.split(/[ :]/);return parseInt(elm[0])*86400+parseInt(elm[1])*3600+parseInt(elm[2])*60+parseInt(elm[3]);break;default:var str=RowData.childNodes[col].innerHTML;if(ignore_case){str=str.toLowerCase();}
return str.replace(/<.*?>/g,"");break;}}
else{return null;}}
function qsort(a,desc){if(a.length==0)return new Array();var left=new Array();var right=new Array();var pivot=a[0];for(var i=1;i<a.length;i++){if(Compare(a[i]['value'],pivot['value'],desc))
left.push(a[i]);else
right.push(a[i]);}
return qsort(left,desc).concat(pivot,qsort(right,desc));}
function SortList(ListId,col,coltype,ignore_case){var ListData=document.getElementById(ListId+'_data');if(ListData){var last_sort=window[ListId+'_col'];var desc=window[ListId+'_desc'];if(last_sort==col){desc=1-desc;}
else{desc=0;}
window[ListId+'_col']=col;window[ListId+'_desc']=desc;var i,N=ListData.childNodes.length;if(N>50){var working=ShowWorking(ListData);}
window[ListId+'_select']={};var a=new Array();for(i=0;i<N;i++){var Row=ListData.childNodes[i];if(Row.style&&Row.style.display!='none'){a.push({"id":Row.id,"value":GetValue(Row,col,coltype,ignore_case),"row":Row.innerHTML,"class":Row.className});}}
a=qsort(a,desc);var j=0;for(i=0;i<N;i++){var Row=ListData.childNodes[i];if(Row.style&&Row.style.display!='none'){Row.innerHTML=a[j]['row'];if(j%2){Row.className=a[j]['class'].replace(/Row(Odd|Even)/gi,"RowOdd");}
else{Row.className=a[j]['class'].replace(/Row(Odd|Even)/gi,"RowEven");}
if(a[j]['class'].indexOf(' ')>=0){window[ListId+'_select'][Row.id]=Row.id;}
j++;}}
if(N>50&&working){HideWorking(working);}}}
function RecalcTotals(ListId){var ListData=document.getElementById(ListId+'_data');if(ListData){var TotalSum=window[ListId+'_sum'];if(TotalSum){var i,M=0,N=ListData.childNodes.length;for(var j in TotalSum){TotalSum[j][2]=0;}
for(i=0;i<N;i++){var Row=ListData.childNodes[i];if(Row.style&&Row.style.display=='block'){M++;for(var j in TotalSum){var val=GetValue(Row,j,TotalSum[j][0]);if(!isNaN(val)){TotalSum[j][2]+=val;}}}}
for(var j in TotalSum){var sumelement=document.getElementById(TotalSum[j][1]);if(sumelement){var sum=TotalSum[j][2];if(TotalSum[j][3]==FORMAT_TOTAL_AVG){if(M>0){sum=sum/M;}
else{sum=0;}}
switch(TotalSum[j][0]){case ELEMENT_INTEGER:sumelement.innerHTML=number_format(sum.toFixed(0));break;case ELEMENT_HEX:sumelement.innerHTML=dechex(sum);break;case ELEMENT_FLOAT:sum=sum/Math.pow(10,TotalSum[j][4]);sumelement.innerHTML=number_format(sum.toFixed(TotalSum[j][4]));break;case ELEMENT_ELAPSED_TIME:sum=Math.round(sum);var days=Math.floor(sum/86400);sum=sum%86400;var hours='0'+Math.floor(sum/3600);hours=hours.substr(hours.length-2)
sum=sum%3600;var minutes='0'+Math.floor(sum/60);minutes=minutes.substr(minutes.length-2)
seconds='0'+sum%60;seconds=seconds.substr(seconds.length-2)
sumelement.innerHTML=days+' '+hours+':'+minutes+':'+seconds;break;}}}}}}
function ExportFilter(ListId,ExportURL){var obj=document.getElementById(ListId+'_filter');if(obj){location.href=ExportURL+(ExportURL.indexOf('?')>=0?'&':'?')+"Filter="+encodeURIComponent(obj.value);}}
function CopyFilter(ListId,Id,CopyURL){var obj=document.getElementById(ListId+'_filter');if(obj&&obj.value){UpdateContent(Id,CopyURL+(CopyURL.indexOf('?')>=0?'&':'?')+"Filter="+encodeURIComponent(obj.value));}}
function ClearIncludes(ListId){list_filter[ListId]='';var ListData=document.getElementById(ListId+'_data');if(ListData){var i,N=ListData.childNodes.length;var line=0;for(i=0;i<N;i++){var Row=ListData.childNodes[i];if(Row.style){Row.style.display='block';if(line%2){Row.className=Row.className.replace(/Row(Odd|Even)/gi,"RowOdd");}
else{Row.className=Row.className.replace(/Row(Odd|Even)/gi,"RowEven");}
line++;}}
RecalcTotals(ListId);}
var obj=document.getElementById(ListId+'_filter');if(obj){obj.value='';obj.focus();}}
function IncludeLines(ListId,cols,val,compare,ignore_case){list_filter[ListId]=val;var ListData=document.getElementById(ListId+'_data');if(ListData){var i,N=ListData.childNodes.length;var line=0;for(i=0;i<N;i++){var Row=ListData.childNodes[i];if(Row.style){if(!compare){compare='=';}
if(ignore_case){val=val.toLowerCase();}
var reg=new RegExp(val,"img");var include=false;for(var x=0;x<cols.length;x++){var NewVal=GetValue(Row,cols[x],ELEMENT_CHAR,ignore_case);if(NewVal){if(val==null||val==''||(compare=='='&&NewVal==val)||(compare=='>'&&NewVal>val)||(compare=='>='&&NewVal>=val)||(compare=='<'&&NewVal<val)||(compare=='<='&&NewVal<=val)||(compare=='!='&&NewVal!=val)||(compare=='<>'&&NewVal!=val)||(compare=='in'&&NewVal.match(reg))){include=true;break;}}}
if(include){Row.style.display='block';if(line%2){Row.className=Row.className.replace(/Row(Odd|Even)/gi,"RowOdd");}
else{Row.className=Row.className.replace(/Row(Odd|Even)/gi,"RowEven");}
line++;}
else{Row.style.display='none';}}}
RecalcTotals(ListId);}}
function SelectLine(ListId,LineId,class_name,multi){try{if(typeof(LineId)=="object"){LineId=LineId.parentNode.parentNode.id;}
if(!multi){var arrSelect=window[ListId+'_select'];for(var i in arrSelect){var Row=document.getElementById(arrSelect[i]);if(Row){$('#'+arrSelect[i]).removeClass(class_name);}}
window[ListId+'_select']={};}
window[ListId+'_select'][LineId]=LineId;$('#'+LineId).addClass(class_name);}
catch(e){return;}}
function UnSelectLines(ListId,class_name){try{var arrSelect=window[ListId+'_select'];for(var i in arrSelect){var Row=document.getElementById(arrSelect[i]);if(Row){$('#'+arrSelect[i]).removeClass(class_name);}}
window[ListId+'_select']={};}
catch(e){return;}}
function RemoveSelectLines(ListId){try{var arrSelect=window[ListId+'_select'];for(var i in arrSelect){var Row=document.getElementById(arrSelect[i]);if(Row){RemoveContent(ListId+'_data',arrSelect[i])}}
window[ListId+'_select']={};}
catch(e){return;}}
function ListExpand(ListId){var max_height=window[ListId+'_max_height'];var show_all=window[ListId+'_show_all'];var obj=document.getElementById(ListId);if(obj&&max_height){if(show_all){obj.style.maxHeight=max_height+'px';window[ListId+'_show_all']=0;}
else{obj.style.maxHeight='none';window[ListId+'_show_all']=1;}}}
function SelectCheckbox(id,val){$('#'+id+'_form input:checkbox:visible').each(function(){if(typeof(val)=='undefined'){this.checked=!this.checked;}
else{this.checked=val;}});}
function UpdateSort(id,post_url){var data=new Array();$("#"+id+"_data div").each(function(i,elm){data[i]=$(elm).attr("id").replace(id+'_','');});if(data.length){$.post(post_url,{"ids[]":data});}}
function TabSelect(TabId,TabIndex,switchonly){var tab=eval(TabId+'_tab');$('#'+TabId+'_'+tab['current']+'_d').hide();var obj=document.getElementById(TabId+'_'+tab['current']+'_t');obj.className=obj.className.replace('Active','Inactive');$('#'+TabId+'_'+TabIndex+'_d').show();var obj=document.getElementById(TabId+'_'+TabIndex+'_t');obj.className=obj.className.replace('Inactive','Active');tab['current']=TabIndex;var tab_index=tab['data'][TabIndex];if(!switchonly&&tab_index&&tab_index['url']){var d=new Date();if(!tab_index['time']||(tab_index['ttl']>-1&&tab_index['time']+tab_index['ttl']*1000<d.getTime())){UpdateContent(TabId+'_'+TabIndex+'_d',tab_index['url'],null,null,tab_index['timeout']);tab_index['time']=d.getTime();}}}
function UpdateNodeImage(obj_name,ParentId,img_closed,img_open){if(img_closed&&img_open){var img_obj=document.getElementById('img_'+ParentId);if(img_obj){if($('#'+obj_name).css("display")=="none"){img_obj.src=img_closed}
else{img_obj.src=img_open;}}}}
function UpdateTreeNode_callback(resp,xmlhttp){if(resp.length){xmlhttp.params["obj"].innerHTML=resp;xmlhttp.EvalScripts();switch(xmlhttp.params["effect"]){case 0:$('#'+xmlhttp.params["obj_name"]).toggle(0);break;case 1:if($('#'+xmlhttp.params["obj_name"]).css("display")=="none"){$('#'+xmlhttp.params["obj_name"]).fadeIn('def');}
else{$('#'+xmlhttp.params["obj_name"]).fadeOut('def');}
break;case 2:case 3:$('#'+xmlhttp.params["obj_name"]).slideToggle('def');break;}}}
function UpdateTreeNode(Id,ParentId,strLink,img_closed,img_open,effect){if(typeof(effect)=="undefined"){effect=2;}
var obj_name=Id+'_'+ParentId+'_e';var obj=document.getElementById(obj_name);if(obj){UpdateNodeImage(obj_name,ParentId,img_open,img_closed)
if(obj.innerHTML==''&&strLink){var params={"obj":obj,"obj_name":obj_name,"ParentId":ParentId,"effect":effect};var HTTPobj=new XMLHttp(UpdateTreeNode_callback,params);HTTPobj.GetContent(strLink);}
else{if(obj.innerHTML!=''){switch(effect){case 0:$('#'+obj_name).toggle(0);break;case 1:if($('#'+obj_name).css("display")=="none"){$('#'+obj_name).fadeIn('def');}
else{$('#'+obj_name).fadeOut('def');}
break;case 2:case 3:$('#'+obj_name).slideToggle('def');break;}}}}}
function UpdateTreeBranch(Id,NodeId,URL,callback,callback_params){BoxHide(Id+'_'+NodeId+'_e');UpdateStaticContent(Id+'_'+NodeId+'_e','');UpdateContent(Id+'_'+NodeId+'_n',URL,callback,callback_params);}
function UpdateTreeSort(id,marker,post_url){var data=new Array();var selector='#'+id+'_'+marker+' div.dragdrop';$(selector).each(function(i,elm){data[i]=$(elm).attr("id").replace(id+'_','');});if(data.length){$.post(post_url,{"ids[]":data});}}//

function TabElement(name, content) {
	this.name = name;
	this.content = content;
	
}

function AddTabElement(name, content) {
	var i = this.elements.length;
	this.elements[i] = new TabElement(name, content);
}

function TabPage(name) {
	this.name = name;
	this.elements = new array();
	this.addElement = AddTabElement;
}

var XDB_DEBUG=false;var ThemeId=null;String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"");}
String.prototype.ltrim=function(){return this.replace(/^\s+/,"");}
String.prototype.rtrim=function(){return this.replace(/\s+$/,"");}
function getStyle(obj,styleProp){var y=null;if(obj.currentStyle)
var y=obj.currentStyle[styleProp];else if(window.getComputedStyle)
var y=document.defaultView.getComputedStyle(obj,null).getPropertyValue(styleProp);return y;}
function getSize(){var myWidth=0,myHeight=0;if(typeof(window.innerWidth)=='number'){myWidth=window.innerWidth;myHeight=window.innerHeight;}
else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){myWidth=document.documentElement.clientWidth;myHeight=document.documentElement.clientHeight;}
else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){myWidth=document.body.clientWidth;myHeight=document.body.clientHeight;}
return[myWidth,myHeight];}
function getScrollXY(element){var scrOfX=0,scrOfY=0;if(element){scrOfY=element.scrollTop;scrOfX=element.scrollLeft;}
else{if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;scrOfX=window.pageXOffset;}
else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}
else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}}
return[scrOfX,scrOfY];}
function GetPosition(element,absolute){var curNode=element;var left=0;var top=0;var width=element.offsetWidth;var height=element.offsetHeight;do{left+=curNode.offsetLeft;top+=curNode.offsetTop;curNode=curNode.offsetParent;if(curNode){var p=getStyle(curNode,'position');}}while(curNode&&(absolute||(p!='relative'&&p!='absolute')));return[left,top,width,height];}
function getElementsByClassName(clsName,htmltag){var arr=new Array();var e=document.getElementsByTagName(htmltag);for(var elem,i=0;i<e.length;i++){if(e[i].className==clsName){arr[arr.length]=e[i];}}
return arr;}
var winPopup=null;function openWindow(strURL,width,height){var w=(width)?width:600;var h=(height)?height:400;var iTop=(screen.height-h);var iLeft=(screen.width-w)/2;if(winPopup!=null)winPopup.close();winPopup=window.open(strURL,"window_popup","screenX="+iLeft+",screenY="+iTop+",left="+iLeft+",top="+iTop+",height="+h+",width="+w+",alwaysRaised=1,scrollbars=1,directories=0,location=0,menubar=0,resizable=0,status=0,toolbar=0");winPopup.focus();}
function closeWindow(){if(winPopup!=null)winPopup.close();}
function MiniClientSniffer(){this.ua=navigator.userAgent.toLowerCase();this.major=parseInt(navigator.appVersion);this.Opera=this.ua.indexOf('opera')!=-1;if(this.Opera)return;this.IE=this.ua.indexOf('msie')!=-1;if(this.IE)return;this.Gecko=this.ua.indexOf('gecko')!=-1;this.Nav=(this.ua.indexOf('mozilla')!=-1&&this.ua.indexOf('spoofer')==-1&&this.ua.indexOf('compatible')==-1);this.Nav4=this.Nav&&this.major==4;}
function MoveInit(e){var ev=(e)?e:event;PopupWindow=is.IE?event.srcElement:e.target;while(!PopupWindow.id.match(/_Title/)&&PopupWindow.className!="Title"&&PopupWindow.tagName!="HTML"&&PopupWindow.tagName!="BODY"){PopupWindow=is.IE?PopupWindow.parentElement:PopupWindow.parentNode;}
if(PopupWindow.className=="TopMiddle"&&PopupWindow.id.match(/_Title/)){PopupWindow=is.IE?PopupWindow.parentElement:PopupWindow.parentNode;if(PopupWindow.className=="StandardPopUp"||PopupWindow.id=="ColorPicker"){if(ev.preventDefault){ev.preventDefault();}
else{ev.returnValue=false;}
var ScrollXY=getScrollXY();posX=ev.clientX+ScrollXY[0];posY=ev.clientY+ScrollXY[1];nowX=parseInt(getStyle(PopupWindow,'left'));nowY=parseInt(getStyle(PopupWindow,'top'));nowZ++;PopupWindow.style.zIndex=nowZ;MoveEnabled=true;document.onmousemove=MoveIt;}}
else{MoveEnabled=false;document.onmousemove=null;PopupWindow=null;}}
function MoveIt(e){if(!MoveEnabled){document.onmousemove=null;}
else{var ev=(e)?e:event;var ScrollXY=getScrollXY();var left=nowX-posX+ScrollXY[0]+ev.clientX;if(left<0)left=0;var top=nowY-posY+ScrollXY[1]+ev.clientY;if(top<0)top=0;PopupWindow.style.left=left+'px';PopupWindow.style.top=top+'px';}}
function CreatePopUp(id,className,parentElement,popup_title,modal){if(modal){CreateModal(id+'_modal');}
var PopUp=document.getElementById(id);if(!PopUp){PopUp=document.createElement('div');PopUp.id=id;if(className){PopUp.className=className;}
if(parentElement){var element=document.getElementById(parentElement);element.appendChild(PopUp);}
if(popup_title){PopUp.innerHTML="<div class=\"TopLeft\"></div><div id=\""+id+"_Title\" class=\"TopMiddle\"><div class=\"Icon\" onclick=\"ClosePopup('"+id+"')\"></div>"+popup_title+"</div><div class=\"TopRight\"></div><div class=\"CenterLeft\"></div><div id=\""+id+"_Body\" class=\"CenterMiddle\"></div><div class=\"CenterRight\"></div><div class=\"BottomLeft\"></div><div class=\"BottomMiddle\"></div><div class=\"BottomRight\"></div>";}
nowZ++;PopUp.style.zIndex=nowZ;}
else{PopUp.className=className;var title=document.getElementById(id+'_Title');if(title){title.innerHTML="<div class=\"Icon\" onclick=\"ClosePopup('"+id+"')\"></div>"+popup_title;}}
return PopUp;}
function ClosePopup(id){BoxRemove(id);BoxRemove(id+'_modal');}
function CreateButton(label,href,confirmation,button_class){if(!button_class){button_class="StandardButton";}
if(confirmation){return'<a class="'+button_class+'" href="javascript:if(confirm(\''+confirmation+'\'))'+href+'"><span class="Left"></span><span class="Center">'+label+'</span><span class="Right"></span></a>';}
else{return'<a class="'+button_class+'" href="'+href+'"><span class="Left"></span><span class="Center">'+label+'</span><span class="Right"></span></a>';}}
function BoxHide(id){$('#'+id).hide();}
function BoxRemove(id){$('#'+id).fadeOut(400,function(){$('#'+id).remove()});}
function BoxShow(id,element){var obj=document.getElementById(id);if(obj){obj.style.display="block";if(element){BoxCenter(id);}}}
function BoxToggle(id,text){var obj=document.getElementById(id);if(obj){var display=getStyle(obj,"display");if(display=="none"){if(text){var ts=new Date();obj.innerHTML=text+' '+ts.toString();}
obj.style.display="block";}
else{obj.style.display="none";}}}
function BoxCenter(id){var obj=$('#'+id);if(obj){var size=getSize();var scroll=getScrollXY();var top=scroll[1]+(size[1]-obj.height())/2;if(top<0)top=0;var left=scroll[0]+(size[0]-obj.width())/2;if(left<0)left=0;MoveTo(id,left,top);}}
function MoveTo(id,left,top){var obj=$('#'+id)
if(obj){var cssProp={position:'absolute',left:left+'px',top:top+'px'};obj.css(cssProp);}}
function HideAll(){$('div.StandardPopUp').css('display','none');}
function ShowAll(){$('div.StandardPopUp').css('display','block');}
function toggleGroup(id,speed){if($('#'+id+'_e').css("display")=='none'){$('#'+id+'_p').removeClass('Closed').addClass('Open');}
else{$('#'+id+'_p').removeClass('Open').addClass('Closed');}
$('#'+id+'_e').slideToggle(speed);}
var is=new MiniClientSniffer();var delay_timer=null;var delay_show=false;var MoveEnabled=false;var PopupWindow=null;var posX=0;var posY=0;var nowX=0;var nowY=0;var offX=0;var offY=0;var nowZ=0;function ShowTooltipDelayed(){if(PopupWindow&&delay_show){if($.browser.msie){$('#Tooltip').show();}
else{$('#Tooltip').fadeIn();}
PopupWindow.style.display='block';if(offX<0){nowX-=PopupWindow.offsetWidth;}
if(offY<0){nowY-=PopupWindow.offsetHeight;}
nowZ++;PopupWindow.style.zIndex=nowZ;PopupWindow.style.left=nowX+'px';PopupWindow.style.top=nowY+'px';}
delay_timer=null;delay_show=false;}
function ShowTooltip(caption,body,delay,e){var ev=(e)?e:event;var obj=CreatePopUp('Tooltip','StandardPopUp','body');if(obj){obj.className="StandardPopUp";if(caption){obj.innerHTML="<div class=\"TopLeft\"></div><div class=\"TopMiddle\">"+caption+"</div><div class=\"TopRight\"></div><div class=\"CenterLeft\"></div><div class=\"CenterMiddle\">"+body+"</div><div class=\"CenterRight\"></div><div class=\"BottomLeft\"></div><div class=\"BottomMiddle\"></div><div class=\"BottomRight\"></div>";}
else{obj.innerHTML="<div class=\"TopLeft\"></div><div class=\"TopMiddle\"></div><div class=\"TopRight\"></div><div class=\"CenterLeft\"></div><div class=\"CenterMiddle\">"+body+"</div><div class=\"CenterRight\"></div><div class=\"BottomLeft\"></div><div class=\"BottomMiddle\"></div><div class=\"BottomRight\"></div>";}
var ScrollXY=getScrollXY();var size=getSize();if(ev.clientX<=size[0]/2){offX=20;}
else{offX=-20;}
if(ev.clientY<=size[1]/2){offY=20;}
else{offY=-20;}
posX=ScrollXY[0]+ev.clientX;posY=ScrollXY[1]+ev.clientY;nowX=posX+offX;nowY=posY+offY;PopupWindow=obj;delay_show=true;if(delay){if(delay_timer){window.clearTimeout(delay_timer);}
delay_timer=window.setTimeout("ShowTooltipDelayed()",delay);}
else{ShowTooltipDelayed();}
MoveEnabled=true;document.onmousemove=MoveIt;}}
function ShowTooltipId(caption,id,delay,e){if(tooltip_cache&&tooltip_cache[id]){ShowTooltip(caption,tooltip_cache[id],delay,e);}}
function ShowTooltipURL(caption,URL,delay,e){var ev=(e)?e:event;var HTTPobj=new XMLHttp();var resp=HTTPobj.GetContent(URL);if(resp){ShowTooltip(caption,resp,delay,ev);}}
function HideTooltip(){MoveEnabled=false;document.onmousemove=null;delay_show=false;if(delay_timer){window.clearTimeout(delay_timer);delay_timer=null;}
if(PopupWindow){if($.browser.msie){$('#Tooltip').hide(function(){$('#Tooltip').remove()});}
else{$('#Tooltip').fadeOut(400,function(){$('#Tooltip').remove()});}
PopupWindow=null;}}
function CreateModal(id,className){if(!className){className='Modal';}
var Modal=document.getElementById(id);if(!Modal){var Modal=document.createElement('div');Modal.id=id;Modal.className=className;Modal.style.display='block';$('body').append(Modal);}
return Modal;}
function ShowWorking(element){if(getStyle(element,'display')=='none'){return null;}
else{var working=document.createElement('div');working.id='Working';working.innerHTML="<img style=\"vertical-align:middle;\" src=\"/images/working-circle.gif\" />";var pos=GetPosition(element);working.style.left=pos[0]+'px';working.style.top=pos[1]+'px';working.style.width=pos[2]+'px';working.style.height=pos[3]+'px';working.style.lineHeight=pos[3]+'px';working.style.zIndex=100;working.style.display='block';element.parentNode.insertBefore(working,element);return working;}}
function HideWorking(working){if(working){working.parentNode.removeChild(working);}}
function UpdateImage(id,URL){var obj=document.getElementById(id);if(obj){obj.src=URL;}}
function MsgBox(message,title){alert(message);}
function inputFocus(fld,className,insert)
{fld.className=className;if(insert&&(fld.type=='text'||fld.type=='textarea')&&fld.value==fld.defaultValue){fld.value="";}}
function inputBlur(fld,className,insert)
{fld.className=className;if(insert&&(fld.type=='text'||fld.type=='textarea')&&fld.value==""){fld.value=fld.defaultValue;}}
function ShowColorPicker(id){var cp=CreatePopUp("ColorPicker","StandardPopUp","body","Color Picker");var input='#'+id;$('#ColorPicker_Body').ColorPicker({flat:true,color:$(input).val().replace('#',''),onSubmit:function(hsb,hex,rgb){$(input).val('#'+hex);}});$('#ColorPicker_Body').append(CreateButton('Cancel','javascript:CloseColorPicker(\''+id+'\')')).append(CreateButton('Save','javascript:CloseColorPicker(\''+id+'\',true)'));BoxCenter('ColorPicker');$('#ColorPicker').fadeIn();}
function AddLoadEvent(obj_id,func){var obj=document.getElementById(obj_id);if(obj.addEventListener){obj.addEventListener('load',func,false);}
else if(div.attachEvent){obj.attachEvent('onload',func);}
else{obj['onload']=func;}}
function AdminPopup_callback(resp,xmlhttp){UpdateContent_callback(resp,xmlhttp);BoxCenter(xmlhttp.params["popup_id"]);$('#'+xmlhttp.params["popup_id"]).fadeIn();}
function ShowSearchResult(search_form){var params={"popup_id":"SearchResult"};var cp=CreatePopUp("SearchResult","StandardPopUp","body","Search Results");$('#SearchResult_Body').html("Searching! Please wait...");if(ValidateForm('SearchResult_Body','search.php?Mode=Search',search_form,true,AdminPopup_callback,params,120000,true)){BoxCenter("SearchResult");$('#SearchResult').fadeIn();}}
function ShowPopup(id,title,body,modal){var cp=CreatePopUp(id,"StandardPopUp","body",title,modal);UpdateStaticContent(id+'_Body',body);BoxCenter(id);$('#'+id).fadeIn();}
function ShowPopupImage(id,title,image_url,modal){var cp=CreatePopUp(id,"StandardPopUp","body",title,modal);UpdateStaticContent(id+'_Body','<img src=\"'+image_url+'\" />');BoxCenter(id);$('#'+id).fadeIn();}
function ShowPopupId(id,title,tip_id,modal){if(tooltip_cache&&tooltip_cache[tip_id]){ShowPopup(id,title,tooltip_cache[tip_id],modal);}}
function ShowPopupURL(id,title,url,modal){var params={"popup_id":id};var cp=CreatePopUp(id,"StandardPopUp","body",title,modal);UpdateContent(id+'_Body',url,AdminPopup_callback,params);}
function CloseColorPicker(id,save){if(save){var input='#'+id;$(input).val('#'+$('#ColorPicker_Body input').val());}
$('#ColorPicker').hide().remove();}
function setCookie(c_name,value,expiredays)
{var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+"="+escape(value)+((expiredays==null)?"":";expires="+exdate.toGMTString());}
document.onmousedown=MoveInit;document.onmouseup=function(){MoveEnabled=false;};(function($){$.fn.center=function(absolute){return this.each(function(){var t=$(this);t.css({position:absolute?'absolute':'fixed',left:'50%',top:'50%',zIndex:'99'}).css({marginLeft:'-'+(t.outerWidth()/2)+'px',marginTop:'-'+(t.outerHeight()/2)+'px'});if(absolute){t.css({marginTop:parseInt(t.css('marginTop'),10)+jQuery(window).scrollTop(),marginLeft:parseInt(t.css('marginLeft'),10)+jQuery(window).scrollLeft()});}});};$.fn.insertAtCaret=function(myValue){return this.each(function(){if(document.selection){this.focus();sel=document.selection.createRange();sel.text=myValue;this.focus();}
else if(this.selectionStart||this.selectionStart=='0'){var startPos=this.selectionStart;var endPos=this.selectionEnd;var scrollTop=this.scrollTop;this.value=this.value.substring(0,startPos)
+myValue
+this.value.substring(endPos,this.value.length);this.focus();this.selectionStart=startPos+myValue.length;this.selectionEnd=startPos+myValue.length;this.scrollTop=scrollTop;}else{this.value+=myValue;this.focus();}});}
$.fn.htmlEditor=function(){var commandEditor=function(target,command){var selected=encodeURIComponent(target.getSelectedHTML());switch(command){case"Image":html='<img @id@ @class@ @style@ src="@src@" />';break;case"Flash":html='<object @id@ @class@ @style@ type="application/x-shockwave-flash" data="@data@"> \
<param name="loop" value="@loop@" /> \
<param name="movie" value="@data@" /> \
<param name="quality" value="high" /> \
<param name="wmode" value="transparent" /> \
<img @style@ src="@src@" alt="" /> \
</object>';break;case"Flash Video":html='<object @id@ @class@ @style@ type="application/x-shockwave-flash" data="/player.swf" name="player"> \
<param name="movie" value="/player.swf" /> \
<param name="allowfullscreen" value="true" /> \
<param name="allowscriptaccess" value="always" /> \
<param name="flashvars" value="file=@data@&image=@url@" /> \
<param name="wmode" value="transparent" /> \
<img @style@ alt="" /> \
</object>';break;case"YouTube":html='<object @id@ @class@ @style@ type="application/x-shockwave-flash" data="@data@" name="YouTube Player"> \
<param name="movie" value="@data@"></param> \
<param name="allowfullscreen" value="true" /> \
<param name="allowscriptaccess" value="always" /> \
<param name="wmode" value="transparent" /> \
<img @style@ alt="" /> \
</object>';break;case"Quicktime Player":break;case"Media Player":break;case"Audio Player":html='<object id=@playerid@ type="application/x-shockwave-flash" data="/audio-player/player.swf" name="Audio Player" style="height:24px; width:290px"> \
<param name="movie" value="/audio-player/player.swf" /> \
<param name="FlashVars" value="playerID=@playerid@&amp;soundFile=@file@" /> \
<param name="quality" value="high" /> \
<param name="menu" value="false" /> \
<param name="wmode" value="transparent" /> \
<img style="height:24px; width:290px" alt="" /> \
</object>';break;case"Popup":html='<span @id@ @class@ @style@ onclick="return ShowPopup(\'@popup_id@\', \'@title@\', \'@body@\', @modal@);">@link@</span>';break;case"Popup Image":html='<span @id@ @class@ @style@ onclick="return ShowPopupImage(\'@popup_id@\', \'@title@\', \'@url@\', @modal@);">@link@</span>';break;case"Popup URL":html='<span @id@ @class@ @style@ onclick="return ShowPopupURL(\'@popup_id@\', \'@title@\', \'@url@\', @modal@);">@link@</span>';break;case"Container":html='<@container@ @id@ @class@ @style@>%content%</@container@>';case"Button":html='<a @id@ @class@ @style@ href="@href@" target="@target@"><span class="Left"></span><span class="Center">@label@</span><span class="Right"></span></a>';break;}
var editorPopup=$("<div/>").addClass("StandardPopUp").attr("id",'WebCommandsAdmin');editorPopup.html("<div class=\"TopLeft\"></div><div id=\"WebCommandsAdmin_Title\" class=\"TopMiddle\"><div class=\"Icon\" onclick=\"ClosePopup('WebCommandsAdmin')\"></div>"+command+"</div><div class=\"TopRight\"></div><div class=\"CenterLeft\"></div><div id=\"WebCommandsAdmin_Body\" class=\"CenterMiddle\"></div><div class=\"CenterRight\"></div><div class=\"BottomLeft\"></div><div class=\"BottomMiddle\"></div><div class=\"BottomRight\"></div>");editorPopup.appendTo("body");var params={"target":target,"html":html};UpdateContent('WebCommandsAdmin_Body','webcommands.php?Command='+command+'&Selected='+selected,commandCallback,params);},commandCallback=function(resp,xmlhttp){UpdateContent_callback(resp,xmlhttp);var but=$("<a/>").addClass("StandardButton").bind('click',function(){insertWebCommand(xmlhttp.params["target"],xmlhttp.params["html"]);});but.html("<span class=\"Left\"></span><span class=\"Center\">Insert</span><span class=\"Right\"></span>");but.appendTo('#WebCommandsAdmin_Body');$('#WebCommandsAdmin').center().fadeIn();},commandHTMLEntity=function(target){var editorPopup=$("<div/>").addClass("StandardPopUp").attr("id",'WebCommandsAdmin').attr("style","width:300px");editorPopup.html("<div class=\"TopLeft\"></div><div id=\"WebCommandsAdmin_Title\" class=\"TopMiddle\"><div class=\"Icon\" onclick=\"ClosePopup('WebCommandsAdmin')\"></div>HTML Entities</div><div class=\"TopRight\"></div><div class=\"CenterLeft\"></div><div id=\"WebCommandsAdmin_Body\" class=\"CenterMiddle\"></div><div class=\"CenterRight\"></div><div class=\"BottomLeft\"></div><div class=\"BottomMiddle\"></div><div class=\"BottomRight\"></div>");editorPopup.appendTo("body");var ent=['&#0153;','&#0169;','&#0174;','&#10003;','&#167;','&#8220;','&#8221;','&#8216;','&#8217;','<span class="CardBlack">&spades;</span>','<span class="CardBlack">&clubs;</span>','<span class="CardRed">&hearts;</span>','<span class="CardRed">&diams;</span>'];for(var i=0;i<ent.length;i++){var link=$("<span/>").addClass("HTMLEntity").append(ent[i]).click(function(){insertHTMLEntity(target,this.innerHTML);});link.appendTo('#WebCommandsAdmin_Body');}
$('#WebCommandsAdmin').center().fadeIn();},insertHTMLEntity=function(target,entity){target.pasteHTML(entity);target.updateTextArea();ClosePopup('WebCommandsAdmin');},insertWebCommand=function(target,command){var form_obj=document.getElementById("WebCommand_form");if(form_obj){for(var i=0;i<form_obj.length;i++){var field_name=form_obj.elements[i].id.substring(5,form_obj.elements[i].id.length);switch(field_name){case'id':case'class':case'style':if(form_obj.elements[i].value.length){command=command.replace(new RegExp('@'+field_name+'@','gim'),' '+field_name+'="'+form_obj.elements[i].value+'"');}
else{command=command.replace(new RegExp('@'+field_name+'@','gim'),'');}
break;default:switch(form_obj.elements[i].type){case'checkbox':if(form_obj.elements[i].checked){command=command.replace(new RegExp('@'+field_name+'@','gim'),1);}
else{command=command.replace(new RegExp('@'+field_name+'@','gim'),0);}
break;case'select-one':var index=form_obj.elements[i].selectedIndex;command=command.replace(new RegExp('@'+field_name+'@','gim'),form_obj.elements[i].options[index].value);break;default:command=command.replace(new RegExp('@'+field_name+'@','gim'),form_obj.elements[i].value);break;}
break;}}
target.pasteHTML(command);target.updateTextArea();ClosePopup('WebCommandsAdmin');}};return this.each(function(){var allowHTML=["html"];entity={css:"entity",text:"Insert Symbol",action:function(btn){commandHTMLEntity(this);}};fontcolor={css:"fontcolor",text:"Select font color",action:function(btn){alert('Not implemented yet');}};image={css:"image",text:"Insert Image",action:function(btn){commandEditor(this,"Image");}};flash={css:"flash",text:"Insert Flash",action:function(btn){commandEditor(this,"Flash");}};flashvideo={css:"flashvideo",text:"Insert Flash Video",action:function(btn){commandEditor(this,"Flash Video");}};youtube={css:"youtube",text:"Insert YouTube Player",action:function(btn){commandEditor(this,"YouTube");}};quicktimeplayer={css:"quicktimeplayer",text:"Insert Quicktime Player",action:function(btn){commandEditor(this,"Quicktime Player");}};mediaplayer={css:"mediaplayer",text:"Insert Media Player",action:function(btn){commandEditor(this,"Media Player");}};audioplayer={css:"audioplayer",text:"Insert Audio Player",action:function(btn){commandEditor(this,"Audio Player");}};popup={css:"popup",text:"Insert Popup",action:function(btn){commandEditor(this,"Popup");}};popupimg={css:"popupimg",text:"Insert Popup Image",action:function(btn){commandEditor(this,"Popup Image");}};popupurl={css:"popupurl",text:"Insert Popup URL",action:function(btn){commandEditor(this,"Popup URL");}};tooltip={css:"tooltip",text:"Insert Tooltop",action:function(btn){alert('Not implemented yet');}};tooltipurl={css:"tooltipurl",text:"Insert Tooltip with URL",action:function(btn){alert('Not implemented yet');}};container={css:"container",text:"Insert Box Container",action:function(btn){commandEditor(this,"Container");}};button={css:"button",text:"Insert Button",action:function(btn){commandEditor(this,"Button");}};quicksearch={css:"quicksearch",text:"Insert Quick Search",action:function(btn){alert('Not implemented yet');}};editelement={css:"editelement",text:"Edit Element",action:function(btn){var html=this.getSelectedHTML();var obj=html.match(/<([^ ]*) /);if(obj){switch(obj[1]){case'img':commandEditor(this,"Image");break;case'object':obj=html.match(/(player.swf)/);if(obj){commandEditor(this,"Flash Video");}
else{commandEditor(this,"Flash");}
break;default:obj=html.match(/(ShowPopup(Image|URL)?)/);if(obj){switch(obj[1]){case"ShowPopup":commandEditor(this,"Popup");break;case"ShowPopupImage":commandEditor(this,"Popup Image");break;case"ShowPopupURL":commandEditor(this,"Popup URL");break;}}
break;}}
else{alert(html);alert(obj);}}};removeformat={css:"removeformat",text:"Remove Format",action:function(btn){this.removeFormat();}};resize={css:"resize",text:"Fit to Content",action:function(btn){this.sizeToContent();}};$(this).htmlarea({toolbar:[["bold","italic","underline","strikethrough","|",entity,"|","subscript","superscript"],["increasefontsize","decreasefontsize",fontcolor],["orderedlist","unorderedlist"],["indent","outdent"],["justifyleft","justifycenter","justifyright","justifyfull"],["p","h1","h2","h3","h4","h5","h6"],[image],["link","unlink","horizontalrule"],[flash,flashvideo,quicktimeplayer,mediaplayer,youtube,audioplayer],[popup,popupimg,popupurl,tooltip,tooltipurl],[container,button,quicksearch],[editelement,removeformat,resize],allowHTML],css:"getcss.php?ThemeId="+ThemeId});});}})(jQuery);//
// $Id: xmlhttp.js,v 1.187 2010/07/29 05:56:20 frank Exp $
//
// Copyright 2006-2007 Tribue (Frank M. Kromann)
// Use of this file is only permitted with the authors consent.

// TODO: Make assync and implement global

function XMLHttp(callback, params, timeout) {
	var that = this;
	this.status = false;
	this.xmlhttp = false;
	this.URL = null;
	this.scripts = new Array();
	this.timeout = (timeout) ? timeout : 30000;
	this.callback = callback;
	this.params = params;
	this.timerid = null;
	this.resp = null;
	this.retry = false;
	this.content = null;
	// Hide tooltip if open
	HideTooltip();
	
	if (window.XMLHttpRequest) {		// code for Mozilla, etc.
		this.xmlhttp = new XMLHttpRequest()
	}
	else if (window.ActiveXObject) {	// code for IE
		this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
	}
	
	this.Response = function() {
		var tmp = that.xmlhttp.responseText.replace(/<\?xml(.*)\/?>\n?/gi, "");
		tmp = tmp.replace(/<!DOCTYPE(.*)?>\n?/gim, "");
		var scr = tmp.match(new RegExp('<script[^>]*>([\\S\\s]*?)<\/script>\\n?', 'img'));
		if (scr) {
			for (var i = 0; i < scr.length; i++) {
				that.scripts[that.scripts.length] = scr[i].replace(/<script[^>]*>/img, '').replace(/<\/script>/img, '');
			}
		}
		return tmp.replace(new RegExp('<script[^>]*>([\\S\\s]*?)<\/script>\\n?', 'img'), '');
	}

	this.EvalScripts = function() {
		for (var i = 0; i < that.scripts.length; i++) {
			eval(that.scripts[i]);
		}
	}
	
	this.ProcessStatus = function(aEvt) {
		if (that.xmlhttp.readyState == 4) {
			switch (that.xmlhttp.status) {
				case 0 :			// Aborted
					break;
				case 200 :			// if Ok
				case 304 :			// if not modified
					that.resp = that.Response();
					break;
				case 403 :			// file not found
				case 404 :
					that.resp = '<div class="PageTitle">Error</div><div class="Error">HTTP: 404 File not found</div><div>' + that.URL + '</div>';
					break;
				default :
					if (that.retry) {
						alert('ProcessStatus Status: ' + that.xmlhttp.status + ' is not supported at this time.');
					}
					else {
						that.retry = true;
						if (that.content) {
							that.xmlhttp.send(that.content);
						}
						else {
							that.xmlhttp.send(null);
						}
					}
					break;
			}
			if (that.timerid) {
				window.clearTimeout(that.timerid);
				that.timerid = null;
			}
			if (that.callback) {
				that.callback(that.resp, that);
			}
		}
	}
	
	this.GetContent = function(URL) {
		that.URL = URL.replace(/&amp;/img, "&");
		if (that.xmlhttp) {
			if (that.callback) {
				that.timerid = window.setTimeout(function() {
					that.xmlhttp.abort();
					alert("AJAX Request timed out: " + that.URL);
					if(that.params["working"]) {
						HideWorking(that.params["working"]);
					}
				}, that.timeout);
				that.xmlhttp.onreadystatechange = that.ProcessStatus;
//				that.xmlhttp.addEventListener("load", that.ProcessStatus, false);
				that.xmlhttp.open("GET", that.URL, true);
			}
			else {
				that.xmlhttp.open("GET", that.URL, false);
			}
			that.xmlhttp.setRequestHeader('X_Requested_With', 'XMLHttpRequest');
			that.xmlhttp.send(null);
			if (!that.callback) {
				that.ProcessStatus();
				return that.resp;
			}
			else {
				return true;
			}
		}
		else {
			return false;
		}
	}
	
	this.PostContent = function(URL, form_id, ignore_defaults) {
		that.URL = URL.replace(/&amp;/img, "&");
		if (that.xmlhttp) {
			var form_obj = document.getElementById(form_id + "_form");
			if (form_obj) {
				var r = [];
				for(var i = 0; i < form_obj.length; i++) {
					switch (form_obj.elements[i].type) {
						case 'undefined' :
							break;
						case 'radio' :
							if (form_obj.elements[i].checked) {
								r[r.length] = encodeURIComponent(form_obj.elements[i].name) + "=" + encodeURIComponent(form_obj.elements[i].value);
							}
							break;
						case 'select-one' :
							var index = form_obj.elements[i].selectedIndex;
							r[r.length] = encodeURIComponent(form_obj.elements[i].name) + "=" + encodeURIComponent(form_obj.elements[i].options[index].value);
							break;
						case 'select-multiple' :
							if (form_obj.elements[i].name.match(/\[\]$/)) {
								for (var o = 0; o < form_obj.elements[i].length; o++) {
									if (form_obj.elements[i].options[o].selected) {
										r[r.length] = encodeURIComponent(form_obj.elements[i].name) + "=" + encodeURIComponent(form_obj.elements[i].options[o].value);
									}
								}
							}
							else {
								var val = 0;
								for (var o = 0; o < form_obj.elements[i].length; o++) {
									if (form_obj.elements[i].options[o].selected) {
										val += parseInt(form_obj.elements[i].options[o].value);
									}
								}
								r[r.length] = encodeURIComponent(form_obj.elements[i].name) + "=" + encodeURIComponent(val);
							}
							break;
						case 'checkbox' :
							if (form_obj.elements[i].checked) {
								r[r.length] = encodeURIComponent(form_obj.elements[i].name) + "=" + encodeURIComponent(form_obj.elements[i].value);
							}
							else {
								r[r.length] = encodeURIComponent(form_obj.elements[i].name) + "=" + encodeURIComponent(0);
							}
							break;
						case 'hidden' :
							r[r.length] = encodeURIComponent(form_obj.elements[i].name) + "=" + encodeURIComponent(form_obj.elements[i].value);
							break;
						case 'password' :
							if (form_obj.elements[i].defaultValue != form_obj.elements[i].value || !ignore_defaults) {
								r[r.length] = encodeURIComponent(form_obj.elements[i].name) + "=" + encodeURIComponent(calcMD5(form_obj.elements[i].value));
							}
							break;
						default :
							if (form_obj.elements[i].defaultValue != form_obj.elements[i].value || !ignore_defaults) {
								r[r.length] = encodeURIComponent(form_obj.elements[i].name) + "=" + encodeURIComponent(form_obj.elements[i].value);
							}
							break;
					}
				}
				that.content = r.join('&');
				if (that.callback) {
					that.timerid = window.setTimeout(function() {
						that.xmlhttp.abort();
						alert("AJAX Request timed out: " + that.URL);
						if(that.params["working"]) {
							HideWorking(that.params["working"]);
						}
					}, that.timeout);
					that.xmlhttp.onreadystatechange = that.ProcessStatus;
					that.xmlhttp.open("POST", that.URL, true);
				}
				else {
					that.xmlhttp.open("POST", that.URL, false);
				}
				that.xmlhttp.setRequestHeader('X_Requested_With', 'XMLHttpRequest');
				that.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				that.xmlhttp.setRequestHeader('Charset', 'UTF-8');
				that.xmlhttp.setRequestHeader('Content-Length', that.content.length);
				that.xmlhttp.send(that.content);
			}
			else if (XDB_DEBUG) {
				alert('Object: ' + form_id + ' not found!');
			}
		}
		if (!that.callback) {
			that.ProcessStatus();
			return that.resp;
		}
	}

	this.GetJSON = function(URL) {
		that.URL = URL;
		if (that.xmlhttp) {
			if (that.callback) {
				that.timerid = window.setTimeout(function() {
					that.xmlhttp.abort();
					alert("AJAX Request timed out: " + that.URL);
				}, that.timeout);
				that.xmlhttp.onreadystatechange = that.ProcessStatus;
				that.xmlhttp.open("GET", URL, true);
			}
			else {
				that.xmlhttp.open("GET", URL, false);
			}
			that.xmlhttp.setRequestHeader('X_Requested_With', 'XMLHttpRequest');
			that.xmlhttp.send("");
		}
		if (that.xmlhttp.readyState == 4) {
			if ($.browser.msie && $.browser.version < 8) {
				return eval(that.xmlhttp.responseText);
			}
			else {
				return JSON.parse(that.xmlhttp.responseText);
			}
		}
		else {
			return that.status;
		}
	}
}

function SetFocus(form_id, field_id) {
	if (form_id && field_id) {
		$('#' + form_id + ' #' + field_id).focus().select();
	}
}

var focus_form = null;
var focus_field = null;

function UpdateContent_callback(resp, xmlhttp) {
	if (resp && resp != '') {
		if (resp.substring(0, 33) == "<body id=\"body\"><div class=\"Error") {
			ShowPopup('CallbackError', 'Error', resp);
		}
		else {
			var id = '#' + xmlhttp.params["id"];
			if (($.browser.msie && $.browser.version < 8) || $(id).css("display") == 'none') {
				$(id).html(resp);
			}
			else {
				$(id).hide().html(resp).fadeIn("normal");
			}
			xmlhttp.EvalScripts()
			if (xmlhttp.params["callback"]) {
				xmlhttp.params["callback"](xmlhttp.params["params"]);
			}
		}
	}
	HideWorking(xmlhttp.params["working"]);
	SetFocus(focus_form, focus_field);
}

function UpdateContent(id, URL, callback, callback_params, timeout) {
	focus_form = null;
	focus_field = null;
	if (URL && URL.length > 0) {
		var obj = document.getElementById(id);
		if (obj){
			var working = ShowWorking(obj);
			var params = {"working":working, "id":id};
			if (callback) {
				if (callback_params) {
					for(var key in callback_params) {
						params[key] = callback_params[key];
					}
				}
			}
			else {
				callback = UpdateContent_callback;
			}
			var HTTPobj = new XMLHttp(callback, params, timeout);
			HTTPobj.GetContent(URL);
		}
		else if (XDB_DEBUG) {
			alert('Object: ' + id + ' not found!');
		}
	}
}

function AddContent_callback(resp, xmlhttp) {
	if (resp && resp != '') {
		$('#' + xmlhttp.params["id"].innerHTML).append(resp);
		xmlhttp.EvalScripts();
	}
	HideWorking(xmlhttp.params["working"]);
	SetFocus(focus_form, focus_field);
}

function AddContent(id, URL) {
	focus_form = null;
	focus_field = null;
	if (URL && URL.length > 0) {
		var obj = document.getElementById(id);
		if (obj){
			var working = ShowWorking(obj);
			var params = {"working":working, "id":id};
			var HTTPobj = new XMLHttp(AddContent_callback, params);
			HTTPobj.GetContent(URL);
		}
		else if (XDB_DEBUG) {
			alert('Object: ' + id + ' not found!');
		}
	}
}

function RemoveContent(parent, child) {
	var p = document.getElementById(parent);
	var c = document.getElementById(child);
	if (p && c) {
		p.removeChild(c);
	}
}

function AddStylesheet(URL, media, title) {
	var cssNode = document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	cssNode.href = URL;
	if (media) {
		cssNode.media = media;
	}
	else {
		cssNode.media = 'screen';
	}
	if (title) {
		cssNode.title = title;
	}
	document.getElementsByTagName("head")[0].appendChild(cssNode);
}

function ReloadStylesheet(URL, title) {
	var nodes = document.getElementsByTagName("link");
	for (var i = 0; i<nodes.length; i++) {
		var s = nodes[i];
		if (s.rel == 'stylesheet' && s.href && s.title == title) {
			s.href = URL + (URL.indexOf('?') >= 0 ? '&' : '?') + 'Reload=' + (new Date().getTime());
		}
	}
}

function ResetForm(form_id) {
	var form_obj = document.getElementById(form_id + "_form");
	if (form_obj) {
		form_obj.reset();
	}
}

function PostContent(id, URL, form_id, callback, callback_params, timeout, ignore_defaults) {
	focus_form = null;
	focus_field = null;
	var obj = document.getElementById(id);
	if (obj){
		var working = ShowWorking(obj);
		var params = {"working":working, "id":id};
		if (callback) {
			if (callback_params) {
				for(var key in callback_params) {
					params[key] = callback_params[key];
				}
			}
		}
		else {
			callback = UpdateContent_callback;
		}
		var HTTPobj = new XMLHttp(callback, params, timeout);
		HTTPobj.PostContent(URL, form_id, ignore_defaults);
	}
	else if (XDB_DEBUG) {
		alert('Object: ' + id + ' not found!');
	}
}

function UpdateStaticContent(id, content) {
	if (typeof(content) != 'undefined') {
		if ($('#' + id)) {
			if ($.browser.msie && $.browser.version < 8) {
				$('#' + id).html(content);
			}
			else {
				$('#' + id).hide().html(content).fadeIn();
			}
		}
		else if (XDB_DEBUG) {
			alert('Object: ' + id + ' not found!');
		}
	}
}

function ShowNotification_callback(resp, xmlhttp) {
	UpdateContent_callback(resp, xmlhttp);
	BoxShow('NotificationPopUp', true);
}

function ShowNotification(page_xid, title) {
	if (page_xid) {
		var notification = CreatePopUp("NotificationPopUp", "StandardPopUp", "body", title);
		UpdateContent('NotificationPopUp_Body', 'page.php?PageId=' + page_xid, ShowNotification_callback);
	}
}

function GetJSON(URL) {
	var HTTPobj = new XMLHttp();
	return HTTPobj.GetJSON(URL);
}
(function($){var ColorPicker=function(){var
ids={},inAction,charMin=65,visible,tpl='<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',defaults={eventName:'click',onShow:function(){},onBeforeShow:function(){},onHide:function(){},onChange:function(){},onSubmit:function(){},color:'ff0000',livePreview:true,flat:false},fillRGBFields=function(hsb,cal){var rgb=HSBToRGB(hsb);$(cal).data('colorpicker').fields.eq(1).val(rgb.r).end().eq(2).val(rgb.g).end().eq(3).val(rgb.b).end();},fillHSBFields=function(hsb,cal){$(cal).data('colorpicker').fields.eq(4).val(hsb.h).end().eq(5).val(hsb.s).end().eq(6).val(hsb.b).end();},fillHexFields=function(hsb,cal){$(cal).data('colorpicker').fields.eq(0).val(HSBToHex(hsb)).end();},setSelector=function(hsb,cal){$(cal).data('colorpicker').selector.css('backgroundColor','#'+HSBToHex({h:hsb.h,s:100,b:100}));$(cal).data('colorpicker').selectorIndic.css({left:parseInt(150*hsb.s/100,10),top:parseInt(150*(100-hsb.b)/100,10)});},setHue=function(hsb,cal){$(cal).data('colorpicker').hue.css('top',parseInt(150-150*hsb.h/360,10));},setCurrentColor=function(hsb,cal){$(cal).data('colorpicker').currentColor.css('backgroundColor','#'+HSBToHex(hsb));},setNewColor=function(hsb,cal){$(cal).data('colorpicker').newColor.css('backgroundColor','#'+HSBToHex(hsb));},keyDown=function(ev){var pressedKey=ev.charCode||ev.keyCode||-1;if((pressedKey>charMin&&pressedKey<=90)||pressedKey==32){return false;}
var cal=$(this).parent().parent();if(cal.data('colorpicker').livePreview===true){change.apply(this);}},change=function(ev){var cal=$(this).parent().parent(),col;if(this.parentNode.className.indexOf('_hex')>0){cal.data('colorpicker').color=col=HexToHSB(fixHex(this.value));}else if(this.parentNode.className.indexOf('_hsb')>0){cal.data('colorpicker').color=col=fixHSB({h:parseInt(cal.data('colorpicker').fields.eq(4).val(),10),s:parseInt(cal.data('colorpicker').fields.eq(5).val(),10),b:parseInt(cal.data('colorpicker').fields.eq(6).val(),10)});}else{cal.data('colorpicker').color=col=RGBToHSB(fixRGB({r:parseInt(cal.data('colorpicker').fields.eq(1).val(),10),g:parseInt(cal.data('colorpicker').fields.eq(2).val(),10),b:parseInt(cal.data('colorpicker').fields.eq(3).val(),10)}));}
if(ev){fillRGBFields(col,cal.get(0));fillHexFields(col,cal.get(0));fillHSBFields(col,cal.get(0));}
setSelector(col,cal.get(0));setHue(col,cal.get(0));setNewColor(col,cal.get(0));cal.data('colorpicker').onChange.apply(cal,[col,HSBToHex(col),HSBToRGB(col)]);},blur=function(ev){var cal=$(this).parent().parent();cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus');},focus=function(){charMin=this.parentNode.className.indexOf('_hex')>0?70:65;$(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');$(this).parent().addClass('colorpicker_focus');},downIncrement=function(ev){var field=$(this).parent().find('input').focus();var current={el:$(this).parent().addClass('colorpicker_slider'),max:this.parentNode.className.indexOf('_hsb_h')>0?360:(this.parentNode.className.indexOf('_hsb')>0?100:255),y:ev.pageY,field:field,val:parseInt(field.val(),10),preview:$(this).parent().parent().data('colorpicker').livePreview};$(document).bind('mouseup',current,upIncrement);$(document).bind('mousemove',current,moveIncrement);},moveIncrement=function(ev){ev.data.field.val(Math.max(0,Math.min(ev.data.max,parseInt(ev.data.val+ev.pageY-ev.data.y,10))));if(ev.data.preview){change.apply(ev.data.field.get(0),[true]);}
return false;},upIncrement=function(ev){change.apply(ev.data.field.get(0),[true]);ev.data.el.removeClass('colorpicker_slider').find('input').focus();$(document).unbind('mouseup',upIncrement);$(document).unbind('mousemove',moveIncrement);return false;},downHue=function(ev){var current={cal:$(this).parent(),y:$(this).offset().top};current.preview=current.cal.data('colorpicker').livePreview;$(document).bind('mouseup',current,upHue);$(document).bind('mousemove',current,moveHue);},moveHue=function(ev){change.apply(ev.data.cal.data('colorpicker').fields.eq(4).val(parseInt(360*(150-Math.max(0,Math.min(150,(ev.pageY-ev.data.y))))/150,10)).get(0),[ev.data.preview]);return false;},clickHue=function(ev){var current={cal:$(this).parent(),y:$(this).offset().top};current.preview=current.cal.data('colorpicker').livePreview;change.apply(current.cal.data('colorpicker').fields.eq(4).val(parseInt(360*(150-Math.max(0,Math.min(150,(ev.pageY-current.y))))/150,10)).get(0),[current.preview]);return false;},upHue=function(ev){fillRGBFields(ev.data.cal.data('colorpicker').color,ev.data.cal.get(0));fillHexFields(ev.data.cal.data('colorpicker').color,ev.data.cal.get(0));$(document).unbind('mouseup',upHue);$(document).unbind('mousemove',moveHue);return false;},downSelector=function(ev){var current={cal:$(this).parent(),pos:$(this).offset()};current.preview=current.cal.data('colorpicker').livePreview;$(document).bind('mouseup',current,upSelector);$(document).bind('mousemove',current,moveSelector);},moveSelector=function(ev){change.apply(ev.data.cal.data('colorpicker').fields.eq(6).val(parseInt(100*(150-Math.max(0,Math.min(150,(ev.pageY-ev.data.pos.top))))/150,10)).end().eq(5).val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX-ev.data.pos.left))))/150,10)).get(0),[ev.data.preview]);return false;},clickSelector=function(ev){var current={cal:$(this).parent(),pos:$(this).offset()};current.preview=current.cal.data('colorpicker').livePreview;change.apply(current.cal.data('colorpicker').fields.eq(6).val(parseInt(100*(150-Math.max(0,Math.min(150,(ev.pageY-current.pos.top))))/150,10)).end().eq(5).val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX-current.pos.left))))/150,10)).get(0),[current.preview]);return false;},upSelector=function(ev){fillRGBFields(ev.data.cal.data('colorpicker').color,ev.data.cal.get(0));fillHexFields(ev.data.cal.data('colorpicker').color,ev.data.cal.get(0));$(document).unbind('mouseup',upSelector);$(document).unbind('mousemove',moveSelector);return false;},enterSubmit=function(ev){$(this).addClass('colorpicker_focus');},leaveSubmit=function(ev){$(this).removeClass('colorpicker_focus');},clickSubmit=function(ev){var cal=$(this).parent();var col=cal.data('colorpicker').color;cal.data('colorpicker').origColor=col;setCurrentColor(col,cal.get(0));cal.data('colorpicker').onSubmit(col,HSBToHex(col),HSBToRGB(col),cal.data('colorpicker').el);},show=function(ev){var cal=$('#'+$(this).data('colorpickerId'));cal.data('colorpicker').onBeforeShow.apply(this,[cal.get(0)]);var pos=$(this).offset();var viewPort=getViewport();var top=pos.top+this.offsetHeight;var left=pos.left;if(top+176>viewPort.t+viewPort.h){top-=this.offsetHeight+176;}
if(left+356>viewPort.l+viewPort.w){left-=356;}
cal.css({left:left+'px',top:top+'px'});if(cal.data('colorpicker').onShow.apply(this,[cal.get(0)])!=false){cal.show();}
$(document).bind('mousedown',{cal:cal},hide);return false;},hide=function(ev){if(!isChildOf(ev.data.cal.get(0),ev.target,ev.data.cal.get(0))){if(ev.data.cal.data('colorpicker').onHide.apply(this,[ev.data.cal.get(0)])!=false){ev.data.cal.hide();}
$(document).unbind('mousedown',hide);}},isChildOf=function(parentEl,el,container){if(parentEl==el){return true;}
if(parentEl.contains){return parentEl.contains(el);}
if(parentEl.compareDocumentPosition){return!!(parentEl.compareDocumentPosition(el)&16);}
var prEl=el.parentNode;while(prEl&&prEl!=container){if(prEl==parentEl)
return true;prEl=prEl.parentNode;}
return false;},getViewport=function(){var m=document.compatMode=='CSS1Compat';return{l:window.pageXOffset||(m?document.documentElement.scrollLeft:document.body.scrollLeft),t:window.pageYOffset||(m?document.documentElement.scrollTop:document.body.scrollTop),w:window.innerWidth||(m?document.documentElement.clientWidth:document.body.clientWidth),h:window.innerHeight||(m?document.documentElement.clientHeight:document.body.clientHeight)};},fixHSB=function(hsb){return{h:Math.min(360,Math.max(0,hsb.h)),s:Math.min(100,Math.max(0,hsb.s)),b:Math.min(100,Math.max(0,hsb.b))};},fixRGB=function(rgb){return{r:Math.min(255,Math.max(0,rgb.r)),g:Math.min(255,Math.max(0,rgb.g)),b:Math.min(255,Math.max(0,rgb.b))};},fixHex=function(hex){var len=6-hex.length;if(len>0){var o=[];for(var i=0;i<len;i++){o.push('0');}
o.push(hex);hex=o.join('');}
return hex;},HexToRGB=function(hex){var hex=parseInt(((hex.indexOf('#')>-1)?hex.substring(1):hex),16);return{r:hex>>16,g:(hex&0x00FF00)>>8,b:(hex&0x0000FF)};},HexToHSB=function(hex){return RGBToHSB(HexToRGB(hex));},RGBToHSB=function(rgb){var hsb={h:0,s:0,b:0};var min=Math.min(rgb.r,rgb.g,rgb.b);var max=Math.max(rgb.r,rgb.g,rgb.b);var delta=max-min;hsb.b=max;if(max!=0){}
hsb.s=max!=0?255*delta/max:0;if(hsb.s!=0){if(rgb.r==max){hsb.h=(rgb.g-rgb.b)/delta;}else if(rgb.g==max){hsb.h=2+(rgb.b-rgb.r)/delta;}else{hsb.h=4+(rgb.r-rgb.g)/delta;}}else{hsb.h=-1;}
hsb.h*=60;if(hsb.h<0){hsb.h+=360;}
hsb.s*=100/255;hsb.b*=100/255;return hsb;},HSBToRGB=function(hsb){var rgb={};var h=Math.round(hsb.h);var s=Math.round(hsb.s*255/100);var v=Math.round(hsb.b*255/100);if(s==0){rgb.r=rgb.g=rgb.b=v;}else{var t1=v;var t2=(255-s)*v/255;var t3=(t1-t2)*(h%60)/60;if(h==360)h=0;if(h<60){rgb.r=t1;rgb.b=t2;rgb.g=t2+t3}
else if(h<120){rgb.g=t1;rgb.b=t2;rgb.r=t1-t3}
else if(h<180){rgb.g=t1;rgb.r=t2;rgb.b=t2+t3}
else if(h<240){rgb.b=t1;rgb.r=t2;rgb.g=t1-t3}
else if(h<300){rgb.b=t1;rgb.g=t2;rgb.r=t2+t3}
else if(h<360){rgb.r=t1;rgb.g=t2;rgb.b=t1-t3}
else{rgb.r=0;rgb.g=0;rgb.b=0}}
return{r:Math.round(rgb.r),g:Math.round(rgb.g),b:Math.round(rgb.b)};},RGBToHex=function(rgb){var hex=[rgb.r.toString(16),rgb.g.toString(16),rgb.b.toString(16)];$.each(hex,function(nr,val){if(val.length==1){hex[nr]='0'+val;}});return hex.join('');},HSBToHex=function(hsb){return RGBToHex(HSBToRGB(hsb));},restoreOriginal=function(){var cal=$(this).parent();var col=cal.data('colorpicker').origColor;cal.data('colorpicker').color=col;fillRGBFields(col,cal.get(0));fillHexFields(col,cal.get(0));fillHSBFields(col,cal.get(0));setSelector(col,cal.get(0));setHue(col,cal.get(0));setNewColor(col,cal.get(0));};return{init:function(opt){opt=$.extend({},defaults,opt||{});if(typeof opt.color=='string'){opt.color=HexToHSB(opt.color);}else if(opt.color.r!=undefined&&opt.color.g!=undefined&&opt.color.b!=undefined){opt.color=RGBToHSB(opt.color);}else if(opt.color.h!=undefined&&opt.color.s!=undefined&&opt.color.b!=undefined){opt.color=fixHSB(opt.color);}else{return this;}
return this.each(function(){if(!$(this).data('colorpickerId')){var options=$.extend({},opt);options.origColor=opt.color;var id='collorpicker_'+parseInt(Math.random()*1000);$(this).data('colorpickerId',id);var cal=$(tpl).attr('id',id);if(options.flat){cal.appendTo(this).show();}else{cal.appendTo(document.body);}
options.fields=cal.find('input').bind('keyup',keyDown).bind('change',change).bind('blur',blur).bind('focus',focus);cal.find('span').bind('mousedown',downIncrement).end().find('>div.colorpicker_current_color').bind('click',restoreOriginal);options.selector=cal.find('div.colorpicker_color').bind('mousedown',downSelector).bind('click',clickSelector);options.selectorIndic=options.selector.find('div div');options.el=this;options.hue=cal.find('div.colorpicker_hue div');cal.find('div.colorpicker_hue').bind('mousedown',downHue).bind('mousedown',clickHue);options.newColor=cal.find('div.colorpicker_new_color');options.currentColor=cal.find('div.colorpicker_current_color');cal.data('colorpicker',options);cal.find('div.colorpicker_submit').bind('mouseenter',enterSubmit).bind('mouseleave',leaveSubmit).bind('click',clickSubmit);fillRGBFields(options.color,cal.get(0));fillHSBFields(options.color,cal.get(0));fillHexFields(options.color,cal.get(0));setHue(options.color,cal.get(0));setSelector(options.color,cal.get(0));setCurrentColor(options.color,cal.get(0));setNewColor(options.color,cal.get(0));if(options.flat){cal.css({position:'relative',display:'block'});}else{$(this).bind(options.eventName,show);}}});},showPicker:function(){return this.each(function(){if($(this).data('colorpickerId')){show.apply(this);}});},hidePicker:function(){return this.each(function(){if($(this).data('colorpickerId')){$('#'+$(this).data('colorpickerId')).hide();}});},setColor:function(col){if(typeof col=='string'){col=HexToHSB(col);}else if(col.r!=undefined&&col.g!=undefined&&col.b!=undefined){col=RGBToHSB(col);}else if(col.h!=undefined&&col.s!=undefined&&col.b!=undefined){col=fixHSB(col);}else{return this;}
return this.each(function(){if($(this).data('colorpickerId')){var cal=$('#'+$(this).data('colorpickerId'));cal.data('colorpicker').color=col;cal.data('colorpicker').origColor=col;fillRGBFields(col,cal.get(0));fillHSBFields(col,cal.get(0));fillHexFields(col,cal.get(0));setHue(col,cal.get(0));setSelector(col,cal.get(0));setCurrentColor(col,cal.get(0));setNewColor(col,cal.get(0));}});}};}();$.fn.extend({ColorPicker:ColorPicker.init,ColorPickerHide:ColorPicker.hidePicker,ColorPickerShow:ColorPicker.showPicker,ColorPickerSetColor:ColorPicker.setColor});})(jQuery)
jQuery.easing['jswing']=jQuery.easing['swing'];jQuery.extend(jQuery.easing,{def:'easeOutQuad',swing:function(x,t,b,c,d){return jQuery.easing[jQuery.easing.def](x,t,b,c,d);},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b;},easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b;},easeInOutQuad:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b;},easeInCubic:function(x,t,b,c,d){return c*(t/=d)*t*t+b;},easeOutCubic:function(x,t,b,c,d){return c*((t=t/d-1)*t*t+1)+b;},easeInOutCubic:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t+b;return c/2*((t-=2)*t*t+2)+b;},easeInQuart:function(x,t,b,c,d){return c*(t/=d)*t*t*t+b;},easeOutQuart:function(x,t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b;},easeInOutQuart:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t+b;return-c/2*((t-=2)*t*t*t-2)+b;},easeInQuint:function(x,t,b,c,d){return c*(t/=d)*t*t*t*t+b;},easeOutQuint:function(x,t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b;},easeInOutQuint:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t*t+b;return c/2*((t-=2)*t*t*t*t+2)+b;},easeInSine:function(x,t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b;},easeOutSine:function(x,t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b;},easeInOutSine:function(x,t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b;},easeInExpo:function(x,t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b;},easeOutExpo:function(x,t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b;},easeInOutExpo:function(x,t,b,c,d){if(t==0)return b;if(t==d)return b+c;if((t/=d/2)<1)return c/2*Math.pow(2,10*(t-1))+b;return c/2*(-Math.pow(2,-10*--t)+2)+b;},easeInCirc:function(x,t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b;},easeOutCirc:function(x,t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b;},easeInOutCirc:function(x,t,b,c,d){if((t/=d/2)<1)return-c/2*(Math.sqrt(1-t*t)-1)+b;return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b;},easeInElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;},easeOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b;},easeInOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b;},easeInBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b;},easeOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;},easeInOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b;},easeInBounce:function(x,t,b,c,d){return c-jQuery.easing.easeOutBounce(x,d-t,0,c,d)+b;},easeOutBounce:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;}},easeInOutBounce:function(x,t,b,c,d){if(t<d/2)return jQuery.easing.easeInBounce(x,t*2,0,c,d)*.5+b;return jQuery.easing.easeOutBounce(x,t*2-d,0,c,d)*.5+c*.5+b;}});
(function($){$.fn.innerfade=function(options){return this.each(function(){$.innerfade(this,options);});};$.innerfade=function(container,options){var settings={'animationtype':'fade','speed':'normal','type':'sequence','timeout':2000,'containerheight':'auto','runningclass':'innerfade','children':null};if(options)
$.extend(settings,options);if(settings.children===null)
var elements=$(container).children();else
var elements=$(container).children(settings.children);if(elements.length>1){$(container).css('position','relative').css('height',settings.containerheight).addClass(settings.runningclass);for(var i=0;i<elements.length;i++){$(elements[i]).css('z-index',String(elements.length-i)).css('position','absolute').hide();};if(settings.type=="sequence"){setTimeout(function(){$.innerfade.next(elements,settings,1,0);},settings.timeout);$(elements[0]).show();}else if(settings.type=="random"){var last=Math.floor(Math.random()*(elements.length));setTimeout(function(){do{current=Math.floor(Math.random()*(elements.length));}while(last==current);$.innerfade.next(elements,settings,current,last);},settings.timeout);$(elements[last]).show();}else if(settings.type=='random_start'){settings.type='sequence';var current=Math.floor(Math.random()*(elements.length));setTimeout(function(){$.innerfade.next(elements,settings,(current+1)%elements.length,current);},settings.timeout);$(elements[current]).show();}else{alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');}}};$.innerfade.next=function(elements,settings,current,last){if(settings.animationtype=='slide'){$(elements[last]).slideUp(settings.speed);$(elements[current]).slideDown(settings.speed);}else if(settings.animationtype=='fade'){$(elements[last]).fadeOut(settings.speed);$(elements[current]).fadeIn(settings.speed,function(){removeFilter($(this)[0]);});}else
alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');if(settings.type=="sequence"){if((current+1)<elements.length){current=current+1;last=current-1;}else{current=0;last=elements.length-1;}}else if(settings.type=="random"){last=current;while(current==last)
current=Math.floor(Math.random()*elements.length);}else
alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');setTimeout((function(){$.innerfade.next(elements,settings,current,last);}),settings.timeout);};})(jQuery);function removeFilter(element){if(element.style.removeAttribute){element.style.removeAttribute('filter');}}
﻿
(function($){$.fn.htmlarea=function(opts){if(opts&&typeof(opts)==="string"){var args=[];for(var i=1;i<arguments.length;i++){args.push(arguments[i]);}
var htmlarea=jHtmlArea(this[0]);var f=htmlarea[opts];if(f){return f.apply(htmlarea,args);}}
return this.each(function(){jHtmlArea(this,opts);});};var jHtmlArea=window.jHtmlArea=function(elem,options){if(elem.jquery){return jHtmlArea(elem[0]);}
if(elem.jhtmlareaObject){return elem.jhtmlareaObject;}else{return new jHtmlArea.fn.init(elem,options);}};jHtmlArea.fn=jHtmlArea.prototype={jhtmlarea:"0.7.0",init:function(elem,options){if(elem.nodeName.toLowerCase()==="textarea"){var opts=$.extend({},jHtmlArea.defaultOptions,options);elem.jhtmlareaObject=this;var textarea=this.textarea=$(elem);var container=this.container=$("<div/>").addClass("jHtmlArea").width(textarea.width()).insertAfter(textarea);var toolbar=this.toolbar=$("<div/>").addClass("ToolBar").appendTo(container);priv.initToolBar.call(this,opts);var iframe=this.iframe=$("<iframe/>").height(textarea.height());iframe.width(textarea.width()-($.browser.msie?0:4));var htmlarea=this.htmlarea=$("<div/>").append(iframe);container.append(htmlarea).append(textarea.hide());priv.initEditor.call(this,opts);priv.attachEditorEvents.call(this);toolbar.width(textarea.width()-2);if(opts.loaded){opts.loaded.call(this);}}},dispose:function(){this.textarea.show().insertAfter(this.container);this.container.remove();this.textarea[0].jhtmlareaObject=null;},execCommand:function(a,b,c){this.iframe[0].contentWindow.focus();this.editor.execCommand(a,b||false,c||null);this.updateTextArea();},ec:function(a,b,c){this.execCommand(a,b,c);},queryCommandValue:function(a){this.iframe[0].contentWindow.focus();return this.editor.queryCommandValue(a);},qc:function(a){return this.queryCommandValue(a);},getSelectedHTML:function(){if($.browser.msie){return this.getRange().htmlText;}else{var elem=this.getRange().cloneContents();return $("<p/>").append($(elem)).html();}},getSelection:function(){if($.browser.msie){return this.editor.selection;}else{return this.iframe[0].contentDocument.defaultView.getSelection();}},getRange:function(){var s=this.getSelection();if(!s){return null;}
return(s.getRangeAt)?s.getRangeAt(0):s.createRange();},html:function(v){if(v){this.pastHTML(v);}else{return toHtmlString();}},pasteHTML:function(html){this.iframe[0].contentWindow.focus();var r=this.getRange();if($.browser.msie){r.pasteHTML(html);}else if($.browser.mozilla){r.deleteContents();r.insertNode($((html.indexOf("<")!=0)?$("<span/>").append(html):html)[0]);}else{r.deleteContents();r.insertNode($(this.iframe[0].contentWindow.document.createElement("span")).append($((html.indexOf("<")!=0)?"<span>"+html+"</span>":html))[0]);}
r.collapse(false);if(r.select){r.select();}},cut:function(){this.ec("cut");},copy:function(){this.ec("copy");},paste:function(){this.ec("paste");},bold:function(){this.ec("bold");},italic:function(){this.ec("italic");},underline:function(){this.ec("underline");},strikeThrough:function(){this.ec("strikethrough");},image:function(url){if($.browser.msie&&!url){this.ec("insertImage",true);}else{this.ec("insertImage",false,(url||prompt("Image URL:","http://")));}},removeFormat:function(){this.ec("removeFormat",false,[]);this.unlink();},link:function(){if($.browser.msie){this.ec("createLink",true);}else{this.ec("createLink",false,prompt("Link URL:","http://"));}},unlink:function(){this.ec("unlink",false,[]);},orderedList:function(){this.ec("insertorderedlist");},unorderedList:function(){this.ec("insertunorderedlist");},superscript:function(){this.ec("superscript");},subscript:function(){this.ec("subscript");},p:function(){this.formatBlock("<p>");},h1:function(){this.heading(1);},h2:function(){this.heading(2);},h3:function(){this.heading(3);},h4:function(){this.heading(4);},h5:function(){this.heading(5);},h6:function(){this.heading(6);},heading:function(h){this.formatBlock($.browser.msie?"Heading "+h:"h"+h);},indent:function(){this.ec("indent");},outdent:function(){this.ec("outdent");},insertHorizontalRule:function(){this.ec("insertHorizontalRule",false,"ht");},justifyLeft:function(){this.ec("justifyLeft");},justifyCenter:function(){this.ec("justifyCenter");},justifyRight:function(){this.ec("justifyRight");},justifyFull:function(){this.ec("justifyFull");},increaseFontSize:function(){if($.browser.msie){this.ec("fontSize",false,this.qc("fontSize")+1);}else if($.browser.safari){this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size","larger")[0]);}else{this.ec("increaseFontSize",false,"big");}},decreaseFontSize:function(){if($.browser.msie){this.ec("fontSize",false,this.qc("fontSize")-1);}else if($.browser.safari){this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size","smaller")[0]);}else{this.ec("decreaseFontSize",false,"small");}},forecolor:function(c){this.ec("foreColor",false,c||prompt("Enter HTML Color:","#"));},formatBlock:function(v){this.ec("formatblock",false,v||null);},showHTMLView:function(){this.updateTextArea();this.textarea.show();this.htmlarea.hide();$("ul li:not(li:has(a.html))",this.toolbar).hide();$("ul:not(:has(:visible))",this.toolbar).hide();$("ul li a.html",this.toolbar).addClass("highlighted");},hideHTMLView:function(){this.updateHtmlArea();this.textarea.hide();this.htmlarea.show();$("ul",this.toolbar).show();$("ul li",this.toolbar).show().find("a.html").removeClass("highlighted");},toggleHTMLView:function(){(this.textarea.is(":hidden"))?this.showHTMLView():this.hideHTMLView();},toHtmlString:function(){return this.editor.body.innerHTML;},toString:function(){return this.editor.body.innerText;},updateTextArea:function(){this.textarea.val(this.toHtmlString());},updateHtmlArea:function(){this.editor.body.innerHTML=this.textarea.val();},sizeToContent:function(){this.iframe.height(this.editor.documentElement.offsetHeight);}};jHtmlArea.fn.init.prototype=jHtmlArea.fn;jHtmlArea.defaultOptions={toolbar:[["html"],["bold","italic","underline","strikethrough","|","subscript","superscript"],["increasefontsize","decreasefontsize"],["orderedlist","unorderedlist"],["indent","outdent"],["justifyleft","justifycenter","justifyright","justifyfull"],["link","unlink","image","horizontalrule"],["p","h1","h2","h3","h4","h5","h6"],["cut","copy","paste"]],css:null,toolbarText:{bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strike-Through",cut:"Cut",copy:"Copy",paste:"Paste",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",p:"Paragraph",indent:"Indent",outdent:"Outdent",horizontalrule:"Insert Horizontal Rule",justifyleft:"Left Justify",justifycenter:"Center Justify",justifyright:"Right Justify",justifyfull:"Justify",increasefontsize:"Increase Font Size",decreasefontsize:"Decrease Font Size",forecolor:"Text Color",link:"Insert Link",unlink:"Remove Link",image:"Insert Image",orderedlist:"Insert Ordered List",unorderedlist:"Insert Unordered List",subscript:"Subscript",superscript:"Superscript",html:"Show/Hide HTML Source View"}};var priv={toolbarButtons:{strikethrough:"strikeThrough",orderedlist:"orderedList",unorderedlist:"unorderedList",horizontalrule:"insertHorizontalRule",justifyleft:"justifyLeft",justifycenter:"justifyCenter",justifyright:"justifyRight",justifyfull:"justifyFull",increasefontsize:"increaseFontSize",decreasefontsize:"decreaseFontSize",html:function(btn){this.toggleHTMLView();}},initEditor:function(options){var edit=this.editor=this.iframe[0].contentWindow.document;edit.designMode='on';edit.open();edit.write(this.textarea.val());edit.close();if(options.css){var e=edit.createElement('link');e.rel='stylesheet';e.type='text/css';e.href=options.css;edit.getElementsByTagName('head')[0].appendChild(e);}},initToolBar:function(options){var that=this;var menuItem=function(className,altText,action){return $("<li/>").append($("<a href='javascript:void(0);'/>").addClass(className).attr("title",altText).click(function(){action.call(that,$(this));}));};function addButtons(arr){if(arr.length){var ul=$("<ul/>").appendTo(that.toolbar);for(var i=0;i<arr.length;i++){var e=arr[i];if((typeof(e)).toLowerCase()==="string"){if(e==="|"){ul.append($('<li class="separator"/>'));}else{var f=(function(e){var m=priv.toolbarButtons[e]||e;if((typeof(m)).toLowerCase()==="function"){return function(btn){m.call(this,btn);};}else{return function(){this[m]();this.editor.body.focus();};}})(e.toLowerCase());var t=options.toolbarText[e.toLowerCase()];ul.append(menuItem(e.toLowerCase(),t||e,f));}}else{ul.append(menuItem(e.css,e.text,e.action));}}}};if(options.toolbar.length!==0&&priv.isArray(options.toolbar[0])){for(var i=0;i<options.toolbar.length;i++){addButtons(options.toolbar[i]);}}else{addButtons(options.toolbar);}},attachEditorEvents:function(){var t=this;var fnHA=function(){t.updateHtmlArea();};t.textarea.click(fnHA).keyup(fnHA).keydown(fnHA).mousedown(fnHA).blur(fnHA);var fnTA=function(){t.updateTextArea();};$(t.editor.body).click(fnTA).keyup(fnTA).keydown(fnTA).mousedown(fnTA).blur(fnTA);$('form').submit(function(){t.toggleHTMLView();t.toggleHTMLView();});if(window.__doPostBack){var old__doPostBack=__doPostBack;window.__doPostBack=function(){if(t){if(t.toggleHTMLView){t.toggleHTMLView();t.toggleHTMLView();}}
return old__doPostBack.apply(window,arguments);};}},isArray:function(v){return v&&typeof v==='object'&&typeof v.length==='number'&&typeof v.splice==='function'&&!(v.propertyIsEnumerable('length'));}};})(jQuery);;(function($){$.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=$.extend({},$.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?$.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value;};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new $.Autocompleter(this,options);});},result:function(handler){return this.bind("result",handler);},search:function(handler){return this.trigger("search",[handler]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(options){return this.trigger("setOptions",[options]);},unautocomplete:function(){return this.trigger("unautocomplete");}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){hasFocus=1;lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}
break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);}
break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);}
break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);}
break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;}
break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break;}}}
if(typeof fn=="function")fn(result);else $input.trigger("result",result&&[result.data,result.value]);}
$.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback);});}).bind("flushCache",function(){cache.flush();}).bind("setOptions",function(){$.extend(options,arguments[1]);if("data"in arguments[1])
cache.populate();}).bind("unautocomplete",function(){select.unbind();$input.unbind();$(input.form).unbind(".autocomplete");});function selectCurrent(){var selected=select.selected();if(!selected)
return false;var v=selected.result;previousValue=v;if(options.multiple){var words=trimWords($input.val());if(words.length>1){var seperator=options.multipleSeparator.length;var cursorAt=$(input).selection().start;var wordAt,progress=0;$.each(words,function(i,word){progress+=word.length;if(cursorAt<=progress){wordAt=i;return false;}
progress+=seperator;});words[wordAt]=v;v=words.join(options.multipleSeparator);}
v+=options.multipleSeparator;}
$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}
function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}
var currentValue=$input.val();if(!skipPrevCheck&&currentValue==previousValue)
return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)
currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value)
return[""];if(!options.multiple)
return[$.trim(value)];return $.map(value.split(options.multipleSeparator),function(word){return $.trim(value).length?$.trim(word):null;});}
function lastWord(value){if(!options.multiple)
return value;var words=trimWords(value);if(words.length==1)
return words[0];var cursorAt=$(input).selection().start;if(cursorAt==value.length){words=trimWords(value)}else{words=trimWords(value.replace(value.substring(cursorAt),""));}
return words[words.length-1];}
function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$(input).selection(previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}
else{$input.val("");$input.trigger("result",null);}}});}};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)
term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i<rows.length;i++){var row=$.trim(rows[i]);if(row){row=row.split("|");parsed[parsed.length]={data:row,value:row[0],result:options.formatResult&&options.formatResult(row,row[0])||row[0]};}}
return parsed;};function stopLoading(){$input.removeClass(options.loadingClass);};};$.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(row){return row[0];},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>");},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)
s=s.toLowerCase();var i=s.indexOf(sub);if(options.matchContains=="word"){i=s.toLowerCase().search("\\b"+sub.toLowerCase());}
if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}
if(!data[q]){length++;}
data[q]=value;}
function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i<ol;i++){var rawValue=options.data[i];rawValue=(typeof rawValue=="string")?[rawValue]:rawValue;var value=options.formatMatch(rawValue,i+1,options.data.length);if(value===false)
continue;var firstChar=value.charAt(0).toLowerCase();if(!stMatchSets[firstChar])
stMatchSets[firstChar]=[];var row={value:value,data:rawValue,result:options.formatResult&&options.formatResult(rawValue)||value};stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row);}};$.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value);});}
setTimeout(populate,25);function flush(){data={};length=0;}
return{flush:flush,add:add,populate:populate,load:function(q){if(!options.cacheLength||!length)
return null;if(!options.url&&options.matchContains){var csub=[];for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}
return csub;}else
if(data[q]){return data[q];}else
if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}
return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)
return;element=$("<div/>").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("<ul/>").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)
element.css("width",options.width);needsInit=false;}
function target(event){var element=event.target;while(element&&element.tagName!="LI")
element=element.parentNode;if(!element)
return[];return element;}
function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset<list.scrollTop()){list.scrollTop(offset);}}};function movePosition(step){active+=step;if(active<0){active=listItems.size()-1;}else if(active>=listItems.size()){active=0;}}
function limitNumberOfItems(available){return options.max&&options.max<available?options.max:available;}
function fillList(){list.empty();var max=limitNumberOfItems(data.length);for(var i=0;i<max;i++){if(!data[i])
continue;var formatted=options.formatItem(data[i].data,i+1,max,data[i].value,term);if(formatted===false)
continue;var li=$("<li/>").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i]);}
listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}
if($.fn.bgiframe)
list.bgiframe();}
return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.fn.selection=function(start,end){if(start!==undefined){return this.each(function(){if(this.createTextRange){var selRange=this.createTextRange();if(end===undefined||start==end){selRange.move("character",start);selRange.select();}else{selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}}else if(this.setSelectionRange){this.setSelectionRange(start,end);}else if(this.selectionStart){this.selectionStart=start;this.selectionEnd=end;}});}
var field=this[0];if(field.createTextRange){var range=document.selection.createRange(),orig=field.value,teststring="<->",textLength=range.text.length;range.text=teststring;var caretAt=field.value.indexOf(teststring);field.value=orig;this.selection(caretAt,caretAt+textLength);return{start:caretAt,end:caretAt+textLength}}else if(field.selectionStart!==undefined){return{start:field.selectionStart,end:field.selectionEnd}}};})(jQuery);
(function($){$.fn.dragsort=function(options){var opts=$.extend({},$.fn.dragsort.defaults,options);var lists=new Array();var list=null,lastPos=null;this.each(function(i,cont){if($(cont).is("table")&&$(cont).children().size()==1&&$(cont).children().is("tbody"))
cont=$(cont).children().get(0);var newList={draggedItem:null,placeHolderItem:null,pos:null,offset:null,offsetLimit:null,container:cont,init:function(){$(this.container).attr("listIdx",i).mousedown(this.grabItem).find(opts.dragSelector).css("cursor","pointer");},grabItem:function(e){if(e.button==2||$(e.target).is(opts.dragSelectorExclude))
return;var elm=e.target;while(!$(elm).is("[listIdx="+$(this).attr("listIdx")+"] "+opts.dragSelector)){if(elm==this)return;elm=elm.parentNode;}
if(list!=null&&list.draggedItem!=null)
list.dropItem();$(e.target).css("cursor","move");list=lists[$(this).attr("listIdx")];list.draggedItem=$(elm).closest(opts.itemSelector);var mt=parseInt(list.draggedItem.css("marginTop"));var ml=parseInt(list.draggedItem.css("marginLeft"));list.offset=list.draggedItem.offset();list.offset.top=e.pageY-list.offset.top+(isNaN(mt)?0:mt)-1;list.offset.left=e.pageX-list.offset.left+(isNaN(ml)?0:ml)-1;if(!opts.dragBetween){var containerHeight=$(list.container).outerHeight()==0?Math.max(1,Math.round(0.5+$(list.container).children(opts.itemSelector).size()*list.draggedItem.outerWidth()/$(list.container).outerWidth()))*list.draggedItem.outerHeight():$(list.container).outerHeight();list.offsetLimit=$(list.container).offset();list.offsetLimit.right=list.offsetLimit.left+$(list.container).outerWidth()-list.draggedItem.outerWidth();list.offsetLimit.bottom=list.offsetLimit.top+containerHeight-list.draggedItem.outerHeight();}
list.draggedItem.css({position:"absolute",opacity:0.8,"z-index":999}).after(opts.placeHolderTemplate);list.placeHolderItem=list.draggedItem.next().css("height",list.draggedItem.height()).attr("placeHolder",true);$(lists).each(function(i,l){l.ensureNotEmpty();l.buildPositionTable();});list.setPos(e.pageX,e.pageY);$(document).bind("selectstart",list.stopBubble);$(document).bind("mousemove",list.swapItems);$(document).bind("mouseup",list.dropItem);return false;},setPos:function(x,y){var top=y-this.offset.top;var left=x-this.offset.left;if(!opts.dragBetween){top=Math.min(this.offsetLimit.bottom,Math.max(top,this.offsetLimit.top));left=Math.min(this.offsetLimit.right,Math.max(left,this.offsetLimit.left));}
this.draggedItem.parents().each(function(){if($(this).css("position")!="static"&&(!$.browser.mozilla||$(this).css("display")!="table")){var offset=$(this).offset();top-=offset.top;left-=offset.left;return false;}});this.draggedItem.css({top:top,left:left});},buildPositionTable:function(){var item=this.draggedItem==null?null:this.draggedItem.get(0);var pos=new Array();$(this.container).children(opts.itemSelector).each(function(i,elm){if(elm!=item){var loc=$(elm).offset();loc.right=loc.left+$(elm).width();loc.bottom=loc.top+$(elm).height();loc.elm=elm;pos.push(loc);}});this.pos=pos;},dropItem:function(){if(list.draggedItem==null)
return;$(list.container).find(opts.dragSelector).css("cursor","pointer");list.placeHolderItem.before(list.draggedItem);list.draggedItem.css({position:"",top:"",left:"",opacity:"","z-index":""});list.placeHolderItem.remove();$("*[emptyPlaceHolder]").remove();opts.dragEnd.apply(list.draggedItem);list.draggedItem=null;$(document).unbind("selectstart",list.stopBubble);$(document).unbind("mousemove",list.swapItems);$(document).unbind("mouseup",list.dropItem);return false;},stopBubble:function(){return false;},swapItems:function(e){if(list.draggedItem==null)
return false;list.setPos(e.pageX,e.pageY);var ei=list.findPos(e.pageX,e.pageY);var nlist=list;for(var i=0;ei==-1&&opts.dragBetween&&i<lists.length;i++){ei=lists[i].findPos(e.pageX,e.pageY);nlist=lists[i];}
if(ei==-1||$(nlist.pos[ei].elm).attr("placeHolder"))
return false;if(lastPos==null||lastPos.top>list.draggedItem.offset().top||lastPos.left>list.draggedItem.offset().left)
$(nlist.pos[ei].elm).before(list.placeHolderItem);else
$(nlist.pos[ei].elm).after(list.placeHolderItem);$(lists).each(function(i,l){l.ensureNotEmpty();l.buildPositionTable();});lastPos=list.draggedItem.offset();return false;},findPos:function(x,y){for(var i=0;i<this.pos.length;i++){if(this.pos[i].left<x&&this.pos[i].right>x&&this.pos[i].top<y&&this.pos[i].bottom>y)
return i;}
return-1;},ensureNotEmpty:function(){if(!opts.dragBetween)
return;var item=this.draggedItem==null?null:this.draggedItem.get(0);var emptyPH=null,empty=true;$(this.container).children(opts.itemSelector).each(function(i,elm){if($(elm).attr("emptyPlaceHolder"))
emptyPH=elm;else if(elm!=item)
empty=false;});if(empty&&emptyPH==null)
$(this.container).append(opts.placeHolderTemplate).children(":last").attr("emptyPlaceHolder",true);else if(!empty&&emptyPH!=null)
$(emptyPH).remove();}};newList.init();lists.push(newList);});return this;};$.fn.dragsort.defaults={itemSelector:"li",dragSelector:"li",dragSelectorExclude:"input, a[href]",dragEnd:function(){},dragBetween:false,placeHolderTemplate:"<li>&nbsp;</li>"};})(jQuery);;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
(function(d){d.tools=d.tools||{};d.tools.tabs={version:"1.0.4",conf:{tabs:"a",current:"current",onBeforeClick:null,onClick:null,effect:"default",initialIndex:0,event:"click",api:false,rotate:false},addEffect:function(e,f){c[e]=f}};var c={"default":function(f,e){this.getPanes().hide().eq(f).show();e.call()},fade:function(g,e){var f=this.getConf(),j=f.fadeOutSpeed,h=this.getPanes();if(j){h.fadeOut(j)}else{h.hide()}h.eq(g).fadeIn(f.fadeInSpeed,e)},slide:function(f,e){this.getPanes().slideUp(200);this.getPanes().eq(f).slideDown(400,e)},ajax:function(f,e){this.getPanes().eq(0).load(this.getTabs().eq(f).attr("href"),e)}};var b;d.tools.tabs.addEffect("horizontal",function(f,e){if(!b){b=this.getPanes().eq(0).width()}this.getCurrentPane().animate({width:0},function(){d(this).hide()});this.getPanes().eq(f).animate({width:b},function(){d(this).show();e.call()})});function a(g,h,f){var e=this,j=d(this),i;d.each(f,function(k,l){if(d.isFunction(l)){j.bind(k,l)}});d.extend(this,{click:function(k,n){var o=e.getCurrentPane();var l=g.eq(k);if(typeof k=="string"&&k.replace("#","")){l=g.filter("[href*="+k.replace("#","")+"]");k=Math.max(g.index(l),0)}if(f.rotate){var m=g.length-1;if(k<0){return e.click(m,n)}if(k>m){return e.click(0,n)}}if(!l.length){if(i>=0){return e}k=f.initialIndex;l=g.eq(k)}if(k===i){return e}n=n||d.Event();n.type="onBeforeClick";j.trigger(n,[k]);if(n.isDefaultPrevented()){return}c[f.effect].call(e,k,function(){n.type="onClick";j.trigger(n,[k])});n.type="onStart";j.trigger(n,[k]);if(n.isDefaultPrevented()){return}i=k;g.removeClass(f.current);l.addClass(f.current);return e},getConf:function(){return f},getTabs:function(){return g},getPanes:function(){return h},getCurrentPane:function(){return h.eq(i)},getCurrentTab:function(){return g.eq(i)},getIndex:function(){return i},next:function(){return e.click(i+1)},prev:function(){return e.click(i-1)},bind:function(k,l){j.bind(k,l);return e},onBeforeClick:function(k){return this.bind("onBeforeClick",k)},onClick:function(k){return this.bind("onClick",k)},unbind:function(k){j.unbind(k);return e}});g.each(function(k){d(this).bind(f.event,function(l){e.click(k,l);return false})});if(location.hash){e.click(location.hash)}else{if(f.initialIndex===0||f.initialIndex>0){e.click(f.initialIndex)}}h.find("a[href^=#]").click(function(k){e.click(d(this).attr("href"),k)})}d.fn.tabs=function(i,f){var g=this.eq(typeof f=="number"?f:0).data("tabs");if(g){return g}if(d.isFunction(f)){f={onBeforeClick:f}}var h=d.extend({},d.tools.tabs.conf),e=this.length;f=d.extend(h,f);this.each(function(l){var j=d(this);var k=j.find(f.tabs);if(!k.length){k=j.children()}var m=i.jquery?i:j.children(i);if(!m.length){m=e==1?d(i):j.parent().find(i)}g=new a(k,m,f);j.data("tabs",g)});return f.api?g:this}})(jQuery);(function(c){var d=[];c.tools=c.tools||{};c.tools.tooltip={version:"1.1.3",conf:{effect:"toggle",fadeOutSpeed:"fast",tip:null,predelay:0,delay:30,opacity:1,lazy:undefined,position:["top","center"],offset:[0,0],cancelDefault:true,relative:false,oneInstance:true,events:{def:"mouseover,mouseout",input:"focus,blur",widget:"focus mouseover,blur mouseout",tooltip:"mouseover,mouseout"},api:false},addEffect:function(e,g,f){b[e]=[g,f]}};var b={toggle:[function(e){var f=this.getConf(),g=this.getTip(),h=f.opacity;if(h<1){g.css({opacity:h})}g.show();e.call()},function(e){this.getTip().hide();e.call()}],fade:[function(e){this.getTip().fadeIn(this.getConf().fadeInSpeed,e)},function(e){this.getTip().fadeOut(this.getConf().fadeOutSpeed,e)}]};function a(f,g){var p=this,k=c(this);f.data("tooltip",p);var l=f.next();if(g.tip){l=c(g.tip);if(l.length>1){l=f.nextAll(g.tip).eq(0);if(!l.length){l=f.parent().nextAll(g.tip).eq(0)}}}function o(u){var t=g.relative?f.position().top:f.offset().top,s=g.relative?f.position().left:f.offset().left,v=g.position[0];t-=l.outerHeight()-g.offset[0];s+=f.outerWidth()+g.offset[1];var q=l.outerHeight()+f.outerHeight();if(v=="center"){t+=q/2}if(v=="bottom"){t+=q}v=g.position[1];var r=l.outerWidth()+f.outerWidth();if(v=="center"){s-=r/2}if(v=="left"){s-=r}return{top:t,left:s}}var i=f.is(":input"),e=i&&f.is(":checkbox, :radio, select, :button"),h=f.attr("type"),n=g.events[h]||g.events[i?(e?"widget":"input"):"def"];n=n.split(/,\s*/);if(n.length!=2){throw"Tooltip: bad events configuration for "+h}f.bind(n[0],function(r){if(g.oneInstance){c.each(d,function(){this.hide()})}var q=l.data("trigger");if(q&&q[0]!=this){l.hide().stop(true,true)}r.target=this;p.show(r);n=g.events.tooltip.split(/,\s*/);l.bind(n[0],function(){p.show(r)});if(n[1]){l.bind(n[1],function(){p.hide(r)})}});f.bind(n[1],function(q){p.hide(q)});if(!c.browser.msie&&!i&&!g.predelay){f.mousemove(function(){if(!p.isShown()){f.triggerHandler("mouseover")}})}if(g.opacity<1){l.css("opacity",g.opacity)}var m=0,j=f.attr("title");if(j&&g.cancelDefault){f.removeAttr("title");f.data("title",j)}c.extend(p,{show:function(r){if(r){f=c(r.target)}clearTimeout(l.data("timer"));if(l.is(":animated")||l.is(":visible")){return p}function q(){l.data("trigger",f);var t=o(r);if(g.tip&&j){l.html(f.data("title"))}r=r||c.Event();r.type="onBeforeShow";k.trigger(r,[t]);if(r.isDefaultPrevented()){return p}t=o(r);l.css({position:"absolute",top:t.top,left:t.left});var s=b[g.effect];if(!s){throw'Nonexistent effect "'+g.effect+'"'}s[0].call(p,function(){r.type="onShow";k.trigger(r)})}if(g.predelay){clearTimeout(m);m=setTimeout(q,g.predelay)}else{q()}return p},hide:function(r){clearTimeout(l.data("timer"));clearTimeout(m);if(!l.is(":visible")){return}function q(){r=r||c.Event();r.type="onBeforeHide";k.trigger(r);if(r.isDefaultPrevented()){return}b[g.effect][1].call(p,function(){r.type="onHide";k.trigger(r)})}if(g.delay&&r){l.data("timer",setTimeout(q,g.delay))}else{q()}return p},isShown:function(){return l.is(":visible, :animated")},getConf:function(){return g},getTip:function(){return l},getTrigger:function(){return f},bind:function(q,r){k.bind(q,r);return p},onHide:function(q){return this.bind("onHide",q)},onBeforeShow:function(q){return this.bind("onBeforeShow",q)},onShow:function(q){return this.bind("onShow",q)},onBeforeHide:function(q){return this.bind("onBeforeHide",q)},unbind:function(q){k.unbind(q);return p}});c.each(g,function(q,r){if(c.isFunction(r)){p.bind(q,r)}})}c.prototype.tooltip=function(e){var f=this.eq(typeof e=="number"?e:0).data("tooltip");if(f){return f}var g=c.extend(true,{},c.tools.tooltip.conf);if(c.isFunction(e)){e={onBeforeShow:e}}else{if(typeof e=="string"){e={tip:e}}}e=c.extend(true,g,e);if(typeof e.position=="string"){e.position=e.position.split(/,?\s/)}if(e.lazy!==false&&(e.lazy===true||this.length>20)){this.one("mouseover",function(h){f=new a(c(this),e);f.show(h);d.push(f)})}else{this.each(function(){f=new a(c(this),e);d.push(f)})}return e.api?f:this}})(jQuery);(function(b){var a=b.tools.tooltip;a.effects=a.effects||{};a.effects.slide={version:"1.0.0"};b.extend(a.conf,{direction:"up",bounce:false,slideOffset:10,slideInSpeed:200,slideOutSpeed:200,slideFade:!b.browser.msie});var c={up:["-","top"],down:["+","top"],left:["-","left"],right:["+","left"]};b.tools.tooltip.addEffect("slide",function(d){var f=this.getConf(),g=this.getTip(),h=f.slideFade?{opacity:f.opacity}:{},e=c[f.direction]||c.up;h[e[1]]=e[0]+"="+f.slideOffset;if(f.slideFade){g.css({opacity:0})}g.show().animate(h,f.slideInSpeed,d)},function(e){var g=this.getConf(),i=g.slideOffset,h=g.slideFade?{opacity:0}:{},f=c[g.direction]||c.up;var d=""+f[0];if(g.bounce){d=d=="+"?"-":"+"}h[f[1]]=d+"="+i;this.getTip().animate(h,g.slideOutSpeed,function(){b(this).hide();e.call()})})})(jQuery);(function(d){var c=d.tools.tooltip;c.plugins=c.plugins||{};c.plugins.dynamic={version:"1.0.1",conf:{api:false,classNames:"top right bottom left"}};function b(h){var e=d(window);var g=e.width()+e.scrollLeft();var f=e.height()+e.scrollTop();return[h.offset().top<=e.scrollTop(),g<=h.offset().left+h.width(),f<=h.offset().top+h.height(),e.scrollLeft()>=h.offset().left]}function a(f){var e=f.length;while(e--){if(f[e]){return false}}return true}d.fn.dynamic=function(g){var h=d.extend({},c.plugins.dynamic.conf),f;if(typeof g=="number"){g={speed:g}}g=d.extend(h,g);var e=g.classNames.split(/\s/),i;this.each(function(){if(d(this).tooltip().jquery){throw"Lazy feature not supported by dynamic plugin. set lazy: false for tooltip"}var j=d(this).tooltip().onBeforeShow(function(n,o){var m=this.getTip(),l=this.getConf();if(!i){i=[l.position[0],l.position[1],l.offset[0],l.offset[1],d.extend({},l)]}d.extend(l,i[4]);l.position=[i[0],i[1]];l.offset=[i[2],i[3]];m.css({visibility:"hidden",position:"absolute",top:o.top,left:o.left}).show();var k=b(m);if(!a(k)){if(k[2]){d.extend(l,g.top);l.position[0]="top";m.addClass(e[0])}if(k[3]){d.extend(l,g.right);l.position[1]="right";m.addClass(e[1])}if(k[0]){d.extend(l,g.bottom);l.position[0]="bottom";m.addClass(e[2])}if(k[1]){d.extend(l,g.left);l.position[1]="left";m.addClass(e[3])}if(k[0]||k[2]){l.offset[0]*=-1}if(k[1]||k[3]){l.offset[1]*=-1}}m.css({visibility:"visible"}).hide()});j.onShow(function(){var l=this.getConf(),k=this.getTip();l.position=[i[0],i[1]];l.offset=[i[2],i[3]]});j.onHide(function(){var k=this.getTip();k.removeClass(g.classNames)});f=j});return g.api?f:this}})(jQuery);(function(b){b.tools=b.tools||{};b.tools.scrollable={version:"1.1.2",conf:{size:5,vertical:false,speed:400,keyboard:true,keyboardSteps:null,disabledClass:"disabled",hoverClass:null,clickable:true,activeClass:"active",easing:"swing",loop:false,items:".items",item:null,prev:".prev",next:".next",prevPage:".prevPage",nextPage:".nextPage",api:false}};var c;function a(o,m){var r=this,p=b(this),d=!m.vertical,e=o.children(),k=0,i;if(!c){c=r}b.each(m,function(s,t){if(b.isFunction(t)){p.bind(s,t)}});if(e.length>1){e=b(m.items,o)}function l(t){var s=b(t);return m.globalNav?s:o.parent().find(t)}o.data("finder",l);var f=l(m.prev),h=l(m.next),g=l(m.prevPage),n=l(m.nextPage);b.extend(r,{getIndex:function(){return k},getClickIndex:function(){var s=r.getItems();return s.index(s.filter("."+m.activeClass))},getConf:function(){return m},getSize:function(){return r.getItems().size()},getPageAmount:function(){return Math.ceil(this.getSize()/m.size)},getPageIndex:function(){return Math.ceil(k/m.size)},getNaviButtons:function(){return f.add(h).add(g).add(n)},getRoot:function(){return o},getItemWrap:function(){return e},getItems:function(){return e.children(m.item)},getVisibleItems:function(){return r.getItems().slice(k,k+m.size)},seekTo:function(s,w,t){if(s<0){s=0}if(k===s){return r}if(b.isFunction(w)){t=w}if(s>r.getSize()-m.size){return m.loop?r.begin():this.end()}var u=r.getItems().eq(s);if(!u.length){return r}var v=b.Event("onBeforeSeek");p.trigger(v,[s]);if(v.isDefaultPrevented()){return r}if(w===undefined||b.isFunction(w)){w=m.speed}function x(){if(t){t.call(r,s)}p.trigger("onSeek",[s])}if(d){e.animate({left:-u.position().left},w,m.easing,x)}else{e.animate({top:-u.position().top},w,m.easing,x)}c=r;k=s;v=b.Event("onStart");p.trigger(v,[s]);if(v.isDefaultPrevented()){return r}f.add(g).toggleClass(m.disabledClass,s===0);h.add(n).toggleClass(m.disabledClass,s>=r.getSize()-m.size);return r},move:function(u,t,s){i=u>0;return this.seekTo(k+u,t,s)},next:function(t,s){return this.move(1,t,s)},prev:function(t,s){return this.move(-1,t,s)},movePage:function(w,v,u){i=w>0;var s=m.size*w;var t=k%m.size;if(t>0){s+=(w>0?-t:m.size-t)}return this.move(s,v,u)},prevPage:function(t,s){return this.movePage(-1,t,s)},nextPage:function(t,s){return this.movePage(1,t,s)},setPage:function(t,u,s){return this.seekTo(t*m.size,u,s)},begin:function(t,s){i=false;return this.seekTo(0,t,s)},end:function(t,s){i=true;var u=this.getSize()-m.size;return u>0?this.seekTo(u,t,s):r},reload:function(){p.trigger("onReload");return r},focus:function(){c=r;return r},click:function(u){var v=r.getItems().eq(u),s=m.activeClass,t=m.size;if(u<0||u>=r.getSize()){return r}if(t==1){if(m.loop){return r.next()}if(u===0||u==r.getSize()-1){i=(i===undefined)?true:!i}return i===false?r.prev():r.next()}if(t==2){if(u==k){u--}r.getItems().removeClass(s);v.addClass(s);return r.seekTo(u,time,fn)}if(!v.hasClass(s)){r.getItems().removeClass(s);v.addClass(s);var x=Math.floor(t/2);var w=u-x;if(w>r.getSize()-t){w=r.getSize()-t}if(w!==u){return r.seekTo(w)}}return r},bind:function(s,t){p.bind(s,t);return r},unbind:function(s){p.unbind(s);return r}});b.each("onBeforeSeek,onStart,onSeek,onReload".split(","),function(s,t){r[t]=function(u){return r.bind(t,u)}});f.addClass(m.disabledClass).click(function(){r.prev()});h.click(function(){r.next()});n.click(function(){r.nextPage()});if(r.getSize()<m.size){h.add(n).addClass(m.disabledClass)}g.addClass(m.disabledClass).click(function(){r.prevPage()});var j=m.hoverClass,q="keydown."+Math.random().toString().substring(10);r.onReload(function(){if(j){r.getItems().hover(function(){b(this).addClass(j)},function(){b(this).removeClass(j)})}if(m.clickable){r.getItems().each(function(s){b(this).unbind("click.scrollable").bind("click.scrollable",function(t){if(b(t.target).is("a")){return}return r.click(s)})})}if(m.keyboard){b(document).unbind(q).bind(q,function(t){if(t.altKey||t.ctrlKey){return}if(m.keyboard!="static"&&c!=r){return}var u=m.keyboardSteps;if(d&&(t.keyCode==37||t.keyCode==39)){r.move(t.keyCode==37?-u:u);return t.preventDefault()}if(!d&&(t.keyCode==38||t.keyCode==40)){r.move(t.keyCode==38?-u:u);return t.preventDefault()}return true})}else{b(document).unbind(q)}});r.reload()}b.fn.scrollable=function(d){var e=this.eq(typeof d=="number"?d:0).data("scrollable");if(e){return e}var f=b.extend({},b.tools.scrollable.conf);d=b.extend(f,d);d.keyboardSteps=d.keyboardSteps||d.size;this.each(function(){e=new a(b(this),d);b(this).data("scrollable",e)});return d.api?e:this}})(jQuery);(function(b){var a=b.tools.scrollable;a.plugins=a.plugins||{};a.plugins.circular={version:"0.5.1",conf:{api:false,clonedClass:"cloned"}};b.fn.circular=function(e){var d=b.extend({},a.plugins.circular.conf),c;b.extend(d,e);this.each(function(){var i=b(this).scrollable(),n=i.getItems(),k=i.getConf(),f=i.getItemWrap(),j=0;if(i){c=i}if(n.length<k.size){return false}n.slice(0,k.size).each(function(o){b(this).clone().appendTo(f).click(function(){i.click(n.length+o)}).addClass(d.clonedClass)});var l=b.makeArray(n.slice(-k.size)).reverse();b(l).each(function(o){b(this).clone().prependTo(f).click(function(){i.click(-o-1)}).addClass(d.clonedClass)});var m=f.children(k.item);var h=k.hoverClass;if(h){m.hover(function(){b(this).addClass(h)},function(){b(this).removeClass(h)})}function g(o){var p=m.eq(o);if(k.vertical){f.css({top:-p.position().top})}else{f.css({left:-p.position().left})}}g(k.size);b.extend(i,{move:function(s,r,p,q){var u=j+s+k.size;var t=u>i.getSize()-k.size;if(u<=0||t){var o=j+k.size+(t?-n.length:n.length);g(o);u=o+s}if(q){m.removeClass(k.activeClass).eq(u+Math.floor(k.size/2)).addClass(k.activeClass)}if(u===j+k.size){return self}return i.seekTo(u,r,p)},begin:function(p,o){return this.seekTo(k.size,p,o)},end:function(p,o){return this.seekTo(n.length,p,o)},click:function(p,r,q){if(!k.clickable){return self}if(k.size==1){return this.next()}var s=p-j,o=k.activeClass;s-=Math.floor(k.size/2);return this.move(s,r,q,true)},getIndex:function(){return j},setPage:function(p,q,o){return this.seekTo(p*k.size+k.size,q,o)},getPageAmount:function(){return Math.ceil(n.length/k.size)},getPageIndex:function(){if(j<0){return this.getPageAmount()-1}if(j>=n.length){return 0}var o=(j+k.size)/k.size-1;return o},getVisibleItems:function(){var o=j+k.size;return m.slice(o,o+k.size)}});i.onStart(function(p,o){j=o-k.size;return false});i.getNaviButtons().removeClass(k.disabledClass)});return d.api?c:this}})(jQuery);(function(b){var a=b.tools.scrollable;a.plugins=a.plugins||{};a.plugins.autoscroll={version:"1.0.1",conf:{autoplay:true,interval:3000,autopause:true,steps:1,api:false}};b.fn.autoscroll=function(d){if(typeof d=="number"){d={interval:d}}var e=b.extend({},a.plugins.autoscroll.conf),c;b.extend(e,d);this.each(function(){var g=b(this).scrollable();if(g){c=g}var i,f,h=true;g.play=function(){if(i){return}h=false;i=setInterval(function(){g.move(e.steps)},e.interval);g.move(e.steps)};g.pause=function(){i=clearInterval(i)};g.stop=function(){g.pause();h=true};if(e.autopause){g.getRoot().add(g.getNaviButtons()).hover(function(){g.pause();clearInterval(f)},function(){if(!h){f=setTimeout(g.play,e.interval)}})}if(e.autoplay){setTimeout(g.play,e.interval)}});return e.api?c:this}})(jQuery);(function(b){var a=b.tools.scrollable;a.plugins=a.plugins||{};a.plugins.navigator={version:"1.0.2",conf:{navi:".navi",naviItem:null,activeClass:"active",indexed:false,api:false,idPrefix:null}};b.fn.navigator=function(d){var e=b.extend({},a.plugins.navigator.conf),c;if(typeof d=="string"){d={navi:d}}d=b.extend(e,d);this.each(function(){var i=b(this).scrollable(),f=i.getRoot(),l=f.data("finder").call(null,d.navi),g=null,k=i.getNaviButtons();if(i){c=i}i.getNaviButtons=function(){return k.add(l)};function j(){if(!l.children().length||l.data("navi")==i){l.empty();l.data("navi",i);for(var m=0;m<i.getPageAmount();m++){l.append(b("<"+(d.naviItem||"a")+"/>"))}g=l.children().each(function(n){var o=b(this);o.click(function(p){i.setPage(n);return p.preventDefault()});if(d.indexed){o.text(n)}if(d.idPrefix){o.attr("id",d.idPrefix+n)}})}else{g=d.naviItem?l.find(d.naviItem):l.children();g.each(function(n){var o=b(this);o.click(function(p){i.setPage(n);return p.preventDefault()})})}g.eq(0).addClass(d.activeClass)}i.onStart(function(o,n){var m=d.activeClass;g.removeClass(m).eq(i.getPageIndex()).addClass(m)});i.onReload(function(){j()});j();var h=g.filter("[href="+location.hash+"]");if(h.length){i.move(g.index(h))}});return d.api?c:this}})(jQuery);(function(b){b.fn.wheel=function(e){return this[e?"bind":"trigger"]("wheel",e)};b.event.special.wheel={setup:function(){b.event.add(this,d,c,{})},teardown:function(){b.event.remove(this,d,c)}};var d=!b.browser.mozilla?"mousewheel":"DOMMouseScroll"+(b.browser.version<"1.9"?" mousemove":"");function c(e){switch(e.type){case"mousemove":return b.extend(e.data,{clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY});case"DOMMouseScroll":b.extend(e,e.data);e.delta=-e.detail/3;break;case"mousewheel":e.delta=e.wheelDelta/120;break}e.type="wheel";return b.event.handle.call(this,e,e.delta)}var a=b.tools.scrollable;a.plugins=a.plugins||{};a.plugins.mousewheel={version:"1.0.1",conf:{api:false,speed:50}};b.fn.mousewheel=function(f){var g=b.extend({},a.plugins.mousewheel.conf),e;if(typeof f=="number"){f={speed:f}}f=b.extend(g,f);this.each(function(){var h=b(this).scrollable();if(h){e=h}h.getRoot().wheel(function(i,j){h.move(j<0?1:-1,f.speed||50);return false})});return f.api?e:this}})(jQuery);(function(c){c.tools=c.tools||{};c.tools.overlay={version:"1.1.2",addEffect:function(e,f,g){b[e]=[f,g]},conf:{top:"10%",left:"center",absolute:false,speed:"normal",closeSpeed:"fast",effect:"default",close:null,oneInstance:true,closeOnClick:true,closeOnEsc:true,api:false,expose:null,target:null}};var b={};c.tools.overlay.addEffect("default",function(e){this.getOverlay().fadeIn(this.getConf().speed,e)},function(e){this.getOverlay().fadeOut(this.getConf().closeSpeed,e)});var d=[];function a(g,k){var o=this,m=c(this),n=c(window),j,i,h,e=k.expose&&c.tools.expose.version;var f=k.target||g.attr("rel");i=f?c(f):null||g;if(!i.length){throw"Could not find Overlay: "+f}if(g&&g.index(i)==-1){g.click(function(p){o.load(p);return p.preventDefault()})}c.each(k,function(p,q){if(c.isFunction(q)){m.bind(p,q)}});c.extend(o,{load:function(u){if(o.isOpened()){return o}var r=b[k.effect];if(!r){throw'Overlay: cannot find effect : "'+k.effect+'"'}if(k.oneInstance){c.each(d,function(){this.close(u)})}u=u||c.Event();u.type="onBeforeLoad";m.trigger(u);if(u.isDefaultPrevented()){return o}h=true;if(e){i.expose().load(u)}var t=k.top;var s=k.left;var p=i.outerWidth({margin:true});var q=i.outerHeight({margin:true});if(typeof t=="string"){t=t=="center"?Math.max((n.height()-q)/2,0):parseInt(t,10)/100*n.height()}if(s=="center"){s=Math.max((n.width()-p)/2,0)}if(!k.absolute){t+=n.scrollTop();s+=n.scrollLeft()}i.css({top:t,left:s,position:"absolute"});u.type="onStart";m.trigger(u);r[0].call(o,function(){if(h){u.type="onLoad";m.trigger(u)}});if(k.closeOnClick){c(document).bind("click.overlay",function(w){if(!o.isOpened()){return}var v=c(w.target);if(v.parents(i).length>1){return}c.each(d,function(){this.close(w)})})}if(k.closeOnEsc){c(document).unbind("keydown.overlay").bind("keydown.overlay",function(v){if(v.keyCode==27){c.each(d,function(){this.close(v)})}})}return o},close:function(q){if(!o.isOpened()){return o}q=q||c.Event();q.type="onBeforeClose";m.trigger(q);if(q.isDefaultPrevented()){return}h=false;b[k.effect][1].call(o,function(){q.type="onClose";m.trigger(q)});var p=true;c.each(d,function(){if(this.isOpened()){p=false}});if(p){c(document).unbind("click.overlay").unbind("keydown.overlay")}return o},getContent:function(){return i},getOverlay:function(){return i},getTrigger:function(){return g},getClosers:function(){return j},isOpened:function(){return h},getConf:function(){return k},bind:function(p,q){m.bind(p,q);return o},unbind:function(p){m.unbind(p);return o}});c.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(p,q){o[q]=function(r){return o.bind(q,r)}});if(e){if(typeof k.expose=="string"){k.expose={color:k.expose}}c.extend(k.expose,{api:true,closeOnClick:k.closeOnClick,closeOnEsc:false});var l=i.expose(k.expose);l.onBeforeClose(function(p){o.close(p)});o.onClose(function(p){l.close(p)})}j=i.find(k.close||".close");if(!j.length&&!k.close){j=c('<div class="close"></div>');i.prepend(j)}j.click(function(p){o.close(p)})}c.fn.overlay=function(e){var f=this.eq(typeof e=="number"?e:0).data("overlay");if(f){return f}if(c.isFunction(e)){e={onBeforeLoad:e}}var g=c.extend({},c.tools.overlay.conf);e=c.extend(true,g,e);this.each(function(){f=new a(c(this),e);d.push(f);c(this).data("overlay",f)});return e.api?f:this}})(jQuery);(function(b){var a=b.tools.overlay;a.plugins=a.plugins||{};a.plugins.gallery={version:"1.0.0",conf:{imgId:"img",next:".next",prev:".prev",info:".info",progress:".progress",disabledClass:"disabled",activeClass:"active",opacity:0.8,speed:"slow",template:"<strong>${title}</strong> <span>Image ${index} of ${total}</span>",autohide:true,preload:true,api:false}};b.fn.gallery=function(d){var o=b.extend({},a.plugins.gallery.conf),m;b.extend(o,d);m=this.overlay();var r=this,j=m.getOverlay(),k=j.find(o.next),g=j.find(o.prev),e=j.find(o.info),c=j.find(o.progress),h=g.add(k).add(e).css({opacity:o.opacity}),s=m.getClosers(),l;function p(u){c.fadeIn();h.hide();s.hide();var t=u.attr("href");var v=new Image();v.onload=function(){c.fadeOut();var y=b("#"+o.imgId,j);if(!y.length){y=b("<img/>").attr("id",o.imgId).css("visibility","hidden");j.prepend(y)}y.attr("src",t).css("visibility","hidden");var z=v.width;var A=(b(window).width()-z)/2;l=r.index(r.filter("[href="+t+"]"));r.removeClass(o.activeClass).eq(l).addClass(o.activeClass);var w=o.disabledClass;h.removeClass(w);if(l===0){g.addClass(w)}if(l==r.length-1){k.addClass(w)}var B=o.template.replace("${title}",u.attr("title")||u.data("title")).replace("${index}",l+1).replace("${total}",r.length);var x=parseInt(e.css("paddingLeft"),10)+parseInt(e.css("paddingRight"),10);e.html(B).css({width:z-x});j.animate({width:z,height:v.height,left:A},o.speed,function(){y.hide().css("visibility","visible").fadeIn(function(){if(!o.autohide){h.fadeIn();s.show()}})})};v.onerror=function(){j.fadeIn().html("Cannot find image "+t)};v.src=t;if(o.preload){r.filter(":eq("+(l-1)+"), :eq("+(l+1)+")").each(function(){var w=new Image();w.src=b(this).attr("href")})}}function f(t,u){t.click(function(){if(t.hasClass(o.disabledClass)){return}var v=r.eq(i=l+(u?1:-1));if(v.length){p(v)}})}f(k,true);f(g);b(document).keydown(function(t){if(!j.is(":visible")||t.altKey||t.ctrlKey){return}if(t.keyCode==37||t.keyCode==39){var u=t.keyCode==37?g:k;u.click();return t.preventDefault()}return true});function q(){if(!j.is(":animated")){h.show();s.show()}}if(o.autohide){j.hover(q,function(){h.fadeOut();s.hide()}).mousemove(q)}var n;this.each(function(){var v=b(this),u=b(this).overlay(),t=u;u.onBeforeLoad(function(){p(v)});u.onClose(function(){r.removeClass(o.activeClass)})});return o.api?n:this}})(jQuery);(function(d){var b=d.tools.overlay;b.effects=b.effects||{};b.effects.apple={version:"1.0.1"};d.extend(b.conf,{start:{absolute:true,top:null,left:null},fadeInSpeed:"fast",zIndex:9999});function c(f){var g=f.offset();return[g.top+f.height()/2,g.left+f.width()/2]}var e=function(n){var k=this.getOverlay(),f=this.getConf(),i=this.getTrigger(),q=this,r=k.outerWidth({margin:true}),m=k.data("img");if(!m){var l=k.css("backgroundImage");if(!l){throw"background-image CSS property not set for overlay"}l=l.substring(l.indexOf("(")+1,l.indexOf(")")).replace(/\"/g,"");k.css("backgroundImage","none");m=d('<img src="'+l+'"/>');m.css({border:0,position:"absolute",display:"none"}).width(r);d("body").append(m);k.data("img",m)}var o=d(window),j=f.start.top||Math.round(o.height()/2),h=f.start.left||Math.round(o.width()/2);if(i){var g=c(i);j=g[0];h=g[1]}if(!f.start.absolute){j+=o.scrollTop();h+=o.scrollLeft()}m.css({top:j,left:h,width:0,zIndex:f.zIndex}).show();m.animate({top:k.css("top"),left:k.css("left"),width:r},f.speed,function(){k.css("zIndex",f.zIndex+1).fadeIn(f.fadeInSpeed,function(){if(q.isOpened()&&!d(this).index(k)){n.call()}else{k.hide()}})})};var a=function(f){var h=this.getOverlay(),i=this.getConf(),g=this.getTrigger(),l=i.start.top,k=i.start.left;h.hide();if(g){var j=c(g);l=j[0];k=j[1]}h.data("img").animate({top:l,left:k,width:0},i.closeSpeed,f)};b.addEffect("apple",e,a)})(jQuery);(function(b){b.tools=b.tools||{};b.tools.expose={version:"1.0.5",conf:{maskId:null,loadSpeed:"slow",closeSpeed:"fast",closeOnClick:true,closeOnEsc:true,zIndex:9998,opacity:0.8,color:"#456",api:false}};function a(){if(b.browser.msie){var f=b(document).height(),e=b(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,f-e<20?e:f]}return[b(window).width(),b(document).height()]}function c(h,g){var e=this,j=b(this),d=null,f=false,i=0;b.each(g,function(k,l){if(b.isFunction(l)){j.bind(k,l)}});b(window).resize(function(){e.fit()});b.extend(this,{getMask:function(){return d},getExposed:function(){return h},getConf:function(){return g},isLoaded:function(){return f},load:function(n){if(f){return e}i=h.eq(0).css("zIndex");if(g.maskId){d=b("#"+g.maskId)}if(!d||!d.length){var l=a();d=b("<div/>").css({position:"absolute",top:0,left:0,width:l[0],height:l[1],display:"none",opacity:0,zIndex:g.zIndex});if(g.maskId){d.attr("id",g.maskId)}b("body").append(d);var k=d.css("backgroundColor");if(!k||k=="transparent"||k=="rgba(0, 0, 0, 0)"){d.css("backgroundColor",g.color)}if(g.closeOnEsc){b(document).bind("keydown.unexpose",function(o){if(o.keyCode==27){e.close()}})}if(g.closeOnClick){d.bind("click.unexpose",function(o){e.close(o)})}}n=n||b.Event();n.type="onBeforeLoad";j.trigger(n);if(n.isDefaultPrevented()){return e}b.each(h,function(){var o=b(this);if(!/relative|absolute|fixed/i.test(o.css("position"))){o.css("position","relative")}});h.css({zIndex:Math.max(g.zIndex+1,i=="auto"?0:i)});var m=d.height();if(!this.isLoaded()){d.css({opacity:0,display:"block"}).fadeTo(g.loadSpeed,g.opacity,function(){if(d.height()!=m){d.css("height",m)}n.type="onLoad";j.trigger(n)})}f=true;return e},close:function(k){if(!f){return e}k=k||b.Event();k.type="onBeforeClose";j.trigger(k);if(k.isDefaultPrevented()){return e}d.fadeOut(g.closeSpeed,function(){k.type="onClose";j.trigger(k);h.css({zIndex:b.browser.msie?i:null})});f=false;return e},fit:function(){if(d){var k=a();d.css({width:k[0],height:k[1]})}},bind:function(k,l){j.bind(k,l);return e},unbind:function(k){j.unbind(k);return e}});b.each("onBeforeLoad,onLoad,onBeforeClose,onClose".split(","),function(k,l){e[l]=function(m){return e.bind(l,m)}})}b.fn.expose=function(d){var e=this.eq(typeof d=="number"?d:0).data("expose");if(e){return e}if(typeof d=="string"){d={color:d}}var f=b.extend({},b.tools.expose.conf);d=b.extend(f,d);this.each(function(){e=new c(b(this),d);b(this).data("expose",e)});return d.api?e:this}})(jQuery);(function(){var e=typeof jQuery=="function";var i={width:"100%",height:"100%",allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:null,onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(e){jQuery.tools=jQuery.tools||{};jQuery.tools.flashembed={version:"1.0.4",conf:i}}function j(){if(c.done){return false}var l=document;if(l&&l.getElementsByTagName&&l.getElementById&&l.body){clearInterval(c.timer);c.timer=null;for(var k=0;k<c.ready.length;k++){c.ready[k].call()}c.ready=null;c.done=true}}var c=e?jQuery:function(k){if(c.done){return k()}if(c.timer){c.ready.push(k)}else{c.ready=[k];c.timer=setInterval(j,13)}};function f(l,k){if(k){for(key in k){if(k.hasOwnProperty(key)){l[key]=k[key]}}}return l}function g(k){switch(h(k)){case"string":k=k.replace(new RegExp('(["\\\\])',"g"),"\\$1");k=k.replace(/^\s?(\d+)%/,"$1pct");return'"'+k+'"';case"array":return"["+b(k,function(n){return g(n)}).join(",")+"]";case"function":return'"function()"';case"object":var l=[];for(var m in k){if(k.hasOwnProperty(m)){l.push('"'+m+'":'+g(k[m]))}}return"{"+l.join(",")+"}"}return String(k).replace(/\s/g," ").replace(/\'/g,'"')}function h(l){if(l===null||l===undefined){return false}var k=typeof l;return(k=="object"&&l.push)?"array":k}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function b(k,n){var m=[];for(var l in k){if(k.hasOwnProperty(l)){m[l]=n(k[l])}}return m}function a(r,t){var q=f({},r);var s=document.all;var n='<object width="'+q.width+'" height="'+q.height+'"';if(s&&!q.id){q.id="_"+(""+Math.random()).substring(9)}if(q.id){n+=' id="'+q.id+'"'}if(q.cachebusting){q.src+=((q.src.indexOf("?")!=-1?"&":"?")+Math.random())}if(q.w3c||!s){n+=' data="'+q.src+'" type="application/x-shockwave-flash"'}else{n+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}n+=">";if(q.w3c||s){n+='<param name="movie" value="'+q.src+'" />'}q.width=q.height=q.id=q.w3c=q.src=null;for(var l in q){if(q[l]!==null){n+='<param name="'+l+'" value="'+q[l]+'" />'}}var o="";if(t){for(var m in t){if(t[m]!==null){o+=m+"="+(typeof t[m]=="object"?g(t[m]):t[m])+"&"}}o=o.substring(0,o.length-1);n+='<param name="flashvars" value=\''+o+"' />"}n+="</object>";return n}function d(m,p,l){var k=flashembed.getVersion();f(this,{getContainer:function(){return m},getConf:function(){return p},getVersion:function(){return k},getFlashvars:function(){return l},getApi:function(){return m.firstChild},getHTML:function(){return a(p,l)}});var q=p.version;var r=p.expressInstall;var o=!q||flashembed.isSupported(q);if(o){p.onFail=p.version=p.expressInstall=null;m.innerHTML=a(p,l)}else{if(q&&r&&flashembed.isSupported([6,65])){f(p,{src:r});l={MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title};m.innerHTML=a(p,l)}else{if(m.innerHTML.replace(/\s/g,"")!==""){}else{m.innerHTML="<h2>Flash version "+q+" or greater is required</h2><h3>"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"</h3>"+(m.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='http://www.adobe.com/go/getflashplayer'>here</a></p>");if(m.tagName=="A"){m.onclick=function(){location.href="http://www.adobe.com/go/getflashplayer"}}}}}if(!o&&p.onFail){var n=p.onFail.call(this);if(typeof n=="string"){m.innerHTML=n}}if(document.all){window[p.id]=document.getElementById(p.id)}}window.flashembed=function(l,m,k){if(typeof l=="string"){var n=document.getElementById(l);if(n){l=n}else{c(function(){flashembed(l,m,k)});return}}if(!l){return}if(typeof m=="string"){m={src:m}}var o=f({},i);f(o,m);return new d(l,o,k)};f(window.flashembed,{getVersion:function(){var m=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var l=navigator.plugins["Shockwave Flash"].description;if(typeof l!="undefined"){l=l.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var n=parseInt(l.replace(/^(.*)\..*$/,"$1"),10);var r=/r/.test(l)?parseInt(l.replace(/^.*r(.*)$/,"$1"),10):0;m=[n,r]}}else{if(window.ActiveXObject){try{var p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(q){try{p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");m=[6,0];p.AllowScriptAccess="always"}catch(k){if(m[0]==6){return m}}try{p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(o){}}if(typeof p=="object"){l=p.GetVariable("$version");if(typeof l!="undefined"){l=l.replace(/^\S+\s+(.*)$/,"$1").split(",");m=[parseInt(l[0],10),parseInt(l[2],10)]}}}}return m},isSupported:function(k){var m=flashembed.getVersion();var l=(m[0]>k[0])||(m[0]==k[0]&&m[1]>=k[1]);return l},domReady:c,asString:g,getHTML:a});if(e){jQuery.fn.flashembed=function(l,k){var m=null;this.each(function(){m=flashembed(this,l,k)});return l.api===false?this:m}}})();
﻿
jQuery.fn.extend({everyTime:function(interval,label,fn,times,belay){return this.each(function(){jQuery.timer.add(this,interval,label,fn,times,belay);});},oneTime:function(interval,label,fn){return this.each(function(){jQuery.timer.add(this,interval,label,fn,1);});},stopTime:function(label,fn){return this.each(function(){jQuery.timer.remove(this,label,fn);});}});jQuery.extend({timer:{global:[],guid:1,dataKey:"jQuery.timer",regex:/^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,powers:{'ms':1,'cs':10,'ds':100,'s':1000,'das':10000,'hs':100000,'ks':1000000},timeParse:function(value){if(value==undefined||value==null)
return null;var result=this.regex.exec(jQuery.trim(value.toString()));if(result[2]){var num=parseFloat(result[1]);var mult=this.powers[result[2]]||1;return num*mult;}else{return value;}},add:function(element,interval,label,fn,times,belay){var counter=0;if(jQuery.isFunction(label)){if(!times)
times=fn;fn=label;label=interval;}
interval=jQuery.timer.timeParse(interval);if(typeof interval!='number'||isNaN(interval)||interval<=0)
return;if(times&&times.constructor!=Number){belay=!!times;times=0;}
times=times||0;belay=belay||false;var timers=jQuery.data(element,this.dataKey)||jQuery.data(element,this.dataKey,{});if(!timers[label])
timers[label]={};fn.timerID=fn.timerID||this.guid++;var handler=function(){if(belay&&this.inProgress)
return;this.inProgress=true;if((++counter>times&&times!==0)||fn.call(element,counter)===false)
jQuery.timer.remove(element,label,fn);this.inProgress=false;};handler.timerID=fn.timerID;if(!timers[label][fn.timerID])
timers[label][fn.timerID]=window.setInterval(handler,interval);this.global.push(element);},remove:function(element,label,fn){var timers=jQuery.data(element,this.dataKey),ret;if(timers){if(!label){for(label in timers)
this.remove(element,label,fn);}else if(timers[label]){if(fn){if(fn.timerID){window.clearInterval(timers[label][fn.timerID]);delete timers[label][fn.timerID];}}else{for(var fn in timers[label]){window.clearInterval(timers[label][fn]);delete timers[label][fn];}}
for(ret in timers[label])break;if(!ret){ret=null;delete timers[label];}}
for(ret in timers)break;if(!ret)
jQuery.removeData(element,this.dataKey);}}}});jQuery(window).bind("unload",function(){jQuery.each(jQuery.timer.global,function(index,item){jQuery.timer.remove(item);});});
(function($)
{$.fn.document=function()
{var element=this[0];if(element.nodeName.toLowerCase()=='iframe')
return element.contentWindow.document;else
return $(this);};$.fn.documentSelection=function()
{var element=this[0];if(element.contentWindow.document.selection)
return element.contentWindow.document.selection.createRange().text;else
return element.contentWindow.getSelection().toString();};$.fn.wysiwyg=function(options)
{if(arguments.length>0&&arguments[0].constructor==String)
{var action=arguments[0].toString();var params=[];for(var i=1;i<arguments.length;i++)
params[i-1]=arguments[i];if(action in Wysiwyg)
{return this.each(function()
{$.data(this,'wysiwyg').designMode();Wysiwyg[action].apply(this,params);});}
else return this;}
var controls={};if(options&&options.controls)
{var controls=options.controls;delete options.controls;}
var options=$.extend({html:'<'+'?xml version="1.0" encoding="UTF-8"?'+'><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">STYLE_SHEET</head><body>INITIAL_CONTENT</body></html>',css:{},debug:false,autoSave:true,rmUnwantedBr:true,brIE:true,controls:{},messages:{}},options);options.messages=$.extend(true,options.messages,Wysiwyg.MSGS_EN);options.controls=$.extend(true,options.controls,Wysiwyg.TOOLBAR);for(var control in controls)
{if(control in options.controls)
$.extend(options.controls[control],controls[control]);else
options.controls[control]=controls[control];}
return this.each(function()
{Wysiwyg(this,options);});};function Wysiwyg(element,options)
{return this instanceof Wysiwyg?this.init(element,options):new Wysiwyg(element,options);}
$.extend(Wysiwyg,{insertImage:function(szURL,attributes)
{var self=$.data(this,'wysiwyg');if(self.constructor==Wysiwyg&&szURL&&szURL.length>0)
{if(attributes)
{self.editorDoc.execCommand('insertImage',false,'#jwysiwyg#');var img=self.getElementByAttributeValue('img','src','#jwysiwyg#');if(img)
{img.src=szURL;for(var attribute in attributes)
{img.setAttribute(attribute,attributes[attribute]);}}}
else
{self.editorDoc.execCommand('insertImage',false,szURL);}}},createLink:function(szURL)
{var self=$.data(this,'wysiwyg');if(self.constructor==Wysiwyg&&szURL&&szURL.length>0)
{var selection=$(self.editor).documentSelection();if(selection.length>0)
{self.editorDoc.execCommand('unlink',false,[]);self.editorDoc.execCommand('createLink',false,szURL);}
else if(self.options.messages.nonSelection)
alert(self.options.messages.nonSelection);}},setContent:function(newContent)
{var self=$.data(this,'wysiwyg');self.setContent(newContent);self.saveContent();},clear:function()
{var self=$.data(this,'wysiwyg');self.setContent('');self.saveContent();},MSGS_EN:{nonSelection:'select the text you wish to link'},TOOLBAR:{bold:{visible:true,tags:['b','strong'],css:{fontWeight:'bold'}},italic:{visible:true,tags:['i','em'],css:{fontStyle:'italic'}},strikeThrough:{visible:false,tags:['s','strike'],css:{textDecoration:'line-through'}},underline:{visible:false,tags:['u'],css:{textDecoration:'underline'}},separator00:{visible:false,separator:true},justifyLeft:{visible:false,css:{textAlign:'left'}},justifyCenter:{visible:false,tags:['center'],css:{textAlign:'center'}},justifyRight:{visible:false,css:{textAlign:'right'}},justifyFull:{visible:false,css:{textAlign:'justify'}},separator01:{visible:false,separator:true},indent:{visible:false},outdent:{visible:false},separator02:{visible:false,separator:true},subscript:{visible:false,tags:['sub']},superscript:{visible:false,tags:['sup']},separator03:{visible:false,separator:true},undo:{visible:false},redo:{visible:false},separator04:{visible:false,separator:true},insertOrderedList:{visible:false,tags:['ol']},insertUnorderedList:{visible:false,tags:['ul']},insertHorizontalRule:{visible:false,tags:['hr']},separator05:{separator:true},createLink:{visible:true,exec:function()
{var selection=$(this.editor).documentSelection();if(selection.length>0)
{if($.browser.msie)
this.editorDoc.execCommand('createLink',true,null);else
{var szURL=prompt('URL','http://');if(szURL&&szURL.length>0)
{this.editorDoc.execCommand('unlink',false,[]);this.editorDoc.execCommand('createLink',false,szURL);}}}
else if(this.options.messages.nonSelection)
alert(this.options.messages.nonSelection);},tags:['a']},insertImage:{visible:true,exec:function()
{if($.browser.msie)
this.editorDoc.execCommand('insertImage',true,null);else
{var szURL=prompt('URL','http://');if(szURL&&szURL.length>0)
this.editorDoc.execCommand('insertImage',false,szURL);}},tags:['img']},separator06:{separator:true},h1mozilla:{visible:true&&$.browser.mozilla,className:'h1',command:'heading',arguments:['h1'],tags:['h1']},h2mozilla:{visible:true&&$.browser.mozilla,className:'h2',command:'heading',arguments:['h2'],tags:['h2']},h3mozilla:{visible:true&&$.browser.mozilla,className:'h3',command:'heading',arguments:['h3'],tags:['h3']},h1:{visible:true&&!($.browser.mozilla),className:'h1',command:'formatBlock',arguments:['Heading 1'],tags:['h1']},h2:{visible:true&&!($.browser.mozilla),className:'h2',command:'formatBlock',arguments:['Heading 2'],tags:['h2']},h3:{visible:true&&!($.browser.mozilla),className:'h3',command:'formatBlock',arguments:['Heading 3'],tags:['h3']},separator07:{visible:false,separator:true},cut:{visible:false},copy:{visible:false},paste:{visible:false},separator08:{separator:true&&!($.browser.msie)},increaseFontSize:{visible:true&&!($.browser.msie),tags:['big']},decreaseFontSize:{visible:true&&!($.browser.msie),tags:['small']},separator09:{separator:true},html:{visible:false,exec:function()
{if(this.viewHTML)
{this.setContent($(this.original).val());$(this.original).hide();}
else
{this.saveContent();$(this.original).show();}
this.viewHTML=!(this.viewHTML);}},removeFormat:{visible:true,exec:function()
{this.editorDoc.execCommand('removeFormat',false,[]);this.editorDoc.execCommand('unlink',false,[]);}}}});$.extend(Wysiwyg.prototype,{original:null,options:{},element:null,editor:null,init:function(element,options)
{var self=this;this.editor=element;this.options=options||{};$.data(element,'wysiwyg',this);var newX=$(element).css("width").replace('px','');var newY=$(element).css("height").replace('px','');if(element.nodeName.toLowerCase()=='textarea')
{this.original=element;if(newX==0&&element.cols>0)
newX=(element.cols*8)+21;if(newY==0&&element.rows>0)
newY=(element.rows*16)+16;var editor=this.editor=$('<iframe></iframe>').css({minHeight:(newY-6).toString()+'px',width:(newX-8).toString()+'px'}).attr('id',$(element).attr('id')+'IFrame');if($.browser.msie)
{this.editor.css('height',(newY).toString()+'px');}}
var panel=this.panel=$('<ul></ul>').addClass('panel');this.appendControls();this.element=$('<div></div>').css({width:(newX>0)?(newX).toString()+'px':'100%'}).addClass('wysiwyg').append(panel).append($('<div><!-- --></div>').css({clear:'both'})).append(editor);$(element).hide().before(this.element);this.viewHTML=false;this.initialHeight=newY-8;this.initialContent=$(element).val();this.initFrame();if(this.initialContent.length==0)
this.setContent('');if(this.options.autoSave)
$('form').submit(function(){self.saveContent();});$('form').bind('reset',function()
{self.setContent(self.initialContent);self.saveContent();});},initFrame:function()
{var self=this;var style='';if(this.options.css&&this.options.css.constructor==String)
style='<link rel="stylesheet" type="text/css" media="screen" href="'+this.options.css+'" />';this.editorDoc=$(this.editor).document();this.editorDoc_designMode=false;try{this.editorDoc.designMode='on';this.editorDoc_designMode=true;}catch(e){$(this.editorDoc).focus(function()
{self.designMode();});}
this.editorDoc.open();this.editorDoc.write(this.options.html.replace(/INITIAL_CONTENT/,this.initialContent).replace(/STYLE_SHEET/,style));this.editorDoc.close();this.editorDoc.contentEditable='true';if($.browser.msie)
{setTimeout(function(){$(self.editorDoc.body).css('border','none');},0);}
$(this.editorDoc).click(function(event)
{self.checkTargets(event.target?event.target:event.srcElement);});$(this.original).focus(function()
{$(self.editorDoc.body).focus();});if(this.options.autoSave)
{$(this.editorDoc).keydown(function(){self.saveContent();}).keyup(function(){self.saveContent();}).mousedown(function(){self.saveContent();});}
if(this.options.css)
{setTimeout(function()
{if(self.options.css.constructor==String)
{}
else
$(self.editorDoc).find('body').css(self.options.css);},0);}
$(this.editorDoc).keydown(function(event)
{if($.browser.msie&&self.options.brIE&&event.keyCode==13)
{var rng=self.getRange();rng.pasteHTML('<br />');rng.collapse(false);rng.select();return false;}});},designMode:function()
{if(!(this.editorDoc_designMode))
{try{this.editorDoc.designMode='on';this.editorDoc_designMode=true;}catch(e){}}},getSelection:function()
{return(window.getSelection)?window.getSelection():document.selection;},getRange:function()
{var selection=this.getSelection();if(!(selection))
return null;return(selection.rangeCount>0)?selection.getRangeAt(0):selection.createRange();},getContent:function()
{return $($(this.editor).document()).find('body').html();},setContent:function(newContent)
{$($(this.editor).document()).find('body').html(newContent);},saveContent:function()
{if(this.original)
{var content=this.getContent();if(this.options.rmUnwantedBr)
content=(content.substr(-4)=='<br>')?content.substr(0,content.length-4):content;$(this.original).val(content);}},appendMenu:function(cmd,args,className,fn)
{var self=this;var args=args||[];$('<li></li>').append($('<a><!-- --></a>').addClass(className||cmd)).mousedown(function(){if(fn)fn.apply(self);else self.editorDoc.execCommand(cmd,false,args);if(self.options.autoSave)self.saveContent();}).appendTo(this.panel);},appendMenuSeparator:function()
{$('<li class="separator"></li>').appendTo(this.panel);},appendControls:function()
{for(var name in this.options.controls)
{var control=this.options.controls[name];if(control.separator)
{if(control.visible!==false)
this.appendMenuSeparator();}
else if(control.visible)
{this.appendMenu(control.command||name,control.arguments||[],control.className||control.command||name||'empty',control.exec);}}},checkTargets:function(element)
{for(var name in this.options.controls)
{var control=this.options.controls[name];var className=control.className||control.command||name||'empty';$('.'+className,this.panel).removeClass('active');if(control.tags)
{var elm=element;do{if(elm.nodeType!=1)
break;if($.inArray(elm.tagName.toLowerCase(),control.tags)!=-1)
$('.'+className,this.panel).addClass('active');}while(elm=elm.parentNode);}
if(control.css)
{var elm=$(element);do{if(elm[0].nodeType!=1)
break;for(var cssProperty in control.css)
if(elm.css(cssProperty).toString().toLowerCase()==control.css[cssProperty])
$('.'+className,this.panel).addClass('active');}while(elm=elm.parent());}}},getElementByAttributeValue:function(tagName,attributeName,attributeValue)
{var elements=this.editorDoc.getElementsByTagName(tagName);for(var i=0;i<elements.length;i++)
{var value=elements[i].getAttribute(attributeName);if($.browser.msie)
{value=value.substr(value.length-attributeValue.length);}
if(value==attributeValue)
return elements[i];}
return false;}});})(jQuery);