/*
  general.js
*/

function SetFocus(TargetFormName) {
  var target = 0;
  var i = 0;

  if (TargetFormName !== "") {
    for (i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name == TargetFormName) {
	target = i;
	break;
      }
    }
  }

  var TargetForm = document.forms[target];

  for (i = 0; i < TargetForm.length; i++) {
    if ((TargetForm.elements[i].type != "image") && (TargetForm.elements[i].type != "hidden") && (TargetForm.elements[i].type != "reset") && (TargetForm.elements[i].type != "submit")) {
      TargetForm.elements[i].focus();

      if ((TargetForm.elements[i].type == "text") || (TargetForm.elements[i].type == "password")) {
	TargetForm.elements[i].select();
      }

      break;
    }
  }
}

function RemoveFormatString(TargetElement, FormatString) {
  if (TargetElement.value == FormatString) {
    TargetElement.value = "";
  }

  TargetElement.select();
}

function submitForm(formName) {
  document.formName.submit();
}

function focusRemoveText(e, o) {
  if (o.firstTime) {
    return;
  }
  o.firstTime = true;
  o.value = "";
}

function ToggleDisplay(obj) {
  if (obj.style.display == 'none') {
    obj.style.display = 'block';
  } else {
    obj.style.display = 'none';
  }
  return true;
}

function updatePage() {
  window.location.reload(true);
}

function setCookie(name, value) {

  $.cookie(name, value);
}

function getUserLocalTimeNew() {
  var dateNow = new Date();
  var new_time = '-' + (dateNow.getTimezoneOffset() / 60);
  //var time_cookie = setCookie('HFUserLocalTimeZoneOffset', new_time);	
  $.cookie('HFUserLocalTimeZoneOffset', new_time, {
    path: '/',
    expires: 10
  });
  alert($.cookie('HFUserLocalTimeZoneOffset'));
  return updatePage();
}

function confirmAction(action, text) {
  var confirmation = confirm(text);
  if (confirmation) {
    window.location = action;
  }
}

function sendText(e, text) {
  var field = e;
  var inputText = text;
  field.value = inputText;
}

function populateInput(input, value) {
  var text = value;

  $('' + input + '').val('' + text + '');
}

// Function alias
function popUpWin(URL, width, height) {
  popUp(URL, width, height);
}

function popUp(URL, width, height) {
  var day = new Date();
  var id = day.getTime();

  popUpWindow = eval("page" + id + " = window.open('" + URL + "', '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left=320,top=150');");

  if (!popUpWindow.opener) popUpWindow.opener = self;
}

function isInteger(text) {
  var validChars = "0123456789";
  var isNumeric = true;
  var tchar;

  for (i = 0; i < text.length && isNumeric == true; i++) {
    tchar = text.charAt(i);
    if (validChars.indexOf(tchar) == -1) {
      isNumeric = false;
    }
  }
  return isNumeric;
}

/**
* Ajax Content
**/
function loadContentPageText(page_id) {
  var url = "/javascript/ajax/page_text.php?page_id=" + page_id;

  $('#content_text').load(url, {
    ajax: "true"
  },
  function(data) {});
}

/**
* Card Messages
**/
function loadCMOccasionMessageTemplates(occasion_id, item_id) {
  var url = "/javascript/ajax/card_message_templates.php?occasion=" + occasion_id + "&items_id=" + item_id;

  $('#card_message_templates_' + item_id).html('<tr><td align="center" valign="middle"><br /><br /><strong>Please Wait</strong><br /><img src="./images/icons/loaders/loading_flower.gif" alt="Please Wait" align="absmiddle" border="0" /></td></tr>');

  $('#card_message_templates_' + item_id).load(url, {
    ajax: "true"
  },
  function(data) {});
}

function loadCMCategoryMessageTemplates(category_id, item_id) {
  var url = "/javascript/ajax/card_message_templates.php?category=" + category_id + "&items_id=" + item_id;

  $('#card_message_templates_' + item_id).html('<tr><td align="center" valign="middle"><br /><br /><strong>Please Wait</strong><br /><img src="./images/icons/loaders/loading_flower.gif" alt="Please Wait" align="absmiddle" border="0" /></td></tr>');

  $('#card_message_templates_' + item_id).load(url, {
    ajax: "true"
  },
  function(data) {});
}

function textCounter(taName, divName, maxLimit) {
  var taObj = document.getElementById(taName);
  if (taObj.value.length > maxLimit) {
    taObj.value = taObj.value.substring(0, maxLimit);
  } else {
    var divObj = document.getElementById(divName);
    var numRemaining = maxLimit - taObj.value.length;
    divObj.innerHTML = "(You have <strong>" + numRemaining + "</strong> characters remaining)";
  }
}

function ciscoBindFocusBlur(field_id, field_text) {
  $(field_id).focus(function() {
    if ($(this).val() == field_text) {
      $(this).val('');
    }
  });

  $(field_id).blur(function() {
    if ($(this).val() == '') {
      $(this).val(field_text);
    }
  });
}

/**
* CHTS
**/
function loadCHTSConcernOptions(concern_id) {
  var url = "/javascript/ajax/chts.php?concern=" + concern_id;

  $('#concern_options').html('<td colspan="3" align="center"><img src="./images/icons/loaders/loading_chts_concerns.gif" alt="Please Wait" border="0" /></td>');

  $('#concern_options').load(url, {
    ajax: "true"
  },
  function(data) {});
}

function loadCHTSResolutionOptions(concern_option_id) {
  var url = "/javascript/ajax/chts_resolutions.php?concern_option_id=" + concern_option_id;

  $('#resolution_options').html('<table width="530" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="150" align="center"><table border="0" cellspacing="0" cellpadding="0" class="ajaxindicator"><tr><td><img src="./images/icons/loaders/loading_chts_resolutions.gif" alt="X" /></td><td width="15">&nbsp;</td><td>Please wait a moment <br />while we take a look at your order.</td></tr></table></td></tr></table>');

  $('#resolution_options').load(url, {
    ajax: "true"
  },
  function(data) {});
}

/**
* Addresses
**/
function loadAddressBookDetails(address_book_id, type, item_id, divclass) {
  if (type == 'delivery') {
    var url = "/javascript/ajax/checkout_delivery_address.php?address_book_id=" + address_book_id + "&items_id=" + item_id;

    $.getJSON(url,
    function(data) {
      $('input[name="delivery[' + item_id + '][firstname]"]').val(data.entry_firstname);
      $('input[name="delivery[' + item_id + '][lastname]"]').val(data.entry_lastname);
      $('input[name="delivery[' + item_id + '][email_address]"]').val(data.entry_email_address);
      $('select[name="delivery[' + item_id + '][location_type]"]').val(data.entry_location_type);
      $('input[name="delivery[' + item_id + '][location_type_info]"]').val(data.entry_location_type_info);
      $('input[name="delivery[' + item_id + '][street_address]"]').val(data.entry_street_address);
      $('input[name="delivery[' + item_id + '][street_address_2]"]').val(data.entry_street_address_2);
      $('input[name="delivery[' + item_id + '][city]"]').val(data.entry_city);
      $('input[name="delivery[' + item_id + '][postcode]"]').val(data.entry_postcode);
      $('select[name="delivery[' + item_id + '][zone_id]"]').val(data.entry_zone_id);
      $('input[name="delivery[' + item_id + '][telephone]"]').val(data.entry_telephone);
      $('select[name="delivery[' + item_id + '][country_id]"]').val(data.entry_country_id);
      $('input[name="delivery[' + item_id + '][save]"]:first').attr('checked', false);
      $('input[name="delivery[' + item_id + '][save]"]:last').attr('checked', true);

      // Check address fields and display correct next/continue button
      checkAddressForms();
    });

  } else if (type == 'billing') {
    var url = "/javascript/ajax/checkout_billing_address.php?address_book_id=" + address_book_id;

    $('#address_details').html('<tr><td height="200" align="center" valign="middle"><strong>Please Wait</strong><br /><img src="./images/icons/loaders/loading_flower.gif" alt="Please Wait" align="absmiddle" border="0" /></td></tr>');

    $('#address_details').load(url, {
      ajax: "true"
    },
    function(data) {});
  }
}

function loadCountryZones(country) {
  var country_id = country;
  var url = "/javascript/ajax/state_dropdown.php?country=" + country_id;

  $('#states').html('<img src="./images/icons/loaders/loading_zones.gif" alt="Please Wait" border="0" vspace="3" />');

  $('#states').load(url, {
    ajax: "true"
  });
}

/**
* Zip Locator
**/
function locateZipCodes(formName) {
  var country = $('#country').val();
  var zone_id = $('#zone_id').val();
  var city = $('#city').val();
  var url = "/javascript/ajax/zip_locator.php?form=" + formName + "&country=" + country + "&zone_id=" + zone_id + "&city=" + city;

  $('#zipResults').html('<table width="550" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="150" align="center"><table border="0" cellspacing="0" cellpadding="0" class="ajaxindicator"><tr><td><img src="./images/icons/loaders/loading_chts_resolutions.gif" alt="X" /></td><td width="15">&nbsp;</td><td>Please wait...</td></tr></table></td></tr></table>');

  $('#zipResults').load(url, {
    ajax: "true"
  },
  function(data) {});
}

/**
* Account
**/
function displayCalendar(m, y) {
  var ran_no = (Math.round((Math.random() * 9999)));
  var url = "/javascript/ajax/calendar.php?m=" + m + "&y=" + y + "&ran=" + ran_no;

  $('#calendar').html('<img src="./images/icons/loaders/loading_flower.gif" alt="Please Wait" border="0" />');

  $('#calendar').load(url, {
    ajax: "true"
  });
}

/**
* Search Smarter
**/

function checkSearchSmarterZipCities(zip_code, zip_options) {
  if(zip_options == undefined)
    zip_options = true;
    
  zip_code.toUpperCase();
  var zip_regex = /(^\d{5}$)|(^[ABCEGHJKLMNPRSTVX]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$)/;
  if (zip_code.match(zip_regex)) {
    if(zip_options) {
      var url = "/javascript/ajax/zip_cities_search_smarter.php?zip_code=" + encodeURI(zip_code);
      $('#searchSmarterZip').load(url, {
	ajax: "true"
      },
      function(data) {
	$(this).html(data).show();
	$('#search_smarter_zip_code').focus();
      });
    }
    else
      $('#searchSmarterZipCode').addClass("inputIsValid");
  }
  else {
    if($('#searchSmarterZipCode').hasClass("inputIsValid"))
      $('#searchSmarterZipCode').removeClass('inputIsValid');
  }
}

function updateSearchSmarterZipInput() {
  if ($('#searchSmarterCity')[0].selectedIndex != '') {
    $('#searchSmarterZipCode').removeClass("inputActionNeeded");
    $('#searchSmarterZipCode').addClass("inputIsValid");
  } else {
    $('#searchSmarterZipCode').removeClass("inputIsValid");
    $('#searchSmarterZipCode').addClass("inputActionNeeded");
  }
}

function resetSmartSearch() {
  //Clear each input individually because of session
  $('#searchSmarterDeliveryDate')[0].selectedIndex = 0;
  $('#searchSmarterOccasionID')[0].selectedIndex = 0;

  $('#searchSmarterRecipient').val('');

  //Remove zip input
  $('#searchSmarterZipCode').val('');
  $('#searchSmarterCity').val('');

  //Add zip input
  $('#searchSmarterZip').html('<input type="text" autocomplete="off" maxlength="10" size="12" onkeyup="checkSearchSmarterZipCities(this.value);" id="searchSmarterZipCode" class="defaultInputText" title="Zip Code" name="search_smarter_zip_code"/>');

  $('.defaultInputText').example(function() {
    return $(this).attr('title');
  });

  return false;
}

/**
* General jQuery
**/
function resetSelect(name, value) {
  $(name).val(value);
}

function fadeDeliveryDateSelect() {
  $('#dates').fadeTo("normal", 0.33);
}

function fadeCardMessageBlock(item_id) {
  if ($('#card_message_' + item_id).attr('checked')) {
    $('#card_message_block_' + item_id).fadeTo("normal", 0.33);
    $('#card_message_occasion_' + item_id).attr("disabled", "disabled");
    $('#card_message_text_' + item_id).attr("disabled", "disabled");
    $('#card_message_signature_' + item_id).attr("disabled", "disabled");
  } else {
    $('#card_message_block_' + item_id).fadeTo("normal", 1);
    $('#card_message_occasion_' + item_id).removeAttr("disabled");
    $('#card_message_text_' + item_id).removeAttr("disabled");
    $('#card_message_signature_' + item_id).removeAttr("disabled");
  }
}

/**
* Upsells
**/
function swapUpsellsImage(id, newImgSrc) {
  $('img#' + id).attr('src', newImgSrc);
}

/**
* Florists
**/
function showFloristPhoneNumber(spanID, floristID) {
  var url = "/javascript/ajax/ftd_florist_phone_number.php?ftd_florists_id=" + floristID;

  $('#floristPhoneNumber_' + spanID).html('<img src="./images/icons/loaders/loading_florist_phone_number.gif" alt="Please Wait" border="0" />');

  $('#floristPhoneNumber_' + spanID).load(url, {
    ajax: "true"
  },
  function() {
    $('#floristPhoneNumber_' + spanID).css({
      fontWeight: 'bold',
      backgroundColor: '#e1e8f0',
      marginLeft: '4px',
      paddingLeft: '4px',
      paddingRight: '5px'
    });
  });
}

/**
* AJAX Request
**/
function getRequest(params) {
  var gUrl = "/javascript/ajax/core.php?" + params;

  var response = $.ajax({
    url: gUrl,
    type: 'GET',
    dataType: 'text',
    error: function() {
      alert('Error loading core AJAX request!');
    }
  }).responseText;

  return response;
}

/**
* Refresh Page
**/
function reloadWin() {
  setTimeout('window.location.reload()', 800);
}

/*
 * jQuery Form Example Plugin 1.4.2
 * Populate form inputs with example text that disappears on focus.
 *
 * e.g.
 *  $('input#name').example('Bob Smith');
 *  $('input[@title]').example(function() {
 *    return $(this).attr('title');
 *  });
 *  $('textarea#message').example('Type your message here', {
 *    className: 'example_text'
 *  });
 *
 * Copyright (c) Paul Mucur (http://mucur.name), 2007-2008.
 * Dual-licensed under the BSD (BSD-LICENSE.txt) and GPL (GPL-LICENSE.txt)
 * licenses.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
(function(a){a.fn.example=function(e,c){var d=a.isFunction(e);var b=a.extend({},c,{example:e});return this.each(function(){var f=a(this);if(a.metadata){var g=a.extend({},a.fn.example.defaults,f.metadata(),b)}else{var g=a.extend({},a.fn.example.defaults,b)}if(!a.fn.example.boundClassNames[g.className]){a(window).unload(function(){a("."+g.className).val("")});a("form").submit(function(){a(this).find("."+g.className).val("")});a.fn.example.boundClassNames[g.className]=true}if(a.browser.msie&&!f.attr("defaultValue")&&(d||f.val()==g.example)){f.val("")}if(f.val()==""&&this!=document.activeElement){f.addClass(g.className);f.val(d?g.example.call(this):g.example)}f.focus(function(){if(a(this).is("."+g.className)){a(this).val("");a(this).removeClass(g.className)}});f.change(function(){if(a(this).is("."+g.className)){a(this).removeClass(g.className)}});f.blur(function(){if(a(this).val()==""){a(this).addClass(g.className);a(this).val(d?g.example.call(this):g.example)}})})};a.fn.example.defaults={className:"example"};a.fn.example.boundClassNames=[]})(jQuery);
/*
  core.addons.js
*/

/**
* SWFObject
**/
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;

/**
* Browser Detection
**/
(function($){$.browserTest=function(a,z){var u='unknown',x='X',m=function(r,h){for(var i=0;i<h.length;i=i+1){r=r.replace(h[i][0],h[i][1]);}return r;},c=function(i,a,b,c){var r={name:m((a.exec(i)||[u,u])[1],b)};r[r.name]=true;r.version=(c.exec(i)||[x,x,x,x])[3];if(r.name.match(/safari/)&&r.version>400){r.version='2.0';}if(r.name==='presto'){r.version=($.browser.version>9.27)?'futhark':'linear_b';}r.versionNumber=parseFloat(r.version,10)||0;r.versionX=(r.version!==x)?(r.version+'').substr(0,1):x;r.className=r.name+r.versionX;return r;};a=(a.match(/Opera|Navigator|Minefield|KHTML|Chrome/)?m(a,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,''],['Chrome Safari','Chrome'],['KHTML','Konqueror'],['Minefield','Firefox'],['Navigator','Netscape']]):a).toLowerCase();$.browser=$.extend((!z)?$.browser:{},c(a,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));$.layout=c(a,/(gecko|konqueror|msie|opera|webkit)/,[['konqueror','khtml'],['msie','trident'],['opera','presto']],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);$.os={name:(/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase())||[u])[0].replace('sunos','solaris')};if(!z){$('html').addClass([$.os.name,$.browser.name,$.browser.className,$.layout.name,$.layout.className].join(' '));}};$.browserTest(navigator.userAgent);})(jQuery);


/**
* jTip.js (Used for all of the jQuery hover help links)
**/
/*
 * JTip
 * By Cody Lindley (http://www.codylindley.com)
 * Under an Attribution, Share Alike License
 * JTip is built on top of the very light weight jquery library.
 */
//on page load (as soon as its ready) call JT_init
$(document).ready(JT_init);

function JT_init(){	
	$('.jTip').hover(
		function(){
			JT_show($(this).attr('href'), this.id, this.name)
		},
		function(){
			$('#JT').remove()
		}
	)
  .click(
		function(){
			if ($(this).attr('return') == null) {
				response = false;
			} else {
				response = $(this).attr('return');
			}
			return response;
		}
	);	   
}

function JT_show(url, linkId, title) {
	if (title == false) title = '&nbsp;';
	var de = document.documentElement;
	var w = self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
	var hasArea = w - getAbsoluteLeft(linkId);
	var clickElementy = getAbsoluteTop(linkId) - 3; //set y position
	
	var queryString = url.replace(/^[^\?]+\??/, '');
	var params = parseQuery(queryString);
	if (params['width'] === undefined) {
		params['width'] = 250;
	}
	if (params['link'] !== undefined) {
		$('#' + linkId).bind('click',
			function(){
				window.location = params['link'];
			}
		);
		$('#' + linkId).css('cursor', 'pointer');
	}
	
	if(hasArea > ((params['width']*1) + 75)) {
		$('body').append('<div id="JT" style="width:'+params['width']*1+'px;"><div id="JT_arrow_left"></div><div id="JT_close_left">'+title+'</div><div id="JT_copy"><div class="JT_loader"><div></div></div>');//right side
		var arrowOffset = getElementWidth(linkId) + 16;
		var clickElementx = getAbsoluteLeft(linkId) + arrowOffset; //set x position
	} else {
		$('body').append('<div id="JT" style="width:'+params['width']*1+'px;"><div id="JT_arrow_right" style="left:'+((params['width']*1)+1)+'px;"></div><div id="JT_close_right">'+title+'</div><div id="JT_copy"><div class="JT_loader"><div></div></div>');//left side
		var clickElementx = getAbsoluteLeft(linkId) - ((params['width']*1) + 24); //set x position
	}
	
	$('#JT').css({
		left: clickElementx+'px', 
		top: clickElementy+'px'
	});
	$('#JT').show();
	$('#JT_copy').load(url);
};

function getElementWidth(objectId) {
	x = document.getElementById(objectId);
	return x.offsetWidth;
};

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while (o.offsetParent != null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	return oLeft
};


function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while (o.offsetParent != null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	return oTop
};

function parseQuery (query) {
   var Params = new Object ();
   if (!query) return Params; // return empty object
   var Pairs = query.split(/[;&]/);
   for (var i=0; i<Pairs.length; i++) {
      var KeyVal = Pairs[i].split('=');
      if (!KeyVal || KeyVal.length != 2) continue;
      var key = unescape(KeyVal[0]);
      var val = unescape(KeyVal[1]);
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
};

function blockEvents(evt) {
	if (evt.target) {
  	evt.preventDefault();
  } else {
    evt.returnValue = false;
  }
};

/**
* Clock (Used in the sub-header)
**/
/*
 * jQuery jclock - Clock plugin - v 0.2.1
 * http://plugins.jquery.com/project/jclock
 *
 * Copyright (c) 2007-2008 Doug Sparling <http://www.dougsparling.com>
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 */
(function($) {

  $.fn.jclock = function(options) {
    var version = '0.2.1';

    // options
    var opts = $.extend({}, $.fn.jclock.defaults, options);
         
    return this.each(function() {
      $this = $(this);
      $this.timerID = null;
      $this.running = false;

      var o = $.meta ? $.extend({}, opts, $this.data()) : opts;

      $this.timeNotation = o.timeNotation;
      $this.am_pm = o.am_pm;
      $this.utc = o.utc;
      $this.utc_offset = o.utc_offset;

      $this.css({
        fontFamily: o.fontFamily,
        fontSize: o.fontSize,
        backgroundColor: o.background,
        color: o.foreground
      });

      $.fn.jclock.startClock($this);

    });
  };
       
  $.fn.jclock.startClock = function(el) {
    $.fn.jclock.stopClock(el);
    $.fn.jclock.displayTime(el);
  };
  $.fn.jclock.stopClock = function(el) {
    if(el.running) {
      clearTimeout(el.timerID);
    }
    el.running = false;
  };
  $.fn.jclock.displayTime = function(el) {
    var time = $.fn.jclock.getTime(el);
    el.html(time);
    el.timerID = setTimeout(function(){$.fn.jclock.displayTime(el)},1000);
  };
  $.fn.jclock.getTime = function(el) {
    var now = new Date();
    var hours, minutes;

    if(el.utc == true) {
      if(el.utc_offset != 0) {
        now.setUTCHours(now.getUTCHours()+el.utc_offset);
      }
      hours = now.getUTCHours();
      minutes = now.getUTCMinutes();
    } else {
      hours = now.getHours();
      minutes = now.getMinutes();
    }

    var am_pm_text = '';
    (hours >= 12) ? am_pm_text = " PM" : am_pm_text = " AM";

    if (el.timeNotation == '12h') {
      if (hours == 0) {
				hours = 12;
			} else {
				hours = ((hours > 12) ? hours - 12 : hours);
			}
    } else {
      hours   = ((hours <  10) ? "" : "") + hours;
    }

    minutes = ((minutes <  10) ? "0" : "") + minutes;

    var timeNow = hours + ":" + minutes;
    if ( (el.timeNotation == '12h') && (el.am_pm == true) ) {
     timeNow += am_pm_text;
    }

    return timeNow;
  };
       
  // plugin defaults
  $.fn.jclock.defaults = {
    timeNotation: '12h',
    am_pm: true,
    utc: true,
    fontFamily: '',
    fontSize: '',
    foreground: '',
    background: '',
    utc_offset: ''
  };

})(jQuery);

/**
* Compatibility (Used for countdown.js)
**/
// Not used at this time.


/**
* Cookies.js
**/
/**
 * 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;
    }
};

/**
* Metadata.js (Used for passing variables to jQuery)
**/
/*
 * Metadata - jQuery plugin for parsing metadata from elements
 *
 * Copyright (c) 2006 John Resig, Yehuda Katz, Jörn Zaefferer, Paul McLanahan
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.metadata.js 3640 2007-10-11 18:34:38Z pmclanahan $
 *
 */

/**
 * Sets the type of metadata to use. Metadata is encoded in JSON, and each property
 * in the JSON will become a property of the element itself.
 *
 * There are three supported types of metadata storage:
 *
 *   attr:  Inside an attribute. The name parameter indicates *which* attribute.
 *          
 *   class: Inside the class attribute, wrapped in curly braces: { }
 *   
 *   elem:  Inside a child element (e.g. a script tag). The
 *          name parameter indicates *which* element.
 *          
 * The metadata for an element is loaded the first time the element is accessed via jQuery.
 *
 * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
 * matched by expr, then redefine the metadata type and run another $(expr) for other elements.
 * 
 * @name $.metadata.setType
 *
 * @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("class")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from the class attribute
 * 
 * @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("attr", "data")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a "data" attribute
 * 
 * @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
 * @before $.metadata.setType("elem", "script")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a nested script element
 * 
 * @param String type The encoding type
 * @param String name The name of the attribute to be used to get metadata (optional)
 * @cat Plugins/Metadata
 * @descr Sets the type of encoding to be used when loading metadata for the first time
 * @type undefined
 * @see metadata()
 */

(function($) {

$.extend({
	metadata : {
		defaults : {
			type: 'class',
			name: 'metadata',
			cre: /({.*})/,
			single: 'metadata'
		},
		setType: function( type, name ){
			this.defaults.type = type;
			this.defaults.name = name;
		},
		get: function( elem, opts ){
			var settings = $.extend({},this.defaults,opts);
			// check for empty string in single property
			if ( !settings.single.length ) settings.single = 'metadata';
			
			var data = $.data(elem, settings.single);
			// returned cached data if it already exists
			if ( data ) return data;
			
			data = "{}";
			
			if ( settings.type == "class" ) {
				var m = settings.cre.exec( elem.className );
				if ( m )
					data = m[1];
			} else if ( settings.type == "elem" ) {
				if( !elem.getElementsByTagName ) return;
				var e = elem.getElementsByTagName(settings.name);
				if ( e.length )
					data = $.trim(e[0].innerHTML);
			} else if ( elem.getAttribute != undefined ) {
				var attr = elem.getAttribute( settings.name );
				if ( attr )
					data = attr;
			}
			
			if ( data.indexOf( '{' ) <0 )
			data = "{" + data + "}";
			
			data = eval("(" + data + ")");
			
			$.data( elem, settings.single, data );
			return data;
		}
	}
});

/**
 * Returns the metadata object for the first member of the jQuery object.
 *
 * @name metadata
 * @descr Returns element's metadata object
 * @param Object opts An object contianing settings to override the defaults
 * @type jQuery
 * @cat Plugins/Metadata
 */
$.fn.metadata = function( opts ){
	return $.metadata.get( this[0], opts );
};

})(jQuery);


/**
* Image Preloading 
**/
/**
 * Preload Images
 * Use: $.preloadImages('/path/to/image1.jpg', '/path/to/image2.gif', '/path/to/image3.png');
 **/
jQuery.preloadImages = function() {
  for(var i = 0; i < arguments.length; i++) {
    jQuery('<img>').attr('src', arguments[i]);
  }
};