function XavierNonsense(){a='13b8fb66af56aeab5fe6371942091eca0462cd06fb808a031619b89ee7b9ac8d356ba63c';a='bd8bc51dfc8891f3ec38434f8073115f9bb442da45aa5ba0b30e42f05ca8f2841525df2e';};function XavierJsLatModified(){return '1272570850';};/** see: http://andreaslagerkvist.com/jquery/center/ */jQuery.fn.center=function(absolute){return this.each(function(){var t=jQuery(this);if(jQuery.browser.msie && jQuery.browser.version=="6.0"){absolute=1;}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()});}});};
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 * used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 * If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 * If set to null or omitted, the cookie will be a session cookie and will not be retained
 * when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 * require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
 if (typeof value != 'undefined') { // name and value given, set cookie
 options = options || {};
 if (value === null) {
 value = '';
 options.expires = -1;
 }
 var expires = '';
 if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
 var date;
 if (typeof options.expires == 'number') {
 date = new Date();
 date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
 } else {
 date = options.expires;
 }
 expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
 }
 // CAUTION: Needed to parenthesize options.path and options.domain
 // in the following expressions, otherwise they evaluate to undefined
 // in the packed version for some reason...
 var path = options.path ? '; path=' + (options.path) : '';
 var domain = options.domain ? '; domain=' + (options.domain) : '';
 var secure = options.secure ? '; secure' : '';
 document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
 } else { // only name given, get cookie
 var cookieValue = null;
 if (document.cookie && document.cookie != '') {
 var cookies = document.cookie.split(';');
 for (var i = 0; i < cookies.length; i++) {
 var cookie = jQuery.trim(cookies[i]);
 // Does this cookie string begin with the name we want?
 if (cookie.substring(0, name.length + 1) == (name + '=')) {
 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
 break;
 }
 }
 }
 return cookieValue;
 }
};
/**
 * All materials custom written for Irrigation Direct by Xavier Berkeley
 *
 * @copyright 2009 Xavier Berkeley, LLC
 */
 /* All on-ready functions that we want to load to initialize the page should be included here 
 - note that prototype will aslo be generating some onready events that are default with 
 magento and will run asynchronously from this onready */

function XbShippingObject()
{
 this.phrases=new Object();
 this.data=new Object();
 this.paint=function(){
 this.loadCartSubtotal();
 this._updateCostsHTML();
 this._updateMessagesHTML();
 this._prepareForm();
 this._clearMask();
 jQuery(".btn-remove").bind("click",XBPrepareDelete);
 return this;
 };
 this.init=function(){
 this.loadData();
 //window.miniZipForm = new VarienForm('mini-ship-form', true);
 this.set('originalSubtotal',this.get('subtotal')).set('originalZipCode',this.get('zipCode')).set('noFailureMessages',true);
 if(this.hasValidZip() && this.isFreeUnknown()){
 this.checkZip();
 }
 this.promptForZipIfNecessary();
 if(jQuery.cookie("shipzippagewait")){jQuery.cookie("shipzippagewait",Math.max(jQuery.cookie("shipzippagewait")-1,1),{path:'/'});}else{jQuery.cookie("shipzippagewait",1,{path:'/'});}
 return this;
 };
 this.loadData=function(){
 if(typeof XBShippingData=='object'){
 for(datagroup in XBShippingData){
 for(data in XBShippingData[datagroup]){
 this.set(data,XBShippingData[datagroup][data]);
 }
 }
 }
 if(typeof XBShippingMessages=='object'){
 for(datagroup in XBShippingMessages){
 for(data in XBShippingMessages[datagroup]){
 this.setPhrase(data,XBShippingMessages[datagroup][data]);
 }
 }
 }
 this.loadCartSubtotal();
 this.setValuesFromCookie();
 return this;
 };
 this.promptForZipIfNecessary=function(){if(this.get('promptForZip')==1&&!this.hasValidZip()&&jQuery.cookie("shipzippagewait")==1){this.showZipDialog();}};
 this.showZipDialog=function(){try{jQuery("#shipping-zone-mask").appendTo("body").height(jQuery(document).height()).show();jQuery("#shipping-zone-wrapper").appendTo("body").center().css("z-index","9999").show();jQuery("#shipping-zone-zip").focus();}catch(e){}};
 this.hideZipDialog=function(){jQuery("#shipping-zone-wrapper").hide();jQuery("#shipping-zone-mask").hide();jQuery.cookie("shipzippagewait",25,{path:'/'});};
 this.loadCartSubtotal=function(){
 cartSub=parseFloat(((jQuery("a#minicart-cart span.price").html()).substring(1)).replace(',',''));
 if(cartSub!=this.get('subtotal')){
 this.set('subtotal',cartSub).set('shippingEstimate',0.00);
 }else{
 this.set('subtotal',cartSub);
 }
 };
 this.getSpendMoreAmount=function(){
 formatted=((arguments.length>0)&&(arguments[0]==true));
 try{
 amount=(this.isFreeShippingAmount())?0.0000:(this.get('freeShippingMinimum')-this.get('subtotal'));
 return formatted ? XBUtil.formatCurrency(amount,2):amount;
 }catch(e){
 if(formatted){
 return XBUtil.formatCurrency(0.0000,2);
 }else{
 return 0.0000
 }
 }
 };
 this.isValidZip=function(){
 z=arguments[0];
 if(!z){
 return false;
 }
 if(z.length<5||z.length>10){
 return false;
 }
 return true;
 };
 this.hasValidZip=function(){
 return this.isValidZip(this.get('zipCode'));
 };
 this.get=function(){
 try{
 return this.data[arguments[0]];
 }catch(e){
 return 0;
 }
 };
 this.set=function(){
 this.data[arguments[0]]=arguments[1];
 return this;
 };
 this.setPhrase=function(){
 this.phrases[arguments[0]]=arguments[1];
 return this;
 };
 this.getPhrase=function(){
 if(arguments.length==2){
 try{
 return XBUtil.sprintf(this.phrases[arguments[0]],arguments[1]);
 }catch(e){
 return '';
 }
 }else{
 try{
 return this.phrases[arguments[0]];
 }catch(e){
 return '';
 }
 }
 };
 this.getFreeShippingMessage=function(){
 //if(!this.shouldShowFreeMessage()&&this.get('noFailureMessages')){
 // return '';
 //}
 if(this.isFreeNotAllowed()){
 return this.getPhrase('noFreeQualify');
 }
 else if(this.isFreeShipping()){
 return this.getPhrase('freeAvailable');
 }
 else if(this.isFreeAllowed()){
 return this.getPhrase('freeQualify',new Array(this.getSpendMoreAmount(true)));
 }
 else if(this.isFreeShippingAmount()){
 return this.getPhrase('freeMayBeAvailable');
 }
 return '';
 };
 this.getRateQuoteMessage=function(){
 return this.getPhrase('quoteStatusError');
 };
 this.getShippingAmount=function(){
 try{
 if(this.isFreeShipping()){
 return 0.00;
 }
 return this.get('shippingEstimate');
 }catch(e){
 return 0.00;
 }
 };
 this.getShippingDisplayAmount=function(){
 };
 this.shouldShowFreeMessage=function(){
 return !this.isFreeNotAllowed();
 };
 this.isFreeShippingAmount=function(){
 return this.get('subtotal')>=this.get('freeShippingMinimum');
 };
 this.isFreeShipping=function(){
 return (this.isFreeAllowed()&&this.isFreeShippingAmount());
 };
 this.isFreeAllowed=function(){
 return this.get('freeShippingAvailable')==1;
 };
 this.isFreeNotAllowed=function(){
 return this.get('freeShippingAvailable')==2;
 };
 this.isFreeUnknown=function(){
 return this.get('freeShippingAvailable')==0;
 };
 this.isUSPSAllowed=function(){
 return(this.get('weight')&&(this.get('weight')<2.0001)&&!this.isEmptyCart());
 };
 this.isEmptyCart=function(){
 return this.get('subtotal')<0.01;
 };
 this.isQuoteValid=function(){
 try{
 return this.get('subtotal')==this.get('originalSubtotal');
 }catch(e){
 return true;
 }
 };
 this.isFreeZipValid=function(){
 try{
 return this.get('zipCode')==this.get('originalZipCode');
 }catch(e){
 return true;
 }
 };
 this.isFreeZipReloadAllowed=function(){
 return false ;
 if(this.get('forceFreeZipReload')){
 return true;
 } 
 return false;
 };
 this.setValuesFromCookie=function(){
 if(!this.get('cookieValue')){
 return this;
 }
 if(this.hasValidZip()){
 return this;
 }
 try{
 cv=this.get('cookieValue').split("___");
 if(this.isValidZip(cv[0])){
 this.set('zipCode',cv[0]);
 if(cv.length>1){
 st=parseInt(cv[1]);
 if(st<3&&st>-1){
 this.set('freeShippingAvailable',st);
 }
 }
 }
 }catch(e){}
 return this;
 };
 this.isQuoteReloadAllowed=function(){
 return true ;
 return (!this.isEmptyCart()&&!this.isFreeShipping()&&(!this.isQuoteValid()||!this.isFreeZipValid()))
 };
 this.checkZip=function(){
 jQuery("#minicart-show").stopTime("hide");
 if(arguments.length>0){
 if(this.isValidZip(arguments[0])){
 this.set('zipCode',arguments[0]);
 }else{
 return false;
 }
 }
 if(!this.hasValidZip()){
 this.set('shippingEstimate',0.00).paint();
 return false;
 }
 if(this.isFreeZipReloadAllowed()){
 this._prepareMask();
 this._checkFreeShipping();
 }
 if(this.isQuoteReloadAllowed()){
 this._prepareMask();
 this.set('originalZipCode',this.get('zipCode')).set('originalSubtotal',this.get('subtotal'));
 this._checkRateQuote();
 }
 };
 this._checkFreeShipping=function(){
 jQuery.getJSON("/shippingzip",{is_ajax:1,zip_code:this.get('zipCode')},function(data){
 XBS.set('noFailureMessages',false).set('state',data[0]['state_abbreviation']).set('city',data[0]['city_name']).set('freeShippingAvailable',parseInt(data[0]['status'])).paint().set('noFailureMessages',true).set('originalZipCode',data[0]['zip_code']);
 });
 };
 this._checkRateQuote=function(){ 
 jQuery.getJSON("/xbcheckout/onepage/miniSaveShipping/",{is_ajax:1,zip_code:this.get('zipCode')},function(data){
 try{
 if(data.status=='success'){
 XBS.set('shippingEstimate',parseFloat(data.rate)).set('quoteStatus',null).set('state',data.state_abbreviation).set('city',data.city_name).set('freeShippingAvailable',parseInt(data.freeShippingAvailable)).set('title',data.title).set('code',data.code).paint();
 }
 else{
 XBS.set('quoteStatus',data.status).set('shippingEstimate',0.00).set('freeShippingAvailable',data.freeShippingAvailable).paint();
 jQuery("#mini-ship-messages-js-quote").html('<div class="error-msg" style="margin:5px;">'+XBS.getRateQuoteMessage()+'</div>');
 }
 }catch(e){
 alert(e);
 XBS.set('subtotal',0.0000).set('shippingEstimate',0.00).paint();
 }
 });};
 this._setPriceDefaults=function(){
 if(isNaN(this.get('subtotal'))){
 this.set('subtotal',0.0000);
 }
 if(isNaN(this.get('shippingEstimate'))){
 this.set('shippingEstimate',0.00);
 }
 };
 this._updateCostsHTML=function(){
 this._setPriceDefaults();
 jQuery("#mini-ship-subtotal-product").html(XBUtil.formatCurrency(this.get('subtotal')));
 var sTitle="";
 if(this.isFreeShipping()){
 sCost='FREE';
 sTitle="UPS Ground";
 }else if((parseFloat(this.get('subtotal'))==0.0)&&this.hasValidZip()){
 sCost=XBUtil.formatCurrency(0.00,2);
 }else if(this.get('quoteStatus')){
 sCost=XBUtil.formatCurrency(0.00,2);
 }else if(this.get('shippingEstimate')>0){
 sCost=XBUtil.formatCurrency(this.get('shippingEstimate'));
 sTitle=this.get('shippingTitle')+" ("+this.get('weight').toString()+"lbs)";
 }else if(this.hasValidZip()){
 sCost=XBUtil.formatCurrency(0.00,2);
 }else{
 sCost=this.getPhrase('defaultPrice');
 }
 jQuery("#mini-ship-subtotal-shipping").attr("title",sTitle).html(sCost);
 jQuery("#mini-ship-subtotal-total").html(XBUtil.formatCurrency(this.get('subtotal')+this.getShippingAmount()));
 
 };
 this._updateMessagesHTML=function(){
 if(this.isFreeShipping()){
 msgclass='success-msg';
 jQuery(".userShippingMessage").html(this.getFreeShippingMessage()).removeClass("noticemsg").addClass("successmsg").css("visibility","visible") ;
 }else if(this.isFreeAllowed()){
 msgclass='notice-msg';
 jQuery(".userShippingMessage").html(this.getFreeShippingMessage()).removeClass("successmsg").addClass("noticemsg").css("visibility","visible") ;
 }else{
 msgclass='nothing';
 if(!this.hasValidZip()){jQuery(".userShippingMessage").css("visibility","visible");}else{jQuery(".userShippingMessage").css("visibility","hidden");}
 }
 jQuery("#mini-ship-messages-js").html(jQuery("<div>").addClass(msgclass).css("margin","5px").html(this.getFreeShippingMessage()));
 if(this.get('city') == ''){jQuery("#shippingLocation").click(function(){XBS.showZipDialog();}).html('<span id="ship-to-link" title="click to change your shipping location">Enter your Shipping Destination</span>');}else{jQuery("#shippingLocation").click(function(){XBS.showZipDialog();}).html('<span id="ship-to-link" title="click to change your shipping location">Shipping to:</span> '+this.get('city')+', '+this.get('state'));}
 
 };
 this._prepareForm=function(){
 jQuery("#mini-ship-input-zip").attr("value",(this.hasValidZip())?this.get('zipCode'):"Zip Code").bind("focus",XBZipFocus);
 jQuery("#mini-ship-form").unbind("submit").bind("submit",function(){
 XBS.checkZip(jQuery("#mini-ship-input-zip").attr("value"));return false;
 });
 jQuery("div.xbButton.xbButtonCalculateShipping").unbind("click").bind("click",function(){
 XBS.checkZip(jQuery("#mini-ship-input-zip").attr("value"));
 return false;
 });
 };
 this._prepareMask=function(){
 jQuery("#mini-ship-messages-js-quote").html("");
 jQuery("#mini-ship-messages-js").html("");
 jQuery("#mini-ship-mask").height(jQuery("#mini-ship").height()).show();
 };
 this._clearMask=function(){
 jQuery("#mini-ship-mask").hide();
 };
 this.prepareDelete=function(){
 this.set('subtotal',0.0000).set('shippingEstimate',0.00).paint();
 };
};
function XBPrepareDelete(){
 if(typeof XBS=='undefined'){
 window.XBS=new XbShippingObject();
 }
 XBS.prepareDelete();
};
function XBZipFocus(){
 jQuery(this).unbind("blur",XBZipFocus);
 if(jQuery(this).attr("value")=="Zip Code"){
 jQuery(this).attr("value","");
 }
};
jQuery(document).ready(function(){
 window.XBS=new XbShippingObject() ;
 XBS.init().paint();
});

var XBUtil={
formatCurrency:function(){
 fixed=2;if(arguments.length>1){fixed=arguments[1];}
 try{
 dc=parseFloat(arguments[0].toString().replace(/\$|\,/g,'')).toFixed(fixed).toString().split('.');
 if(isNaN(dc[0])){rval=0.0;return "$"+rval.toFixed(fixed).toString();}
 dollar=dc[0];cents=dc[1];var rgx = /(\d+)(\d{3})/;
 while (rgx.test(dollar)){dollar=dollar.replace(rgx, '$1'+','+'$2');}
 return "$"+dollar+"."+cents;
 }catch(e){rval=0.0;return "$"+rval.toFixed(fixed).toString();}
 },
sprintf:function(){
 str='';s=arguments[0];if(!s){return '';}s=s.split('%s');r=arguments[1];r.push('');for(i=0;i<s.length;i++){str+=s[i]+r[i]}return str;
 }
};
/* End of XBShipping */

function updateQuickCart( content ) {
 jQuery(".quickCart .cartwrap").css("visibility","hidden");
 jQuery(".quickCart, #minicart-show, #minicart-chad").unbind("mouseenter").unbind("mouseleave");
 
 jQuery(".quickCart").slideUp(300, function() {
 jQuery("#minicart").html( content );
 createQuickcartLinks();
 //XBShipping.updateSubtotal();
 //XBShipping.prepareQuickCartShipping();
 //XBShipping.getRate();
 try{XBS.init().paint().checkZip();}catch(e){}
 jQuery("#minicart-show").trigger("click");
 setupQuickcartEvents();
 startCartHideTimer(7500);
 });
}

// start timer to hide cart
function startCartHideTimer(duration) {
 if ( jQuery("#mini-ship-input-zip:focus").size() > 0 ) {
 return false;
 }
 jQuery("#minicart-show").stopTime("hide");
 jQuery("#minicart-show").oneTime(duration, "hide", function() {
 jQuery(".quickCart .cartwrap").css("visibility","hidden");
 jQuery(".quickCart").slideUp(300, function() {
 jQuery("#minicart-show").stopTime("ch-hide");
 jQuery("#minicart-chad").slideDown(200, function() {
 startChadHideTimer(6000);
 });
 });
 jQuery(document).unbind("click");
 createQuickcartLinks();
 setupQuickcartEvents();
 });
}

// set up click toggle functionality for #minicart-show
function createQuickcartLinks() {
 jQuery("#minicart-show, #minicart-chad").unbind("click").click( function() {
 jQuery("#minicart-show").unbind("click");
 jQuery(this).stopTime("hide");
 jQuery(".quickCart .cartwrap").css("visibility","hidden");
 jQuery(".quickCart").slideDown(500, function() {
 // on click anywhere but the update cart OK box or quickCart, hide quickCart
 jQuery(document).unbind("click").click( function(e) {
 setupQuickcartEvents();
 if ( jQuery(e.target).parents("#minicart").size() == 0 && jQuery(e.target).parents(".ajaxcartpro_confirm").size() == 0 ) {
 jQuery(".quickCart .cartwrap").css("visibility","hidden");
 jQuery(".quickCart").slideUp(300);
 createQuickcartLinks();
 jQuery(document).unbind("click");
 }
 });
 jQuery("#minicart-show, #minicart-chad").unbind("click").click( function() {
 jQuery("#minicart-show").unbind("click");
 jQuery(document).unbind("click");
 jQuery(".quickCart .cartwrap").css("visibility","hidden");
 jQuery(".quickCart").slideUp(300, function(){
 createQuickcartLinks();
 setupQuickcartEvents();
 });
 });
 jQuery(".quickCart .cartwrap").hide().css("visibility","visible").fadeIn(200);
 });
 });
 jQuery("#minicartinner button.cart-button").attr("onclick","").unbind("click").click( xbCartLink );

}

function showProgressBlockFor(el) {
 jQuery(el).next("dd.complete").slideToggle(200);
}
function setupQuickcartEvents() {
 // set width of quickCart so it looks right on first use in ie
 jQuery(".quickCart").css("width","240px");
 
 // Stop timer when mouse enters quickcart or minicart-show, start when it leaves
 jQuery(".quickCart, #minicart-show, #minicart-chad").unbind("mouseenter").unbind("mouseleave").hover( function() { 
 jQuery("#minicart-chad").slideDown(200);
 jQuery("#minicart-show").stopTime("hide");
 jQuery("#minicart-show").stopTime("ch-hide");
 // console.log("stop");
 }, function() {
 jQuery("#minicart-show").stopTime("hide");
 jQuery("#minicart-show").stopTime("ch-hide");
 startCartHideTimer(2000);
 startChadHideTimer(6000);
 });
}
function jtest(){
//alert(XBShipping.AVAILABLE);
}
// tierPricing charts
 function hideTierPriceCharts() {
 jQuery(".listTierPrice").each( function() {
 if ( jQuery(this).parents(".tierPricesIcon").size() > 0 ) {
 jQuery(this).css("visibility","hidden");
 }
 else {
 jQuery(this).css("visibility","visible").css("display","block");
 }
 });
 jQuery(document).unbind("click");
 }
 
 function setUpTierPriceCharts() {
 hideTierPriceCharts();
 jQuery(".tierPricesIcon").each( function() {
 jQuery(this).unbind("click").click( function() {
 hideTierPriceCharts();
 jQuery(this).children(".listTierPrice").css("visibility","visible");
 setTimeout('jQuery(document).click( function(e) { if ( jQuery(e.target).hasClass(".tierPricing") == false && jQuery(e.target).parents(".tierPricing").size() == 0 ) { hideTierPriceCharts(); setUpTierPriceCharts(); } });',100);
 });
 });
 }
 
 function setupCartTierPrices() {
 // initial setup of tier price blocks for the cart
 jQuery(".checkout-cart-index .cart-table .listTierPrice").each( function() {
 jQuery(this).append('<div class="yourPrice" style="width: 110px; position: absolute; display: none;"><div class="yourPriceText" style="padding: 1px 5px; float: left; text-align: left; width: 90px; font-size: 10px; color: #000000; font-weight: normal; line-height: 12px;">Your price</div><div style="float: right; width: 10px; color: #FF0000; font-weight: bold; line-height: 12px; font-size: 12px;">&raquo;</div></div>');
 });
 // Alignment fix for IE
 if ( jQuery.browser.msie ) {
 jQuery(".yourPrice").css("padding-top","2px");
 }
 
 // Set up "update cart" links for each row
 /*jQuery(".updateCart").each( function() {
 jQuery(this).click( function() {
 jQuery(this).parents("form").submit();
 return false;
 });
 });
 */
 // and the big one at the bottom
 jQuery(".update-cart").click( function() {
 jQuery("#cartForm").submit();
 });
 // On product page, highlight appropriate tier price for your quantity
 jQuery(".checkout-cart-index .cart-table .qtyBox .qty").each( function() {
 jQuery(this).change( function() {
 var qty = jQuery(this).val();
 var origQty = jQuery(this).siblings(".hqty").text();
 // Show or hide update cart button depending on whether quantity have changed
 if ( qty != origQty ) {
 // jQuery(this).parents("td").find(".updateCart").show();
 jQuery(this).parents("tr").addClass("needs-update");
 if ( jQuery.browser.msie && Number( jQuery.browser.version ) < 8 ) {
 jQuery("tr.needs-update").each( function() {
 jQuery(this).find("td").css("background-color","#FAFAEC");
 });
 }
 }
 else {
 if ( jQuery.browser.msie && Number( jQuery.browser.version ) < 8 ) {
 jQuery("tr.needs-update").each( function() {
 jQuery(this).find("td").css("background-color","#FFF");
 });
 }
 jQuery(this).parents("tr").removeClass("needs-update");
 }
 jQuery(this).parents("tr").find(".tierPricing").find(".tierPriceQty").each( function() {
 var tierRange = jQuery(this).html().replace(/,/g,"").replace(/\s/g,"").replace(/\t/g,"").split("-");
 if ( jQuery(this).html().indexOf("+") != -1 ) {
 tierRange = new Array();
 tierRange[0] = jQuery(this).html().replace(/\s/g,"").replace(/,/g,"").replace(/\t/g,"").replace(/\+/g,"");
 tierRange[1] = '999999999999';
 }
 if ( Number( qty ) >= Number( tierRange[0] ) && Number( qty ) <= Number( tierRange[1] ) ) {
 
 jQuery(this).siblings(".tierPrice").find(".price").addClass("active");
 var thisPrice = jQuery(this).siblings(".tierPrice").find(".price").text().replace("$","");
 if ( jQuery(this).parents("table").find(".price.active").parents("tr").next("tr").size() > 0 ) {
 var nextLowest = jQuery(this).parents("table").find(".price.active").parents("tr").next("tr").find(".price").html().replace("$","");
 }
 jQuery(this).parents("table").parents("td").find(".yourPrice").find(".yourPriceText").html("Your price").css("text-align","right");
 if ( nextLowest && Number(tierRange[1]) < 999999999999 ) {
 var toBuy = (Number(tierRange[1])+1) - Number(qty);
 var savings = ( Number( thisPrice ) - Number( nextLowest ) ) / Number( thisPrice );
 if ( toBuy < 5 ) {
 toBuy = "only "+ toBuy;
 }
 jQuery(this).parents("table").parents("td").find(".yourPrice").find(".yourPriceText").html("Buy "+ toBuy +" more to save "+ (Number(savings)*100).toFixed(0) + "% on these").css("text-align","left");
 }
 jQuery(this).parents("table").parents("td").find(".yourPrice").css("top", jQuery(this).parents("tr").find(".tierPrice").position()["top"]).css("left", jQuery(this).parents("tr").position()["left"]-115).show();
 }
 else {
 jQuery(this).siblings(".tierPrice").find(".price").removeClass("active");
 }
 });
 });
 });
 
 // Now trigger it onload
 jQuery(".checkout-cart-index .cart-table .qtyBox .qty").each( function() {
 jQuery(this).trigger("change");
 });
 setupQuantityBoxes();
 }
 
 function setupQuantityBoxes() {
 jQuery("input.qty").bind("blur",function(){if(isNaN(jQuery(this).attr("value"))){jQuery(this).attr("value","1");}
 });
 jQuery(".qtyBox span.plus").unbind("click").click(function(){
 var p=jQuery(this).parent().children("input");
 p.attr("value",isNaN(parseInt(p.attr("value"))+1)?1:parseInt(p.attr("value"))+1).change();
 });
 jQuery(".qtyBox span.minus").unbind("click").click(function(){
 var p=jQuery(this).parent().children("input");
 p.attr("value",isNaN(parseInt(p.attr("value"))+1)?1:(parseInt(p.attr("value"))-1)<1?1:parseInt(p.attr("value"))-1).change();
 });
 }
 
 function swapZoomForThumbPic( linkId ) {
 if ( jQuery("#"+linkId).size() == 0 ) {
 return false;
 }
 var linkEl = jQuery("#"+linkId);
 jQuery("#image").attr("src", linkEl.attr("href")).attr("title", linkEl.attr("title"));
 try {
 jQuery('.product-image-zoom').css('line-height', jQuery('.product-img-box').css('height') ); 
 }
 catch(err) {} 
 return false;
 }
 
 function hideRequiredInsertOptional() {
 jQuery("form .form-list, #freehat_form, #catalogrequest_form").find("label").each( function() {
 if ( jQuery(this).siblings(".required-entry, .validate-select").size() == 0 && jQuery(document).find(".required").size() > 0 && jQuery(this).parents("#checkout-payment-method-load").size() == 0 ) {
 if ( jQuery(this).html().indexOf("(Optional)") == -1 ) {
 jQuery(this).html(jQuery(this).html() +"<span class='label-explanation'> (Optional)</span>");
 }
 }
 else {
 jQuery(document).find(".required").hide();
 }
 });
 }
 
 // Checkout: Shipping method: Create a message on top for free shipping
 function createhippingMethodMessage() {
 if(typeof window.XBS =='undefined'){window.XBS=newXbShippingObject();XBS.init();}
 if(XBS.shouldShowFreeMessage()) {
 jQuery("#shipping-method-note").html(XBS.getFreeShippingMessage()).show();
 } 
 
 
// if ( XBShipping.getAmountMoreToSpendForFreeShipping() > 0 ) {
// jQuery("#shipping-method-note").html("Spend another $"+ XBShipping.getAmountMoreToSpendForFreeShipping() +" to get FREE shipping").show();
// }
// else {
// jQuery("#shipping-method-note").html("You have qualified for FREE shipping.").show();
// }
// 
 }
 
 // start timer to hide minicart chad (click here to view cart & shipping)
 function startChadHideTimer(duration) {
 // console.log("start");
 jQuery("#minicart-show").stopTime("ch-hide");
 jQuery("#minicart-show").oneTime(duration, "ch-hide", function() {
 jQuery("#minicart-chad").slideUp(200);
 });
 }
function xbCartLink(){
 try{var uenc='/add/uenc/'+uencPage.replace(",","");}catch(e) {var uenc='';}
 document.location.href='/checkout/cart'+ uenc;
 }
jQuery(document).ready(function(){
 // Remove any default values in form fields put there bay shippingZip ajax call
 jQuery(".form-list input").each( function() {
 if( jQuery(this).val() == 'id_default_ship_estimate__000000' ) {
 jQuery(this).val("");
 }
 }); 
 
 // Change checkout links on click
 jQuery("div.ajaxcartpro_confirm button.cart-button").attr("onclick","").unbind("click").click( xbCartLink );
 // Fix buttons inside <a> tags for crappy ie
 if(jQuery.browser.msie){
 jQuery('button').each( function() {
 if ( jQuery(this).attr("onclick") == undefined && jQuery(this).parent().get(0).tagName == 'A' ) {
 jQuery(this).click( function() {
 document.location.href=jQuery(this).parents("a").attr("href");
 });
 }
 });
 }
 
 // alert( jQuery.browser.version );

 //a=setTimeout("jtest()",1000*15);
 // Set up valve and controller header toggle popups
 jQuery(".category-headerbox").find(".toggle").each( function() {
 jQuery(this).css("position","absolute").css("left",jQuery(".category-headerbox-txt").position()["left"] +10 ).css("top","10px") ;
 });
 jQuery(".category-headerbox").find(".switch").each( function() {
 if(jQuery.browser.msie){
 jQuery(this).css("left",Number( jQuery(this).css("left").replace("px","") )+ 8 + "px").css("font-size","24px").css("width","20px");
 }
 jQuery(this).mouseover( function() {
 jQuery("#toggle-"+ jQuery(this).attr("id")).fadeIn(200);
 });
 jQuery(this).mouseout( function() {
 jQuery("#toggle-"+ jQuery(this).attr("id")).fadeOut(200);
 });
 });
 
 /*
 var thisPage = window.location.pathname;
 var $origHREFs=Array();
 
 jQuery("#newNavList li a").each(function() {
 var target = jQuery(this).children("span").attr("class") ;
 $origHREFs[target]=jQuery(this).attr("href");
 jQuery(this).attr("href","#"+target);
 });
 
 var $navTabs = jQuery("#newNav").tabs({event: 'mouseover'}); var defaultTab = $navTabs.tabs('option','selected');
 jQuery("#newNavList li a").each(function() {
 jQuery(this).click(function(){location.href=$origHREFs[jQuery(this).children("span").attr("class")];}).css('cursor','pointer');
 });
 jQuery("#newNav").bind("mouseleave",function(){$navTabs.tabs('select',defaultTab);});
 
 // An extra bit to identify the active subcategory by URL (matching link to window location in top nav)
 jQuery("#newNav .ui-tabs-panel.ui-widget-content").not("ui-tabs-hide").find("ul li").each( function() {
 var link = jQuery(this).find("a").attr("href");
 // alert( "http://"+ window.location.hostname + thisPage.substring( 0, thisPage.lastIndexOf("\/") ) );
 var thisPageArr = thisPage.split("/");
 // We'll add to this string on each loop until we find a match btwn link and the page's url
 var lookingFor = "";
 for ( var i=0;i<thisPageArr.length;i++ ) {
 lookingFor += thisPageArr[i];
 if ( link == lookingFor || link == "http://"+ window.location.hostname + lookingFor ) {
 jQuery(this).find("a").addClass("active");
 break;
 }
 lookingFor += "/";
 }
 });
 */
 // jQuery("#left_nav").treeview();
 
 /* 11/12/09 - JO: moved these next 2 items down, nav should go first */
 createQuickcartLinks();
 setupQuickcartEvents();
 
 /*
 jQuery("#minicart li").removeClass("ui-state-default, ui-corner-top");
 // Add class "active" to the current category's link
 jQuery("#left_nav.treeview li.active a:first").addClass("active");
 
 // An extra bit to identify the active subcategory by URL (matching link to window location
 jQuery("#left_nav.treeview li.active ul li").each( function() {
 var link = jQuery(this).find("a").attr("href");
 // alert( link +" "+ "http://"+ window.location.hostname+ "/"+ thisPage );
 if ( link == thisPage || link == "http://"+ window.location.hostname + thisPage ) {
 jQuery(this).find("a").addClass("active");
 }
 });
 */
 //other tabs
 jQuery(".tabset").tabs();
 if ( jQuery(".tabset ul:first").find("li").size() == 1 ) {
 jQuery(".tabset ul:first").find("li").addClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active");
 jQuery("#product_description").addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");
 }
 
 setupQuantityBoxes();
 // Change the class aw_ajax_cart updates when the cart changes. Default is set in js/aw_ajaxcartpro/ajaxcartpro-1....js
 aw_cartDivClass = ".minicartinner";
 
 
 jQuery("div.showTierPrices input.qty").each( function() {
 jQuery(this).bind("click",function(){
 try{setUpTierPriceCharts();} 
 catch(e){};
 jQuery("#"+jQuery(this).attr("id")+"tierPrices").trigger("click");
 });
 jQuery(this).bind("change",function(){
 setUpTierPriceCharts();
 jQuery("#"+jQuery(this).attr("id")+"tierPrices").trigger("click");
 });
 });
 
 
 // initial setup of tier price blocks
 setUpTierPriceCharts();
 jQuery(".product-view .product-shop .listTierPrice").append('<div id="yourPrice" style="width: 80px; color: #F4A804; font-weight: bold; line-height: 20px; position: absolute; display: none;">Your price &raquo;</div>');
 
 // On product page, highlight appropriate tier price for your quantity
 jQuery(".product-view .product-shop .add-to-cart #qty").change( function() {
 var qty = jQuery(".product-view .product-shop .add-to-cart #qty").val();
 jQuery(".product-view .product-shop .listTierPrice .tierPricing .tierPriceQty").each( function() {
 var tierRange = jQuery(this).html().replace(/\s/g,"").replace(/\t/g,"").split("-");
 if ( jQuery(this).html().indexOf("+") != -1 ) {
 tierRange = new Array();
 tierRange[0] = jQuery(this).html().replace(/\s/g,"").replace(/\t/g,"").replace(/\+/g,"");
 tierRange[1] = '1000000';
 }
 jQuery(this).removeClass("active");
 if ( Number( qty ) >= Number( tierRange[0] ) && Number( qty ) <= Number( tierRange[1] ) ) {
 jQuery(this).css("border","1px solid #F4A804").css("border-right","0"); 
 jQuery(this).parents("tr").find("td.tierPrice").css("border","1px solid #F4A804").css("border-left","0");
 jQuery("#yourPrice").css("top", jQuery(this).position()["top"]).css("left", jQuery(this).position()["left"]-80).show();
 }
 else {
 jQuery(this).parents("tr").find("td").css("border","0").css("border-bottom","1px dotted #AFAFAD");
 }
 });
 });
 // Now trigger it onload
 jQuery(".product-view .product-shop .add-to-cart #qty").trigger("change");
 
 // Run function to set up tier prices for cart
 setTimeout('setupCartTierPrices();',2000);
 
 // decoration: stripe the charts, add both so that differetn styles can decide if odds or evens get the color:
 jQuery("table.xb-chart tbody tr:even").addClass("xb-stripe-even") ;
 jQuery("table.xb-chart tbody tr:odd").addClass("xb-stripe-odd") ;
 // get the shipping info in the Quick Cart
 //XBShipping.__init();
 //XBShipping.prepareQuickCartShipping() ;
 
 // if this is a cart page, the "checkout object will be present
 if (typeof checkout != "undefined") {
 // Mage's setMethod is used in conjnction with radio buttons for "check out as guest" and "register". We will overwrite it to respond to "whichMethod", which we'll pass with buttons
 checkout.setMethod = function( whichMethod ){
 // alert("setMethod overwtitten");
 if ( whichMethod == 'guest' ) {
 this.method = 'guest';
 var request = new Ajax.Request(
 this.saveMethodUrl,
 {method: 'post', onFailure: this.ajaxFailure.bind(this), parameters: {method:'guest'}}
 );
 Element.hide('register-customer-password');
 Element.show('checkout-register-toggle');
 this.gotoSection('billing');
 }
 else if ( whichMethod == 'register' ) {
 this.method = 'register'; 
 var request = new Ajax.Request(
 this.saveMethodUrl,
 {method: 'post', onFailure: this.ajaxFailure.bind(this), parameters: {method:'register'}}
 );
 Element.show('register-customer-password');
 Element.hide('checkout-register-toggle');
 this.gotoSection('billing');
 }
 else{
 alert(Translator.translate('Please choose to register or to checkout as a guest'));
 return false;
 }
 };
 
 // Overwrite shippingMethod.validate in /skin/frontend/default/xavierberkeley/js/opcheckout.js to use a dropdown list instead of radio buttons (what were they thinking?)
 shippingMethod.validate = function(){
 var methods = document.getElementsByName('shipping_method');
 if (methods.length==0) {
 alert(Translator.translate('Your order can not be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.'));
 return false;
 }
 
 if(!this.validator.validate()) {
 return false;
 }
 
 if ( jQuery("#s_method").val() != "" ) {
 return true;
 }
 alert(Translator.translate('Please specify shipping method.'));
 return false;
 };
 
 // Overwrite payment.init() in /skin/frontend/default/xavierberkeley/js/opcheckout.js
 payment.init = function(){
 var elements = Form.getElements(this.form);
 if ($(this.form)) {
 $(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
 }
 var method = null;
 method = jQuery("#p_method").val();
 if (method) this.switchMethod(method);
 
 jQuery("#p_method").change( function() {
 payment.switchMethod( jQuery("#p_method").val() );
 });
 };
 
 // Overwrite payment.validate in /skin/frontend/default/xavierberkeley/js/opcheckout.js
 payment.validate = function(){
 var methods = document.getElementsByName('payment[method]');
 if (methods.length==0) {
 alert(Translator.translate('Your order can not be completed at this time as there is no payment methods available for it.'));
 return false;
 }
 if ( jQuery("#p_method").val() != "" ) {
 return true;
 }
 alert(Translator.translate('Please specify payment method.'));
 return false;
 }
 
 // Overwrite the gotoSection and back functions to make sure the "checkoutsteps block at the top of the page updates when the active section does
 checkout.gotoSection = function(section) {
 if ( section == "shipping_method" ) {
 createhippingMethodMessage();
 }
 jQuery(".opc-state").removeClass("active");
 jQuery("#opc-state-"+ section).addClass("active");
 section = $('opc-'+section);
 section.addClassName('allow');
 this.accordion.openSection(section);
 }
 
 checkout.back = function() {
 if (this.loadWaiting) return;
 this.accordion.openPrevSection(true);
 var activeStep = jQuery(".section.active").attr("id").replace("opc-","opc-state-");
 jQuery(".opc-state").removeClass("active");
 jQuery("#"+ activeStep).addClass("active");
 if ( activeStep.indexOf("shipping_method") != -1 ) {
 createhippingMethodMessage();
 }
 }
 
 shipping.syncWithBilling = function() {
 $('billing-address-select') && this.newAddress(!$('billing-address-select').value);
 $('shipping:same_as_billing').checked = true;
 if (!$('billing-address-select') || !$('billing-address-select').value) {
 arrElements = Form.getElements(this.form);
 for (var elemIndex in arrElements) {
 if (arrElements[elemIndex].id) {
 var sourceField = $(arrElements[elemIndex].id.replace(/^shipping:/, 'billing:'));
 if (sourceField){
 arrElements[elemIndex].value = sourceField.value;
 }
 }
 }
 //$('shipping:country_id').value = $('billing:country_id').value;
 shippingRegionUpdater.update();
 $('shipping:region_id').value = $('billing:region_id').value;
 $('shipping:region').value = $('billing:region').value;
 //shippingForm.elementChildLoad($('shipping:country_id'), this.setRegionValue.bind(this));
 } else {
 $('shipping-address-select').value = $('billing-address-select').value;
 }
 hideRequiredInsertOptional();
 }
 
 shipping.save = function(){
 if ($('shipping:telephone').value == '' ) {
 $('shipping:telephone').value = 0;
 }
 if (checkout.loadWaiting!=false) return;
 var validator = new Validation(this.form);
 if (validator.validate()) {
 checkout.setLoadWaiting('shipping');
 var request = new Ajax.Request(
 this.saveUrl,
 {
 method:'post',
 onComplete: this.onComplete,
 onSuccess: this.onSave,
 onFailure: checkout.ajaxFailure.bind(checkout),
 parameters: Form.serialize(this.form)
 }
 );
 }
 }
 
 billing.save = function() {
 if (checkout.loadWaiting!=false) return;
 // put in a dummy phone number if not entered
 if ($('billing:telephone').value == '' ) {
 $('billing:telephone').value = 0;
 }
 
 var validator = new Validation(this.form);
 if (validator.validate()) {
 if (checkout.method=='register' && $('billing:customer_password').value != $('billing:confirm_password').value) {
 alert(Translator.translate('Error: Passwords do not match'));
 return;
 }
 checkout.setLoadWaiting('billing');
 
 // if ($('billing:use_for_shipping') && $('billing:use_for_shipping').checked) {
 // $('billing:use_for_shipping').value=1;
 // }
 
 var request = new Ajax.Request(
 this.saveUrl,
 {
 method: 'post',
 onComplete: this.onComplete,
 onSuccess: this.onSave,
 onFailure: checkout.ajaxFailure.bind(checkout),
 parameters: Form.serialize(this.form)
 }
 );
 }
 }
 
 /*
 billing.newAddress = function(isNew){
 if (isNew) {
 this.resetSelectedAddress();
 Element.show('billing-new-address-form');
 billing.setAddress( jQuery("#billing-address-select").val() );
 } else {
 Element.show('billing-new-address-form');
 billing.setAddress( jQuery("#billing-address-select").val() );
 }
 }
 
 
 billing.setAddress( jQuery("#billing-address-select").val() );
 Element.show('billing-new-address-form');
 
 jQuery("#billing-address-select").change( function() {
 billing.setAddress( jQuery("#billing-address-select").val() );
 });
 */
 }
 
 // Try to set the line-height in product zoom box so it fits image
 try {
 jQuery(".product-image-zoom").css("line-height", jQuery(".product-img-box").css("height") );
 }
 catch(err) {
 // do something
 }
 
 // If there are no additional images add lightbox to the main image
 if ( jQuery(".product-image-zoom").size() > 0 && jQuery(".more-views img").size() == 0 ) {
 jQuery(".product-image-zoom #image").wrap('<a href="'+ jQuery(".product-image-zoom #image").attr("src") +'" title="'+ jQuery(".product-image-zoom #image").attr("title").replace(/\"/g,'&quot;') +'" class="lightbox"></a>');
 }
 
 // Having the same image twice in the carousel for products bothered me but I wanted the large (default) one to still have lightbox...
 jQuery(".product-image-zoom #image").click( function() {
 // get the last bit of the src attribute
 var zoomPic = jQuery(this);
 var thisSrc = jQuery(this).attr("src");
 thisSrc = thisSrc.substring( thisSrc.lastIndexOf("/") );
 // Loop through the thumbnails until you find the same src
 jQuery(".more-views img").each( function() {
 if ( jQuery(this).attr("src").substring( jQuery(this).attr("src").lastIndexOf("/") ) == thisSrc ) {
 // trigger a click on that one
 jQuery(this).parents("a").trigger("click");
 };
 })
 });

 jQuery("a.lightbox").lightBox({
 overlayBgColor: '#000',
 overlayOpacity: 0.6,
 maxHeight: screen.height * 0.9,
 maxWidth: screen.width * 0.9,
 imageLoading: '/skin/frontend/default/xavierberkeley/images/lightbox-ico-loading.gif',
 imageBtnClose: '/skin/frontend/default/xavierberkeley/images/lightbox-btn-close.gif',
 imageBtnPrev: '/skin/frontend/default/xavierberkeley/images/lightbox-btn-prev.gif',
 imageBtnNext: '/skin/frontend/default/xavierberkeley/images/lightbox-btn-next.gif',
 containerResizeSpeed: 350,
 fixedNavigation: true
 });
 
 /*
 // VERY TEMPORARY ie6 fixes (playing around to get layout right, will fix CSS properly when what needs adjustment is established)
 if ( jQuery.browser.msie && jQuery.browser.version=="6.0") {
 jQuery(".page").css("width","1010px");
 jQuery(".col2-left-layout .col-main").css("margin-right","0px").css("width","715px");
 jQuery(".col-left").css("margin","0px 5px");
 jQuery(".content-right-box").css("margin-left","10px");
 }
 */
 // OK, we're going to hide all red asterisks (rewuired inputs) and put "(optional)" afeter each non-required field's label
 hideRequiredInsertOptional();
 
 
 // Hacky but elegent, this little bit truncates values in the address select menu in checkout
 jQuery("#opc .address-select > option").each( function() {
 if ( String(jQuery(this).text()).length > 105 ) {
 jQuery(this).text( jQuery(this).text().substring(0,102) +"..." );
 }
 });
 
 if ( jQuery("#newNavToo ul.sf-navbar li.current").size() == 0 ) {
 jQuery("#newNavToo ul.sf-navbar li:first").addClass("current");
 }
 // Social Networking links. Have to add these via js cuz magento caches calls to getCurrentUrl();
 var pageTitle = escape(document.title.replace(/\u2013/g,'-').replace(/\u2018/g,'\'').replace(/\u2019/g,'\'').replace(/\u201C/g,'"').replace(/\u201D/g,'"').replace(/[^\x20-\x7F]/g,'_'));
 var pageLocation = escape(document.location);
 // To add a link, add it to this array with a properly constructed URL. Put an icon in the image folder under its key.
 var shareSites = {
 email: '#email-this-page',
 digg: 'http://digg.com/submit?phase=2&url='+ pageLocation +'&title='+ pageTitle ,
 delicious: 'http://del.icio.us/submit?url='+ pageLocation +'&title='+ pageTitle ,
 stumbleUpon: 'http://www.stumbleupon.com/submit?url='+ pageLocation +'&title='+ pageTitle ,
 twitter: 'http://twitter.com/home?status=Currently+reading+'+ pageLocation
 };
 // Append each link to the shareTools div in the footer
 for (var a in shareSites) {
 jQuery("#shareTools").append('<a class="sharelink" href="'+ shareSites[a] +'" target="_blank" id="share-link-'+ a +'"><img src="/skin/frontend/default/xavierberkeley/images/icon_share_'+ a +'.gif" alt="'+ a +'" /></a>');
 }
 jQuery("#share-link-email").click(emailPage);
 jQuery("#printTools").click(function(){window.print();});
 jQuery("div.video-teaser a").each(function(){
 jQuery(this).mouseover(function(){jQuery(this).find("img.play-video-button").attr('src','/video/thumbnails-play/_play-button-hover.png');});
 jQuery(this).mouseout(function(){jQuery(this).find("img.play-video-button").attr('src','/video/thumbnails-play/_play-button.png');});
 });
}); // end document ready

function emailPage(){
subject = escape(document.title.replace(/\u2013/g,'-').replace(/\u2018/g,'\'').replace(/\u2019/g,'\'').replace(/\u201C/g,'"').replace(/\u201D/g,'"').replace(/[^\x20-\x7F]/g,'_'));
str = 'mailto:?subject=' + subject + '&body=' + subject + '%0D%0Ahttp://' + location.host + location.pathname +'?src=em' ;
location.href=str;return false;} 

function xbDLToggle(id){jQuery("#definition"+id).toggle();if(jQuery("#definition"+id).css("display")=="none"){jQuery("#term"+id).removeClass("dton");}else{jQuery("#term"+id).addClass("dton");}}


function TrustLogo(logo,code,autoMove){host=location.host;return tLUC(logo,code,code,autoMove);}function TrustLogo_MouseOver(ev,code){return tLL(ev,code);}function TrustLogo_MouseMove(ev,code){return tLM(ev,code);}function TrustLogo_MouseOut(ev,code){return tLN(ev,code);};function TrustLogo_Credentials(ev,code){return tLWC(ev,code);};function tLL(ev,tLb){tLeB(ev,tLiB(tLMC,tLb),tLRC(tLb));}function tLM(ev,tLb){tLXB(ev);}function tLN(ev,tLb){tLTC(tLRC(tLb));}function tLWC(ev,tLa){tLXC(tLiB(tLLC,tLa));}function tLXC(URL){window.open(URL,'tl_wnd_credentials'+(new Date()).getTime(),tLYC);}var tLB="SCAS";var tLC="SCAS";
var tLD="SC";var tLE="SC";var tLF="SCOP";var tLG="SCOP";var tLH="SCCC";var tLI="SCCC";var tLnC='http://www.trustlogo.com/';if(window.location.protocol.toLowerCase()=="https:"){tLnC='https://secure.comodo.com/';}var tLbC=tLnC+"trustlogo/images/popup/";var tLlC=tLnC+"trustlogo/javascript/tl_tl_popupParent.htm#";var tLyC=tLnC+"trustlogo/logos/";var tLMC=tLnC+'ttb_searcher/trustlogo?';var tLLC=tLMC+"v_querytype=W&";tLMC=tLMC+"v_querytype=C&";var tLNC='&x=6&y=5';
var tLgC=120;
var tLeC=445;var tLhC=580;if (window.attachEvent){var tLhC=620;var tLeC=460;}

var tLP=290;var tLQ=210;

var tLfC=60;var tLiC=160;if(tLu()){tLP=tLP+20;}var tLU=3;var tLV=3;var tLzC="";
var tLR=500;var tLS=500;/*var tLT=7000;*/var tLT=2000;var tLW=100;var tLO=new Array();function tLZC(URL){var i;for(i=0;i<tLO.length;i++){if(tLO[i].src==URL){return;}}var im=new Image();im.src=URL;tLO[tLO.length]=im;}function tLaC(tLPC){tLZC(tLbC+"seal_bg.gif");tLZC(tLbC+"warranty_level.gif");}function tLX(str){return String(str).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\'/g,"&#27;").replace(/\"/g,"&#22;");}function tLY(str){return String(str).replace(/\%/g,"%25").replace(/\#/g,"%23")
.replace(/\&/g,"%26").replace(/\?/g,"%3f").replace(/\+/g,"%2b").replace(/\=/g,"%3d").replace(/\ /g,"+").replace(/\%/g,"%25");}if(tLw()){if((screen.availHeight-tLgC)<(tLhC+tLiC)){tLhC=screen.availHeight-tLiC;tLgC=0;}if((screen.availWidth-tLfC)<tLeC){tLeC=screen.availWidth;tLfC=0;}}var tLYC='toolbar=0,scrollbars=1,location=1,status=1,menubar=1,resizable=1,width='+tLeC+',height='+tLhC+',left='+tLfC+',top='+tLgC;function tLiB(tLKC,tLPC){return tLKC+'v_shortname='+tLY(tLPC)+'&v_search='+tLY(window.location.protocol+"//"+host+window.location.pathname)+tLNC;}function tLQC(tLa){return 'if(window.open(\''+tLX(tLiB(tLLC,tLa))+'\',\'tl_wnd_credentials\'+(new Date()).getTime(),\''+tLYC+'\')){};tLlB(tLTB);';
}function tLRC(tLb){var tLc="tl_popup";if(tLi()&&!tLo()){tLc=tLc+tLb;}else if(tLi()&&tLo()){tLc=tLc+tLb;}else{}return tLc;}function tL1C(s,q,l){var a=s.split(".");if(a.length<2){return "";};var tLZ=tLyC+q+"/"+l+"/"+a[a.length-1];for(var lIndex=a.length-2;lIndex>=0;lIndex--){tLZ=tLZ+"/"+a[lIndex].substr(0,2)+"/"+a[lIndex];}tLZ=tLZ+"/"+s+"."+q+"."+l+".gif";tLZ=tLZ.toLowerCase();return tLZ;}function tL0C(tLZ,tLb){if(!tLZ)return false;if(tLZ==true){tLZ="small";}if(tLZ=="small"||tLZ=="large"){tLZ=tL1C(host,tLb,tLZ);}return tLZ;}function tL9C(e,xy){if(e&&xy){xy[0]=xy[0]+e.offsetLeft;
xy[1]=xy[1]+e.offsetTop;if(e.offsetParent){xy[0]=xy[0]-e.scrollLeft;xy[1]=xy[1]-e.scrollTop;tL9C(e.offsetParent,xy);}}}function tL2C(){var tLhB=tLJB("tL4C");tLhB.style.pixelLeft=0;tLhB.style.pixelTop=0;tLhB.style.display="block";var tL6C=0;var tL7C=0;for(var tL8C=tLhB.offsetParent;tL8C;tL8C=tL8C.offsetParent){tL6C+=tL8C.clientLeft+tL8C.offsetLeft-tL8C.scrollLeft;tL7C+=tL8C.clientTop+tL8C.offsetTop-tL8C.scrollTop;}tL6C-=tL_C().clientLeft-tL_C().scrollLeft;tL7C-=tL_C().clientTop-tL_C().scrollTop;if(tLzC=="topright"){tLhB.style.pixelLeft=tL6C+tL_C().scrollLeft+tL_C().clientWidth-tLhB.offsetWidth;
tLhB.style.pixelTop=tL7C+tL_C().scrollTop;}else if(tLzC=="bottomright"){tLhB.style.pixelLeft=tL6C+tL_C().scrollLeft+tL_C().clientWidth-tLhB.offsetWidth;tLhB.style.pixelTop=tL7C+tL_C().scrollTop+tL_C().clientHeight-tLhB.offsetHeight;}else if(tLzC=="bottomleft"){tLhB.style.pixelLeft=tL6C+tL_C().scrollLeft;tLhB.style.pixelTop=tL7C+tL_C().scrollTop+tL_C().clientHeight-tLhB.offsetHeight;}else if(tLzC=="topleft"){tLhB.style.pixelLeft=tL6C+tL_C().scrollLeft;tLhB.style.pixelTop=tL7C+tL_C().scrollTop;}else{}tLhB.style.display="block";};function tL3C(){window.attachEvent("onscroll",tL2C);window.attachEvent("onresize",tL2C);
window.attachEvent("onreadystatechange",tL2C);window.attachEvent("onload",tL2C);tLIC(tL2C,100);tLIC(tL2C,250);tLIC(tL2C,500);tLIC(tL2C,1000);tLIC(tL2C,2000);tLIC(tL2C,4000);tLIC(tL2C,8000);}function tLUC(tLZ,tLa,tLb,tL5C){if(!tLy()){tL5C=false;}tLZ=tL0C(tLZ,tLb);tLaC(tLb);var tLc=tLRC(tLb);var tLOC=' style="position:absolute;z-index:0;visibility: hidden;background-color: transparent;overflow:hidden;"';if(tLi()&&!tLo()){if(tL5C){tL5C=tL5C.toString().toLowerCase();if((tL5C !="topright")&&(tL5C !="topleft")&&(tL5C !="bottomright")&&(tL5C !="bottomleft")&&(tL5C !="none")){tL5C="topright";}if(tL5C=="none"){
tL5C=false;}tLzC=tL5C;}if(!tLJB(tLc)){if(tLZ){var str="";if(tL5C){str=str+'<div id="tL4C" style="zIndex:0;position:absolute;border:none;padding:0pt;margin:0pt;background-color:transparent;display:none;">'}str=str+'<a href="javascript:'+tLQC(tLa)+'" onmouseover="tLeB(event,\''+tLX(tLiB(tLMC,tLb))+'\',\''+tLc+'\')" onmousemove="tLXB(event)"onmouseout="tLTC(\''+tLc+'\')" ondragstart="return false;"><im'+'g src="'+tLX(tLZ)+'" border=0 onmousedown="return tLKB(event,\''+tLX(tLiB(tLLC,tLa))+'\');" oncontextmenu="return tLLB(event);" /></a><!---->';if(tL5C){str=str+"</div>";tL3C();}document.write(str);
}document.write('<div id="'+tLc+'" name="'+tLc+'" '+tLOC+' onmouseover="tLoB(\''+tLc+'\')" onmousemove="tLpC(\''+tLc+'\')" onmouseout="tLpB(\''+tLc+'\')">&nbsp;</div>');}}else if(tLi()&&tLo()){var tLfB='<iframe src="'+tLX(tLiB(tLMC,tLb))+'" id="'+tLc+'tLDD" name="'+tLc+'tLDD" width="'+tLP+'" height="'+tLQ+'" frameborder="0" allowtransparency="true" style="background:transparent;width:'+tLP+';height:'+tLQ+'"></iframe>';if(!tLJB(tLc)){document.write('<div id="'+tLc+'" name="'+tLc+'" '+tLOC+' onmouseover="tLoB(\''+tLc+'\')" onmousemove="tLpC(\''+tLc+'\')" onmouseout="tLpB(\''+tLc+'\')">'+tLfB+'</div>');
}if(tLZ){document.write('<a href="javascript:'+tLQC(tLa)+'" onmouseover="tLeB(event,\''+tLX(tLiB(tLMC,tLb))+'\',\''+tLc+'\')" onmousemove="tLXB(event)" onmouseout="tLTC(\''+tLc+'\')" ondragstart="return false;"><im'+'g src="'+tLX(tLZ)+'" border=0 onmousedown="return tLKB(event,\''+tLX(tLiB(tLLC,tLa))+'\');" oncontextmenu="return tLLB(event);" /></a>');}}else{if(tLZ){document.write('<a href="javascript:'+tLQC(tLa)+'" title="Click to verify" onmouseover="if(window.status=\'Click to verify\'){}"><im'+'g src="'+tLX(tLZ)+'" border=0 oncontextmenu="return tLLB(event);" title="Click to verify" onmouseover="if(window.status=\'Click to verify\'){}"'
+'/></a><!---->');}}}function tLrC(left1,top1,width1,height1,left2,top2,width2,height2){if(left1+width1<left2)return false;if(top1+height1<top2)return false;if(left2+width2<left1)return false;if(top2+height2<top1)return false;return true;}function tLsC(sty){if(sty.display=="none")return false;if(sty.visibility=="hidden")return false;if(sty.visibility=="visible")return true;return true;}function tLtC(e){if(!tLsC(e.currentStyle))return false;while(e.currentStyle.visibility=="inherit"){e=e.parentElement;if(!e)return true;if(!tLsC(e.currentStyle))return false;}return true;}function tLuC(left,top,width,height,e,tLCD){
if(!tLCD){if(!tLtC(e))return false;}var tLBD=e.offsetLeft;var tLAD=e.offsetTop;for(var tL8C=e.offsetParent;tL8C;tL8C=tL8C.offsetParent){tLBD+=tL8C.clientLeft+tL8C.offsetLeft-tL8C.scrollLeft;tLAD+=tL8C.clientTop+tL8C.offsetTop-tL8C.scrollTop;}tLBD-=tL_C().clientLeft-tL_C().scrollLeft;tLAD-=tL_C().clientTop-tL_C().scrollTop;return tLrC(left,top,width,height,tLBD,tLAD,e.offsetWidth,e.offsetHeight);}function tLvC(left,top,width,height,coll,tLCD){for(var lIndex=0;lIndex<coll.length;lIndex++){if(tLuC(left,top,width,height,coll[lIndex],tLCD)){return true;}}return false;}function tLjC(){if(tLx()){if(false
||tL_C().clientWidth<tLP-10||tL_C().clientHeight<tLQ-10||tLvC(tLOB,tLPB,tLP,tLQ,document.getElementsByTagName("object"))||tLvC(tLOB,tLPB,tLP,tLQ,document.getElementsByTagName("embed"))||tLvC(tLOB,tLPB,tLP,tLQ,document.getElementsByTagName("applet"))||tLvC(tLOB,tLPB,tLP,tLQ,document.getElementsByTagName("select")))return true;return false;}return false;}function tLz(){if((tLi())&&!tLv()){return true;}return false;}var tLGB;function tLHB(){if(tLGB){return tLGB;};var tLFB="UNSUPPORTED:tL_B::";var tL1=tLFB;var tL2=tLFB;var tL3="MSIE5:tLtB:tLvB:tLyB:tLwB:tL3B:tL7B:tL5B:tLAC:tLBC::";var tL4="MSIE5_5:tLtB:tLvB:tLyB:tLxB:tLwB:tL3B:tL7B:tL5B:tLAC:tLBC:tLCC:tLDC::";
var tL5=tL4;var tL6=tL5;var tL7="MACIE5_1:tLtB:tLvB:tLyB:tLzB:tLwB:tL3B:tL7B:tL5B:tLAC:tLBC::";var tL8=tLFB;var tL9="OPERA6:tLvB:tL4B:tLxB:tLwB:tLyB:tL3B:tL7B:tL6B:tLsB::";var tL_=tLFB;var tLAB="NS6:tLvB:tLwB:tLyB:tL2B:tL8B:tL6B::";var tLBB=tLAB;var tLCB=tLFB;var tLDB="UP:tLtB:tLyB:tLwB:tL7B::";var tLEB="UPUP:tLtB:tLvB:tLyB:tLxB:tLwB:tL3B:tL7B:tL5B:tLAC:tLBC:tLCC:tLDC::";var tLEC=navigator.userAgent;var tLFC=navigator.appVersion;tLGB=tLFB;var tLGC=0;if(document.getElementById){tLGB=tLEB;tLGC=tLEC.indexOf("Opera ");if(tLGC !=-1){var tLjB=parseFloat(tLEC.substring(tLGC+6,tLGC+10));if(tLjB<5){tLGB=tLCB;}else if(tLjB<=5.999){
tLGB=tL8;}else if(tLjB<7){tLGB=tL9;}else{tLGB=tLEB;}}else if(navigator.appName=="Microsoft Internet Explorer"){tLGC=tLFC.indexOf("MSIE ");var tLjB=parseFloat(tLFC.substring(tLGC+5,tLGC+9));if(navigator.platform=="MacPPC"||navigator.platform=="Mac68K"){tLGB=tL7}else{tLGB=tLEB;if(tLjB<=3.5){tLGB=tL1;}else if(tLjB<=4.5){tLGB=tL2;}else if(tLjB<5.49){tLGB=tL3;}else if(tLjB<6){tLGB=tL4;}else if(tLjB<6.5){tLGB=tL5;}else{tLGB=tL6;}}}else if(navigator.appName=="Netscape"){var tLjB=parseFloat(tLFC);if(tLjB<4.7){tLGB=tLFB;}else if(tLjB<4.8){tLGB=tL_}else{tLGB=tLAB;}}else{tLGB=tLEB;}}else if(document.all){
if(navigator.appName=="Microsoft Internet Explorer"){tLGC=tLFC.indexOf("MSIE ");var tLjB=parseFloat(tLFC.substring(tLGC+5,tLGC+9));if(navigator.platform=="MacPPC"||navigator.platform=="Mac68K"){tLGB=tL7}else{tLGB=tLEB;if(tLjB<=3.5){tLGB=tL1;}else if(tLjB<=4.5){tLGB=tL2;}else if(tLjB<5.49){tLGB=tL3;}else if(tLjB<6){tLGB=tL4;}else if(tLjB<6.5){tLGB=tL5;}else{tLGB=tL6;}}}else{tLGB=tLDB;}}else if(document.layers){if(navigator.appName=="Netscape"){var tLjB=parseFloat(tLFC);if(tLjB<4.7){tLGB=tLCB;}else if(tLjB<4.8){tLGB=tL_;}else{tLGB=tLAB;}}else{tLGB=tLCB;}}else{tLGB=tLFB;}return tLGB;}function tLIB(feat){
var tLkB=tLHB();feat=":"+feat+":";if(tLkB.indexOf(feat)==-1){return false;}return true;}function tLd(){return tLIB("tLtB");};function tLe(){return tLIB("tLuB");};function tLf(){return tLIB("tLvB");};function tLh(){return tLIB("tLxB");};function tLi(){return tLIB("tLyB");};function tLj(){return tLIB("tLzB");};function tLl(){return tLIB("tL1B");};function tLm(){return tLIB("tL2B");};function tLn(){return tLIB("tL3B");};function tLo(){return tLIB("tL4B");};function tLp(){return tLIB("tL5B");};function tLq(){return tLIB("tL6B");};function tLr(){return tLIB("tL7B");};function tLs(){return tLIB("tL8B");};
function tLt(){return tLIB("tLAC");};function tLu(){return tLIB("tLsB");};function tLx(){return tLIB("tLCC");};function tLv(){return tLIB("tL_B");};function tLw(){return tLIB("tLBC");};function tLy(){return tLIB("tLDC");};function tLJB(id){if(tLf()){return document.getElementById(id);}else if(tLd()){return document.all[id];}else if(tLe()){return document.layers[id];}else{return null;}}function tLHC(id){window.clearTimeout(id);}function tLIC(str,del){return window.setTimeout(str,del);}function tLKB(ev,URL){if(!tLz())return true;if(ev.button&2){alert("This TrustLogo is protected");if(tLp()){ev.cancelBubble=true;
ev.returnValue=false;}else if(tLq()){ev.preventDefault();ev.cancelPropagation();}return false;}if(ev.button&1){return true;window.open(URL,'tl_wnd_credentials'+(new Date()).getTime(),tLYC);if(tLp()){ev.cancelBubble=true;ev.returnValue=false;}else if(tLq()){ev.preventDefault();ev.cancelPropagation();}return false;}}function tLLB(ev){if(!tLz())return;if(tLp()){ev.cancelBubble=true;ev.returnValue=false;}else if(tLq()){ev.preventDefault();ev.cancelPropagation();}return false;}function tLMB(){if(!tLz())return;tLQB=0;tLnB(tLNB,tLOB,tLPB,tLTB);}var tLNB="";var tLOB=0;var tLPB=0;var tLQB=0;var tLRB=0;var tLSB=null;
var tLTB="";var tLUB=false;var tLVB=0;var tLWB="";function tL_C(){if(document.compatMode=="CSS1Compat"){return document.body.parentElement;}else{return document.body;}}function tLXB(ev){if(!tLz())return;if(tLWB)return;var tLYB;var tLZB;var tLaB=0;var tLbB=0;var tLcB=800;var tLdB=600;if(tLn()){tLaB=tL_C().scrollLeft;tLbB=tL_C().scrollTop;tLcB=tL_C().clientWidth;tLdB=tL_C().clientHeight;tLYB=ev.clientX+tLaB;tLZB=ev.clientY+tLbB;}else if(tLm()){tLYB=ev.pageX;tLZB=ev.pageY;tLaB=window.pageXOffset;tLbB=window.pageYOffset;tLcB=window.innerWidth;tLdB=window.innerHeight;}if(tLaB+tLcB>=tLYB+tLP){tLOB=tLYB+tLU;
}else if(tLaB<=tLYB-tLP){tLOB=tLYB-tLP-tLU;}else{tLOB=tLaB+tLcB/2-tLP/2;}if(tLbB+tLdB>=tLZB+tLQ){tLPB=tLZB+tLV;}else if(tLbB<=tLZB-tLQ){tLPB=tLZB-tLQ-tLV;}else{tLPB=tLbB+tLdB/2-tLQ/2;}return true;}function tLeB(ev,tLSC,tLc){if(!tLz())return;var tLVC='src="'+tLX(tLSC)+'" id="'+tLc+'tLDD" name="'+tLc+'tLDD" width="'+tLP+'" height="'+tLQ+'"';var tLkC='src="'+tLlC+tLX(tLY(tLSC))+'" id="'+tLc+'tLDD" name="'+tLc+'tLDD" width="'+tLP+'" height="'+tLQ+'"';var tLfB='<iframe '+tLVC+' frameborder="0" allowtransparency="true" style="background:transparent;overflow:hidden;"></iframe>';var tLmC='<iframe '+tLkC+' frameborder="0" allowtransparency="true" style="background:transparent;overflow:hidden;" ' 
+'ondeactivate="tLIC(\'tLlB(\\\''+tLc+'\\\');\',1);"></iframe>';var tLgB='<layer width='+tLP+' height='+tLQ+'><layer '+tLVC+' style="position:relative;background:transparent;" onmouseover="tLoB(\''+tLc+'\')" onmouseout="tLpB(\''+tLc+'\')"></layer></layer>';if(tLjC()){tLNB=tLmC;}else if(tLi()){tLNB=tLfB;}else{return;}if(tLTB&&(tLc !=tLTB)){tLlB(tLTB);tLlB(tLc);tLmB();}if(tLUB)return;var tLhB;if(tLi()){tLhB=tLJB(tLc);if(tLhB.style.visibility=="visible"){if(tLNB !=tLWB){if(tLRB){tLHC(tLRB);tLRB=0;}tLlB(tLc);tLWB=tLNB;}else{if(tLRB){tLHC(tLRB);tLRB=0;}return;}}}tLXB(ev);tLTB=tLc;if(!tLQB){tLQB=tLIC("tLMB()",tLR);
if(tLRB){tLHC(tLRB);tLRB=0;}}}function tLnB(tLoC,x,y,tLc){if(!tLz())return;if(tLoC !=tLWB){if(tLRB){tLHC(tLRB);tLRB=0;}tLlB(tLc);}tLWB=tLoC;if(!tLz())return;var tLhB;if(tLi()){tLhB=tLJB(tLc);tLhB.style.visibility="visible";if(tLhB&&tLhB.offsetParent){var xy=new Array(-x,-y);tL9C(tLhB.offsetParent,xy);x=-xy[0];y=-xy[1];}if(tLr()){tLhB.style.pixelLeft=x;if(!tLj()){tLhB.style.pixelTop=y;}tLhB.style.pixelWidth=tLP;tLhB.style.pixelHeight=tLQ;}else{tLhB.style.left=x+"px";if(!tLj()){tLhB.style.top=y+"px";}tLhB.style.width=tLP+"px";tLhB.style.height=tLQ+"px";}tLhB.style.borderWidth='0px';if(!tLo()){tLhB.innerHTML=tLoC;
}if(tLjC()){var tLqB=tLJB(tLc+'tLDD');}tLhB.style.zIndex=0;tLhB.style.visibility="visible";}}function tLqC(){return !tLh()||tLjC();}function tLTC(tLc){if(!tLz())return;if(tLQB){tLHC(tLQB);tLQB=0;}if(tLqC()){if(!tLRB){tLRB=tLIC('tLlB("'+tLc+'")',tLT);}}else{if(!tLRB){tLRB=tLIC('tLlB("'+tLc+'")',tLS);}}}function tLpC(tLc){if(!tLz())return;if(tLRB){tLHC(tLRB);tLRB=0;}if(tLqC()&&tLRB==0){tLRB=tLIC('tLlB("'+tLc+'")',tLT);}}function tLoB(tLc){if(!tLz())return;if(tLRB){tLHC(tLRB);tLRB=0;}if(tLqC()&&tLRB==0){tLRB=tLIC('tLlB("'+tLc+'")',tLT);}}function tLpB(tLc){if(!tLz())return;if(tLqC()){if(!tLRB){tLRB=tLIC('tLlB("'+tLc+'")',tLT);
}}else{if(!tLRB){tLRB=tLIC('tLlB("'+tLc+'")',tLS);}}}function tLlB(tLc){if(!tLz())return;if(tLRB){tLRB=0;}if(tLQB&&tLTB==tLc){tLHC(tLQB);tLQB=0;}tLWB="";var tLhB;if(tLi()){tLhB=tLJB(tLc);}if(!tLz())return;if(null==tLhB){}else if(tLi()){tLhB.style.visibility="hidden";tLhB.innerHTML="";}else{tLhB.visibility="hide";}if(!tLVB){tLUB=true;tLVB=tLIC("tLmB()",tLW);}}function tLmB(){if(tLVB){tLVB=0;tLUB=false;}}
function createStyleRule(selector, declaration) {if (!document.getElementsByTagName ||!(document.createElement || document.createElementNS)) return;var agt = navigator.userAgent.toLowerCase();var is_ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera") == -1));var is_iewin=(is_ie&&(agt.indexOf("win")!=-1));var is_iemac=(is_ie&&(agt.indexOf("mac")!=-1));if (is_iemac) return;var head = document.getElementsByTagName("head")[0];var style=(typeof document.createElementNS!="undefined")?document.createElementNS("http://www.w3.org/1999/xhtml", "style"):document.createElement("style");
if (!is_iewin) {var styleRule = document.createTextNode(selector + " {" + declaration + "}");style.appendChild(styleRule);}style.setAttribute("type", "text/css");style.setAttribute("media", "screen"); head.appendChild(style);if (is_iewin&&document.styleSheets&&document.styleSheets.length>0){var lastStyle = document.styleSheets[document.styleSheets.length - 1];if (typeof lastStyle.addRule == "object"){lastStyle.addRule(selector, declaration);}}}
version=0;if (navigator.appVersion.indexOf("MSIE")!=-1){temp=navigator.appVersion.split("MSIE");version=parseFloat(temp[1]);}
if (version>=5.5 && (window.createPopup) && (!(document.documentElement && typeof document.documentElement.style.maxHeight!="undefined"))){document.writeln('<style type="text/css">#comodoTL{display:none;}</style>');}
else {createStyleRule("#comodoTL", "display:none;");}
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category AW
 * @package AW_Ajaxcartpro
 * @copyright Copyright (c) 2003-2009 aheadWorks Co. (http://www.aheadworks.com)
 * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */
$_=function(){var F=typeof arguments[0]=="undefined"?null:arguments[0];var B=F;var C=arguments.length;var A=[];if(!C){return document}if(C>1){for(var E=0;E<C;E++){A.push($_(arguments[E]))}}else{if(B&&(B instanceof Array||(typeof B!="string"&&!(B instanceof String))&&(!(B instanceof Function))&&((typeof B.length)+"")!="undefined"&&!B.tagName)){var C=B.length;for(var E=0;E<C;E++){A.push($_(B[E]))}}else{if(C){if(B&&!B.$__OK){if(typeof B=="string"||B instanceof String){B=$_.$_STR.$__init(B)}else{if(typeof B=="number"||B instanceof Number){B=$_.$_NUMBER.$__init(B)}else{switch(typeof B){case"function":$_.$_FUNC.$__init(B);break;default:if(B.nodeType){$_.$_DOM.$__init(B)}else{$_.$_OBJ.$__init(B)}}}}if(B){B.$__OK=true;B.empty=B.empty||function(){return !this}}}A.push(B)}}}if(A.length!=1){var G=$_.$__flat(A);if(G[0]&&G[0].$__EXT&&G[0].$__TYPE){var I=G[0].$__EXT;var H=G[0].$__TYPE;for(var E=I.length-1;E>=0;E--){for(var D=G.length-1;D>=0;D--){if(G[D].$__TYPE===H){if($_[H].$_$_&&$_[H].$_$_[I[E]]){if(!$_[H].$_$_[I[E]].accepts||$_[H].$_$_[I[E]].accepts(el)){$_[H].$_$_[I[E]].init(G)}break}}}}}return G}else{return A[0]}};$_.ie=!!(navigator.appName=="Microsoft Internet Explorer"&&!window.opera);$_.ie6=$_.ie&&navigator.appVersion.match("6");$_.opera=!!window.opera;$_.gecko=!!((window.netscape&&!window.opera));$_.safari=!!(navigator.userAgent.toLowerCase().indexOf("safari")!=-1);$_.__={};$_.raise=function(B,C){var D=["Error::",B||"",(B&&C)?"::":"",(B&&C)?C:(B?"":"Unknown error")];var A=D.join("");if(console.log){console.log(A)}else{alert(A)}};$_.$_STR={$_:{},$_$_:{},$__init:function(C){var B=C instanceof String?C:new String(C);if(B){B.$__EXT=[]}B.$__TYPE="$_STR";for(var A in $_.$_STR.$_){if(!$_.$_STR.$_[A].accepts||$_.$_STR.$_[A].accepts(B)){B=$_.$_STR.$_[A].init(B);if(!B||!B.$__TYPE||B.$__TYPE!=="$_STR"){continue}B.$__EXT[B.$__EXT.length]=A}}return B}};$_.$_DOM={$_:{},$_$_:{},$__init:function(B){B.$__UID=Math.random();B.$__EXT=[];B.$__TYPE="$_DOM";for(var A in $_.$_DOM.$_){if(!$_.$_DOM.$_[A].accepts||$_.$_DOM.$_[A].accepts(B)){$_.$_DOM.$_[A].init(B);B.$__EXT[B.$__EXT.length]=A}}}};$_.$_OBJ={$_:{},$_$_:{},$__init:function(B){B.$__EXT=[];B.$__TYPE="$_OBJ";for(var A in $_.$_OBJ.$_){if(!$_.$_OBJ.$_[A].accepts||$_.$_OBJ.$_[A].accepts(B)){$_.$_OBJ.$_[A].init(B);B.$__EXT[B.$__EXT.length]=A}}}};$_.$_NUMBER={$_:{},$_$_:{},$__init:function(B){var C=B instanceof Number?B:new Number(B);C.$__EXT=[];C.$__TYPE="$_NUMBER";for(var A in $_.$_NUMBER.$_){if(!$_.$_NUMBER.$_[A].accepts||$_.$_NUMBER.$_[A].accepts(C)){$_.$_NUMBER.$_[A].init(C);C.$__EXT[C.$__EXT.length]=A}}return C}};$_.$_FUNC={$_:{},$__exec:[],$__init:function(A){return A}};$_.copy=$_.$__copy=function(C){var B=[];var A=C.length;for(var D=0;D<A;D++){B.push(C[D])}return B};$_.flat=$_.$__flat=function(A,E){var C=E||[];var B=A.length;for(var D=0;D<B;D++){if(A[D]&&A[D].length&&(typeof A[D]!="string"&&!(A[D] instanceof String))&&!A[D].nodeType){$_.flat(A[D],C)}else{if(!(A[D] instanceof Array)){C.push(A[D])}}}return C};Array.prototype.contains=function(C){var B;var A=this.length;for(B=0;B<A;B++){if(this[B]===C){return true}}return null};Array.prototype.search=function(B){var A=this.length;if(typeof B=="function"){for(i=0;i<A;i++){if(B(this[i])){return i}}}else{for(i=0;i<A;i++){if(this[i]==B){return i}}}return null};Array.prototype.intersects=function(){var D=[];var B=this.length;var F=arguments.length;for(var E=0;E<B;E++){var A=false;for(var C=0;C<F;C++){if(arguments[C]===null||arguments[C]===false){var A=true}else{if(arguments[C].contains&&typeof arguments[C].length!="undefined"){if(!arguments[C].contains(this[E])){var A=true;break}}else{if(arguments[C]!=this[E]){var A=true;break}}}}if(!A){D.push(this[E])}}if(D){if(D.length){return D}else{return[]}}else{return[]}return(D||D.length)?D:null};Array.prototype.apply=function(B){for(var A=0;A<this.length;A++){B(this[A])}};Array.prototype.empty=function(){return !this.join("").length};$_.extend=function(C,B){for(var A in B){C[A]=B[A]}return C};$_.$_DOM.$_.XMLHttp={accepts:function(A){return A.tagName&&A.tagName.toLowerCase()=="form"},init:function(A){A.getData=function(){var E=A.elements;var C=[];var F={};for(var D=E.length-1;D>=0;D--){var B=$_(E[D]);if(B.name&&B.type!="file"&&B.type!="radio"&&B.type!="button"){var H=B.VAL();if(H!==false){if(H instanceof Array){for(var G=0;G<H.length;G++){C[C.length]=encodeURIComponent(B.name)+"="+encodeURIComponent(H[G])}}else{C[C.length]=encodeURIComponent(B.name)+"="+encodeURIComponent(H)}}}else{if(B.type=="radio"){if(!F[B.name]){if(B.checked){F[B.name]=1;C[C.length]=encodeURIComponent(B.name)+"="+encodeURIComponent(B.VAL())}}}}}return C.join("&")};A.GET=function(C){var B=new $_.__.XMLHttp(A.action,A.getData());B.requestMethod="GET";if(C){B.async(C)}return B.parse()},A.POST=function(C){var B=new $_.__.XMLHttp(A.action,A.getData());if(C){B.async(C)}return B.parse()},A.SEND=function(B){return A[(A.method.toLowerCase()=="post")?"POST":"GET"](B)}}};$_.__.XMLHttp=function(A,B){this.URL=A||window.location.protocol+"//"+window.location.host+window.location.pathname;this.requestMethod=B?"POST":"GET";this.data=B?B:false;this.is_async=false;this.callBack==false;this.request=window.XMLHttpRequest?(new XMLHttpRequest()):(new ActiveXObject("Microsoft.XMLHTTP"))};$_.__.XMLHttp.prototype.async=function(A){this.callBack=(typeof A=="function")?A:false;return this};$_.__.XMLHttp.prototype.parse=function(){var B=this;if(typeof this.data!="string"){var A=0;var D="";for(var C in this.data){D=D+(A?"&":"")+encodeURIComponent(C)+"="+encodeURIComponent(this.data[C]);A++}this.data=D}if(this.requestMethod=="GET"&&this.data.length){var E=(this.URL.lastIndexOf("?")==-1)?"?":"";this.URL=this.URL+E+this.data;this.data=null}this.request.open(this.requestMethod,this.URL,(this.callBack?true:false));if((this.callBack?true:false)){this.request.onreadystatechange=function(F){return function(){F.onStateChange()}}(this)}if(typeof(this.request.setRequestHeader)!="undefined"){this.request.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}this.request.send((this.data&&this.data.length)?this.data:null);if(!this.callBack){return this.doParse()}};$_.__.XMLHttp.prototype.onStateChange=function(){if(this.request.readyState==4){if(!parseInt(this.request.status)||this.request.status==200){this.doParse()}else{if(typeof this.onError[this.request.status]=="function"){this.callBack(this.onError[this.request.status](this.URL))}return this.callBack(false)}}};$_.__.XMLHttp.prototype.doParse=function(){var parsed=null;if(this.request.status&&this.request.status!=200){if(typeof this.onError[this.request.status]=="function"){this.onError[this.request.status](this.URL)}else{return false}}else{var ct=this.request.getResponseHeader("Content-type");switch(ct){case"application/x-javascript":case"text/javascript":case"application/ecmascript":case"text/ecmascript":try{var detectChar=this.request.responseText.match(/\s*(.{1})/);var parsed=/[0-9{(['"]/.test(detectChar)?eval("("+this.request.responseText+")"):this.request.responseText}catch(e){if(e.name=="SyntaxError"){$_.raise("Transfer","Got syntax error in "+this.URL)}else{$_.raise("Transfer","Unknown error while parsing remote JS "+this.URL)}}break;default:parsed=this.request.responseText}this.parsed=parsed?parsed:null;if((typeof this.callBack)=="function"){this.callBack(this.parsed);this.callBack=null;return true}else{return this.parsed}}};$_.__.XMLHttp.prototype.onError={1403:function(A){$_.raise("Transfer","Acess denied while accessing "+A)},1404:function(A){$_.raise("Transfer","Not found while accessing "+A);return false}};$_.$_STR.$_.XMLHttp={accepts:function(A){return true},init:function(A){A.GET=function(B){return new $_.__.XMLHttp(A).async(B||null).parse()};A.POST=function(C,B){return new $_.__.XMLHttp(A,C||null).async(B||null).parse()};return A}};$_.$_DOM.$_.valueSetGet={accepts:function(A){return(["INPUT","SELECT","TEXTAREA"]).contains(A.tagName.toUpperCase())},init:function(A){A.VAL=function(C,F){if(!C){switch(A.tagName){case"SELECT":if(A.selectedIndex==-1){return false}if(A.multiple){var D=[];for(var E=0;E<A.options.length;E++){if(A.options[E].selected){D.push(A.options[E].value)}}return D}return A.options[A.selectedIndex].value;break;case"INPUT":if(A.type.toLowerCase()==="radio"&&A.form&&A.name){var B=A.form[A.name].length?A.form[A.name]:[A.form[A.name]];for(var E=0;E<B.length;E++){if(B[E].checked){return B[E].value}}return false}if(A.type.toLowerCase()=="checkbox"&&!A.checked){return false}default:return A.value}}else{switch(A.tagName){case"SELECT":for(var E=A.options.length-1;E>=0;E--){if(A.options[E].value==C){A.options[E].selected=true;break}}break;default:return A.value=C}}if(F){if(!$_.ie){var G=document.createEvent("HTMLEvents");G.initEvent("change",false,false);A.dispatchEvent(G)}else{A.fireEvent("onchange")}}};A.encode2URI=function(B){var C=A.VAL();return((A.name||B)&&(C!==false))?encodeURIComponent(A.name)+"="+encodeURIComponent(C):false};A.CRC32=function(){var B=A.encode2URI(1);return(B!==false)?$_(B).CRC32():false}}};$_.$_DOM.$_$_.valueSetGet={init:function(A){A.VAL=function(B){var C=A.length;if(!B){var E=[];var G={};for(var F=0;F<C;F++){if(A[F].type.toLowerCase()!=="radio"){var D=A[F].VAL();if(D!==false){E[E.length]=D}}else{if(!G[A.name]){G[A.name]=true;E[E.length]=A[F].VAL()}}}return $_(E)}else{for(var F=0;F<C;F++){if(A[F].type.toLowerCase()!=="radio"){}else{if(A[F].value==B){A[F].checked=true}}}}};A.encode2URI=function(){var B=A.length;var C=[];var F={};for(var D=0;D<B;D++){var E=false;if(A[D].type.toLowerCase()!=="radio"){E=A[D].encode2URI()}else{if(!F[A.name]){F[A.name]=true;E=A[D].encode2URI()}}if(E!==false){C[C.length]=A[D].encode2URI()}}return C.join("&")};A.CRC32=function(){var B=A.encode2URI();return(B!==false)?$_(B).CRC32():false}}};$_.$_DOM.$_.All={init:function(A){A.setLoading=function(){};A.$_T=function(C){var B=[];for(var D=0;D<arguments.length;D++){B.push($_.copy(A.getElementsByTagName(arguments[D])))}return B[1]?B:B[0]}}};$_.__.Mutation=function(A){this.element=A;this.FPS=30;this.duration=0;this.framesCount=0;this.movies=[];this.sequence=[]};$_.__.Mutation.prototype.set=function(F,E,C){var B=[];for(var A in F){var D=new $_.__.Mutagen();if(F[A]=="auto"){if(A=="height"){F[A]=this.element.offsetHeight+"px"}}if(D["__"+A]){if(typeof E[A]!=="undefined"){D["__"+A](F[A],E[A],C);B.push(D.movie)}}else{if(typeof E[A]!=="undefined"){D.__Number.apply(D,[A,F[A],E[A],C]);B.push(D.movie)}}}this.duration+=C*1000/this.FPS;this.sequence.push(B)};$_.__.Mutation.prototype.clear=function(){this.movies=[];this.sequence=[];this.duration=0};$_.__.Mutation.prototype.play=function(){if(this.paused||this.element.mutating){return}this.element.mutating=1;var I=[];for(var H=0;this.movies=this.sequence[H];H++){var G=this.movies[0].length;for(var E=0;E<G;E++){var C=this.movies.length;var F={};for(var B=0;B<C;B++){$_.extend(F,this.movies[B][E])}I[I.length]=F}}var A=I.length/this.FPS;var D=Math.ceil(A*1000/I.length);this.currentIndex=0;this.intId=setInterval(function(J,K){return function(){if(!J[K.currentIndex]){K.element.mutating=0;clearInterval(K.intId);K.currentIndex=0;if(K.isCyclic){K.play()}if(K.onPlay){K.onPlay()}return}K.element.CSS(J[K.currentIndex]);K.currentIndex+=1}}(I,this),D)};$_.__.Mutation.prototype._play=function(){if(this.paused||this.element.mutating){return}this.element.mutating=1;this.funcs=[];var E=0;var K=this;if(this.onPlay){setTimeout(function(){K.onPlay()},Math.ceil(this.duration))}setTimeout(function(){K.element.mutating=0},Math.ceil(this.duration));var J=null;var B=Math.ceil(1000/this.FPS);for(var I=0;this.movies=this.sequence[I];I++){var H=this.movies[0].length;for(var G=0;G<H;G++){var F=this.movies.length;for(var D=0;D<F;D++){var A=this.movies[D][G];if(J!=A){var C=function(M,L){return function(){M.CSS(L)}}(this.element,A);this.funcs.push(C);setTimeout(C,E+B*G)}var J=A}}E+=B*G}if(this.isCyclic){setTimeout(function(){K.play()},E)}};$_.__.Mutation.prototype.rewind=function(){if(this.paused||this.element.mutating){return}this.element.mutating=1;var E=0;var C=this;if(this.onRewind){setTimeout(function(){C.onRewind()},Math.ceil(this.duration))}setTimeout(function(){C.element.mutating=0},Math.ceil(this.duration));var B=Math.ceil(this.duration/this.funcs.length);var A=this.funcs.length;for(var D=0;this.funcs[D];D++){setTimeout(this.funcs[D],B*(A-D))}};$_.__.Mutation.prototype.pause=function(){this.paused=true};$_.__.Mutation.prototype.stop=function(){clearInterval(this.intId);this.element.mutating=0};$_.__.Mutation.prototype.unpause=function(){this.paused=false};$_.__.Mutagen=function(){this.movie=[]};$_.__.Mutagen.prototype.__backgroundColor=function(C,B,A){this.__Color.apply(this,["backgroundColor",C,B,A])};$_.__.Mutagen.prototype.__borderColor=function(C,B,A){this.__Color.apply(this,["borderColor",C,B,A])};$_.__.Mutagen.prototype.__color=function(C,B,A){this.__Color.apply(this,["color",C,B,A])};$_.__.Mutagen.prototype.__Color=function(D,O,N,C){var I=new RGBColor(O);var P=new RGBColor(N);var K=new RGBColor("red");var B=(P.r-I.r)/C;var J=(P.g-I.g)/C;var E=(P.b-I.b)/C;var A=I.r;var H=I.g;var M=I.b;var L="";for(var G=0;G<C;G++){A+=B;H+=J;M+=E;K.r=Math.round(A);K.g=Math.round(H);K.b=Math.round(M);var F={};F[D]=K.toHex();this.movie.push(F)}};$_.__.Mutagen.prototype.__eNumber=function(B,G,F,A){var I=G.toString().replace(/[\-0-9]+/,"");F=parseFloat(F);G=parseFloat(G);var H=(F-G)/A;var E=G;for(var D=0;D<A;D++){E+=H;var C={};C[B]=Math.round(E)+I;this.movie.push(C)}};$_.__.Mutagen.prototype.__Number=function(B,G,F,A){var I=G.toString().replace(/[\-0-9]+/,"");F=parseFloat(F);G=parseFloat(G);var H=(F-G)/A;var E=G;var J=I=="px"?1:100;for(var D=0;D<A;D++){E+=H;var C={};C[B]=Math.round(E*J)/J+I;this.movie.push(C)}};$_.$_DOM.$_.Mutation={init:function(A){A.mutate=function(){A.mutation=new $_.__.Mutation(A);var B=arguments.length-1;if(typeof arguments[B]=="function"){A.mutation.onPlay=function(G){return function(){G()}}(arguments[B]);B--}var F=Math.round(arguments[B]/(B-1));for(var D=0;D<B-1;D++){var E=arguments[D];var C=arguments[D+1];A.mutation.set(E,C,F)}A.mutation.play()};A.demutate=function(B){if(typeof B=="function"){A.mutation.onRewind=function(){B()}}A.mutation.rewind()}}};$_.$_DOM.$_$_.Mutation={init:function(A){A.mutate=function(){var C=A.length;var G=[];var D=arguments.length-1;if(typeof arguments[D]=="function"){var I=function(K){return function(){K()}}(arguments[D]);D--}var B=Math.round(arguments[D]/(D-1));for(var E=0;E<C;E++){A[E].mutation=new $_.__.Mutation(A[E]);for(var F=0;F<D-1;F++){var H=arguments[F];var J=arguments[F+1];A[E].mutation.set(H,J,B)}if(E==(C-1)){A[E].mutation.onPlay=I}G[E]=A[E].mutation}for(var F=0;F<C;F++){G[F].play()}};A.demutate=function(D){var B=A.length;for(var C=0;C<B;C++){if(typeof D=="function"&&(C==B-1)){A[C].mutation.onRewind=function(){D()}}A[C].mutation.rewind()}}}};if(!$_.ie){$_.$_DOM.$_.CSS={init:function(A){A.CSS=function(C){if(typeof C!="string"){for(var B in C){A.style[B]=C[B]}return A}else{return A.style[C]}};A.CSSSave=function(C){A.$_style={};for(var B in C){A.$_style[B]=C[B]}return A};A.CSSLoad=function(){for(var B in A.$_style){A.style[B]=A.$_style[B]}return A}}}}else{$_.$_DOM.$_.CSS={init:function(A){A.CSS=function(E){if(typeof E!="string"){for(var D in E){if("opacity"==D){var C=A.filters["DXImageTransform.Microsoft.alpha"]||A.filters.alpha;A.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+E[D]*100+")";A.style.zoom=A.style.zoom||1}else{A.style[D]=E[D]}}return A}else{if(E!="opacity"){return A.style[E]}var B=A.style.filter.match(/opacity=([0-9]+)/);if(B){return B[1]/100}}};A.CSSSave=function(C){A.$_style={};for(var B in C){A.$_style[B]=C[B]}return A};A.CSSLoad=function(){for(var B in A.$_style){A.style[B]=A.$_style[B]}return A}}}}$_.$_DOM.$_$_.CSS={init:function(A){A.CSS=function(C){for(var B=A.length-1;B>=0;B--){A[B].CSS(C)}return A}}};function RGBColor(A){this.ok=false;if(A.charAt(0)=="#"){A=A.substr(1,6)}A=A.replace(/ /g,"");A=A.toLowerCase();var C={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var E in C){if(A==E){A=C[E]}}var H=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(I){return[parseInt(I[1]),parseInt(I[2]),parseInt(I[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(I){return[parseInt(I[1],16),parseInt(I[2],16),parseInt(I[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(I){return[parseInt(I[1]+I[1],16),parseInt(I[2]+I[2],16),parseInt(I[3]+I[3],16)]}}];for(var D=0;D<H.length;D++){var F=H[D].re;var B=H[D].process;var G=F.exec(A);if(G){channels=B(G);this.r=channels[0];this.g=channels[1];this.b=channels[2];this.ok=true}}this.r=(this.r<0||isNaN(this.r))?0:((this.r>255)?255:this.r);this.g=(this.g<0||isNaN(this.g))?0:((this.g>255)?255:this.g);this.b=(this.b<0||isNaN(this.b))?0:((this.b>255)?255:this.b);this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"};this.toHex=function(){var K=this.r.toString(16);var J=this.g.toString(16);var I=this.b.toString(16);if(K.length==1){K="0"+K}if(J.length==1){J="0"+J}if(I.length==1){I="0"+I}return"#"+K+J+I}}$_.$_DOM.$_.Collection=$_.$_STR.$_.Collection=$_.$_OBJ.$_.Collection=$_.$_NUMBER.$_.Collection={init:function(A){A.apply=function(B){B(A)};return A}};Array.prototype.$_=function(){return this};Array.prototype.apply=function(C){var A=this.length;for(var B=0;B<A;B++){C(this[B])}return this};$_.$_STR.$_.DOMAccess={accepts:function(A){var B=A.charAt(0);return(B=="#"||B=="."||B=="~"||B=="@"||B==">")},init:function(H){var E=H.match(/[#.~@][a-z0-9_\-]+/ig);if(E.length>=2){var I=[];for(var F=0;F<E.length;F++){I[I.length]=$_(E[F])}return $_(I[0].intersects.apply(I[0],I.slice(1)))}switch(H.charAt(0)){case"#":var B=!$_.__[H]?$_(document.getElementById(H.substr(1))):$_.__[H];break;case"@":var B=$_(document.getElementsByName(H.substr(1)));break;case"~":var K=H.substr(1).toLowerCase();switch(K){case"checkbox":case"radio":case"password":case"image":case"text":var D=$_("~input");var B=[];for(var C=0;C<D.length;C++){if(D[C].type&&D[C].type==K){B[B.length]=D[C]}}B=$_(B);break;default:var B=$_(document.getElementsByTagName(K))}break;case".":var J=new Array();var D=document.getElementsByTagName("*");var G=D.length;var A=new RegExp("(^|\\s)"+H.substr(1)+"(\\s|$)");for(F=0,C=0;F<G;F++){if(A.test(D[F].className)){J[C]=D[F];C++}}var B=$_(J);break}return B}};$_.$_STR.$_$_.DOMAccess={init:function(A){var B=[];for(var C=0;C<A.length;C++){B[B.length]=$_.$_STR.$_.DOMAccess.init(A[C])}return B}};$_.$_DOM.$_.DOMAccess={init:function(A){A.$_=function(G){if(arguments.length>1){var I=[];for(var F=0;F<arguments.length;F++){I.push(A.$_(arguments[F]))}return $_(I)}var E=G.match(/[#.~@>][a-z0-9_\-\*]+/ig);if(E.length>=2){var H=[];for(var F=0;F<E.length;F++){H[H.length]=$_(E[F])}return $_(H[0].intersects.apply(H[0],H.slice(1)))}switch(G.charAt(0)){case"~":var J=G.substr(1).toLowerCase();switch(J){case"checkbox":case"radio":case"password":case"image":case"text":var D=A.$_("~input");var B=[];for(var C=0;C<D.length;C++){if(D[C].type&&D[C].type==J){B[B.length]=D[C]}}B=$_(B);break;default:var B=$_(A.getElementsByTagName(J))}break;case">":var B=[];var D=A.childNodes;for(var F=D.length-1;F>=0;F--){if(D[F].tagName){B.push(D[F])}}B.reverse();break;case"@":var B=(function(Q,P,L){var M=new Array();if(P==null){P=document}if(L==null){L="*"}var N=P.getElementsByTagName(L);var O=N.length;var K=new RegExp("(^|\\s)"+Q+"(\\s|$)");for(F=0,C=0;F<O;F++){if(K.test(N[F].name)){M[C]=N[F];C++}}return M})(G.substr(1),A,null);break;case".":var B=(function(M,Q,L){var P=new Array();if(Q==null){Q=document}if(L==null){L="*"}var N=Q.getElementsByTagName(L);var O=N.length;var K=new RegExp("(^|\\s)"+M+"(\\s|$)");for(F=0,C=0;F<O;F++){if(K.test(N[F].className)){P[C]=N[F];C++}}return P})(G.substr(1),A,null);break}return $_(B)};A.intersects=function(B){for(var C=0;C<B.length;C++){if(A==B[C]){return A}}return null}}};$_.$_DOM.$_$_.DOMAccess={init:function(A){A.$_=function(D){var B=[];for(var C=0;C<A.length;C++){B[B.length]=A[C].$_.apply(A[C],arguments)}return $_(B)};A.intersects=Array.prototype.intersects}};
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category AW
 * @package AW_Ajaxcartpro
 * @copyright Copyright (c) 2003-2009 aheadWorks Co. (http://www.aheadworks.com)
 * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */
 
var aw_cartDivClass = '.box base-mini mini-cart';
var aw_topLinkCartClass = '.top-link-cart';
var aw_addToCartButtonClass = '.form-button';
var aw_bigCartClass = '.col-main';

if (window.location.toString().search('/product_compare/') != -1){
 var win = window.opener;
}
else{
 var win = window;
}

function setLocation(url){
 if(AW_ACP.isCartPage && ((url.search('/add') != -1 ) || (url.search('/remove') != -1 )) ){
 ajaxcartsend(url+'awacp/1/is_checkout/1', 'url', '', '');
 }else if (url.search('checkout/cart/add') != -1 ){
 ajaxcartsend(url+'awacp/1', 'url', '', '');
 }else{
 window.location.href = url;
 }
}

var cnt1 = 20;
__intId = setInterval(
 /* Hangs event listener for @ADD TO CART@ links*/
 function(){
 cnt1--;
 if(typeof productAddToCartForm != 'undefined'){
 try {
 // This fix is applied to magento <1.3.1
 // $_('#product_addtocart_form').$_(aw_addToCartButtonClass).setAttribute('type', 'button');
 }catch(err){
 
 }
 productAddToCartForm.submit = function(url){
 if(this.validator && this.validator.validate()){ 
 ajaxcartsend('?awacp=1', 'form', this, '');
 }
 return false;
 }
 clearInterval(__intId);
 }
 if(!cnt1) clearInterval(__intId);
 },
 500
);

var cnt2 = 20;
__intId2 = setInterval(
 /* This hangs event listener on @DELETE@ items from cart*/
 function(){ 
 cnt2--;
 if(!$_(aw_cartDivClass).empty() || ((typeof AW_ACP !== 'undefined') && AW_ACP.isCartPage)){
 updateDeleteLinks();
 clearInterval(__intId2);
 }
 if(!cnt2) clearInterval(__intId);
 },
 500
);






function setPLocation(url, setFocus){
 if (url.search('checkout/cart/add') != -1){ //CART ADD
 window.opener.focus();
 ajaxcartsend(url+'/awacp/1', 'url', '');
 }
 else{
 if(setFocus) {
 window.opener.focus();
 }
 window.opener.location.href = url;
 }
}

function ajaxcartsend(url, type, obj){
 showProgressAnimation();
 if (type == 'form'){ 
 $_('#product_addtocart_form').action += url; 
 $_('#product_addtocart_form').POST( 
 function(resp){
 hideProgressAnimation(); 
 if (resp.r != 'success'){
 obj.form.submit();
 }
 else{
 if(AW_ACP.useConfirmation){ 
 showConfirmDialog(); 
 } 
 updateCartView(resp);
 }
 }
 );
 }
 if (type == 'url'){
 $_(url).GET(
 function(resp){
 hideProgressAnimation();
 if (resp.r != 'success'){
 win.location.href=url;
 }
 else{ 
 if(AW_ACP.useConfirmation){ 
 showConfirmDialog(); 
 } 
 updateCartView(resp);
 }
 }
 );
 }
}

function updateDeleteLinks(){
 var tmpLinks = document.links;//win.$_(aw_cartDivClass).getElementsByTagName('a',win.$_(aw_cartDivClass));
 for (i=0; i<tmpLinks.length; i++){
 if (tmpLinks[i].href.search('checkout/cart/delete') != -1){
 url = tmpLinks[i].href.replace(/\/uenc\/.+,/g, "");
 var del = url.match(/delete\/id\/\d+\//g);
 var id = del[0].match(/\d+/g);
 if (win.location.protocol == 'https:'){
 aw_base_url = aw_base_url.replace("http:", "https:");
 } 
 if(!AW_ACP.isCartPage){
 tmpLinks[i].href = 'javascript:ajaxcartprodelete("' + aw_base_url + 'ajaxcartpro/cart/remove/id/' + id +'")';
 }else{
 tmpLinks[i].href = 'javascript:ajaxcartprodelete("' + aw_base_url + 'ajaxcartpro/cart/remove/id/' + id +'/is_checkout/1")';
 }
 }
 }
}

function updateTopLinks(resp){
 // We don't need the top links to update since we're not using them.
 // win.$_(aw_topLinkCartClass).innerHTML = resp.links;
}

function updateCartView(resp){
 if(AW_ACP.isCartPage)
 return updateBigCartView(resp);
 var oldHeight = win.$_(aw_cartDivClass).offsetHeight;
 // Replacing this
 /*
 var tmpDiv = win.document.createElement('div');
 tmpDiv.innerHTML = resp.cart;
 
 var tmpParent = win.$_(aw_cartDivClass).parentNode;
 tmpParent.replaceChild(tmpDiv.firstChild, win.$_(aw_cartDivClass));
 */
 // with this
 updateQuickCart( resp.cart );
 //Details popup support
 truncateOptions();
 
 var newHeight = win.$_(aw_cartDivClass).offsetHeight;
 
 if (aw_ajaxcartpro_cartanim == 'opacity'){
 $_(win.$_(aw_cartDivClass)).mutate(
 {opacity:0}, 
 {opacity:1},
 30
 );
 }
 if (aw_ajaxcartpro_cartanim == 'grow'){
 $_(win.$_(aw_cartDivClass)).style.overflow = 'hidden';
 $_(win.$_(aw_cartDivClass)).mutate( 
 {opacity:0, height: oldHeight + 'px'},
 {opacity:1, height: newHeight + 'px'},
 30
 );
 }
 if (aw_ajaxcartpro_cartanim == 'blink'){
 $_(win.$_(aw_cartDivClass)).mutate(
 {opacity:0}, 
 {opacity:1},
 10
 );
 }
 updateDeleteLinks();
 updateTopLinks(resp);
}

function updateBigCartView(resp){
 $_(aw_bigCartClass).innerHTML = resp.cart
 if($_('#shopping-cart-table')){
 decorateTable('shopping-cart-table')
 }
 updateDeleteLinks();
 updateTopLinks(resp);
 updateAddLinks();
 // xb.js function to set up tier price blocks
 setupCartTierPrices();
}


function ajaxcartprodelete(url){ 
 showProgressAnimation();
 $_(url).GET(
 function(resp){ 
 hideProgressAnimation();
 updateCartView(resp, '');
 }
 );
}

function showProgressAnimation(){
 var pW = 260;
 var pH = 50;
 p = win.$_('.ajaxcartpro_progress');
 p.style.width = pW + 'px'; 
 p.style.height = pH + 'px';
 if ($_.ie && !navigator.appVersion.match("8")){
 p.style.position = 'absolute';
 }
 if (aw_ajaxcartpro_proganim == 'center'){ 
 p.style.top = (screen.height/2) - (pH) + 'px';
 }
 if (aw_ajaxcartpro_proganim == 'top'){ 
 p.style.top = '0px';
 }
 if (aw_ajaxcartpro_proganim == 'bottom'){
 p.style.bottom = '0px'; 
 }
 if (aw_ajaxcartpro_proganim != 'none'){
 p.style.display = 'block'; 
 }
 
}


function showConfirmDialog(){
 var pW = 260;
 var pH = 104;
 p = $_('.ajaxcartpro_confirm');
 p.style.width = pW + 'px'; 
 p.style.height = pH + 'px';
 
 if ($_.ie && !navigator.appVersion.match("8")){
 p.style.position = 'absolute';
 }else{
 p.style.position = 'fixed';
 if (aw_ajaxcartpro_proganim == 'center'){ 
 p.style.top = (screen.height/2) - (pH) + 'px';
 }
 if (aw_ajaxcartpro_proganim == 'top'){ 
 p.style.top = '0px';
 }
 if (aw_ajaxcartpro_proganim == 'bottom'){
 p.style.bottom = '0px'; 
 }
 }
 if (aw_ajaxcartpro_proganim != 'none'){
 p.style.display = 'block'; 
 }
}

function hideProgressAnimation(){
 $_('.ajaxcartpro_progress').style.display = 'none';
}

window.onload = function(){
 updateAddLinks()
 
 // Some other onclicks
 $_('#aw_acp_continue').onclick = function(e){
 e = e||event;
 if(e.preventDefault)
 e.preventDefault()
 $_('.ajaxcartpro_confirm').style.display='none'; return false;
 }
 
 $_('#aw_acp_checkout').onclick = function(e){
 $_('.ajaxcartpro_confirm').style.display='none'; return true;
 } 
 
 if(!$_(aw_cartDivClass).empty() || ((typeof AW_ACP !== 'undefined') && AW_ACP.isCartPage)){
 updateDeleteLinks();
 }
 
} 

function updateAddLinks(){
 var ats = document.links;
 for (i=ats.length-1; i>=0; i--){
 if (ats[i].href.search('checkout/cart/add') != -1){
 ats[i].onclick = function(link){
 return function(){
 setLocation(link)
 }
 }(ats[i].href);
 ats[i].href="javascript:void(0)";
 }
 }
}

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.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){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
 */
if(typeof Product=='undefined') {
 var Product = {};
}

/********************* IMAGE ZOOMER ***********************/

Product.Zoom = Class.create();
/**
 * Image zoom control
 *
 * @author Magento Core Team <core@magentocommerce.com>
 */
Product.Zoom.prototype = {
 initialize: function(imageEl, trackEl, handleEl, zoomInEl, zoomOutEl, hintEl){
 this.containerEl = $(imageEl).parentNode;
 this.imageEl = $(imageEl);
 this.handleEl = $(handleEl);
 this.trackEl = $(trackEl);
 this.hintEl = $(hintEl);

 this.containerDim = Element.getDimensions(this.containerEl);
 this.imageDim = Element.getDimensions(this.imageEl);

 this.imageDim.ratio = this.imageDim.width/this.imageDim.height;

 this.floorZoom = 1;

 if (this.imageDim.width > this.imageDim.height) {
 this.ceilingZoom = this.imageDim.width / this.containerDim.width;
 } else {
 this.ceilingZoom = this.imageDim.height / this.containerDim.height;
 }

 if (this.imageDim.width <= this.containerDim.width
 && this.imageDim.height <= this.containerDim.height) {
 this.trackEl.up().hide();
 this.hintEl.hide();
 this.containerEl.removeClassName('product-image-zoom');
 return;
 }

 this.imageX = 0;
 this.imageY = 0;
 this.imageZoom = 1;

 this.sliderSpeed = 0;
 this.sliderAccel = 0;
 this.zoomBtnPressed = false;

 this.showFull = false;

 this.selects = document.getElementsByTagName('select');

 this.draggable = new Draggable(imageEl, {
 starteffect:false,
 reverteffect:false,
 endeffect:false,
 snap:this.contain.bind(this)
 });

 this.slider = new Control.Slider(handleEl, trackEl, {
 axis:'horizontal',
 minimum:0,
 maximum:Element.getDimensions(this.trackEl).width,
 alignX:0,
 increment:1,
 sliderValue:0,
 onSlide:this.scale.bind(this),
 onChange:this.scale.bind(this)
 });

 this.scale(0);

 Event.observe(this.imageEl, 'dblclick', this.toggleFull.bind(this));

 Event.observe($(zoomInEl), 'mousedown', this.startZoomIn.bind(this));
 Event.observe($(zoomInEl), 'mouseup', this.stopZooming.bind(this));
 Event.observe($(zoomInEl), 'mouseout', this.stopZooming.bind(this));

 Event.observe($(zoomOutEl), 'mousedown', this.startZoomOut.bind(this));
 Event.observe($(zoomOutEl), 'mouseup', this.stopZooming.bind(this));
 Event.observe($(zoomOutEl), 'mouseout', this.stopZooming.bind(this));
 },

 toggleFull: function () {
 this.showFull = !this.showFull;
 //TODO: hide selects for IE only

 for (i=0; i<this.selects.length; i++) {
 this.selects[i].style.visibility = this.showFull ? 'hidden' : 'visible';
 }
 val_scale = !this.showFull ? this.slider.value : 1;
 this.scale(val_scale);

 this.trackEl.style.visibility = this.showFull ? 'hidden' : 'visible';
 this.containerEl.style.overflow = this.showFull ? 'visible' : 'hidden';
 this.containerEl.style.zIndex = this.showFull ? '1000' : '9';

 return this;
 },

 scale: function (v) {

 var centerX = (this.containerDim.width*(1-this.imageZoom)/2-this.imageX)/this.imageZoom;
 var centerY = (this.containerDim.height*(1-this.imageZoom)/2-this.imageY)/this.imageZoom;

 this.imageZoom = this.floorZoom+(v*(this.ceilingZoom-this.floorZoom));

 this.imageEl.style.width = (this.imageZoom*this.containerDim.width)+'px';
 if(this.containerDim.ratio){
 this.imageEl.style.height = (this.imageZoom*this.containerDim.width*this.containerDim.ratio)+'px'; // for safari
 }

 this.imageX = this.containerDim.width*(1-this.imageZoom)/2-centerX*this.imageZoom;
 this.imageY = this.containerDim.height*(1-this.imageZoom)/2-centerY*this.imageZoom;

 this.contain(this.imageX, this.imageY, this.draggable);

 return true;
 },

 startZoomIn: function()
 {
 this.zoomBtnPressed = true;
 this.sliderAccel = .002;
 this.periodicalZoom();
 this.zoomer = new PeriodicalExecuter(this.periodicalZoom.bind(this), .05);
 return this;
 },

 startZoomOut: function()
 {
 this.zoomBtnPressed = true;
 this.sliderAccel = -.002;
 this.periodicalZoom();
 this.zoomer = new PeriodicalExecuter(this.periodicalZoom.bind(this), .05);
 return this;
 },

 stopZooming: function()
 {
 if (!this.zoomer || this.sliderSpeed==0) {
 return;
 }
 this.zoomBtnPressed = false;
 this.sliderAccel = 0;
 },

 periodicalZoom: function()
 {
 if (!this.zoomer) {
 return this;
 }

 if (this.zoomBtnPressed) {
 this.sliderSpeed += this.sliderAccel;
 } else {
 this.sliderSpeed /= 1.5;
 if (Math.abs(this.sliderSpeed)<.001) {
 this.sliderSpeed = 0;
 this.zoomer.stop();
 this.zoomer = null;
 }
 }
 this.slider.value += this.sliderSpeed;

 this.slider.setValue(this.slider.value);
 this.scale(this.slider.value);

 return this;
 },

 contain: function (x,y,draggable) {

 var dim = Element.getDimensions(draggable.element);

 var xMin = 0, xMax = this.containerDim.width-dim.width;
 var yMin = 0, yMax = this.containerDim.height-dim.height;

 x = x>xMin ? xMin : x;
 x = x<xMax ? xMax : x;
 y = y>yMin ? yMin : y;
 y = y<yMax ? yMax : y;

 this.imageX = x;
 this.imageY = y;

 this.imageEl.style.left = this.imageX+'px';
 this.imageEl.style.top = this.imageY+'px';

 return [x,y];
 }
}

/**************************** CONFIGURABLE PRODUCT **************************/
Product.Config = Class.create();
Product.Config.prototype = {
 initialize: function(config){
 this.config = config;
 this.taxConfig = this.config.taxConfig;
 this.settings = $$('.super-attribute-select');
 this.state = new Hash();
 this.priceTemplate = new Template(this.config.template);
 this.prices = config.prices;

 this.settings.each(function(element){
 Event.observe(element, 'change', this.configure.bind(this))
 }.bind(this));

 // fill state
 this.settings.each(function(element){
 var attributeId = element.id.replace(/[a-z]*/, '');
 if(attributeId && this.config.attributes[attributeId]) {
 element.config = this.config.attributes[attributeId];
 element.attributeId = attributeId;
 this.state[attributeId] = false;
 }
 }.bind(this))

 // Init settings dropdown
 var childSettings = [];
 for(var i=this.settings.length-1;i>=0;i--){
 var prevSetting = this.settings[i-1] ? this.settings[i-1] : false;
 var nextSetting = this.settings[i+1] ? this.settings[i+1] : false;
 if(i==0){
 this.fillSelect(this.settings[i])
 }
 else {
 this.settings[i].disabled=true;
 }
 $(this.settings[i]).childSettings = childSettings.clone();
 $(this.settings[i]).prevSetting = prevSetting;
 $(this.settings[i]).nextSetting = nextSetting;
 childSettings.push(this.settings[i]);
 }

 // try retireve options from url
 var separatorIndex = window.location.href.indexOf('#');
 if (separatorIndex!=-1) {
 var paramsStr = window.location.href.substr(separatorIndex+1);
 this.values = paramsStr.toQueryParams();
 this.settings.each(function(element){
 var attributeId = element.attributeId;
 element.value = this.values[attributeId];
 this.configureElement(element);
 }.bind(this));
 }
 },

 configure: function(event){
 var element = Event.element(event);
 this.configureElement(element);
 },

 configureElement : function(element) {
 this.reloadOptionLabels(element);
 if(element.value){
 this.state[element.config.id] = element.value;
 if(element.nextSetting){
 element.nextSetting.disabled = false;
 this.fillSelect(element.nextSetting);
 this.resetChildren(element.nextSetting);
 }
 }
 else {
 this.resetChildren(element);
 }
 this.reloadPrice();
// Calculator.updatePrice();
 },

 reloadOptionLabels: function(element){
 var selectedPrice;
 if(element.options[element.selectedIndex].config){
 selectedPrice = parseFloat(element.options[element.selectedIndex].config.price)
 }
 else{
 selectedPrice = 0;
 }
 for(var i=0;i<element.options.length;i++){
 if(element.options[i].config){
 element.options[i].text = this.getOptionLabel(element.options[i].config, element.options[i].config.price-selectedPrice);
 }
 }
 },

 resetChildren : function(element){
 if(element.childSettings) {
 for(var i=0;i<element.childSettings.length;i++){
 element.childSettings[i].selectedIndex = 0;
 element.childSettings[i].disabled = true;
 if(element.config){
 this.state[element.config.id] = false;
 }
 }
 }
 },

 fillSelect: function(element){
 var attributeId = element.id.replace(/[a-z]*/, '');
 var options = this.getAttributeOptions(attributeId);
 this.clearSelect(element);
 element.options[0] = new Option(this.config.chooseText, '');

 var prevConfig = false;
 if(element.prevSetting){
 prevConfig = element.prevSetting.options[element.prevSetting.selectedIndex];
 }

 if(options) {
 var index = 1;
 for(var i=0;i<options.length;i++){
 var allowedProducts = [];
 if(prevConfig) {
 for(var j=0;j<options[i].products.length;j++){
 if(prevConfig.config.allowedProducts
 && prevConfig.config.allowedProducts.indexOf(options[i].products[j])>-1){
 allowedProducts.push(options[i].products[j]);
 }
 }
 } else {
 allowedProducts = options[i].products.clone();
 }

 if(allowedProducts.size()>0){
 options[i].allowedProducts = allowedProducts;
 element.options[index] = new Option(this.getOptionLabel(options[i], options[i].price), options[i].id);
 element.options[index].config = options[i];
 index++;
 }
 }
 }
 },

 getOptionLabel: function(option, price){
 var price = parseFloat(price);
 if (this.taxConfig.includeTax) {
 var tax = price / (100 + this.taxConfig.defaultTax) * this.taxConfig.defaultTax;
 var excl = price - tax;
 var incl = excl*(1+(this.taxConfig.currentTax/100));
 } else {
 var tax = price * (this.taxConfig.currentTax / 100);
 var excl = price;
 var incl = excl + tax;
 }

 if (this.taxConfig.showIncludeTax || this.taxConfig.showBothPrices) {
 price = incl;
 } else {
 price = excl;
 }

 var str = option.label;
 if(price){
 if (this.taxConfig.showBothPrices) {
 str+= ' ' + this.formatPrice(excl, true) + ' (' + this.formatPrice(price, true) + ' ' + this.taxConfig.inclTaxTitle + ')';
 } else {
 str+= ' ' + this.formatPrice(price, true);
 }
 }
 return str;
 },

 formatPrice: function(price, showSign){
 var str = '';
 price = parseFloat(price);
 if(showSign){
 if(price<0){
 str+= '-';
 price = -price;
 }
 else{
 str+= '+';
 }
 }

 var roundedPrice = (Math.round(price*100)/100).toString();

 if (this.prices && this.prices[roundedPrice]) {
 str+= this.prices[roundedPrice];
 }
 else {
 str+= this.priceTemplate.evaluate({price:price.toFixed(2)});
 }
 return str;
 },

 clearSelect: function(element){
 for(var i=element.options.length-1;i>=0;i--){
 element.remove(i);
 }
 },

 getAttributeOptions: function(attributeId){
 if(this.config.attributes[attributeId]){
 return this.config.attributes[attributeId].options;
 }
 },

 reloadPrice: function(){
 var price = 0;
 for(var i=this.settings.length-1;i>=0;i--){
 var selected = this.settings[i].options[this.settings[i].selectedIndex];
 if(selected.config){
 price += parseFloat(selected.config.price);
 }
 }

 optionsPrice.changePrice('config', price);
 optionsPrice.reload();

 return price;

 if($('product-price-'+this.config.productId)){
 $('product-price-'+this.config.productId).innerHTML = price;
 }
 this.reloadOldPrice();
 },

 reloadOldPrice: function(){
 if ($('old-price-'+this.config.productId)) {

 var price = parseFloat(this.config.oldPrice);
 for(var i=this.settings.length-1;i>=0;i--){
 var selected = this.settings[i].options[this.settings[i].selectedIndex];
 if(selected.config){
 price+= parseFloat(selected.config.price);
 }
 }
 if (price < 0)
 price = 0;
 price = this.formatPrice(price);

 if($('old-price-'+this.config.productId)){
 $('old-price-'+this.config.productId).innerHTML = price;
 }

 }
 }
}


/**************************** SUPER PRODUCTS ********************************/

Product.Super = {};
Product.Super.Configurable = Class.create();

Product.Super.Configurable.prototype = {
 initialize: function(container, observeCss, updateUrl, updatePriceUrl, priceContainerId) {
 this.container = $(container);
 this.observeCss = observeCss;
 this.updateUrl = updateUrl;
 this.updatePriceUrl = updatePriceUrl;
 this.priceContainerId = priceContainerId;
 this.registerObservers();
 },
 registerObservers: function() {
 var elements = this.container.getElementsByClassName(this.observeCss);
 elements.each(function(element){
 Event.observe(element, 'change', this.update.bindAsEventListener(this));
 }.bind(this));
 return this;
 },
 update: function(event) {
 var elements = this.container.getElementsByClassName(this.observeCss);
 var parameters = Form.serializeElements(elements, true);

 new Ajax.Updater(this.container, this.updateUrl + '?ajax=1', {
 parameters:parameters,
 onComplete:this.registerObservers.bind(this)
 });
 var priceContainer = $(this.priceContainerId);
 if(priceContainer) {
 new Ajax.Updater(priceContainer, this.updatePriceUrl + '?ajax=1', {
 parameters:parameters
 });
 }
 }
}

/**************************** PRICE RELOADER ********************************/
Product.OptionsPrice = Class.create();
Product.OptionsPrice.prototype = {
 initialize: function(config) {
 this.productId = config.productId;
 this.priceFormat = config.priceFormat;
 this.includeTax = config.includeTax;
 this.defaultTax = config.defaultTax;
 this.currentTax = config.currentTax;
 this.productPrice = config.productPrice;
 this.showIncludeTax = config.showIncludeTax;
 this.showBothPrices = config.showBothPrices;
 this.productPrice = config.productPrice;
 this.productOldPrice = config.productOldPrice;
 this.skipCalculate = config.skipCalculate;
 this.duplicateIdSuffix = config.idSuffix;

 this.oldPlusDisposition = config.oldPlusDisposition;
 this.plusDisposition = config.plusDisposition;

 this.oldMinusDisposition = config.oldMinusDisposition;
 this.minusDisposition = config.minusDisposition;

 this.optionPrices = {};
 this.containers = {};

 this.displayZeroPrice = true;

 this.initPrices();
 },

 setDuplicateIdSuffix: function(idSuffix) {
 this.duplicateIdSuffix = idSuffix;
 },

 initPrices: function() {
 this.containers[0] = 'product-price-' + this.productId;
 this.containers[1] = 'bundle-price-' + this.productId;
 this.containers[2] = 'price-including-tax-' + this.productId;
 this.containers[3] = 'price-excluding-tax-' + this.productId;
 this.containers[4] = 'old-price-' + this.productId;
 },

 changePrice: function(key, price) {
 this.optionPrices[key] = parseFloat(price);
 },

 getOptionPrices: function() {
 var result = 0;
 var nonTaxable = 0;
 $H(this.optionPrices).each(function(pair) {
 if (pair.key == 'nontaxable') {
 nonTaxable = pair.value;
 } else {
 result += pair.value;
 }
 });
 var r = new Array(result, nonTaxable);
 return r;
 },

 reload: function() {
 var price;
 var formattedPrice;
 var optionPrices = this.getOptionPrices();
 var nonTaxable = optionPrices[1];
 optionPrices = optionPrices[0];
 $H(this.containers).each(function(pair) {
 var _productPrice;
 var _plusDisposition;
 var _minusDisposition;
 if ($(pair.value)) {
 if (pair.value == 'old-price-'+this.productId && this.productOldPrice != this.productPrice) {
 _productPrice = this.productOldPrice;
 _plusDisposition = this.oldPlusDisposition;
 _minusDisposition = this.oldMinusDisposition;
 } else {
 _productPrice = this.productPrice;
 _plusDisposition = this.plusDisposition;
 _minusDisposition = this.minusDisposition;
 }

 var price = optionPrices+parseFloat(_productPrice)
 if (this.includeTax == 'true') {
 // tax = tax included into product price by admin
 var tax = price / (100 + this.defaultTax) * this.defaultTax;
 var excl = price - tax;
 var incl = excl*(1+(this.currentTax/100));
 } else {
 var tax = price * (this.currentTax / 100);
 var excl = price;
 var incl = excl + tax;
 }

 excl += parseFloat(_plusDisposition);
 incl += parseFloat(_plusDisposition);
 excl -= parseFloat(_minusDisposition);
 incl -= parseFloat(_minusDisposition);

 //adding nontaxlable part of options
 excl += parseFloat(nonTaxable);
 incl += parseFloat(nonTaxable);

 if (pair.value == 'price-including-tax-'+this.productId) {
 price = incl;
 } else if (pair.value == 'old-price-'+this.productId) {
 if (this.showIncludeTax || this.showBothPrices) {
 price = incl;
 } else {
 price = excl;
 }
 } else {
 if (this.showIncludeTax) {
 price = incl;
 } else {
 if (!this.skipCalculate || _productPrice == 0) {
 price = excl;
 } else {
 price = optionPrices+parseFloat(_productPrice);
 }
 }
 }

 if (price < 0) price = 0;

 if (price > 0 || this.displayZeroPrice) {
 formattedPrice = this.formatPrice(price);
 } else {
 formattedPrice = '';
 }

 if ($(pair.value).select('.price')[0]) {
 $(pair.value).select('.price')[0].innerHTML = formattedPrice;
 if ($(pair.value+this.duplicateIdSuffix) && $(pair.value+this.duplicateIdSuffix).select('.price')[0]) {
 $(pair.value+this.duplicateIdSuffix).select('.price')[0].innerHTML = formattedPrice;
 }
 } else {
 $(pair.value).innerHTML = formattedPrice;
 if ($(pair.value+this.duplicateIdSuffix)) {
 $(pair.value+this.duplicateIdSuffix).innerHTML = formattedPrice;
 }
 }
 };
 }.bind(this));
 },
 formatPrice: function(price) {
 return formatCurrency(price, this.priceFormat);
 }
}

/* Copyright Mihai Bazon, 2002-2005 | www.bazon.net/mishoo
 * -----------------------------------------------------------
 *
 * The DHTML Calendar, version 1.0 "It is happening again"
 *
 * Details and latest version at:
 * www.dynarch.com/projects/calendar
 *
 * This script is developed by Dynarch.com. Visit us at www.dynarch.com.
 *
 * This script is distributed under the GNU Lesser General Public License.
 * Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
 */

// $Id: calendar.js,v 1.51 2005/03/07 16:44:31 mishoo Exp $

/** The Calendar object constructor. */
Calendar = function (firstDayOfWeek, dateStr, onSelected, onClose) {
 // member variables
 this.activeDiv = null;
 this.currentDateEl = null;
 this.getDateStatus = null;
 this.getDateToolTip = null;
 this.getDateText = null;
 this.timeout = null;
 this.onSelected = onSelected || null;
 this.onClose = onClose || null;
 this.dragging = false;
 this.hidden = false;
 this.minYear = 1970;
 this.maxYear = 2050;
 this.dateFormat = Calendar._TT["DEF_DATE_FORMAT"];
 this.ttDateFormat = Calendar._TT["TT_DATE_FORMAT"];
 this.isPopup = true;
 this.weekNumbers = true;
 this.firstDayOfWeek = typeof firstDayOfWeek == "number" ? firstDayOfWeek : Calendar._FD; // 0 for Sunday, 1 for Monday, etc.
 this.showsOtherMonths = false;
 this.dateStr = dateStr;
 this.ar_days = null;
 this.showsTime = false;
 this.time24 = true;
 this.yearStep = 2;
 this.hiliteToday = true;
 this.multiple = null;
 // HTML elements
 this.table = null;
 this.element = null;
 this.tbody = null;
 this.firstdayname = null;
 // Combo boxes
 this.monthsCombo = null;
 this.yearsCombo = null;
 this.hilitedMonth = null;
 this.activeMonth = null;
 this.hilitedYear = null;
 this.activeYear = null;
 // Information
 this.dateClicked = false;

 // one-time initializations
 if (typeof Calendar._SDN == "undefined") {
 // table of short day names
 if (typeof Calendar._SDN_len == "undefined")
 Calendar._SDN_len = 3;
 var ar = new Array();
 for (var i = 8; i > 0;) {
 ar[--i] = Calendar._DN[i].substr(0, Calendar._SDN_len);
 }
 Calendar._SDN = ar;
 // table of short month names
 if (typeof Calendar._SMN_len == "undefined")
 Calendar._SMN_len = 3;
 ar = new Array();
 for (var i = 12; i > 0;) {
 ar[--i] = Calendar._MN[i].substr(0, Calendar._SMN_len);
 }
 Calendar._SMN = ar;
 }
};

// ** constants

/// "static", needed for event handlers.
Calendar._C = null;

/// detect a special case of "web browser"
Calendar.is_ie = ( /msie/i.test(navigator.userAgent) &&
 !/opera/i.test(navigator.userAgent) );

Calendar.is_ie5 = ( Calendar.is_ie && /msie 5\.0/i.test(navigator.userAgent) );

/// detect Opera browser
Calendar.is_opera = /opera/i.test(navigator.userAgent);

/// detect KHTML-based browsers
Calendar.is_khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);

/// detect Gecko browsers
Calendar.is_gecko = navigator.userAgent.match(/gecko/i);

// BEGIN: UTILITY FUNCTIONS; beware that these might be moved into a separate
// library, at some point.

// Returns CSS property for element
Calendar.getStyle = function(element, style) {
 if (element.currentStyle) {
 var y = element.currentStyle[style];
 } else if (window.getComputedStyle) {
 var y = document.defaultView.getComputedStyle(element,null).getPropertyValue(style);
 }

 return y;
};

/*
 * Different ways to find element's absolute position
 */
Calendar.getAbsolutePos = function(element) {

 var res = new Object();
 res.x = 0; res.y = 0;

 // variant 1 (working best, copy-paste from prototype library)
 do {
 res.x += element.offsetLeft || 0;
 res.y += element.offsetTop || 0;
 element = element.offsetParent;
 if (element) {
 if (element.tagName.toUpperCase() == 'BODY') break;
 var p = Calendar.getStyle(element, 'position');
 if (p !== 'static') break;
 }
 } while (element);

 return res;

 // variant 2 (good solution, but lost in IE8)
 if (element !== null) {
 res.x = element.offsetLeft;
 res.y = element.offsetTop;

 var offsetParent = element.offsetParent;
 var parentNode = element.parentNode;

 while (offsetParent !== null) {
 res.x += offsetParent.offsetLeft;
 res.y += offsetParent.offsetTop;

 if (offsetParent != document.body && offsetParent != document.documentElement) {
 res.x -= offsetParent.scrollLeft;
 res.y -= offsetParent.scrollTop;
 }
 //next lines are necessary to support FireFox problem with offsetParent
 if (Calendar.is_gecko) {
 while (offsetParent != parentNode && parentNode !== null) {
 res.x -= parentNode.scrollLeft;
 res.y -= parentNode.scrollTop;
 parentNode = parentNode.parentNode;
 }
 }
 parentNode = offsetParent.parentNode;
 offsetParent = offsetParent.offsetParent;
 }
 }
 return res;

 // variant 2 (not working)

// var SL = 0, ST = 0;
// var is_div = /^div$/i.test(el.tagName);
// if (is_div && el.scrollLeft)
// SL = el.scrollLeft;
// if (is_div && el.scrollTop)
// ST = el.scrollTop;
// var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
// if (el.offsetParent) {
// var tmp = this.getAbsolutePos(el.offsetParent);
// r.x += tmp.x;
// r.y += tmp.y;
// }
// return r;
};

Calendar.isRelated = function (el, evt) {
 var related = evt.relatedTarget;
 if (!related) {
 var type = evt.type;
 if (type == "mouseover") {
 related = evt.fromElement;
 } else if (type == "mouseout") {
 related = evt.toElement;
 }
 }
 while (related) {
 if (related == el) {
 return true;
 }
 related = related.parentNode;
 }
 return false;
};

Calendar.removeClass = function(el, className) {
 if (!(el && el.className)) {
 return;
 }
 var cls = el.className.split(" ");
 var ar = new Array();
 for (var i = cls.length; i > 0;) {
 if (cls[--i] != className) {
 ar[ar.length] = cls[i];
 }
 }
 el.className = ar.join(" ");
};

Calendar.addClass = function(el, className) {
 Calendar.removeClass(el, className);
 el.className += " " + className;
};

// FIXME: the following 2 functions totally suck, are useless and should be replaced immediately.
Calendar.getElement = function(ev) {
 var f = Calendar.is_ie ? window.event.srcElement : ev.currentTarget;
 while (f.nodeType != 1 || /^div$/i.test(f.tagName))
 f = f.parentNode;
 return f;
};

Calendar.getTargetElement = function(ev) {
 var f = Calendar.is_ie ? window.event.srcElement : ev.target;
 while (f.nodeType != 1)
 f = f.parentNode;
 return f;
};

Calendar.stopEvent = function(ev) {
 ev || (ev = window.event);
 if (Calendar.is_ie) {
 ev.cancelBubble = true;
 ev.returnValue = false;
 } else {
 ev.preventDefault();
 ev.stopPropagation();
 }
 return false;
};

Calendar.addEvent = function(el, evname, func) {
 if (el.attachEvent) { // IE
 el.attachEvent("on" + evname, func);
 } else if (el.addEventListener) { // Gecko / W3C
 el.addEventListener(evname, func, true);
 } else {
 el["on" + evname] = func;
 }
};

Calendar.removeEvent = function(el, evname, func) {
 if (el.detachEvent) { // IE
 el.detachEvent("on" + evname, func);
 } else if (el.removeEventListener) { // Gecko / W3C
 el.removeEventListener(evname, func, true);
 } else {
 el["on" + evname] = null;
 }
};

Calendar.createElement = function(type, parent) {
 var el = null;
 if (document.createElementNS) {
 // use the XHTML namespace; IE won't normally get here unless
 // _they_ "fix" the DOM2 implementation.
 el = document.createElementNS("http://www.w3.org/1999/xhtml", type);
 } else {
 el = document.createElement(type);
 }
 if (typeof parent != "undefined") {
 parent.appendChild(el);
 }
 return el;
};

// END: UTILITY FUNCTIONS

// BEGIN: CALENDAR STATIC FUNCTIONS

/** Internal -- adds a set of events to make some element behave like a button. */
Calendar._add_evs = function(el) {
 with (Calendar) {
 addEvent(el, "mouseover", dayMouseOver);
 addEvent(el, "mousedown", dayMouseDown);
 addEvent(el, "mouseout", dayMouseOut);
 if (is_ie) {
 addEvent(el, "dblclick", dayMouseDblClick);
 el.setAttribute("unselectable", true);
 }
 }
};

Calendar.findMonth = function(el) {
 if (typeof el.month != "undefined") {
 return el;
 } else if (typeof el.parentNode.month != "undefined") {
 return el.parentNode;
 }
 return null;
};

Calendar.findYear = function(el) {
 if (typeof el.year != "undefined") {
 return el;
 } else if (typeof el.parentNode.year != "undefined") {
 return el.parentNode;
 }
 return null;
};

Calendar.showMonthsCombo = function () {
 var cal = Calendar._C;
 if (!cal) {
 return false;
 }
 var cal = cal;
 var cd = cal.activeDiv;
 var mc = cal.monthsCombo;
 if (cal.hilitedMonth) {
 Calendar.removeClass(cal.hilitedMonth, "hilite");
 }
 if (cal.activeMonth) {
 Calendar.removeClass(cal.activeMonth, "active");
 }
 var mon = cal.monthsCombo.getElementsByTagName("div")[cal.date.getMonth()];
 Calendar.addClass(mon, "active");
 cal.activeMonth = mon;
 var s = mc.style;
 s.display = "block";
 if (cd.navtype < 0)
 s.left = cd.offsetLeft + "px";
 else {
 var mcw = mc.offsetWidth;
 if (typeof mcw == "undefined")
 // Konqueror brain-dead techniques
 mcw = 50;
 s.left = (cd.offsetLeft + cd.offsetWidth - mcw) + "px";
 }
 s.top = (cd.offsetTop + cd.offsetHeight) + "px";
};

Calendar.showYearsCombo = function (fwd) {
 var cal = Calendar._C;
 if (!cal) {
 return false;
 }
 var cal = cal;
 var cd = cal.activeDiv;
 var yc = cal.yearsCombo;
 if (cal.hilitedYear) {
 Calendar.removeClass(cal.hilitedYear, "hilite");
 }
 if (cal.activeYear) {
 Calendar.removeClass(cal.activeYear, "active");
 }
 cal.activeYear = null;
 var Y = cal.date.getFullYear() + (fwd ? 1 : -1);
 var yr = yc.firstChild;
 var show = false;
 for (var i = 12; i > 0; --i) {
 if (Y >= cal.minYear && Y <= cal.maxYear) {
 yr.innerHTML = Y;
 yr.year = Y;
 yr.style.display = "block";
 show = true;
 } else {
 yr.style.display = "none";
 }
 yr = yr.nextSibling;
 Y += fwd ? cal.yearStep : -cal.yearStep;
 }
 if (show) {
 var s = yc.style;
 s.display = "block";
 if (cd.navtype < 0)
 s.left = cd.offsetLeft + "px";
 else {
 var ycw = yc.offsetWidth;
 if (typeof ycw == "undefined")
 // Konqueror brain-dead techniques
 ycw = 50;
 s.left = (cd.offsetLeft + cd.offsetWidth - ycw) + "px";
 }
 s.top = (cd.offsetTop + cd.offsetHeight) + "px";
 }
};

// event handlers

Calendar.tableMouseUp = function(ev) {
 var cal = Calendar._C;
 if (!cal) {
 return false;
 }
 if (cal.timeout) {
 clearTimeout(cal.timeout);
 }
 var el = cal.activeDiv;
 if (!el) {
 return false;
 }
 var target = Calendar.getTargetElement(ev);
 ev || (ev = window.event);
 Calendar.removeClass(el, "active");
 if (target == el || target.parentNode == el) {
 Calendar.cellClick(el, ev);
 }
 var mon = Calendar.findMonth(target);
 var date = null;
 if (mon) {
 date = new CalendarDateObject(cal.date);
 if (mon.month != date.getMonth()) {
 date.setMonth(mon.month);
 cal.setDate(date);
 cal.dateClicked = false;
 cal.callHandler();
 }
 } else {
 var year = Calendar.findYear(target);
 if (year) {
 date = new CalendarDateObject(cal.date);
 if (year.year != date.getFullYear()) {
 date.setFullYear(year.year);
 cal.setDate(date);
 cal.dateClicked = false;
 cal.callHandler();
 }
 }
 }
 with (Calendar) {
 removeEvent(document, "mouseup", tableMouseUp);
 removeEvent(document, "mouseover", tableMouseOver);
 removeEvent(document, "mousemove", tableMouseOver);
 cal._hideCombos();
 _C = null;
 return stopEvent(ev);
 }
};

Calendar.tableMouseOver = function (ev) {
 var cal = Calendar._C;
 if (!cal) {
 return;
 }
 var el = cal.activeDiv;
 var target = Calendar.getTargetElement(ev);
 if (target == el || target.parentNode == el) {
 Calendar.addClass(el, "hilite active");
 Calendar.addClass(el.parentNode, "rowhilite");
 } else {
 if (typeof el.navtype == "undefined" || (el.navtype != 50 && (el.navtype == 0 || Math.abs(el.navtype) > 2)))
 Calendar.removeClass(el, "active");
 Calendar.removeClass(el, "hilite");
 Calendar.removeClass(el.parentNode, "rowhilite");
 }
 ev || (ev = window.event);
 if (el.navtype == 50 && target != el) {
 var pos = Calendar.getAbsolutePos(el);
 var w = el.offsetWidth;
 var x = ev.clientX;
 var dx;
 var decrease = true;
 if (x > pos.x + w) {
 dx = x - pos.x - w;
 decrease = false;
 } else
 dx = pos.x - x;

 if (dx < 0) dx = 0;
 var range = el._range;
 var current = el._current;
 var count = Math.floor(dx / 10) % range.length;
 for (var i = range.length; --i >= 0;)
 if (range[i] == current)
 break;
 while (count-- > 0)
 if (decrease) {
 if (--i < 0)
 i = range.length - 1;
 } else if ( ++i >= range.length )
 i = 0;
 var newval = range[i];
 el.innerHTML = newval;

 cal.onUpdateTime();
 }
 var mon = Calendar.findMonth(target);
 if (mon) {
 if (mon.month != cal.date.getMonth()) {
 if (cal.hilitedMonth) {
 Calendar.removeClass(cal.hilitedMonth, "hilite");
 }
 Calendar.addClass(mon, "hilite");
 cal.hilitedMonth = mon;
 } else if (cal.hilitedMonth) {
 Calendar.removeClass(cal.hilitedMonth, "hilite");
 }
 } else {
 if (cal.hilitedMonth) {
 Calendar.removeClass(cal.hilitedMonth, "hilite");
 }
 var year = Calendar.findYear(target);
 if (year) {
 if (year.year != cal.date.getFullYear()) {
 if (cal.hilitedYear) {
 Calendar.removeClass(cal.hilitedYear, "hilite");
 }
 Calendar.addClass(year, "hilite");
 cal.hilitedYear = year;
 } else if (cal.hilitedYear) {
 Calendar.removeClass(cal.hilitedYear, "hilite");
 }
 } else if (cal.hilitedYear) {
 Calendar.removeClass(cal.hilitedYear, "hilite");
 }
 }
 return Calendar.stopEvent(ev);
};

Calendar.tableMouseDown = function (ev) {
 if (Calendar.getTargetElement(ev) == Calendar.getElement(ev)) {
 return Calendar.stopEvent(ev);
 }
};

Calendar.calDragIt = function (ev) {
 var cal = Calendar._C;
 if (!(cal && cal.dragging)) {
 return false;
 }
 var posX;
 var posY;
 if (Calendar.is_ie) {
 posY = window.event.clientY + document.body.scrollTop;
 posX = window.event.clientX + document.body.scrollLeft;
 } else {
 posX = ev.pageX;
 posY = ev.pageY;
 }
 cal.hideShowCovered();
 var st = cal.element.style;
 st.left = (posX - cal.xOffs) + "px";
 st.top = (posY - cal.yOffs) + "px";
 return Calendar.stopEvent(ev);
};

Calendar.calDragEnd = function (ev) {
 var cal = Calendar._C;
 if (!cal) {
 return false;
 }
 cal.dragging = false;
 with (Calendar) {
 removeEvent(document, "mousemove", calDragIt);
 removeEvent(document, "mouseup", calDragEnd);
 tableMouseUp(ev);
 }
 cal.hideShowCovered();
};

Calendar.dayMouseDown = function(ev) {
 var el = Calendar.getElement(ev);
 if (el.disabled) {
 return false;
 }
 var cal = el.calendar;
 cal.activeDiv = el;
 Calendar._C = cal;
 if (el.navtype != 300) with (Calendar) {
 if (el.navtype == 50) {
 el._current = el.innerHTML;
 addEvent(document, "mousemove", tableMouseOver);
 } else
 addEvent(document, Calendar.is_ie5 ? "mousemove" : "mouseover", tableMouseOver);
 addClass(el, "hilite active");
 addEvent(document, "mouseup", tableMouseUp);
 } else if (cal.isPopup) {
 cal._dragStart(ev);
 }
 if (el.navtype == -1 || el.navtype == 1) {
 if (cal.timeout) clearTimeout(cal.timeout);
 cal.timeout = setTimeout("Calendar.showMonthsCombo()", 250);
 } else if (el.navtype == -2 || el.navtype == 2) {
 if (cal.timeout) clearTimeout(cal.timeout);
 cal.timeout = setTimeout((el.navtype > 0) ? "Calendar.showYearsCombo(true)" : "Calendar.showYearsCombo(false)", 250);
 } else {
 cal.timeout = null;
 }
 return Calendar.stopEvent(ev);
};

Calendar.dayMouseDblClick = function(ev) {
 Calendar.cellClick(Calendar.getElement(ev), ev || window.event);
 if (Calendar.is_ie) {
 document.selection.empty();
 }
};

Calendar.dayMouseOver = function(ev) {
 var el = Calendar.getElement(ev);
 if (Calendar.isRelated(el, ev) || Calendar._C || el.disabled) {
 return false;
 }
 if (el.ttip) {
 if (el.ttip.substr(0, 1) == "_") {
 el.ttip = el.caldate.print(el.calendar.ttDateFormat) + el.ttip.substr(1);
 }
 el.calendar.tooltips.innerHTML = el.ttip;
 }
 if (el.navtype != 300) {
 Calendar.addClass(el, "hilite");
 if (el.caldate) {
 Calendar.addClass(el.parentNode, "rowhilite");
 }
 }
 return Calendar.stopEvent(ev);
};

Calendar.dayMouseOut = function(ev) {
 with (Calendar) {
 var el = getElement(ev);
 if (isRelated(el, ev) || _C || el.disabled)
 return false;
 removeClass(el, "hilite");
 if (el.caldate)
 removeClass(el.parentNode, "rowhilite");
 if (el.calendar)
 el.calendar.tooltips.innerHTML = _TT["SEL_DATE"];
 return stopEvent(ev);
 }
};

/**
 * A generic "click" handler :) handles all types of buttons defined in this
 * calendar.
 */
Calendar.cellClick = function(el, ev) {
 var cal = el.calendar;
 var closing = false;
 var newdate = false;
 var date = null;
 if (typeof el.navtype == "undefined") {
 if (cal.currentDateEl) {
 Calendar.removeClass(cal.currentDateEl, "selected");
 Calendar.addClass(el, "selected");
 closing = (cal.currentDateEl == el);
 if (!closing) {
 cal.currentDateEl = el;
 }
 }
 cal.date.setDateOnly(el.caldate);
 date = cal.date;
 var other_month = !(cal.dateClicked = !el.otherMonth);
 if (!other_month && !cal.currentDateEl)
 cal._toggleMultipleDate(new CalendarDateObject(date));
 else
 newdate = !el.disabled;
 // a date was clicked
 if (other_month)
 cal._init(cal.firstDayOfWeek, date);
 } else {
 if (el.navtype == 200) {
 Calendar.removeClass(el, "hilite");
 cal.callCloseHandler();
 return;
 }
 date = new CalendarDateObject(cal.date);
 if (el.navtype == 0)
 date.setDateOnly(new CalendarDateObject()); // TODAY
 // unless "today" was clicked, we assume no date was clicked so
 // the selected handler will know not to close the calenar when
 // in single-click mode.
 // cal.dateClicked = (el.navtype == 0);
 cal.dateClicked = false;
 var year = date.getFullYear();
 var mon = date.getMonth();
 function setMonth(m) {
 var day = date.getDate();
 var max = date.getMonthDays(m);
 if (day > max) {
 date.setDate(max);
 }
 date.setMonth(m);
 };
 switch (el.navtype) {
 case 400:
 Calendar.removeClass(el, "hilite");
 var text = Calendar._TT["ABOUT"];
 if (typeof text != "undefined") {
 text += cal.showsTime ? Calendar._TT["ABOUT_TIME"] : "";
 } else {
 // FIXME: this should be removed as soon as lang files get updated!
 text = "Help and about box text is not translated into this language.\n" +
 "If you know this language and you feel generous please update\n" +
 "the corresponding file in \"lang\" subdir to match calendar-en.js\n" +
 "and send it back to <mihai_bazon@yahoo.com> to get it into the distribution ;-)\n\n" +
 "Thank you!\n" +
 "http://dynarch.com/mishoo/calendar.epl\n";
 }
 alert(text);
 return;
 case -2:
 if (year > cal.minYear) {
 date.setFullYear(year - 1);
 }
 break;
 case -1:
 if (mon > 0) {
 setMonth(mon - 1);
 } else if (year-- > cal.minYear) {
 date.setFullYear(year);
 setMonth(11);
 }
 break;
 case 1:
 if (mon < 11) {
 setMonth(mon + 1);
 } else if (year < cal.maxYear) {
 date.setFullYear(year + 1);
 setMonth(0);
 }
 break;
 case 2:
 if (year < cal.maxYear) {
 date.setFullYear(year + 1);
 }
 break;
 case 100:
 cal.setFirstDayOfWeek(el.fdow);
 return;
 case 50:
 var range = el._range;
 var current = el.innerHTML;
 for (var i = range.length; --i >= 0;)
 if (range[i] == current)
 break;
 if (ev && ev.shiftKey) {
 if (--i < 0)
 i = range.length - 1;
 } else if ( ++i >= range.length )
 i = 0;
 var newval = range[i];
 el.innerHTML = newval;
 cal.onUpdateTime();
 return;
 case 0:
 // TODAY will bring us here
 if ((typeof cal.getDateStatus == "function") &&
 cal.getDateStatus(date, date.getFullYear(), date.getMonth(), date.getDate())) {
 return false;
 }
 break;
 }
 if (!date.equalsTo(cal.date)) {
 cal.setDate(date);
 newdate = true;
 } else if (el.navtype == 0)
 newdate = closing = true;
 }
 if (newdate) {
 ev && cal.callHandler();
 }
 if (closing) {
 Calendar.removeClass(el, "hilite");
 ev && cal.callCloseHandler();
 }
};

// END: CALENDAR STATIC FUNCTIONS

// BEGIN: CALENDAR OBJECT FUNCTIONS

/**
 * This function creates the calendar inside the given parent. If _par is
 * null than it creates a popup calendar inside the BODY element. If _par is
 * an element, be it BODY, then it creates a non-popup calendar (still
 * hidden). Some properties need to be set before calling this function.
 */
Calendar.prototype.create = function (_par) {
 var parent = null;
 if (! _par) {
 // default parent is the document body, in which case we create
 // a popup calendar.
 parent = document.getElementsByTagName("body")[0];
 this.isPopup = true;
 } else {
 parent = _par;
 this.isPopup = false;
 }
 this.date = this.dateStr ? new CalendarDateObject(this.dateStr) : new CalendarDateObject();

 var table = Calendar.createElement("table");
 this.table = table;
 table.cellSpacing = 0;
 table.cellPadding = 0;
 table.calendar = this;
 Calendar.addEvent(table, "mousedown", Calendar.tableMouseDown);

 var div = Calendar.createElement("div");
 this.element = div;
 div.className = "calendar";
 if (this.isPopup) {
 div.style.position = "absolute";
 div.style.display = "none";
 }
 div.appendChild(table);

 var thead = Calendar.createElement("thead", table);
 var cell = null;
 var row = null;

 var cal = this;
 var hh = function (text, cs, navtype) {
 cell = Calendar.createElement("td", row);
 cell.colSpan = cs;
 cell.className = "button";
 if (navtype != 0 && Math.abs(navtype) <= 2)
 cell.className += " nav";
 Calendar._add_evs(cell);
 cell.calendar = cal;
 cell.navtype = navtype;
 cell.innerHTML = "<div unselectable='on'>" + text + "</div>";
 return cell;
 };

 row = Calendar.createElement("tr", thead);
 var title_length = 6;
 (this.isPopup) && --title_length;
 (this.weekNumbers) && ++title_length;

 hh("?", 1, 400).ttip = Calendar._TT["INFO"];
 this.title = hh("", title_length, 300);
 this.title.className = "title";
 if (this.isPopup) {
 this.title.ttip = Calendar._TT["DRAG_TO_MOVE"];
 this.title.style.cursor = "move";
 hh("&#x00d7;", 1, 200).ttip = Calendar._TT["CLOSE"];
 }

 row = Calendar.createElement("tr", thead);
 row.className = "headrow";

 this._nav_py = hh("&#x00ab;", 1, -2);
 this._nav_py.ttip = Calendar._TT["PREV_YEAR"];

 this._nav_pm = hh("&#x2039;", 1, -1);
 this._nav_pm.ttip = Calendar._TT["PREV_MONTH"];

 this._nav_now = hh(Calendar._TT["TODAY"], this.weekNumbers ? 4 : 3, 0);
 this._nav_now.ttip = Calendar._TT["GO_TODAY"];

 this._nav_nm = hh("&#x203a;", 1, 1);
 this._nav_nm.ttip = Calendar._TT["NEXT_MONTH"];

 this._nav_ny = hh("&#x00bb;", 1, 2);
 this._nav_ny.ttip = Calendar._TT["NEXT_YEAR"];

 // day names
 row = Calendar.createElement("tr", thead);
 row.className = "daynames";
 if (this.weekNumbers) {
 cell = Calendar.createElement("td", row);
 cell.className = "name wn";
 cell.innerHTML = Calendar._TT["WK"];
 }
 for (var i = 7; i > 0; --i) {
 cell = Calendar.createElement("td", row);
 if (!i) {
 cell.navtype = 100;
 cell.calendar = this;
 Calendar._add_evs(cell);
 }
 }
 this.firstdayname = (this.weekNumbers) ? row.firstChild.nextSibling : row.firstChild;
 this._displayWeekdays();

 var tbody = Calendar.createElement("tbody", table);
 this.tbody = tbody;

 for (i = 6; i > 0; --i) {
 row = Calendar.createElement("tr", tbody);
 if (this.weekNumbers) {
 cell = Calendar.createElement("td", row);
 }
 for (var j = 7; j > 0; --j) {
 cell = Calendar.createElement("td", row);
 cell.calendar = this;
 Calendar._add_evs(cell);
 }
 }

 if (this.showsTime) {
 row = Calendar.createElement("tr", tbody);
 row.className = "time";

 cell = Calendar.createElement("td", row);
 cell.className = "time";
 cell.colSpan = 2;
 cell.innerHTML = Calendar._TT["TIME"] || "&nbsp;";

 cell = Calendar.createElement("td", row);
 cell.className = "time";
 cell.colSpan = this.weekNumbers ? 4 : 3;

 (function(){
 function makeTimePart(className, init, range_start, range_end) {
 var part = Calendar.createElement("span", cell);
 part.className = className;
 part.innerHTML = init;
 part.calendar = cal;
 part.ttip = Calendar._TT["TIME_PART"];
 part.navtype = 50;
 part._range = [];
 if (typeof range_start != "number")
 part._range = range_start;
 else {
 for (var i = range_start; i <= range_end; ++i) {
 var txt;
 if (i < 10 && range_end >= 10) txt = '0' + i;
 else txt = '' + i;
 part._range[part._range.length] = txt;
 }
 }
 Calendar._add_evs(part);
 return part;
 };
 var hrs = cal.date.getHours();
 var mins = cal.date.getMinutes();
 var t12 = !cal.time24;
 var pm = (hrs > 12);
 if (t12 && pm) hrs -= 12;
 var H = makeTimePart("hour", hrs, t12 ? 1 : 0, t12 ? 12 : 23);
 var span = Calendar.createElement("span", cell);
 span.innerHTML = ":";
 span.className = "colon";
 var M = makeTimePart("minute", mins, 0, 59);
 var AP = null;
 cell = Calendar.createElement("td", row);
 cell.className = "time";
 cell.colSpan = 2;
 if (t12)
 AP = makeTimePart("ampm", pm ? "pm" : "am", ["am", "pm"]);
 else
 cell.innerHTML = "&nbsp;";

 cal.onSetTime = function() {
 var pm, hrs = this.date.getHours(),
 mins = this.date.getMinutes();
 if (t12) {
 pm = (hrs >= 12);
 if (pm) hrs -= 12;
 if (hrs == 0) hrs = 12;
 AP.innerHTML = pm ? "pm" : "am";
 }
 H.innerHTML = (hrs < 10) ? ("0" + hrs) : hrs;
 M.innerHTML = (mins < 10) ? ("0" + mins) : mins;
 };

 cal.onUpdateTime = function() {
 var date = this.date;
 var h = parseInt(H.innerHTML, 10);
 if (t12) {
 if (/pm/i.test(AP.innerHTML) && h < 12)
 h += 12;
 else if (/am/i.test(AP.innerHTML) && h == 12)
 h = 0;
 }
 var d = date.getDate();
 var m = date.getMonth();
 var y = date.getFullYear();
 date.setHours(h);
 date.setMinutes(parseInt(M.innerHTML, 10));
 date.setFullYear(y);
 date.setMonth(m);
 date.setDate(d);
 this.dateClicked = false;
 this.callHandler();
 };
 })();
 } else {
 this.onSetTime = this.onUpdateTime = function() {};
 }

 var tfoot = Calendar.createElement("tfoot", table);

 row = Calendar.createElement("tr", tfoot);
 row.className = "footrow";

 cell = hh(Calendar._TT["SEL_DATE"], this.weekNumbers ? 8 : 7, 300);
 cell.className = "ttip";
 if (this.isPopup) {
 cell.ttip = Calendar._TT["DRAG_TO_MOVE"];
 cell.style.cursor = "move";
 }
 this.tooltips = cell;

 div = Calendar.createElement("div", this.element);
 this.monthsCombo = div;
 div.className = "combo";
 for (i = 0; i < Calendar._MN.length; ++i) {
 var mn = Calendar.createElement("div");
 mn.className = Calendar.is_ie ? "label-IEfix" : "label";
 mn.month = i;
 mn.innerHTML = Calendar._SMN[i];
 div.appendChild(mn);
 }

 div = Calendar.createElement("div", this.element);
 this.yearsCombo = div;
 div.className = "combo";
 for (i = 12; i > 0; --i) {
 var yr = Calendar.createElement("div");
 yr.className = Calendar.is_ie ? "label-IEfix" : "label";
 div.appendChild(yr);
 }

 this._init(this.firstDayOfWeek, this.date);
 parent.appendChild(this.element);
};

/** keyboard navigation, only for popup calendars */
Calendar._keyEvent = function(ev) {
 var cal = window._dynarch_popupCalendar;
 if (!cal || cal.multiple)
 return false;
 (Calendar.is_ie) && (ev = window.event);
 var act = (Calendar.is_ie || ev.type == "keypress"),
 K = ev.keyCode;
 if (ev.ctrlKey) {
 switch (K) {
 case 37: // KEY left
 act && Calendar.cellClick(cal._nav_pm);
 break;
 case 38: // KEY up
 act && Calendar.cellClick(cal._nav_py);
 break;
 case 39: // KEY right
 act && Calendar.cellClick(cal._nav_nm);
 break;
 case 40: // KEY down
 act && Calendar.cellClick(cal._nav_ny);
 break;
 default:
 return false;
 }
 } else switch (K) {
 case 32: // KEY space (now)
 Calendar.cellClick(cal._nav_now);
 break;
 case 27: // KEY esc
 act && cal.callCloseHandler();
 break;
 case 37: // KEY left
 case 38: // KEY up
 case 39: // KEY right
 case 40: // KEY down
 if (act) {
 var prev, x, y, ne, el, step;
 prev = K == 37 || K == 38;
 step = (K == 37 || K == 39) ? 1 : 7;
 function setVars() {
 el = cal.currentDateEl;
 var p = el.pos;
 x = p & 15;
 y = p >> 4;
 ne = cal.ar_days[y][x];
 };setVars();
 function prevMonth() {
 var date = new CalendarDateObject(cal.date);
 date.setDate(date.getDate() - step);
 cal.setDate(date);
 };
 function nextMonth() {
 var date = new CalendarDateObject(cal.date);
 date.setDate(date.getDate() + step);
 cal.setDate(date);
 };
 while (1) {
 switch (K) {
 case 37: // KEY left
 if (--x >= 0)
 ne = cal.ar_days[y][x];
 else {
 x = 6;
 K = 38;
 continue;
 }
 break;
 case 38: // KEY up
 if (--y >= 0)
 ne = cal.ar_days[y][x];
 else {
 prevMonth();
 setVars();
 }
 break;
 case 39: // KEY right
 if (++x < 7)
 ne = cal.ar_days[y][x];
 else {
 x = 0;
 K = 40;
 continue;
 }
 break;
 case 40: // KEY down
 if (++y < cal.ar_days.length)
 ne = cal.ar_days[y][x];
 else {
 nextMonth();
 setVars();
 }
 break;
 }
 break;
 }
 if (ne) {
 if (!ne.disabled)
 Calendar.cellClick(ne);
 else if (prev)
 prevMonth();
 else
 nextMonth();
 }
 }
 break;
 case 13: // KEY enter
 if (act)
 Calendar.cellClick(cal.currentDateEl, ev);
 break;
 default:
 return false;
 }
 return Calendar.stopEvent(ev);
};

/**
 * (RE)Initializes the calendar to the given date and firstDayOfWeek
 */
Calendar.prototype._init = function (firstDayOfWeek, date) {
 var today = new CalendarDateObject(),
 TY = today.getFullYear(),
 TM = today.getMonth(),
 TD = today.getDate();
 this.table.style.visibility = "hidden";
 var year = date.getFullYear();
 if (year < this.minYear) {
 year = this.minYear;
 date.setFullYear(year);
 } else if (year > this.maxYear) {
 year = this.maxYear;
 date.setFullYear(year);
 }
 this.firstDayOfWeek = firstDayOfWeek;
 this.date = new CalendarDateObject(date);
 var month = date.getMonth();
 var mday = date.getDate();
 var no_days = date.getMonthDays();

 // calendar voodoo for computing the first day that would actually be
 // displayed in the calendar, even if it's from the previous month.
 // WARNING: this is magic. ;-)
 date.setDate(1);
 var day1 = (date.getDay() - this.firstDayOfWeek) % 7;
 if (day1 < 0)
 day1 += 7;
 date.setDate(-day1);
 date.setDate(date.getDate() + 1);

 var row = this.tbody.firstChild;
 var MN = Calendar._SMN[month];
 var ar_days = this.ar_days = new Array();
 var weekend = Calendar._TT["WEEKEND"];
 var dates = this.multiple ? (this.datesCells = {}) : null;
 for (var i = 0; i < 6; ++i, row = row.nextSibling) {
 var cell = row.firstChild;
 if (this.weekNumbers) {
 cell.className = "day wn";
 cell.innerHTML = date.getWeekNumber();
 cell = cell.nextSibling;
 }
 row.className = "daysrow";
 var hasdays = false, iday, dpos = ar_days[i] = [];
 for (var j = 0; j < 7; ++j, cell = cell.nextSibling, date.setDate(iday + 1)) {
 iday = date.getDate();
 var wday = date.getDay();
 cell.className = "day";
 cell.pos = i << 4 | j;
 dpos[j] = cell;
 var current_month = (date.getMonth() == month);
 if (!current_month) {
 if (this.showsOtherMonths) {
 cell.className += " othermonth";
 cell.otherMonth = true;
 } else {
 cell.className = "emptycell";
 cell.innerHTML = "&nbsp;";
 cell.disabled = true;
 continue;
 }
 } else {
 cell.otherMonth = false;
 hasdays = true;
 }
 cell.disabled = false;
 cell.innerHTML = this.getDateText ? this.getDateText(date, iday) : iday;
 if (dates)
 dates[date.print("%Y%m%d")] = cell;
 if (this.getDateStatus) {
 var status = this.getDateStatus(date, year, month, iday);
 if (this.getDateToolTip) {
 var toolTip = this.getDateToolTip(date, year, month, iday);
 if (toolTip)
 cell.title = toolTip;
 }
 if (status === true) {
 cell.className += " disabled";
 cell.disabled = true;
 } else {
 if (/disabled/i.test(status))
 cell.disabled = true;
 cell.className += " " + status;
 }
 }
 if (!cell.disabled) {
 cell.caldate = new CalendarDateObject(date);
 cell.ttip = "_";
 if (!this.multiple && current_month
 && iday == mday && this.hiliteToday) {
 cell.className += " selected";
 this.currentDateEl = cell;
 }
 if (date.getFullYear() == TY &&
 date.getMonth() == TM &&
 iday == TD) {
 cell.className += " today";
 cell.ttip += Calendar._TT["PART_TODAY"];
 }
 if (weekend.indexOf(wday.toString()) != -1)
 cell.className += cell.otherMonth ? " oweekend" : " weekend";
 }
 }
 if (!(hasdays || this.showsOtherMonths))
 row.className = "emptyrow";
 }
 this.title.innerHTML = Calendar._MN[month] + ", " + year;
 this.onSetTime();
 this.table.style.visibility = "visible";
 this._initMultipleDates();
 // PROFILE
 // this.tooltips.innerHTML = "Generated in " + ((new CalendarDateObject()) - today) + " ms";
};

Calendar.prototype._initMultipleDates = function() {
 if (this.multiple) {
 for (var i in this.multiple) {
 var cell = this.datesCells[i];
 var d = this.multiple[i];
 if (!d)
 continue;
 if (cell)
 cell.className += " selected";
 }
 }
};

Calendar.prototype._toggleMultipleDate = function(date) {
 if (this.multiple) {
 var ds = date.print("%Y%m%d");
 var cell = this.datesCells[ds];
 if (cell) {
 var d = this.multiple[ds];
 if (!d) {
 Calendar.addClass(cell, "selected");
 this.multiple[ds] = date;
 } else {
 Calendar.removeClass(cell, "selected");
 delete this.multiple[ds];
 }
 }
 }
};

Calendar.prototype.setDateToolTipHandler = function (unaryFunction) {
 this.getDateToolTip = unaryFunction;
};

/**
 * Calls _init function above for going to a certain date (but only if the
 * date is different than the currently selected one).
 */
Calendar.prototype.setDate = function (date) {
 if (!date.equalsTo(this.date)) {
 this._init(this.firstDayOfWeek, date);
 }
};

/**
 * Refreshes the calendar. Useful if the "disabledHandler" function is
 * dynamic, meaning that the list of disabled date can change at runtime.
 * Just * call this function if you think that the list of disabled dates
 * should * change.
 */
Calendar.prototype.refresh = function () {
 this._init(this.firstDayOfWeek, this.date);
};

/** Modifies the "firstDayOfWeek" parameter (pass 0 for Synday, 1 for Monday, etc.). */
Calendar.prototype.setFirstDayOfWeek = function (firstDayOfWeek) {
 this._init(firstDayOfWeek, this.date);
 this._displayWeekdays();
};

/**
 * Allows customization of what dates are enabled. The "unaryFunction"
 * parameter must be a function object that receives the date (as a JS Date
 * object) and returns a boolean value. If the returned value is true then
 * the passed date will be marked as disabled.
 */
Calendar.prototype.setDateStatusHandler = Calendar.prototype.setDisabledHandler = function (unaryFunction) {
 this.getDateStatus = unaryFunction;
};

/** Customization of allowed year range for the calendar. */
Calendar.prototype.setRange = function (a, z) {
 this.minYear = a;
 this.maxYear = z;
};

/** Calls the first user handler (selectedHandler). */
Calendar.prototype.callHandler = function () {
 if (this.onSelected) {
 this.onSelected(this, this.date.print(this.dateFormat));
 }
};

/** Calls the second user handler (closeHandler). */
Calendar.prototype.callCloseHandler = function () {
 if (this.onClose) {
 this.onClose(this);
 }
 this.hideShowCovered();
};

/** Removes the calendar object from the DOM tree and destroys it. */
Calendar.prototype.destroy = function () {
 var el = this.element.parentNode;
 el.removeChild(this.element);
 Calendar._C = null;
 window._dynarch_popupCalendar = null;
};

/**
 * Moves the calendar element to a different section in the DOM tree (changes
 * its parent).
 */
Calendar.prototype.reparent = function (new_parent) {
 var el = this.element;
 el.parentNode.removeChild(el);
 new_parent.appendChild(el);
};

// This gets called when the user presses a mouse button anywhere in the
// document, if the calendar is shown. If the click was outside the open
// calendar this function closes it.
Calendar._checkCalendar = function(ev) {
 var calendar = window._dynarch_popupCalendar;
 if (!calendar) {
 return false;
 }
 var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
 for (; el != null && el != calendar.element; el = el.parentNode);
 if (el == null) {
 // calls closeHandler which should hide the calendar.
 window._dynarch_popupCalendar.callCloseHandler();
 return Calendar.stopEvent(ev);
 }
};

/** Shows the calendar. */
Calendar.prototype.show = function () {
 var rows = this.table.getElementsByTagName("tr");
 for (var i = rows.length; i > 0;) {
 var row = rows[--i];
 Calendar.removeClass(row, "rowhilite");
 var cells = row.getElementsByTagName("td");
 for (var j = cells.length; j > 0;) {
 var cell = cells[--j];
 Calendar.removeClass(cell, "hilite");
 Calendar.removeClass(cell, "active");
 }
 }
 this.element.style.display = "block";
 this.hidden = false;
 if (this.isPopup) {
 window._dynarch_popupCalendar = this;
 Calendar.addEvent(document, "keydown", Calendar._keyEvent);
 Calendar.addEvent(document, "keypress", Calendar._keyEvent);
 Calendar.addEvent(document, "mousedown", Calendar._checkCalendar);
 }
 this.hideShowCovered();
};

/**
 * Hides the calendar. Also removes any "hilite" from the class of any TD
 * element.
 */
Calendar.prototype.hide = function () {
 if (this.isPopup) {
 Calendar.removeEvent(document, "keydown", Calendar._keyEvent);
 Calendar.removeEvent(document, "keypress", Calendar._keyEvent);
 Calendar.removeEvent(document, "mousedown", Calendar._checkCalendar);
 }
 this.element.style.display = "none";
 this.hidden = true;
 this.hideShowCovered();
};

/**
 * Shows the calendar at a given absolute position (beware that, depending on
 * the calendar element style -- position property -- this might be relative
 * to the parent's containing rectangle).
 */
Calendar.prototype.showAt = function (x, y) {
 var s = this.element.style;
 s.left = x + "px";
 s.top = y + "px";
 this.show();
};

/** Shows the calendar near a given element. */
Calendar.prototype.showAtElement = function (el, opts) {
 var self = this;
 var p = Calendar.getAbsolutePos(el);
 if (!opts || typeof opts != "string") {
 this.showAt(p.x, p.y + el.offsetHeight);
 return true;
 }
 function fixPosition(box) {
 if (box.x < 0)
 box.x = 0;
 if (box.y < 0)
 box.y = 0;
 var cp = document.createElement("div");
 var s = cp.style;
 s.position = "absolute";
 s.right = s.bottom = s.width = s.height = "0px";
 document.body.appendChild(cp);
 var br = Calendar.getAbsolutePos(cp);
 document.body.removeChild(cp);
 if (Calendar.is_ie) {
 br.y += document.body.scrollTop;
 br.x += document.body.scrollLeft;
 } else {
 br.y += window.scrollY;
 br.x += window.scrollX;
 }
 var tmp = box.x + box.width - br.x;
 if (tmp > 0) box.x -= tmp;
 tmp = box.y + box.height - br.y;
 if (tmp > 0) box.y -= tmp;
 };
 this.element.style.display = "block";
 Calendar.continuation_for_the_fucking_khtml_browser = function() {
 var w = self.element.offsetWidth;
 var h = self.element.offsetHeight;
 self.element.style.display = "none";
 var valign = opts.substr(0, 1);
 var halign = "l";
 if (opts.length > 1) {
 halign = opts.substr(1, 1);
 }
 // vertical alignment
 switch (valign) {
 case "T": p.y -= h; break;
 case "B": p.y += el.offsetHeight; break;
 case "C": p.y += (el.offsetHeight - h) / 2; break;
 case "t": p.y += el.offsetHeight - h; break;
 case "b": break; // already there
 }
 // horizontal alignment
 switch (halign) {
 case "L": p.x -= w; break;
 case "R": p.x += el.offsetWidth; break;
 case "C": p.x += (el.offsetWidth - w) / 2; break;
 case "l": p.x += el.offsetWidth - w; break;
 case "r": break; // already there
 }
 p.width = w;
 p.height = h + 40;
 self.monthsCombo.style.display = "none";
 fixPosition(p);
 self.showAt(p.x, p.y);
 };
 if (Calendar.is_khtml)
 setTimeout("Calendar.continuation_for_the_fucking_khtml_browser()", 10);
 else
 Calendar.continuation_for_the_fucking_khtml_browser();
};

/** Customizes the date format. */
Calendar.prototype.setDateFormat = function (str) {
 this.dateFormat = str;
};

/** Customizes the tooltip date format. */
Calendar.prototype.setTtDateFormat = function (str) {
 this.ttDateFormat = str;
};

/**
 * Tries to identify the date represented in a string. If successful it also
 * calls this.setDate which moves the calendar to the given date.
 */
Calendar.prototype.parseDate = function(str, fmt) {
 if (!fmt)
 fmt = this.dateFormat;
 this.setDate(Date.parseDate(str, fmt));
};

Calendar.prototype.hideShowCovered = function () {
 if (!Calendar.is_ie && !Calendar.is_opera)
 return;
 function getVisib(obj){
 var value = obj.style.visibility;
 if (!value) {
 if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C
 if (!Calendar.is_khtml)
 value = document.defaultView.
 getComputedStyle(obj, "").getPropertyValue("visibility");
 else
 value = '';
 } else if (obj.currentStyle) { // IE
 value = obj.currentStyle.visibility;
 } else
 value = '';
 }
 return value;
 };

 var tags = new Array("applet", "iframe", "select");
 var el = this.element;

 var p = Calendar.getAbsolutePos(el);
 var EX1 = p.x;
 var EX2 = el.offsetWidth + EX1;
 var EY1 = p.y;
 var EY2 = el.offsetHeight + EY1;

 for (var k = tags.length; k > 0; ) {
 var ar = document.getElementsByTagName(tags[--k]);
 var cc = null;

 for (var i = ar.length; i > 0;) {
 cc = ar[--i];

 p = Calendar.getAbsolutePos(cc);
 var CX1 = p.x;
 var CX2 = cc.offsetWidth + CX1;
 var CY1 = p.y;
 var CY2 = cc.offsetHeight + CY1;

 if (this.hidden || (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) {
 if (!cc.__msh_save_visibility) {
 cc.__msh_save_visibility = getVisib(cc);
 }
 cc.style.visibility = cc.__msh_save_visibility;
 } else {
 if (!cc.__msh_save_visibility) {
 cc.__msh_save_visibility = getVisib(cc);
 }
 cc.style.visibility = "hidden";
 }
 }
 }
};

/** Internal function; it displays the bar with the names of the weekday. */
Calendar.prototype._displayWeekdays = function () {
 var fdow = this.firstDayOfWeek;
 var cell = this.firstdayname;
 var weekend = Calendar._TT["WEEKEND"];
 for (var i = 0; i < 7; ++i) {
 cell.className = "day name";
 var realday = (i + fdow) % 7;
 if (i) {
 cell.ttip = Calendar._TT["DAY_FIRST"].replace("%s", Calendar._DN[realday]);
 cell.navtype = 100;
 cell.calendar = this;
 cell.fdow = realday;
 Calendar._add_evs(cell);
 }
 if (weekend.indexOf(realday.toString()) != -1) {
 Calendar.addClass(cell, "weekend");
 }
 cell.innerHTML = Calendar._SDN[(i + fdow) % 7];
 cell = cell.nextSibling;
 }
};

/** Internal function. Hides all combo boxes that might be displayed. */
Calendar.prototype._hideCombos = function () {
 this.monthsCombo.style.display = "none";
 this.yearsCombo.style.display = "none";
};

/** Internal function. Starts dragging the element. */
Calendar.prototype._dragStart = function (ev) {
 if (this.dragging) {
 return;
 }
 this.dragging = true;
 var posX;
 var posY;
 if (Calendar.is_ie) {
 posY = window.event.clientY + document.body.scrollTop;
 posX = window.event.clientX + document.body.scrollLeft;
 } else {
 posY = ev.clientY + window.scrollY;
 posX = ev.clientX + window.scrollX;
 }
 var st = this.element.style;
 this.xOffs = posX - parseInt(st.left);
 this.yOffs = posY - parseInt(st.top);
 with (Calendar) {
 addEvent(document, "mousemove", calDragIt);
 addEvent(document, "mouseup", calDragEnd);
 }
};

// BEGIN: DATE OBJECT PATCHES

/** Adds the number of days array to the Date object. */
Date._MD = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

/** Constants used for time computations */
Date.SECOND = 1000 /* milliseconds */;
Date.MINUTE = 60 * Date.SECOND;
Date.HOUR = 60 * Date.MINUTE;
Date.DAY = 24 * Date.HOUR;
Date.WEEK = 7 * Date.DAY;

Date.parseDate = function(str, fmt) {
 var today = new CalendarDateObject();
 var y = 0;
 var m = -1;
 var d = 0;

 // translate date into en_US, because split() cannot parse non-latin stuff
 var a = str;
 var i;
 for (i = 0; i < Calendar._MN.length; i++) {
 a = a.replace(Calendar._MN[i], enUS.m.wide[i]);
 }
 for (i = 0; i < Calendar._SMN.length; i++) {
 a = a.replace(Calendar._SMN[i], enUS.m.abbr[i]);
 }
 a = a.replace(Calendar._am, 'am');
 a = a.replace(Calendar._am.toLowerCase(), 'am');
 a = a.replace(Calendar._pm, 'pm');
 a = a.replace(Calendar._pm.toLowerCase(), 'pm');

 a = a.split(/\W+/);

 var b = fmt.match(/%./g);
 var i = 0, j = 0;
 var hr = 0;
 var min = 0;
 for (i = 0; i < a.length; ++i) {
 if (!a[i])
 continue;
 switch (b[i]) {
 case "%d":
 case "%e":
 d = parseInt(a[i], 10);
 break;

 case "%m":
 m = parseInt(a[i], 10) - 1;
 break;

 case "%Y":
 case "%y":
 y = parseInt(a[i], 10);
 (y < 100) && (y += (y > 29) ? 1900 : 2000);
 break;

 case "%b":
 for (j = 0; j < 12; ++j) {
 if (enUS.m.abbr[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { m = j; break; }
 }
 break;

 case "%B":
 for (j = 0; j < 12; ++j) {
 if (enUS.m.wide[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { m = j; break; }
 }
 break;

 case "%H":
 case "%I":
 case "%k":
 case "%l":
 hr = parseInt(a[i], 10);
 break;

 case "%P":
 case "%p":
 if (/pm/i.test(a[i]) && hr < 12)
 hr += 12;
 else if (/am/i.test(a[i]) && hr >= 12)
 hr -= 12;
 break;

 case "%M":
 min = parseInt(a[i], 10);
 break;
 }
 }
 if (isNaN(y)) y = today.getFullYear();
 if (isNaN(m)) m = today.getMonth();
 if (isNaN(d)) d = today.getDate();
 if (isNaN(hr)) hr = today.getHours();
 if (isNaN(min)) min = today.getMinutes();
 if (y != 0 && m != -1 && d != 0)
 return new CalendarDateObject(y, m, d, hr, min, 0);
 y = 0; m = -1; d = 0;
 for (i = 0; i < a.length; ++i) {
 if (a[i].search(/[a-zA-Z]+/) != -1) {
 var t = -1;
 for (j = 0; j < 12; ++j) {
 if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { t = j; break; }
 }
 if (t != -1) {
 if (m != -1) {
 d = m+1;
 }
 m = t;
 }
 } else if (parseInt(a[i], 10) <= 12 && m == -1) {
 m = a[i]-1;
 } else if (parseInt(a[i], 10) > 31 && y == 0) {
 y = parseInt(a[i], 10);
 (y < 100) && (y += (y > 29) ? 1900 : 2000);
 } else if (d == 0) {
 d = a[i];
 }
 }
 if (y == 0)
 y = today.getFullYear();
 if (m != -1 && d != 0)
 return new CalendarDateObject(y, m, d, hr, min, 0);
 return today;
};

/** Returns the number of days in the current month */
Date.prototype.getMonthDays = function(month) {
 var year = this.getFullYear();
 if (typeof month == "undefined") {
 month = this.getMonth();
 }
 if (((0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))) && month == 1) {
 return 29;
 } else {
 return Date._MD[month];
 }
};

/** Returns the number of day in the year. */
Date.prototype.getDayOfYear = function() {
 var now = new CalendarDateObject(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
 var then = new CalendarDateObject(this.getFullYear(), 0, 0, 0, 0, 0);
 var time = now - then;
 return Math.floor(time / Date.DAY);
};

/** Returns the number of the week in year, as defined in ISO 8601. */
Date.prototype.getWeekNumber = function() {
 var d = new CalendarDateObject(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
 var DoW = d.getDay();
 d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu
 var ms = d.valueOf(); // GMT
 d.setMonth(0);
 d.setDate(4); // Thu in Week 1
 return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;
};

/** Checks date and time equality */
Date.prototype.equalsTo = function(date) {
 return ((this.getFullYear() == date.getFullYear()) &&
 (this.getMonth() == date.getMonth()) &&
 (this.getDate() == date.getDate()) &&
 (this.getHours() == date.getHours()) &&
 (this.getMinutes() == date.getMinutes()));
};

/** Set only the year, month, date parts (keep existing time) */
Date.prototype.setDateOnly = function(date) {
 var tmp = new CalendarDateObject(date);
 this.setDate(1);
 this.setFullYear(tmp.getFullYear());
 this.setMonth(tmp.getMonth());
 this.setDate(tmp.getDate());
};

/** Prints the date in a string according to the given format. */
Date.prototype.print = function (str) {
 var m = this.getMonth();
 var d = this.getDate();
 var y = this.getFullYear();
 var wn = this.getWeekNumber();
 var w = this.getDay();
 var s = {};
 var hr = this.getHours();
 var pm = (hr >= 12);
 var ir = (pm) ? (hr - 12) : hr;
 var dy = this.getDayOfYear();
 if (ir == 0)
 ir = 12;
 var min = this.getMinutes();
 var sec = this.getSeconds();
 s["%a"] = Calendar._SDN[w]; // abbreviated weekday name [FIXME: I18N]
 s["%A"] = Calendar._DN[w]; // full weekday name
 s["%b"] = Calendar._SMN[m]; // abbreviated month name [FIXME: I18N]
 s["%B"] = Calendar._MN[m]; // full month name
 // FIXME: %c : preferred date and time representation for the current locale
 s["%C"] = 1 + Math.floor(y / 100); // the century number
 s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31)
 s["%e"] = d; // the day of the month (range 1 to 31)
 // FIXME: %D : american date style: %m/%d/%y
 // FIXME: %E, %F, %G, %g, %h (man strftime)
 s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format)
 s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format)
 s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
 s["%k"] = hr; // hour, range 0 to 23 (24h format)
 s["%l"] = ir; // hour, range 1 to 12 (12h format)
 s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
 s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
 s["%n"] = "\n"; // a newline character
 s["%p"] = pm ? Calendar._pm.toUpperCase() : Calendar._am.toUpperCase();
 s["%P"] = pm ? Calendar._pm.toLowerCase() : Calendar._am.toLowerCase();
 // FIXME: %r : the time in am/pm notation %I:%M:%S %p
 // FIXME: %R : the time in 24-hour notation %H:%M
 s["%s"] = Math.floor(this.getTime() / 1000);
 s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59
 s["%t"] = "\t"; // a tab character
 // FIXME: %T : the time in 24-hour notation (%H:%M:%S)
 s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn;
 s["%u"] = w + 1; // the day of the week (range 1 to 7, 1 = MON)
 s["%w"] = w; // the day of the week (range 0 to 6, 0 = SUN)
 // FIXME: %x : preferred date representation for the current locale without the time
 // FIXME: %X : preferred time representation for the current locale without the date
 s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99)
 s["%Y"] = y; // year with the century
 s["%%"] = "%"; // a literal '%' character

 var re = /%./g;
 if (!Calendar.is_ie5 && !Calendar.is_khtml)
 return str.replace(re, function (par) { return s[par] || par; });

 var a = str.match(re);
 for (var i = 0; i < a.length; i++) {
 var tmp = s[a[i]];
 if (tmp) {
 re = new RegExp(a[i], 'g');
 str = str.replace(re, tmp);
 }
 }

 return str;
};

Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear;
Date.prototype.setFullYear = function(y) {
 var d = new CalendarDateObject(this);
 d.__msh_oldSetFullYear(y);
 if (d.getMonth() != this.getMonth())
 this.setDate(28);
 this.__msh_oldSetFullYear(y);
};

CalendarDateObject.prototype = new Date();
CalendarDateObject.prototype.constructor = CalendarDateObject;
CalendarDateObject.prototype.parent = Date.prototype;
function CalendarDateObject() {
 var dateObj;
 if (arguments.length > 1) {
 dateObj = eval("new this.parent.constructor("+Array.prototype.slice.call(arguments).join(",")+");");
 } else if (arguments.length > 0) {
 dateObj = new this.parent.constructor(arguments[0]);
 } else {
 dateObj = new this.parent.constructor();
 if (typeof(CalendarDateObject._LOCAL_TIMZEONE_OFFSET_SECONDS) != "undefined") {
 dateObj.setTime(dateObj.getTime()+(CalendarDateObject._LOCAL_TIMZEONE_OFFSET_SECONDS - dateObj.getTimezoneOffset())*1000);
 }
 }
 return dateObj;
}

// END: DATE OBJECT PATCHES


// global object that remembers the calendar
window._dynarch_popupCalendar = null;

/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/
 * ---------------------------------------------------------------------------
 *
 * The DHTML Calendar
 *
 * Details and latest version at:
 * http://dynarch.com/mishoo/calendar.epl
 *
 * This script is distributed under the GNU Lesser General Public License.
 * Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
 *
 * This file defines helper functions for setting up the calendar. They are
 * intended to help non-programmers get a working calendar on their site
 * quickly. This script should not be seen as part of the calendar. It just
 * shows you what one can do with the calendar, while in the same time
 * providing a quick and simple method for setting it up. If you need
 * exhaustive customization of the calendar creation process feel free to
 * modify this code to suit your needs (this is recommended and much better
 * than modifying calendar.js itself).
 */
 Calendar.setup=function(params){function param_default(pname,def){if(typeof params[pname]=="undefined"){params[pname]=def;}};param_default("inputField",null);param_default("displayArea",null);param_default("button",null);param_default("eventName","click");param_default("ifFormat","%Y/%m/%d");param_default("daFormat","%Y/%m/%d");param_default("singleClick",true);param_default("disableFunc",null);param_default("dateStatusFunc",params["disableFunc"]);param_default("dateText",null);param_default("firstDay",null);param_default("align","Br");param_default("range",[1900,2999]);param_default("weekNumbers",true);param_default("flat",null);param_default("flatCallback",null);param_default("onSelect",null);param_default("onClose",null);param_default("onUpdate",null);param_default("date",null);param_default("showsTime",false);param_default("timeFormat","24");param_default("electric",true);param_default("step",2);param_default("position",null);param_default("cache",false);param_default("showOthers",false);param_default("multiple",null);var tmp=["inputField","displayArea","button"];for(var i in tmp){if(typeof params[tmp[i]]=="string"){params[tmp[i]]=document.getElementById(params[tmp[i]]);}}if(!(params.flat||params.multiple||params.inputField||params.displayArea||params.button)){alert("Calendar.setup:\n Nothing to setup (no fields found). Please check your code");return false;}function onSelect(cal){var p=cal.params;var update=(cal.dateClicked||p.electric);if(update&&p.inputField){p.inputField.value=cal.date.print(p.ifFormat);if(typeof p.inputField.onchange=="function")p.inputField.onchange();}if(update&&p.displayArea)p.displayArea.innerHTML=cal.date.print(p.daFormat);if(update&&typeof p.onUpdate=="function")p.onUpdate(cal);if(update&&p.flat){if(typeof p.flatCallback=="function")p.flatCallback(cal);}if(update&&p.singleClick&&cal.dateClicked)cal.callCloseHandler();};if(params.flat!=null){if(typeof params.flat=="string")params.flat=document.getElementById(params.flat);if(!params.flat){alert("Calendar.setup:\n Flat specified but can't find parent.");return false;}var cal=new Calendar(params.firstDay,params.date,params.onSelect||onSelect);cal.showsOtherMonths=params.showOthers;cal.showsTime=params.showsTime;cal.time24=(params.timeFormat=="24");cal.params=params;cal.weekNumbers=params.weekNumbers;cal.setRange(params.range[0],params.range[1]);cal.setDateStatusHandler(params.dateStatusFunc);cal.getDateText=params.dateText;if(params.ifFormat){cal.setDateFormat(params.ifFormat);}if(params.inputField&&typeof params.inputField.value=="string"){cal.parseDate(params.inputField.value);}cal.create(params.flat);cal.show();return false;}var triggerEl=params.button||params.displayArea||params.inputField;triggerEl["on"+params.eventName]=function(){var dateEl=params.inputField||params.displayArea;var dateFmt=params.inputField?params.ifFormat:params.daFormat;var mustCreate=false;var cal=window.calendar;if(dateEl)params.date=Date.parseDate(dateEl.value||dateEl.innerHTML,dateFmt);if(!(cal&&params.cache)){window.calendar=cal=new Calendar(params.firstDay,params.date,params.onSelect||onSelect,params.onClose||function(cal){cal.hide();});cal.showsTime=params.showsTime;cal.time24=(params.timeFormat=="24");cal.weekNumbers=params.weekNumbers;mustCreate=true;}else{if(params.date)cal.setDate(params.date);cal.hide();}if(params.multiple){cal.multiple={};for(var i=params.multiple.length;--i>=0;){var d=params.multiple[i];var ds=d.print("%Y%m%d");cal.multiple[ds]=d;}}cal.showsOtherMonths=params.showOthers;cal.yearStep=params.step;cal.setRange(params.range[0],params.range[1]);cal.params=params;cal.setDateStatusHandler(params.dateStatusFunc);cal.getDateText=params.dateText;cal.setDateFormat(dateFmt);if(mustCreate)cal.create();cal.refresh();if(!params.position)cal.showAtElement(params.button||params.displayArea||params.inputField,params.align);else cal.showAt(params.position[0],params.position[1]);return false;};return cal;};
