var couponfound = false;
$(document).ready( function () {
	DoCoupon();
});

function DoCoupon(){
	var dt = new Date();
	$.ajax({
	    url: DealerSiteConfig.CouponServiceURL + '&amp;mnss=' + parseInt(Math.random() * 5000) + '.' + dt.getTime(),
	    success: function (data, textStatus, req) {
	        var x = eval(data);
	        if (x && x.d) {	            
	            if (x.d.code == 'fail') {
	                HandleFail(x.d);
	            } else {
	                couponfound = HandleSuccess(x.d);
	                if (!couponfound) {
	                    setTimeout("DoCoupon()", DealerSiteConfig.CouponCheckInterval);
	                }
	            }
	        }
	        else {
	            HandleFail(data);
            }
	    }
	});
}

function HandleSuccess(obj) {
	if (obj.method == 'inframe') {
		OpenCoupon(obj.url);
		return true;
	} else if (obj.method == 'popunder') {
		popUnderCoupon(obj.url, obj.title, 'height=400,width=700,status=no,toolbar=no,menubar=no,location=no',false);
		return true;
	} else if (obj.method == 'popover') {
		popOverCoupon(obj.url, obj.title, 'height=400,width=700,status=no,toolbar=no,menubar=no,location=no', false);
		return true;
	}
	return false;
}

function HandleFail(obj) {
}

function OpenCoupon(url) {
	$("#couponlink").attr("href", url);
	$("#couponlink").fancybox({
		'type': 'iframe',
		'width': 700,
		'height': 400,
		'transitionIn': 'fade',
		'transitionOut': 'none',
		'overlayShow': false,
		'hideOnOverlayClick': false,
		'autoScale': false,
		'autoDimensions': false,
		'centerOnScroll': true,
		'scrolling': 'no'
	});
	$("#couponlink").click();
}

function popOverCoupon(url, title, args, breplace) {
	var pUWnd = window.open(url, title, args, breplace).blur();
	window.focus();
}

function popUnderCoupon(url, title, args, breplace) {
	var pUWnd = window.open(url, title, args, breplace).blur();
	window.focus();
}function VSHelpIconCover(bottom, top, ignoreSize) {
	var location = GetElementPosition(bottom);
	top.style.position = 'absolute';
	top.style.top = location[1] + 'px';
	top.style.left = location[0] + 'px';
	if (!ignoreSize) {
		top.style.height = bottom.offsetHeight + 'px';
		top.style.width = bottom.offsetWidth + 'px';
	}
}

function GetScreenHeight()
{
	var y;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight;
	if (test1 > test2) // all but Explorer Mac
	{
		y = document.body.scrollHeight;
	}
	else // Explorer Mac;
		 //would also work in Explorer 6 Strict, Mozilla and Safari
	{
		y = document.body.offsetHeight;
	}
	
	return y;
}

function resizeIframe(framePage, iframeID) { 
if(self==parent) return false; /* Checks that page is in iframe. */ 
else if(document.getElementById&&document.all) /* Sniffs for IE5+.*/ 

var FramePageHeight = framePage.scrollHeight + 10; /* framePage 
is the ID of the framed page's BODY tag. The added 10 pixels prevent an 
unnecessary scrollbar. */ 

if(parent.document.getElementById(iframeID) != null)
{
parent.document.getElementById(iframeID).style.height=FramePageHeight; 
}
/* "iframeID" is the ID of the inline frame in the parent page. */ 
} 
function writeFlash(flashdata)
{
	document.write(flashdata);
}
function ENav(control, RecordID) { SetPageData('TargetControl', control); SetPageData('RecordID',RecordID); document.forms[0].submit();}
function VNav(control, RecordID) { SetPageData('TargetControl', control); SetPageData('RecordID', RecordID); SetPageData('ViewMode', 'Y'); document.forms[0].submit();}
function SetPageData(Key,Value)
{ var arr; var data; var DataLen; var Updated; var i; arr = document.getElementById('__PageData').value.split('|'); DataLen = arr.length - 1; data = ""; for (i=0; i<DataLen; i+=2)
{ if (i != 0) data += '|'; data += arr[i]; data += '|'; if (Key.toUpperCase() == arr[i].toUpperCase())
{ data += Value; Updated = true;}
else
{ data += arr[i+1];}
}
if (!Updated)
{ if (DataLen > 0) data += '|'; { data += Key; data += '|'; data += Value;}
}

document.getElementById('__PageData').value = data;}

/***********************************************
* Cool DHTML tooltip script- � Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
//var tipobj=document.all? document.getElementById('dhtmltooltip') : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){

if(document.getElementById('dhtmltooltip') == null)
{
	//document.writeln('<div id="dhtmltooltip"></div>');
}
else
{
if (ns6||ie){
if (typeof thewidth!="undefined") document.getElementById('dhtmltooltip').style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") document.getElementById('dhtmltooltip').style.backgroundColor=thecolor
//alert(thetext);
if(document.getElementById('dhtmltooltip').innerHTML!=thetext)
{
	document.getElementById('dhtmltooltip').innerHTML=thetext;
}
enabletip=true;
return false;
}
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<document.getElementById('dhtmltooltip').offsetWidth)
//move the horizontal position of the menu to the left by it's width
document.getElementById('dhtmltooltip').style.left=ie? ietruebody().scrollLeft+event.clientX-document.getElementById('dhtmltooltip').offsetWidth+"px" : window.pageXOffset+e.clientX-document.getElementById('dhtmltooltip').offsetWidth+"px"
else if (curX<leftedge)
document.getElementById('dhtmltooltip').style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
document.getElementById('dhtmltooltip').style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<document.getElementById('dhtmltooltip').offsetHeight)
document.getElementById('dhtmltooltip').style.top=ie? ietruebody().scrollTop+event.clientY-document.getElementById('dhtmltooltip').offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-document.getElementById('dhtmltooltip').offsetHeight-offsetypoint+"px"
else
document.getElementById('dhtmltooltip').style.top=curY+offsetypoint+"px"
document.getElementById('dhtmltooltip').style.visibility="visible"
}
}

function hideddrivetip(){
if(document.getElementById('dhtmltooltip'))
{
if (ns6||ie){
enabletip=false;
document.getElementById('dhtmltooltip').style.visibility="hidden"
document.getElementById('dhtmltooltip').style.left="-1000px"
document.getElementById('dhtmltooltip').style.backgroundColor=''
document.getElementById('dhtmltooltip').style.width=''
}
}
}

document.onmousemove=positiontip;
function OpenPopupWindow(QueryString, PopupName)
{ 
	OpenWindow('Popup.aspx?' + QueryString, PopupName);
}

function OpenWindow(URL, PopupName, myWidth, myHeight)
{ 
if(myWidth == null)
{ myWidth = 1000;}
if(myHeight == null)
{ myHeight = 670;}
			var left = (screen.width - myWidth) / 2;
			var top = ((screen.height - myHeight - 80) / 2) - 10;
if(PopupName == null)
{ PopupName = 'OpenWindow';}

   var win;
   try
   {
	  win = window.open(URL, PopupName.replace(' ',''), 'height=' + myHeight + ', width=' + myWidth + ', left=' + left + ', top='+ top +', resizable=1 location=0, menubar=0, scrollbars=1, toolbar=0, status=1'); 
	  win.focus();
   }
   catch(ex)
   {
	  alert('A popup blocker has prevented this window from opening.\r\nTrying holding the CTRL key on the keyboard and click the link again, or disable your popup blocker for this website.');
   }
}
function OpenModalWindow(QueryString, PopupName, myWidth, myHeight, myScrollbar)
{ if(myWidth == null)
{ myWidth = 1000;}
if(myHeight == null)
{ myHeight = 670;}
if(myScrollbar == null)
{ myScrollbar = 'yes';}
			var left = (screen.width - myWidth) / 2;
			var top = ((screen.height - myHeight- 80) / 2) - 10;
if(PopupName == null)
{ PopupName = 'ModalPopup';}
window.showModalDialog('PopupModal.aspx?' + QueryString, window, 'dialogHeight: ' + myHeight +'px; dialogWidth: ' + myWidth +'px; edge: Raised; center: Yes; help: Yes; resizable: No; status: No; ScrollBars: ' + myScrollbar + ';');}

function OpenModalWindowWithPage(QueryString, PopupName, myWidth, myHeight, myScrollbar)
{ if(myWidth == null)
{ myWidth = 1000;}
if(myHeight == null)
{ myHeight = 670;}
if(myScrollbar == null)
{ myScrollbar = 'yes';}
			var left = (screen.width - myWidth) / 2;
			var top = ((screen.height - myHeight- 80) / 2) - 10;
if(PopupName == null)
{ PopupName = 'ModalPopup';}
window.showModalDialog(QueryString, window, 'dialogHeight: ' + myHeight +'px; dialogWidth: ' + myWidth +'px; edge: Raised; center: Yes; help: Yes; resizable: No; status: No; ScrollBars: ' + myScrollbar + ';');}


function NumbersOnly()
{ try
{ if(window.event.ctrlKey && (window.event.keyCode == 88 || window.event.keyCode == 86 || window.event.keyCode == 67))
{ 
   window.event.returnValue=true;
}
else if(!window.event.shiftKey &&
( (window.event.keyCode > 95 && window.event.keyCode <106) || (window.event.keyCode > 44 && window.event.keyCode <58) || window.event.keyCode ==8 || window.event.keyCode ==9 || window.event.keyCode ==37 || window.event.keyCode ==39)
)
{ window.event.returnValue=true;}
else if(window.event.shiftKey && window.event.keyCode == 9)
{ window.event.returnValue=true;}
else
{ window.event.returnValue=false;}
}
catch(e){}
}

function NumbersAndPeriodOnly(obj)
{

 try
{ 
	if(window.event.ctrlKey && (window.event.keyCode == 88 || window.event.keyCode == 86 || window.event.keyCode == 67))
	{ 
	   window.event.returnValue=true;
	}
	else if((window.event.keyCode ==110|| window.event.keyCode ==190) && obj != null && obj.value.indexOf('.') > 0)
	{
		window.event.returnValue=false;
	}
	else if(!window.event.shiftKey &&
	( (window.event.keyCode > 95 && window.event.keyCode <106) || (window.event.keyCode > 44 && window.event.keyCode <58) || window.event.keyCode ==8 || window.event.keyCode ==9 || window.event.keyCode ==37 || window.event.keyCode ==39 || window.event.keyCode ==110|| window.event.keyCode ==190)
	)
	{ window.event.returnValue=true;}
	else if(window.event.shiftKey && window.event.keyCode == 9)
	{ 
		window.event.returnValue=true;
	}
	else
	{ 
		window.event.returnValue=false;
	}
}
catch(e){}
}

function MaskSSN(s) {
	val = s.value.replace(/\D/gi, "");
	valid = new RegExp(/^(?!000)([0-9]\d{2}|7([0-9]\d|7[012]))([ -]?)(?!00)\d\d\3(?!0000)\d{4}$/)
	if (val != "" && val.match(valid)) {
		parts = val.match(/(\d{3})(\d{2})(\d{4})/);
		if (parts && parts.length == 4)
			s.value = parts[1] + "-" + parts[2] + "-" + parts[3];
	}
	else {
		s.value = "";
	}
}//Social Insurance Number validator for Canada
function MaskSIN(s)
{
	val = s.value.replace(/\D/gi, "");
	valid = new RegExp(/^\d{3}\s?\d{3}\s?\d{3}$/)
	if (val != "" && val.match(valid))
	{
		parts = val.match(/(\d{3})(\d{3})(\d{3})/);
		if (parts && parts.length == 4)
			s.value = parts[1] + "-" + parts[2] + "-" + parts[3];
	}
	else
	{
		s.value = "";
	}
}
function MaskPhone(s)
{ var sNewValue = s.value; var iLength = 0; var err = false; var zChar = new Array(' ', '(', ')', '-', '.'); sNewValue = ParseChar(sNewValue, zChar); if (isNaN(sNewValue)) { err = true; alert("Not a valid phone number.  Type 10 digits, or in the format (999) 999-9999.");}
else { if (sNewValue.length == 10)
iLength = 10; else if (sNewValue.length == 0)
sNewValue = ""; else if (sNewValue.length < 10)
{ err = true; alert("Not a valid phone number.  Type 10 digits, or in the format (999) 999-9999.");}
else if (sNewValue.length > 10)
{ iLength = 10; if (sNewValue.charAt(0) == "1" && sNewValue.length == 11)
{ sNewValue = sNewValue.substring(1,11);}
else
sNewValue = sNewValue.substring(0,10); err = true; alert("Not a valid phone number.  Type 10 digits, or in the format (999) 999-9999.");}
}
if (!err) { sNewValue = FormatPhone(sNewValue,iLength); s.value = sNewValue;}
else { s.value = sNewValue; s.select(); s.focus();}
}
function FormatPhone(sPhone, iLength)
{ var sNewPhone = ""; if (iLength == 10)
{ sNewPhone = "(" + sPhone.substring(0,3) + ") " + sPhone.substring(3,6) + "-" + sPhone.substring(6,10); return sNewPhone;}
else
return sPhone;}
function ParseChar(sStr, sChar)
{ if (sChar.length == null)
{ zChar = new Array(sChar);}
else zChar = sChar; for (i=0; i<zChar.length; i++)
{ sNewStr = ""; var iStart = 0; var iEnd = sStr.indexOf(sChar[i]); while (iEnd != -1)
{ sNewStr += sStr.substring(iStart, iEnd); iStart = iEnd + 1; iEnd = sStr.indexOf(sChar[i], iStart);}
sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length); sStr = sNewStr;}
return sNewStr;}
function MaskDate(s)
{ var sNewValue = s.value.split('\\').join('/').split('-').join('/').split('.').join('/'); var iLength = 0; var err = false; var arr = sNewValue.split('/'); for(var i = 0; i < arr.length; i++)
{ if(arr[i].length == 1)
{ arr[i] = "0" + arr[i];}
}
sNewValue = arr.join('/'); var zChar = new Array('/', '-', '.'); sNewValue = ParseChar(sNewValue, zChar); if (isNaN(sNewValue)) { err = true; alert("Not a valid date.  Type the digits, or in the format MM/DD/YYYY.");}
else { if (sNewValue.length == 8)
iLength = 8; else if (sNewValue.length == 0)
sNewValue = ""; else if (sNewValue.length <= 6)
{ err = true; alert("Not a valid date.  Type the digits, or in the format MM/DD/YYYY.");}
else if (sNewValue.length > 8)
{ iLength = 8; sNewValue = sNewValue.substring(0,8); err = true; alert("Not a valid date.  Type the digits, or in the format MM/DD/YYYY.");}
else if (sNewValue.length == 7)
{ if (s.value.substr(2, 1) == "/" || s.value.substr(2, 1) == "." || s.value.substr(2, 1) == "-")
{ sNewValue = sNewValue.substr(0, 2) + "0" + sNewValue.substr(2, 1) + sNewValue.substr(3, 4)
}
else if (s.value.substr(1, 1) == "/" || s.value.substr(1, 1) == "." || s.value.substr(1, 1) == "-")
{ sNewValue = "0" + sNewValue.substr(0, 1) + sNewValue.substr(1, 2) + sNewValue.substr(3, 4)
}
else if (sNewValue.substr(0, 1) >= "1" && sNewValue.substr(0, 1) <= "9" &&
sNewValue.substr(1, 2) >= "01" && sNewValue.substr(1, 2) <= "31")
{ sNewValue = "0" + sNewValue.substr(0, 1) + sNewValue.substr(1, 2) + sNewValue.substr(3, 4)
}
else if (sNewValue.substr(0, 2) >= "01" && sNewValue.substr(0, 2) <= "12" &&
sNewValue.substr(2, 1) >= "1" && sNewValue.substr(2, 1) <= "9")
{ sNewValue = sNewValue.substr(0, 2) + "0" + sNewValue.substr(2, 1) + sNewValue.substr(3, 4)
}
else
{ err = true; alert("Not a valid date.  Type the digits, or in the format MM/DD/YYYY.");}
}
}
if (!err) { sNewValue = FormatDate(sNewValue); s.value = sNewValue;}
else { s.value = sNewValue; s.select(); s.focus();}
}
function FormatDate(sDate)
{ var sNewDate = ""; if (sDate.length > 0)
sNewDate = sDate.substr(0,2) + "/" + sDate.substr(2,2) + "/" + sDate.substr(4,4); return sNewDate;}


// Cross-browser event handling
// by Scott Andrew LePera
// http://www.scottandrew.com/weblog/articles/cbs-events

// Modified 2004-08-10 by Andrew Grgeory to work around Konqueror bug
// Modified 2004-06-04 by Andrew Gregory to support legacy (NS3,4) browsers
// http://www.scss.com.au/family/andrew/

// eg. addEvent(imgObj, 'mousedown', processEvent, false);
function addEvent(obj, evType, fn, useCapture) {
  // work around Konqueror bug #57913 which prevents
  // window.addEventListener('load',...) from working
  var ua = navigator.userAgent;
  var konq = ua.indexOf('KHTML') != -1 && ua.indexOf('Safari') == -1 && obj == window && evType == 'load';
  // don't use addEventListener for Konq, have Konq fall back to the old
  // obj.onload method
  if (obj.addEventListener && !konq) {
	obj.addEventListener(evType, fn, useCapture);
	return true;
  } else if (obj.attachEvent) {
	return obj.attachEvent('on' + evType, fn);
  } else {
	if (!obj.cb_events) {
	  obj.cb_events = new Object();
	  obj.cb_ftemp = null;
	}
	var events = obj.cb_events[evType];
	if (!events) {
	  events = new Array();
	  obj.cb_events[evType] = events;
	}
	var i = 0;
	while ((i < events.length) && (events[i] != fn)) {
	  i++;
	}
	if (i == events.length) {
	  events[i] = fn;
	  obj['on' + evType] = new Function("var ret=false,e=this.cb_events['"+evType+"'];if(e){for(var i=0;i<e.length;i++){this.cb_ftemp=e[i];ret=this.cb_ftemp()||ret;}return ret;}");
	}
	return true;
  }
}

// eg. removeEvent(imgObj, 'mousedown', processEvent, false);
function removeEvent(obj, evType, fn, useCapture) {
  // work around Konqueror bug #57913 which prevents
  // window.addEventListener('load',...) from working
  var ua = navigator.userAgent;
  var konq = ua.indexOf('KHTML') != -1 && ua.indexOf('Safari') == -1 && obj == window && evType == 'load';
  // don't use addEventListener for Konq, have Konq fall back to the old
  // obj.onload method
  if (obj.removeEventListener && !konq) {
	obj.removeEventListener(evType, fn, useCapture);
	return true;
  } else if (obj.detachEvent) {
	return obj.detachEvent('on' + evType, fn);
  } else {
	var ret = false;
	if (obj.cb_events) {
	  var events = obj.cb_events[evType];
	  if (events) {
		// remove any matching functions from the events array, shuffling items
		// down to fill in the space before truncating the array
		var dest = 0;
		for (var src = 0; src < events.length; src++) {
		  if (dest != src) {
			events[dest] = events[src];
		  }
		  if (events[dest] == fn) {
			ret = true;
		  } else {
			dest++;
		  }
		}
		events.length = dest;
	  }
	}
	return ret;
  }
}


function GetElementPosition(obj) {
	var curleft = 0;
	var curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
if (typeof $ != 'undefined') {
	$.dealerSiteSettings = {
		debug: false
	};
	var reMsAjax = /^\/Date\((d|-|.*)\)\/$/;

	function parseMSAjaxDate(dtString) {
		var a = reMsAjax.exec(dtString);
		if (a) {
			var b = a[1].split(/[-,.]/);
			return new Date(+b[0]);
		}
		return dtString;
	};
	function Processing() {
		proc = document.createElement("div");
		$(proc).width($(document).width());
		$(proc).height($(document).height());
		$(proc).fadeTo(10, .9)
		proc.className = "processing";
		$(document.body).append(proc);
		$(document).ready(
            function () {
            	$(proc).hide();
            }
        );
	}
	function checkForDateString(jsonObj) {
		if (typeof jsonObj === 'string') {
			jsonObj = parseMSAjaxDate(jsonObj);
		}
		else if (typeof jsonObj == 'object') {
			for (var i in jsonObj) {
				var val = jsonObj[i]; if (typeof val == 'object' || typeof val == 'string') {
					jsonObj[i] = checkForDateString(val);
				}
			}
		}
		return jsonObj;
	}
	$.createParamsFromObj = function (data) {
		var params = '';
		for (var i in data) {
			if (params.length > 0) {
				params += '&';
			}
			params += i + '=' + encodeURIComponent(data[i]);
		}

		return params;
	}
	function successHelper(data, textStatus, callback) {
		if (callback) {
			data = checkForDateString(data);
			if (callback.length == 2) {
				callback(data, textStatus);
			}
			else if (callback.length == 1) {
				callback(data);
			}
			else {
				callback();
			}
		}
	}
	$.ajaxJSONPost = function (service, method, data, callback, error, cache) {
		var url = service + '/' + method;
		$.ajax({
			url: url,
			data: data,
			type: 'POST',
			processData: true,
			contentType: 'application/json',
			timeout: 10000,
			dataType: 'json',
			success: function (data, textStatus) { successHelper(data, textStatus, callback); },
			error: error,
			cache: cache
		});
	}
	$.ajaxJSONGet = function (service, method, data, callback, error, cache) {
		var url = service + '/' + method
		if (data)
			url += '?' + $.createParamsFromObj(data);
		$.ajax({
			url: url,
			type: 'GET',
			processData: true,
			contentType: 'application/json',
			timeout: 10000,
			dataType: 'json',
			success: function (data, textStatus) { successHelper(data, textStatus, callback); },
			error: error,
			cache: cache
		});
	}
	$.ajaxJSONGetSynchronous = function (service, method, data, callback, error, cache) {
		var url = service + '/' + method
		if (data)
			url += '?' + $.createParamsFromObj(data);
		$.ajax({
			url: url,
			type: 'GET',
			processData: true,
			contentType: 'application/json',
			timeout: 10000,
			async: false,
			dataType: 'json',
			success: function (data, textStatus) { successHelper(data, textStatus, callback); },
			error: error,
			cache: cache
		});
	}
	$.fn.loadSelectList = function (data, changefunction, defaultFirstValue) {
		if (data == null || data.length <= 0) {
			if ($.dealerSiteSettings.debug) {
				alert('No data for list id:');
			}
			this.hide();
			return this;
		}
		this.children().remove();
		this.each(function () {
			var element = this;
			var option = document.createElement('option');
			option.value = '';
			if (defaultFirstValue) {
				option.innerHTML = defaultFirstValue;
			}
			else {
				option.innerHTML = 'All';
			}
			element.appendChild(option);
			$(data).each(function () {
				var option = document.createElement('option');
				option.value = this.Value;
				option.innerHTML = this.Name;
				element.appendChild(option);
			});
		});
		if (changefunction) {
			this.change(changefunction);
		}
		return this.show();
	}
	$.fn.loadModel = function () {
	    this.hide().each(function () {
	        var selectList = this;
	        $.ajaxJSONGet('/services/Inventory.svc', 'GetModels', {
	            inventoryType: $('#' + this.searchID).find('select#type').val(),
	            make: $('#' + this.searchID).find('select#make').val()
	        },
				function (data) {
				    $(selectList).loadSelectList(data.d);
				});
	    });
	    return this;
	}
	$.fn.loadMake = function () {
		this.hide().each(function () {
			var selectList = this;
			$.ajaxJSONGet('/services/Inventory.svc', 'GetMakes',
                {
                	inventoryType: $('#' + this.searchID).find('select#type').val()
                },
                function (data) {
                	$(selectList).loadSelectList(data.d, function () {
                		var id = this.searchID;
                		$('#' + id).find('select#model').loadModel();
                	});
                });
		});
		return this;
    }
    $.fn.loadMakeADP = function () {
        this.hide().each(function () {
        	var selectList = this; //select DealerName from DealerInvoiceItem inner join dealer on dealerinvoiceitem.dealerid = dealer.dealerid where InvoiceItemID = 88 and Dealer.DMSName = 'ADP'
        	$.ajaxJSONGet('/services/Inventory.svc', 'GetMakesADP',
                        {},
                        function (data) {
                            $(selectList).loadSelectList(data.d, null, ' -- Select -- ');
                        });
     });
        return this;
    }
    $.fn.loadModelADP = function (makeID) {
        this.hide().each(function () {
        	var selectList = this; //select DealerName from DealerInvoiceItem inner join dealer on dealerinvoiceitem.dealerid = dealer.dealerid where InvoiceItemID = 88 and Dealer.DMSName = 'ADP'
        	$.ajaxJSONGet('/services/Inventory.svc', 'GetModelsADP', 
            {
                make: makeID
            },
				    function (data) {
				        $(selectList).loadSelectList(data.d, function () {
				            SetModelVal();
				        }, ' -- Select -- ');
				    });
        });
        return this;
    }
	$.fn.loadInventoryType = function () {
		this.hide().each(function () {
			var selectControl = this;
			$.ajaxJSONGet('/services/Inventory.svc', 'GetInventoryTypes', null, function (data) {
				$(selectControl).loadSelectList(data.d, function () {
					var id = selectControl.searchID;
					$('#' + id).find('select#make').loadMake();
				});
			});
		});
		return this;
	}
	$.fn.searchControl = function () {
		this.hide();
		this.each(function () {
			var type = $('select#type', this);
			var make = $('select#make', this);
			var model = $('select#model', this);
			var searchButton = $('#searchButton', this); // Use old inventory search
			var searchButtonNewSearch = $('#searchButtonNewSearch', this); // Use new inventory search
			var searchButtonCarsForSale = $('#searchButtonCarsForSale', this); // Use new inventory search
			var minPrice = $('select#minprice', this);
			var maxPrice = $('select#maxprice', this);

			if (typeof this.id == 'undefined' || this.id == null || this.id.length == 0) {
				this.id = 'basicSearchJQueryControl';
			}
			var loaded = false;
			if (type.length > 0) {
				var inventoryTypeList = type.get(0);
				inventoryTypeList.searchID = this.id;
				type.loadInventoryType();
				loaded = true;
			}
			if (make.length > 0) {
				var makeList = make.get(0);
				makeList.searchID = this.id;
				make.loadMake();
			}
			if (model.length > 0) {
				var modelList = model.get(0);
				modelList.searchID = this.id;
			}
			// uses the old inventory search
			if (searchButton.length > 0) {
				var search = searchButton.get(0);
				search.searchID = this.id;
				searchButton.click(function () {
					var search = $('#' + this.searchID);
					var url = "/Pre-Owned-Inventory.aspx?InventoryType=" + search.find('select#type').val() +
					"&Make=" + encodeURIComponent(search.find('select#make').val()) + "&Model=" + encodeURIComponent(search.find('select#model').val().replace(/\s\(.+\)/g, ''));
					top.window.location = url;
				});
			}
			// Uses the new Search inventory search.
			if (searchButtonNewSearch.length > 0) {
				var search = searchButtonNewSearch.get(0);
				search.searchID = this.id;
				searchButtonNewSearch.click(function () {
					var search = $('#' + this.searchID);
					var url = "/Inventory/Search/?InventoryType=" + search.find('select#type').val() +
					"&Make=" + encodeURIComponent(search.find('select#make').val()) + "&Model=" + encodeURIComponent(search.find('select#model').val().replace(/\s\(.+\)/g, ''));
					top.window.location = url;
				});
			}
			// Uses the new Search inventory search.
			if (searchButtonCarsForSale.length > 0) {
				var search = searchButtonCarsForSale.get(0);
				search.searchID = this.id;
				if (minPrice.length > 0 && maxPrice.length > 0) {
					searchButtonCarsForSale.click(function () {
						var search = $('#' + this.searchID);
						var url = "/Inventory/Cars-For-Sale/"

						var make = search.find('select#make').val();
						var model = search.find('select#model').val();
						var type = search.find('select#type').val();
						var minprice = search.find('select#minprice').val();
						var maxprice = search.find('select#maxprice').val();

						if (make && make != "All" && make != "") {
							url += "Make/" + encodeURIComponent(make) + "/";
						}
						if (model && model != "All" && model != "") {
							url += "Model/" + encodeURIComponent(model.replace(/\s\(.+\)/g, '')) + "/";
						}
						if (minprice && maxprice) {
							url += "Price/" + minprice + "-" + maxprice + "/";
						}
						if (type) {
							url += (search.find('select#type').val() == "N" ? "New/" : "Used/");
						}
						top.window.location = url;
					});
				}
				else {
					searchButtonCarsForSale.click(function () {
						var search = $('#' + this.searchID);
						var url = "/Inventory/Cars-For-Sale/"
						var make = search.find('select#make').val();
						var model = search.find('select#model').val();
						var type = search.find('select#type').val();


						if (make && make != "All" && make != "") {
							url += "Make/" + encodeURIComponent(make) + "/"
						}
						if (model && model != "All" && make != "") {
							url += "Model/" + encodeURIComponent(model.replace(/\s\(.+\)/g, '')) + "/";
						}
						if (search.find('select#type').val()) {
							url += (type == "N" ? "New/" : "Used/");
						}
						top.window.location = url;
					});
				}
			}
		});
		this.show();
		return this;
	}
	$.fn.loadTooltip = function () {
		try {
			$("[tooltip]").tooltip({
				track: true,
				delay: 0,
				fade: 250,
				showURL: false,
				extraClass: "tooltip",
				fixPNG: true,
				bodyHandler: function () {
					return $(this).attr("tooltip").split(" - ")[0];
				}
			});
		}
		catch (e)
		{ }
	}
	$.fn.BookMarkPage = function () {
		if (document.all)
			window.external.AddFavorite(location.href, document.title);
		else if (window.opera)
			return;
		else
			window.sidebar.addPanel(document.title, location.href, "");
	}
	$.fn.PrintPage = function () {
		//might want to do special stuff like unhide elements and hide others.
		$("[style]")
		window.print();
	}
	//fade one image into the next $(.blah img).crossfade("http://newimg.jpg", 1000);
	$.fn.crossfade = function (src, duration) {
		current = $(this);
		newImg = document.createElement("img");
		$(newImg).attr("src", current.attr("src"));
		$(newImg).css("height", current.height());
		$(newImg).css("width", current.width());
		$(newImg).css("position", "absolute");
		$(newImg).css("left", current.offset().left);
		current.after(newImg);
		$(current[0]).attr("src", src);
		$(current[0]).ready(function () {
			$(newImg).fadeOut(duration || 1000, function () { $(newImg).remove(); });
		});
	}
	$.fn.FormatPhone = function () {
		current = this[0];
		current.value = current.value.replace(/[^0-9]/g, "");
		if (current.value.length >= 10) {
			f = "(" + current.value.substring(0, 3) + ") ";
			f += current.value.substring(3, 6);
			f += "-" + current.value.substring(6, 10);
			if (current.value.length > 10) {
				f += "x" + current.value.substring(10);
			}
			current.value = f;
		}
	}
	$.fn.loadElement = function (link) {
		var e = $(this);
		//e.html("<img src='../../images/loading.gif' />");
		$.get(link, function (data) {
			if (jQuery.browser.msie) {
				var iframe = document.createElement('iframe');
				iframe.width = 450;
				iframe.height = 1000;
				iframe.border = 0;
				e.html('');
				e.append(iframe);
				iframe.contentWindow.document.write(data);
				e.html(iframe.contentWindow.document.body.innerHTML);
			}
			else {
				var c = $(data).find("#content").parent().parent();
				if (c.length > 0) {
					e.append(c.get(0));
				}
			}
			$(data).find('script').each(function () {
				$('body').append(this);
			});

		}, function () {
		});
	}
}
/*
 * jQuery Tooltip plugin 1.3
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 * http://docs.jquery.com/Plugins/Tooltip
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */;(function($){var helper={},current,title,tID,IE=$.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),track=false;$.tooltip={blocked:false,defaults:{delay:200,fade:false,showURL:true,extraClass:"",top:15,left:15,id:"tooltip"},block:function(){$.tooltip.blocked=!$.tooltip.blocked;}};$.fn.extend({tooltip:function(settings){settings=$.extend({},$.tooltip.defaults,settings);createHelper(settings);return this.each(function(){$.data(this,"tooltip",settings);this.tOpacity=helper.parent.css("opacity");this.tooltipText=this.title;$(this).removeAttr("title");this.alt="";}).mouseover(save).mouseout(hide).click(hide);},fixPNG:IE?function(){return this.each(function(){var image=$(this).css('backgroundImage');if(image.match(/^url\(["']?(.*\.png)["']?\)$/i)){image=RegExp.$1;$(this).css({'backgroundImage':'none','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+image+"')"}).each(function(){var position=$(this).css('position');if(position!='absolute'&&position!='relative')$(this).css('position','relative');});}});}:function(){return this;},unfixPNG:IE?function(){return this.each(function(){$(this).css({'filter':'',backgroundImage:''});});}:function(){return this;},hideWhenEmpty:function(){return this.each(function(){$(this)[$(this).html()?"show":"hide"]();});},url:function(){return this.attr('href')||this.attr('src');}});function createHelper(settings){if(helper.parent)return;helper.parent=$('<div id="'+settings.id+'"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide();if($.fn.bgiframe)helper.parent.bgiframe();helper.title=$('h3',helper.parent);helper.body=$('div.body',helper.parent);helper.url=$('div.url',helper.parent);}function settings(element){return $.data(element,"tooltip");}function handle(event){if(settings(this).delay)tID=setTimeout(show,settings(this).delay);else
show();track=!!settings(this).track;$(document.body).bind('mousemove',update);update(event);}function save(){if($.tooltip.blocked||this==current||(!this.tooltipText&&!settings(this).bodyHandler))return;current=this;title=this.tooltipText;if(settings(this).bodyHandler){helper.title.hide();var bodyContent=settings(this).bodyHandler.call(this);if(bodyContent.nodeType||bodyContent.jquery){helper.body.empty().append(bodyContent)}else{helper.body.html(bodyContent);}helper.body.show();}else if(settings(this).showBody){var parts=title.split(settings(this).showBody);helper.title.html(parts.shift()).show();helper.body.empty();for(var i=0,part;(part=parts[i]);i++){if(i>0)helper.body.append("<br/>");helper.body.append(part);}helper.body.hideWhenEmpty();}else{helper.title.html(title).show();helper.body.hide();}if(settings(this).showURL&&$(this).url())helper.url.html($(this).url().replace('http://','')).show();else
helper.url.hide();helper.parent.addClass(settings(this).extraClass);if(settings(this).fixPNG)helper.parent.fixPNG();handle.apply(this,arguments);}function show(){tID=null;if((!IE||!$.fn.bgiframe)&&settings(current).fade){if(helper.parent.is(":animated"))helper.parent.stop().show().fadeTo(settings(current).fade,current.tOpacity);else
helper.parent.is(':visible')?helper.parent.fadeTo(settings(current).fade,current.tOpacity):helper.parent.fadeIn(settings(current).fade);}else{helper.parent.show();}update();}function update(event){if($.tooltip.blocked)return;if(event&&event.target.tagName=="OPTION"){return;}if(!track&&helper.parent.is(":visible")){$(document.body).unbind('mousemove',update)}if(current==null){$(document.body).unbind('mousemove',update);return;}helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");var left=helper.parent[0].offsetLeft;var top=helper.parent[0].offsetTop;if(event){left=event.pageX+settings(current).left;top=event.pageY+settings(current).top;var right='auto';if(settings(current).positionLeft){right=$(window).width()-left;left='auto';}helper.parent.css({left:left,right:right,top:top});}var v=viewport(),h=helper.parent[0];if(v.x+v.cx<h.offsetLeft+h.offsetWidth){left-=h.offsetWidth+20+settings(current).left;helper.parent.css({left:left+'px'}).addClass("viewport-right");}if(v.y+v.cy<h.offsetTop+h.offsetHeight){top-=h.offsetHeight+20+settings(current).top;helper.parent.css({top:top+'px'}).addClass("viewport-bottom");}}function viewport(){return{x:$(window).scrollLeft(),y:$(window).scrollTop(),cx:$(window).width(),cy:$(window).height()};}function hide(event){if($.tooltip.blocked)return;if(tID)clearTimeout(tID);current=null;var tsettings=settings(this);function complete(){helper.parent.removeClass(tsettings.extraClass).hide().css("opacity","");}if((!IE||!$.fn.bgiframe)&&tsettings.fade){if(helper.parent.is(':animated'))helper.parent.stop().fadeTo(tsettings.fade,0,complete);else
helper.parent.stop().fadeOut(tsettings.fade,complete);}else
complete();if(settings(this).fixPNG)helper.parent.unfixPNG();}})(jQuery);



$(document).ready($(document).loadTooltip);
//Version 2.99
(function (e, c) { function h(b) { e.fn.cycle.debug && a(b) } function a() { window.console && console.log && console.log("[cycle] " + Array.prototype.join.call(arguments, " ")) } function j(b, g, a) { var d = e(b).data("cycle.opts"), c = !!b.cyclePause; c && d.paused ? d.paused(b, d, g, a) : !c && d.resumed && d.resumed(b, d, g, a) } function i(b, g, k) { function d(b, g, k) { if (!b && !0 === g) { b = e(k).data("cycle.opts"); if (!b) return a("options not found, can not resume"), !1; if (k.cycleTimeout) clearTimeout(k.cycleTimeout), k.cycleTimeout = 0; t(b.elements, b, 1, !b.backwards) } } if (b.cycleStop == c) b.cycleStop = 0; if (g === c || null === g) g = {}; if (g.constructor == String) switch (g) { case "destroy": case "stop": k = e(b).data("cycle.opts"); if (!k) return !1; b.cycleStop++; b.cycleTimeout && clearTimeout(b.cycleTimeout); b.cycleTimeout = 0; k.elements && e(k.elements).stop(); e(b).removeData("cycle.opts"); "destroy" == g && l(k); return !1; case "toggle": return b.cyclePause = 1 === b.cyclePause ? 0 : 1, d(b.cyclePause, k, b), j(b), !1; case "pause": return b.cyclePause = 1, j(b), !1; case "resume": return b.cyclePause = 0, d(!1, k, b), j(b), !1; case "prev": case "next": k = e(b).data("cycle.opts"); if (!k) return a('options not found, "prev/next" ignored'), !1; e.fn.cycle[g](k); return !1; default: g = { fx: g} } else if (g.constructor == Number) { var i = g, g = e(b).data("cycle.opts"); if (!g) return a("options not found, can not advance slide"), !1; if (0 > i || i >= g.elements.length) return a("invalid slide index: " + i), !1; g.nextSlide = i; if (b.cycleTimeout) clearTimeout(b.cycleTimeout), b.cycleTimeout = 0; if ("string" == typeof k) g.oneTimeFx = k; t(g.elements, g, 1, i >= g.currSlide); return !1 } return g } function d(b, g) { if (!e.support.opacity && g.cleartype && b.style.filter) try { b.style.removeAttribute("filter") } catch (a) { } } function l(b) { b.next && e(b.next).unbind(b.prevNextEvent); b.prev && e(b.prev).unbind(b.prevNextEvent); if (b.pager || b.pagerAnchorBuilder) e.each(b.pagerAnchors || [], function () { this.unbind().remove() }); b.pagerAnchors = null; b.destroy && b.destroy(b) } function n(b, g, k, i, z) { var q, f = e.extend({}, e.fn.cycle.defaults, i || {}, e.metadata ? b.metadata() : e.meta ? b.data() : {}), h = e.isFunction(b.data) ? b.data(f.metaAttr) : null; h && (f = e.extend(f, h)); if (f.autostop) f.countdown = f.autostopCount || k.length; var l = b[0]; b.data("cycle.opts", f); f.$cont = b; f.stopCount = l.cycleStop; f.elements = k; f.before = f.before ? [f.before] : []; f.after = f.after ? [f.after] : []; !e.support.opacity && f.cleartype && f.after.push(function () { d(this, f) }); f.continuous && f.after.push(function () { t(k, f, 0, !f.backwards) }); m(f); !e.support.opacity && f.cleartype && !f.cleartypeNoBg && r(g); "static" == b.css("position") && b.css("position", "relative"); f.width && b.width(f.width); f.height && "auto" != f.height && b.height(f.height); f.startingSlide != c ? (f.startingSlide = parseInt(f.startingSlide, 10), f.startingSlide >= k.length || 0 > f.startSlide ? f.startingSlide = 0 : q = !0) : f.startingSlide = f.backwards ? k.length - 1 : 0; if (f.random) { f.randomMap = []; for (h = 0; h < k.length; h++) f.randomMap.push(h); f.randomMap.sort(function () { return Math.random() - 0.5 }); if (q) for (q = 0; q < k.length; q++) { if (f.startingSlide == f.randomMap[q]) f.randomIndex = q } else f.randomIndex = 1, f.startingSlide = f.randomMap[1] } else if (f.startingSlide >= k.length) f.startingSlide = 0; f.currSlide = f.startingSlide || 0; var o = f.startingSlide; g.css({ position: "absolute", top: 0, left: 0 }).hide().each(function (b) { b = f.backwards ? o ? b <= o ? k.length + (b - o) : o - b : k.length - b : o ? b >= o ? k.length - (b - o) : o - b : k.length - b; e(this).css("z-index", b) }); e(k[o]).css("opacity", 1).show(); d(k[o], f); f.fit && (f.aspect ? g.each(function () { var b = e(this), g = !0 === f.aspect ? b.width() / b.height() : f.aspect; f.width && b.width() != f.width && (b.width(f.width), b.height(f.width / g)); f.height && b.height() < f.height && (b.height(f.height), b.width(f.height * g)) }) : (f.width && g.width(f.width), f.height && "auto" != f.height && g.height(f.height))); f.center && (!f.fit || f.aspect) && g.each(function () { var b = e(this); b.css({ "margin-left": f.width ? (f.width - b.width()) / 2 + "px" : 0, "margin-top": f.height ? (f.height - b.height()) / 2 + "px" : 0 }) }); f.center && !f.fit && !f.slideResize && g.each(function () { var b = e(this); b.css({ "margin-left": f.width ? (f.width - b.width()) / 2 + "px" : 0, "margin-top": f.height ? (f.height - b.height()) / 2 + "px" : 0 }) }); if (f.containerResize && !b.innerHeight()) { for (var n = h = q = 0; n < k.length; n++) { var v = e(k[n]), w = v[0], u = v.outerWidth(), x = v.outerHeight(); u || (u = w.offsetWidth || w.width || v.attr("width")); x || (x = w.offsetHeight || w.height || v.attr("height")); q = u > q ? u : q; h = x > h ? x : h } 0 < q && 0 < h && b.css({ width: q + "px", height: h + "px" }) } var B = !1; f.pause && b.hover(function () { B = !0; this.cyclePause++; j(l, !0) }, function () { B && this.cyclePause--; j(l, !0) }); if (!1 === s(f)) return !1; var C = !1; i.requeueAttempts = i.requeueAttempts || 0; g.each(function () { var b = e(this); this.cycleH = f.fit && f.height ? f.height : b.height() || this.offsetHeight || this.height || b.attr("height") || 0; this.cycleW = f.fit && f.width ? f.width : b.width() || this.offsetWidth || this.width || b.attr("width") || 0; if (b.is("img")) { var b = e.browser.mozilla && 34 == this.cycleW && 19 == this.cycleH && !this.complete, g = e.browser.opera && (42 == this.cycleW && 19 == this.cycleH || 37 == this.cycleW && 17 == this.cycleH) && !this.complete, k = 0 == this.cycleH && 0 == this.cycleW && !this.complete; if (e.browser.msie && 28 == this.cycleW && 30 == this.cycleH && !this.complete || b || g || k) { if (z.s && f.requeueOnImageNotLoaded && 100 > ++i.requeueAttempts) return a(i.requeueAttempts, " - img slide not loaded, requeuing slideshow: ", this.src, this.cycleW, this.cycleH), setTimeout(function () { e(z.s, z.c).cycle(i) }, f.requeueTimeout), C = !0, !1; a("could not determine size of image: " + this.src, this.cycleW, this.cycleH) } } return !0 }); if (C) return !1; f.cssBefore = f.cssBefore || {}; f.cssAfter = f.cssAfter || {}; f.cssFirst = f.cssFirst || {}; f.animIn = f.animIn || {}; f.animOut = f.animOut || {}; g.not(":eq(" + o + ")").css(f.cssBefore); e(g[o]).css(f.cssFirst); if (f.timeout) { f.timeout = parseInt(f.timeout, 10); if (f.speed.constructor == String) f.speed = e.fx.speeds[f.speed] || parseInt(f.speed, 10); f.sync || (f.speed /= 2); for (q = "none" == f.fx ? 0 : "shuffle" == f.fx ? 500 : 250; f.timeout - f.speed < q; ) f.timeout += f.speed } if (f.easing) f.easeIn = f.easeOut = f.easing; if (!f.speedIn) f.speedIn = f.speed; if (!f.speedOut) f.speedOut = f.speed; f.slideCount = k.length; f.currSlide = f.lastSlide = o; if (f.random) { if (++f.randomIndex == k.length) f.randomIndex = 0; f.nextSlide = f.randomMap[f.randomIndex] } else f.nextSlide = f.backwards ? 0 == f.startingSlide ? k.length - 1 : f.startingSlide - 1 : f.startingSlide >= k.length - 1 ? 0 : f.startingSlide + 1; if (!f.multiFx) if (q = e.fn.cycle.transitions[f.fx], e.isFunction(q)) q(b, g, f); else if ("custom" != f.fx && !f.multiFx) return a("unknown transition: " + f.fx, "; slideshow terminating"), !1; b = g[o]; f.skipInitializationCallbacks || (f.before.length && f.before[0].apply(b, [b, b, f, !0]), f.after.length && f.after[0].apply(b, [b, b, f, !0])); f.next && e(f.next).bind(f.prevNextEvent, function () { return y(f, 1) }); f.prev && e(f.prev).bind(f.prevNextEvent, function () { return y(f, 0) }); (f.pager || f.pagerAnchorBuilder) && A(k, f); D(f, k); return f } function m(b) { b.original = { before: [], after: [] }; b.original.cssBefore = e.extend({}, b.cssBefore); b.original.cssAfter = e.extend({}, b.cssAfter); b.original.animIn = e.extend({}, b.animIn); b.original.animOut = e.extend({}, b.animOut); e.each(b.before, function () { b.original.before.push(this) }); e.each(b.after, function () { b.original.after.push(this) }) } function s(b) { var g, k, d = e.fn.cycle.transitions; if (0 < b.fx.indexOf(",")) { b.multiFx = !0; b.fxs = b.fx.replace(/\s*/g, "").split(","); for (g = 0; g < b.fxs.length; g++) { var i = b.fxs[g]; k = d[i]; if (!k || !d.hasOwnProperty(i) || !e.isFunction(k)) a("discarding unknown transition: ", i), b.fxs.splice(g, 1), g-- } if (!b.fxs.length) return a("No valid transitions named; slideshow terminating."), !1 } else if ("all" == b.fx) for (p in b.multiFx = !0, b.fxs = [], d) k = d[p], d.hasOwnProperty(p) && e.isFunction(k) && b.fxs.push(p); if (b.multiFx && b.randomizeEffects) { k = Math.floor(20 * Math.random()) + 30; for (g = 0; g < k; g++) d = Math.floor(Math.random() * b.fxs.length), b.fxs.push(b.fxs.splice(d, 1)[0]); h("randomized fx sequence: ", b.fxs) } return !0 } function D(b, g) { b.addSlide = function (a, d) { var i = e(a), c = i[0]; b.autostopCount || b.countdown++; g[d ? "unshift" : "push"](c); if (b.els) b.els[d ? "unshift" : "push"](c); b.slideCount = g.length; b.random && (b.randomMap.push(b.slideCount - 1), b.randomMap.sort(function () { return Math.random() - 0.5 })); i.css("position", "absolute"); i[d ? "prependTo" : "appendTo"](b.$cont); d && (b.currSlide++, b.nextSlide++); !e.support.opacity && b.cleartype && !b.cleartypeNoBg && r(i); b.fit && b.width && i.width(b.width); b.fit && b.height && "auto" != b.height && i.height(b.height); c.cycleH = b.fit && b.height ? b.height : i.height(); c.cycleW = b.fit && b.width ? b.width : i.width(); i.css(b.cssBefore); (b.pager || b.pagerAnchorBuilder) && e.fn.cycle.createPagerAnchor(g.length - 1, c, e(b.pager), g, b); if (e.isFunction(b.onAddSlide)) b.onAddSlide(i); else i.hide() } } function t(b, g, a, d) { function i() { var a = 0; g.timeout && !g.continuous ? (a = u(b[g.currSlide], b[g.nextSlide], g, d), "shuffle" == g.fx && (a -= g.speedOut)) : g.continuous && j.cyclePause && (a = 10); if (0 < a) j.cycleTimeout = setTimeout(function () { t(b, g, 0, !g.backwards) }, a) } if (a && g.busy && g.manualTrump) h("manualTrump in go(), stopping active transition"), e(b).stop(!0, !0), g.busy = 0; if (g.busy) h("transition active, ignoring new tx request"); else { var j = g.$cont[0], f = b[g.currSlide], l = b[g.nextSlide]; if (!(j.cycleStop != g.stopCount || 0 === j.cycleTimeout && !a)) if (!a && !j.cyclePause && !g.bounce && (g.autostop && 0 >= --g.countdown || g.nowrap && !g.random && g.nextSlide < g.currSlide)) g.end && g.end(g); else { var n = !1; if ((a || !j.cyclePause) && g.nextSlide != g.currSlide) { var n = !0, o = g.fx; f.cycleH = f.cycleH || e(f).height(); f.cycleW = f.cycleW || e(f).width(); l.cycleH = l.cycleH || e(l).height(); l.cycleW = l.cycleW || e(l).width(); if (g.multiFx) { if (d && (g.lastFx == c || ++g.lastFx >= g.fxs.length)) g.lastFx = 0; else if (!d && (g.lastFx == c || 0 > --g.lastFx)) g.lastFx = g.fxs.length - 1; o = g.fxs[g.lastFx] } if (g.oneTimeFx) o = g.oneTimeFx, g.oneTimeFx = null; e.fn.cycle.resetState(g, o); g.before.length && e.each(g.before, function (b, a) { j.cycleStop == g.stopCount && a.apply(l, [f, l, g, d]) }); var m = function () { g.busy = 0; e.each(g.after, function (b, a) { j.cycleStop == g.stopCount && a.apply(l, [f, l, g, d]) }); j.cycleStop || i() }; h("tx firing(" + o + "); currSlide: " + g.currSlide + "; nextSlide: " + g.nextSlide); g.busy = 1; if (g.fxFn) g.fxFn(f, l, g, m, d, a && g.fastOnEvent); else if (e.isFunction(e.fn.cycle[g.fx])) e.fn.cycle[g.fx](f, l, g, m, d, a && g.fastOnEvent); else e.fn.cycle.custom(f, l, g, m, d, a && g.fastOnEvent) } else i(); if (n || g.nextSlide == g.currSlide) if (g.lastSlide = g.currSlide, g.random) { g.currSlide = g.nextSlide; if (++g.randomIndex == b.length) g.randomIndex = 0, g.randomMap.sort(function () { return Math.random() - 0.5 }); g.nextSlide = g.randomMap[g.randomIndex]; if (g.nextSlide == g.currSlide) g.nextSlide = g.currSlide == g.slideCount - 1 ? 0 : g.currSlide + 1 } else g.backwards ? (a = 0 > g.nextSlide - 1) && g.bounce ? (g.backwards = !g.backwards, g.nextSlide = 1, g.currSlide = 0) : (g.nextSlide = a ? b.length - 1 : g.nextSlide - 1, g.currSlide = a ? 0 : g.nextSlide + 1) : (a = g.nextSlide + 1 == b.length) && g.bounce ? (g.backwards = !g.backwards, g.nextSlide = b.length - 2, g.currSlide = b.length - 1) : (g.nextSlide = a ? 0 : g.nextSlide + 1, g.currSlide = a ? b.length - 1 : g.nextSlide - 1); n && g.pager && g.updateActivePagerLink(g.pager, g.currSlide, g.activePagerClass) } } } function u(b, a, e, d) { if (e.timeoutFn) { for (b = e.timeoutFn.call(b, b, a, e, d); "none" != e.fx && 250 > b - e.speed; ) b += e.speed; h("calculated timeout: " + b + "; speed: " + e.speed); if (!1 !== b) return b } return e.timeout } function y(b, a) { var d = a ? 1 : -1, i = b.elements, c = b.$cont[0], j = c.cycleTimeout; if (j) clearTimeout(j), c.cycleTimeout = 0; if (b.random && 0 > d) { b.randomIndex--; if (-2 == --b.randomIndex) b.randomIndex = i.length - 2; else if (-1 == b.randomIndex) b.randomIndex = i.length - 1; b.nextSlide = b.randomMap[b.randomIndex] } else if (b.random) b.nextSlide = b.randomMap[b.randomIndex]; else if (b.nextSlide = b.currSlide + d, 0 > b.nextSlide) { if (b.nowrap) return !1; b.nextSlide = i.length - 1 } else if (b.nextSlide >= i.length) { if (b.nowrap) return !1; b.nextSlide = 0 } c = b.onPrevNextEvent || b.prevNextClick; e.isFunction(c) && c(0 < d, b.nextSlide, i[b.nextSlide]); t(i, b, 1, a); return !1 } function A(b, a) { var d = e(a.pager); e.each(b, function (i, c) { e.fn.cycle.createPagerAnchor(i, c, d, b, a) }); a.updateActivePagerLink(a.pager, a.startingSlide, a.activePagerClass) } function r(b) { function a(b) { b = parseInt(b, 10).toString(16); return 2 > b.length ? "0" + b : b } function d(b) { for (; b && "html" != b.nodeName.toLowerCase(); b = b.parentNode) { var i = e.css(b, "background-color"); if (i && 0 <= i.indexOf("rgb")) return b = i.match(/\d+/g), "#" + a(b[0]) + a(b[1]) + a(b[2]); if (i && "transparent" != i) return i } return "#ffffff" } h("applying clearType background-color hack"); b.each(function () { e(this).css("background-color", d(this)) }) } if (e.support == c) e.support = { opacity: !e.browser.msie }; e.expr[":"].paused = function (b) { return b.cyclePause }; e.fn.cycle = function (b, g) { var d = { s: this.selector, c: this.context }; if (0 === this.length && "stop" != b) { if (!e.isReady && d.s) return a("DOM not ready, queuing slideshow"), e(function () { e(d.s, d.c).cycle(b, g) }), this; a("terminating; zero elements found by selector" + (e.isReady ? "" : " (DOM not ready)")); return this } return this.each(function () { var c = i(this, b, g); if (!1 !== c) { c.updateActivePagerLink = c.updateActivePagerLink || e.fn.cycle.updateActivePagerLink; this.cycleTimeout && clearTimeout(this.cycleTimeout); this.cycleTimeout = this.cyclePause = 0; var j = e(this), l = c.slideExpr ? e(c.slideExpr, this) : j.children(), f = l.get(), m = n(j, l, f, c, d); if (!1 !== m) if (2 > f.length) a("terminating; too few slides: " + f.length); else if (j = m.continuous ? 10 : u(f[m.currSlide], f[m.nextSlide], m, !m.backwards)) j += m.delay || 0, 10 > j && (j = 10), h("first timeout: " + j), this.cycleTimeout = setTimeout(function () { t(f, m, 0, !c.backwards) }, j) } }) }; e.fn.cycle.resetState = function (b, a) { a = a || b.fx; b.before = []; b.after = []; b.cssBefore = e.extend({}, b.original.cssBefore); b.cssAfter = e.extend({}, b.original.cssAfter); b.animIn = e.extend({}, b.original.animIn); b.animOut = e.extend({}, b.original.animOut); b.fxFn = null; e.each(b.original.before, function () { b.before.push(this) }); e.each(b.original.after, function () { b.after.push(this) }); var d = e.fn.cycle.transitions[a]; e.isFunction(d) && d(b.$cont, e(b.elements), b) }; e.fn.cycle.updateActivePagerLink = function (b, a, d) { e(b).each(function () { e(this).children().removeClass(d).eq(a).addClass(d) }) }; e.fn.cycle.next = function (b) { y(b, 1) }; e.fn.cycle.prev = function (b) { y(b, 0) }; e.fn.cycle.createPagerAnchor = function (b, a, d, i, c) { e.isFunction(c.pagerAnchorBuilder) ? (a = c.pagerAnchorBuilder(b, a), h("pagerAnchorBuilder(" + b + ", el) returned: " + a)) : a = '<a href="#">' + (b + 1) + "</a>"; if (a) { var l = e(a); if (0 === l.parents("body").length) { var f = []; 1 < d.length ? (d.each(function () { var b = l.clone(!0); e(this).append(b); f.push(b[0]) }), l = e(f)) : l.appendTo(d) } c.pagerAnchors = c.pagerAnchors || []; c.pagerAnchors.push(l); d = function (a) { a.preventDefault(); c.nextSlide = b; var a = c.$cont[0], f = a.cycleTimeout; if (f) clearTimeout(f), a.cycleTimeout = 0; a = c.onPagerEvent || c.pagerClick; e.isFunction(a) && a(c.nextSlide, i[c.nextSlide]); t(i, c, 1, c.currSlide < b) }; /mouseenter|mouseover/i.test(c.pagerEvent) ? l.hover(d, function () { }) : l.bind(c.pagerEvent, d); !/^click/.test(c.pagerEvent) && !c.allowPagerClickBubble && l.bind("click.cycle", function () { return !1 }); var m = c.$cont[0], n = !1; c.pauseOnPagerHover && l.hover(function () { n = !0; m.cyclePause++; j(m, !0, !0) }, function () { n && m.cyclePause--; j(m, !0, !0) }) } }; e.fn.cycle.hopsFromLast = function (b, a) { var e = b.lastSlide, d = b.currSlide; return a ? d > e ? d - e : b.slideCount - e : d < e ? e - d : e + b.slideCount - d }; e.fn.cycle.commonReset = function (b, a, d, c, i, j) { e(d.elements).not(b).hide(); if ("undefined" == typeof d.cssBefore.opacity) d.cssBefore.opacity = 1; d.cssBefore.display = "block"; if (d.slideResize && !1 !== c && 0 < a.cycleW) d.cssBefore.width = a.cycleW; if (d.slideResize && !1 !== i && 0 < a.cycleH) d.cssBefore.height = a.cycleH; d.cssAfter = d.cssAfter || {}; d.cssAfter.display = "none"; e(b).css("zIndex", d.slideCount + (!0 === j ? 1 : 0)); e(a).css("zIndex", d.slideCount + (!0 === j ? 0 : 1)) }; e.fn.cycle.custom = function (b, a, d, c, i, j) { var f = e(b), h = e(a), l = d.speedIn, b = d.speedOut, m = d.easeIn, a = d.easeOut; h.css(d.cssBefore); j && (l = "number" == typeof j ? b = j : b = 1, m = a = null); var n = function () { h.animate(d.animIn, l, m, function () { c() }) }; f.animate(d.animOut, b, a, function () { f.css(d.cssAfter); d.sync || n() }); d.sync && n() }; e.fn.cycle.transitions = { fade: function (b, a, d) { a.not(":eq(" + d.currSlide + ")").css("opacity", 0); d.before.push(function (b, a, d) { e.fn.cycle.commonReset(b, a, d); d.cssBefore.opacity = 0 }); d.animIn = { opacity: 1 }; d.animOut = { opacity: 0 }; d.cssBefore = { top: 0, left: 0} } }; e.fn.cycle.ver = function () { return "2.9999" }; e.fn.cycle.defaults = { activePagerClass: "activeSlide", after: null, allowPagerClickBubble: !1, animIn: null, animOut: null, aspect: !1, autostop: 0, autostopCount: 0, backwards: !1, before: null, center: null, cleartype: !e.support.opacity, cleartypeNoBg: !1, containerResize: 1, continuous: 0, cssAfter: null, cssBefore: null, delay: 0, easeIn: null, easeOut: null, easing: null, end: null, fastOnEvent: 0, fit: 0, fx: "fade", fxFn: null, height: "auto", manualTrump: !0, metaAttr: "cycle", next: null, nowrap: 0, onPagerEvent: null, onPrevNextEvent: null, pager: null, pagerAnchorBuilder: null, pagerEvent: "click.cycle", pause: 0, pauseOnPagerHover: 0, prev: null, prevNextEvent: "click.cycle", random: 0, randomizeEffects: 1, requeueOnImageNotLoaded: !0, requeueTimeout: 250, rev: 0, shuffle: null, skipInitializationCallbacks: !1, slideExpr: null, slideResize: 1, speed: 1E3, speedIn: null, speedOut: null, startingSlide: c, sync: 1, timeout: 4E3, timeoutFn: null, updateActivePagerLink: null, width: null} })(jQuery); (function (e) { e.fn.cycle.transitions.none = function (c, h, a) { a.fxFn = function (a, c, d, h) { e(c).show(); e(a).hide(); h() } }; e.fn.cycle.transitions.fadeout = function (c, h, a) { h.not(":eq(" + a.currSlide + ")").css({ display: "block", opacity: 1 }); a.before.push(function (a, c, d, h, n, m) { e(a).css("zIndex", d.slideCount + (!0 === !m ? 1 : 0)); e(c).css("zIndex", d.slideCount + (!0 === !m ? 0 : 1)) }); a.animIn.opacity = 1; a.animOut.opacity = 0; a.cssBefore.opacity = 1; a.cssBefore.display = "block"; a.cssAfter.zIndex = 0 }; e.fn.cycle.transitions.scrollUp = function (c, h, a) { c.css("overflow", "hidden"); a.before.push(e.fn.cycle.commonReset); c = c.height(); a.cssBefore.top = c; a.cssBefore.left = 0; a.cssFirst.top = 0; a.animIn.top = 0; a.animOut.top = -c }; e.fn.cycle.transitions.scrollDown = function (c, h, a) { c.css("overflow", "hidden"); a.before.push(e.fn.cycle.commonReset); c = c.height(); a.cssFirst.top = 0; a.cssBefore.top = -c; a.cssBefore.left = 0; a.animIn.top = 0; a.animOut.top = c }; e.fn.cycle.transitions.scrollLeft = function (c, h, a) { c.css("overflow", "hidden"); a.before.push(e.fn.cycle.commonReset); c = c.width(); a.cssFirst.left = 0; a.cssBefore.left = c; a.cssBefore.top = 0; a.animIn.left = 0; a.animOut.left = 0 - c }; e.fn.cycle.transitions.scrollRight = function (c, h, a) { c.css("overflow", "hidden"); a.before.push(e.fn.cycle.commonReset); c = c.width(); a.cssFirst.left = 0; a.cssBefore.left = -c; a.cssBefore.top = 0; a.animIn.left = 0; a.animOut.left = c }; e.fn.cycle.transitions.scrollHorz = function (c, h, a) { c.css("overflow", "hidden").width(); a.before.push(function (a, c, d, h) { d.rev && (h = !h); e.fn.cycle.commonReset(a, c, d); d.cssBefore.left = h ? c.cycleW - 1 : 1 - c.cycleW; d.animOut.left = h ? -a.cycleW : a.cycleW }); a.cssFirst.left = 0; a.cssBefore.top = 0; a.animIn.left = 0; a.animOut.top = 0 }; e.fn.cycle.transitions.scrollVert = function (c, h, a) { c.css("overflow", "hidden"); a.before.push(function (a, c, d, h) { d.rev && (h = !h); e.fn.cycle.commonReset(a, c, d); d.cssBefore.top = h ? 1 - c.cycleH : c.cycleH - 1; d.animOut.top = h ? a.cycleH : -a.cycleH }); a.cssFirst.top = 0; a.cssBefore.left = 0; a.animIn.top = 0; a.animOut.left = 0 }; e.fn.cycle.transitions.slideX = function (c, h, a) { a.before.push(function (a, c, d) { e(d.elements).not(a).hide(); e.fn.cycle.commonReset(a, c, d, !1, !0); d.animIn.width = c.cycleW }); a.cssBefore.left = 0; a.cssBefore.top = 0; a.cssBefore.width = 0; a.animIn.width = "show"; a.animOut.width = 0 }; e.fn.cycle.transitions.slideY = function (c, h, a) { a.before.push(function (a, c, d) { e(d.elements).not(a).hide(); e.fn.cycle.commonReset(a, c, d, !0, !1); d.animIn.height = c.cycleH }); a.cssBefore.left = 0; a.cssBefore.top = 0; a.cssBefore.height = 0; a.animIn.height = "show"; a.animOut.height = 0 }; e.fn.cycle.transitions.shuffle = function (c, h, a) { c = c.css("overflow", "visible").width(); h.css({ left: 0, top: 0 }); a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d, !0, !0, !0) }); if (!a.speedAdjusted) a.speed /= 2, a.speedAdjusted = !0; a.random = 0; a.shuffle = a.shuffle || { left: -c, top: 15 }; a.els = []; for (c = 0; c < h.length; c++) a.els.push(h[c]); for (c = 0; c < a.currSlide; c++) a.els.push(a.els.shift()); a.fxFn = function (a, c, d, h, n) { d.rev && (n = !n); var m = n ? e(a) : e(c); e(c).css(d.cssBefore); var s = d.slideCount; m.animate(d.shuffle, d.speedIn, d.easeIn, function () { for (var c = e.fn.cycle.hopsFromLast(d, n), i = 0; i < c; i++) n ? d.els.push(d.els.shift()) : d.els.unshift(d.els.pop()); if (n) { c = 0; for (i = d.els.length; c < i; c++) e(d.els[c]).css("z-index", i - c + s) } else c = e(a).css("z-index"), m.css("z-index", parseInt(c, 10) + 1 + s); m.animate({ left: 0, top: 0 }, d.speedOut, d.easeOut, function () { e(n ? this : a).hide(); h && h() }) }) }; e.extend(a.cssBefore, { display: "block", opacity: 1, top: 0, left: 0 }) }; e.fn.cycle.transitions.turnUp = function (c, h, a) { a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d, !0, !1); d.cssBefore.top = c.cycleH; d.animIn.height = c.cycleH; d.animOut.width = c.cycleW }); a.cssFirst.top = 0; a.cssBefore.left = 0; a.cssBefore.height = 0; a.animIn.top = 0; a.animOut.height = 0 }; e.fn.cycle.transitions.turnDown = function (c, h, a) { a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d, !0, !1); d.animIn.height = c.cycleH; d.animOut.top = a.cycleH }); a.cssFirst.top = 0; a.cssBefore.left = 0; a.cssBefore.top = 0; a.cssBefore.height = 0; a.animOut.height = 0 }; e.fn.cycle.transitions.turnLeft = function (c, h, a) { a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d, !1, !0); d.cssBefore.left = c.cycleW; d.animIn.width = c.cycleW }); a.cssBefore.top = 0; a.cssBefore.width = 0; a.animIn.left = 0; a.animOut.width = 0 }; e.fn.cycle.transitions.turnRight = function (c, h, a) { a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d, !1, !0); d.animIn.width = c.cycleW; d.animOut.left = a.cycleW }); e.extend(a.cssBefore, { top: 0, left: 0, width: 0 }); a.animIn.left = 0; a.animOut.width = 0 }; e.fn.cycle.transitions.zoom = function (c, h, a) { a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d, !1, !1, !0); d.cssBefore.top = c.cycleH / 2; d.cssBefore.left = c.cycleW / 2; e.extend(d.animIn, { top: 0, left: 0, width: c.cycleW, height: c.cycleH }); e.extend(d.animOut, { width: 0, height: 0, top: a.cycleH / 2, left: a.cycleW / 2 }) }); a.cssFirst.top = 0; a.cssFirst.left = 0; a.cssBefore.width = 0; a.cssBefore.height = 0 }; e.fn.cycle.transitions.fadeZoom = function (c, h, a) { a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d, !1, !1); d.cssBefore.left = c.cycleW / 2; d.cssBefore.top = c.cycleH / 2; e.extend(d.animIn, { top: 0, left: 0, width: c.cycleW, height: c.cycleH }) }); a.cssBefore.width = 0; a.cssBefore.height = 0; a.animOut.opacity = 0 }; e.fn.cycle.transitions.blindX = function (c, h, a) { c = c.css("overflow", "hidden").width(); a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d); d.animIn.width = c.cycleW; d.animOut.left = a.cycleW }); a.cssBefore.left = c; a.cssBefore.top = 0; a.animIn.left = 0; a.animOut.left = c }; e.fn.cycle.transitions.blindY = function (c, h, a) { c = c.css("overflow", "hidden").height(); a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d); d.animIn.height = c.cycleH; d.animOut.top = a.cycleH }); a.cssBefore.top = c; a.cssBefore.left = 0; a.animIn.top = 0; a.animOut.top = c }; e.fn.cycle.transitions.blindZ = function (c, h, a) { h = c.css("overflow", "hidden").height(); c = c.width(); a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d); d.animIn.height = c.cycleH; d.animOut.top = a.cycleH }); a.cssBefore.top = h; a.cssBefore.left = c; a.animIn.top = 0; a.animIn.left = 0; a.animOut.top = h; a.animOut.left = c }; e.fn.cycle.transitions.growX = function (c, h, a) { a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d, !1, !0); d.cssBefore.left = this.cycleW / 2; d.animIn.left = 0; d.animIn.width = this.cycleW; d.animOut.left = 0 }); a.cssBefore.top = 0; a.cssBefore.width = 0 }; e.fn.cycle.transitions.growY = function (c, h, a) { a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d, !0, !1); d.cssBefore.top = this.cycleH / 2; d.animIn.top = 0; d.animIn.height = this.cycleH; d.animOut.top = 0 }); a.cssBefore.height = 0; a.cssBefore.left = 0 }; e.fn.cycle.transitions.curtainX = function (c, h, a) { a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d, !1, !0, !0); d.cssBefore.left = c.cycleW / 2; d.animIn.left = 0; d.animIn.width = this.cycleW; d.animOut.left = a.cycleW / 2; d.animOut.width = 0 }); a.cssBefore.top = 0; a.cssBefore.width = 0 }; e.fn.cycle.transitions.curtainY = function (c, h, a) { a.before.push(function (a, c, d) { e.fn.cycle.commonReset(a, c, d, !0, !1, !0); d.cssBefore.top = c.cycleH / 2; d.animIn.top = 0; d.animIn.height = c.cycleH; d.animOut.top = a.cycleH / 2; d.animOut.height = 0 }); a.cssBefore.height = 0; a.cssBefore.left = 0 }; e.fn.cycle.transitions.cover = function (c, h, a) { var j = a.direction || "left", i = c.css("overflow", "hidden").width(), d = c.height(); a.before.push(function (a, c, h) { e.fn.cycle.commonReset(a, c, h); "right" == j ? h.cssBefore.left = -i : "up" == j ? h.cssBefore.top = d : "down" == j ? h.cssBefore.top = -d : h.cssBefore.left = i }); a.animIn.left = 0; a.animIn.top = 0; a.cssBefore.top = 0; a.cssBefore.left = 0 }; e.fn.cycle.transitions.uncover = function (c, h, a) { var j = a.direction || "left", i = c.css("overflow", "hidden").width(), d = c.height(); a.before.push(function (a, c, h) { e.fn.cycle.commonReset(a, c, h, !0, !0, !0); "right" == j ? h.animOut.left = i : "up" == j ? h.animOut.top = -d : "down" == j ? h.animOut.top = d : h.animOut.left = -i }); a.animIn.left = 0; a.animIn.top = 0; a.cssBefore.top = 0; a.cssBefore.left = 0 }; e.fn.cycle.transitions.toss = function (c, h, a) { var j = c.css("overflow", "visible").width(), i = c.height(); a.before.push(function (a, c, h) { e.fn.cycle.commonReset(a, c, h, !0, !0, !0); !h.animOut.left && !h.animOut.top ? e.extend(h.animOut, { left: 2 * j, top: -i / 2, opacity: 0 }) : h.animOut.opacity = 0 }); a.cssBefore.left = 0; a.cssBefore.top = 0; a.animIn.left = 0 }; e.fn.cycle.transitions.wipe = function (c, h, a) { var j = c.css("overflow", "hidden").width(), i = c.height(); a.cssBefore = a.cssBefore || {}; var d; a.clip && (/l2r/.test(a.clip) ? d = "rect(0px 0px " + i + "px 0px)" : /r2l/.test(a.clip) ? d = "rect(0px " + j + "px " + i + "px " + j + "px)" : /t2b/.test(a.clip) ? d = "rect(0px " + j + "px 0px 0px)" : /b2t/.test(a.clip) ? d = "rect(" + i + "px " + j + "px " + i + "px 0px)" : /zoom/.test(a.clip) && (c = parseInt(i / 2, 10), h = parseInt(j / 2, 10), d = "rect(" + c + "px " + h + "px " + c + "px " + h + "px)")); a.cssBefore.clip = a.cssBefore.clip || d || "rect(0px 0px 0px 0px)"; var c = a.cssBefore.clip.match(/(\d+)/g), l = parseInt(c[0], 10), n = parseInt(c[1], 10), m = parseInt(c[2], 10), s = parseInt(c[3], 10); a.before.push(function (a, c, d) { if (a != c) { var h = e(a), A = e(c); e.fn.cycle.commonReset(a, c, d, !0, !0, !1); d.cssAfter.display = "block"; var r = 1, b = parseInt(d.speedIn / 13, 10) - 1; (function k() { var a = l ? l - parseInt(r * (l / b), 10) : 0, c = s ? s - parseInt(r * (s / b), 10) : 0, d = m < i ? m + parseInt(r * ((i - m) / b || 1), 10) : i, e = n < j ? n + parseInt(r * ((j - n) / b || 1), 10) : j; A.css({ clip: "rect(" + a + "px " + e + "px " + d + "px " + c + "px)" }); r++ <= b ? setTimeout(k, 13) : h.css("display", "none") })() } }); e.extend(a.cssBefore, { display: "block", opacity: 1, top: 0, left: 0 }); a.animIn = { left: 0 }; a.animOut = { left: 0} } })(jQuery);/*
 * FancyBox - jQuery Plugin
 * Simple and fancy lightbox alternative
 *
 * Examples and documentation at: http://fancybox.net
 * 
 * Copyright (c) 2008 - 2010 Janis Skarnelis
 * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
 * 
 * Version: 1.3.4 (11/11/2010)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("<div/>")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');
F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)||
c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=
false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel",
function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("<img />").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+c+
'"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';P+=" "+x+'="'+H+'"'});C+='<embed src="'+c+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+P+"></embed></object>";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win==
"function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('<div style="width:'+a+";height:"+c+
";overflow: "+(e.scrolling=="auto"?"auto":e.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor,
opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length?
d.titlePosition=="float"?'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+s+'</td><td id="fancybox-title-float-right"></td></tr></table>':'<div id="fancybox-title-'+d.titlePosition+'">'+s+"</div>":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding});
y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height==
i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents());
f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode==
37||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto");
s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+(b.browser.msie?'allowtransparency="true""':"")+' scrolling="'+e.scrolling+'" src="'+d.href+'"></iframe>').appendTo(j);
f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c);
j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type==
"image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"),
10)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)};
b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k=
0,C=a.length;k<C;k++)if(typeof a[k]=="object")b(a[k]).data("fancybox",b.extend({},g,a[k]));else a[k]=b({}).data("fancybox",b.extend({content:a[k]},g));o=jQuery.merge(o,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},g,a));else a=b({}).data("fancybox",b.extend({content:a},g));o.push(a)}if(q>o.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+
1)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a<l.length){q=a;I()}else if(d.cyclic&&l.length>1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h=
true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1;
b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5-
d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),t=b('<div id="fancybox-loading"><div></div></div>'),u=b('<div id="fancybox-overlay"></div>'),f=b('<div id="fancybox-wrap"></div>'));D=b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f);
D.append(j=b('<div id="fancybox-content"></div>'),E=b('<a id="fancybox-close"></a>'),n=b('<div id="fancybox-title"></div>'),z=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),A=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()});
b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(D)}}};
b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",
easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(jQuery);
