/*
 * jQuery Form Plugin
 * version: 2.22 (09-MAR-2009)
 * @requires jQuery v1.2.2 or later
 *
 * Examples and documentation at: http://malsup.com/jquery/form/
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
;(function($) {

/*
    Usage Note:
    -----------
    Do not use both ajaxSubmit and ajaxForm on the same form.  These
    functions are intended to be exclusive.  Use ajaxSubmit if you want
    to bind your own submit handler to the form.  For example,

    $(document).ready(function() {
        $('#myForm').bind('submit', function() {
            $(this).ajaxSubmit({
                target: '#output'
            });
            return false; // <-- important!
        });
    });

    Use ajaxForm when you want the plugin to manage all the event binding
    for you.  For example,

    $(document).ready(function() {
        $('#myForm').ajaxForm({
            target: '#output'
        });
    });

    When using ajaxForm, the ajaxSubmit function will be invoked for you
    at the appropriate time.
*/

/**
 * ajaxSubmit() provides a mechanism for immediately submitting
 * an HTML form using AJAX.
 */
$.fn.ajaxSubmit = function(options) {
    // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
    if (!this.length) {
        log('ajaxSubmit: skipping submit process - no element selected');
        return this;
    }

    if (typeof options == 'function')
        options = { success: options };

    // clean url (don't include hash)
    var url = this.attr('action') || window.location.href;
    url = url.match(/([^#]+)/)[1];

    options = $.extend({
        url:  url,
        type: this.attr('method') || 'GET'
    }, options || {});

    // hook for manipulating the form data before it is extracted;
    // convenient for use with rich editors like tinyMCE or FCKEditor
    var veto = {};
    this.trigger('form-pre-serialize', [this, options, veto]);
    if (veto.veto) {
        log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
        return this;
    }

    // provide opportunity to alter form data before it is serialized
    if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
        log('ajaxSubmit: submit aborted via beforeSerialize callback');
        return this;
    }

    var a = this.formToArray(options.semantic);
    if (options.data) {
        options.extraData = options.data;
        for (var n in options.data) {
          if(options.data[n] instanceof Array) {
            for (var k in options.data[n])
              a.push( { name: n, value: options.data[n][k] } )
          }
          else
             a.push( { name: n, value: options.data[n] } );
        }
    }

    // give pre-submit callback an opportunity to abort the submit
    if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
        log('ajaxSubmit: submit aborted via beforeSubmit callback');
        return this;
    }

    // fire vetoable 'validate' event
    this.trigger('form-submit-validate', [a, this, options, veto]);
    if (veto.veto) {
        log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
        return this;
    }

    var q = $.param(a);

    if (options.type.toUpperCase() == 'GET') {
        options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
        options.data = null;  // data is null for 'get'
    }
    else
        options.data = q; // data is the query string for 'post'

    var $form = this, callbacks = [];
    if (options.resetForm) callbacks.push(function() { $form.resetForm(); });
    if (options.clearForm) callbacks.push(function() { $form.clearForm(); });

    // perform a load on the target only if dataType is not provided
    if (!options.dataType && options.target) {
        var oldSuccess = options.success || function(){};
        callbacks.push(function(data) {
            $(options.target).html(data).each(oldSuccess, arguments);
        });
    }
    else if (options.success)
        callbacks.push(options.success);

    options.success = function(data, status) {
        for (var i=0, max=callbacks.length; i < max; i++)
            callbacks[i].apply(options, [data, status, $form]);
    };

    // are there files to upload?
    var files = $('input:file', this).fieldValue();
    var found = false;
    for (var j=0; j < files.length; j++)
        if (files[j])
            found = true;

    // options.iframe allows user to force iframe mode
   if (options.iframe || found) {
       // hack to fix Safari hang (thanks to Tim Molendijk for this)
       // see:  http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
       if (options.closeKeepAlive)
           $.get(options.closeKeepAlive, fileUpload);
       else
           fileUpload();
       }
   else
       $.ajax(options);

    // fire 'notify' event
    this.trigger('form-submit-notify', [this, options]);
    return this;


    // private function for handling file uploads (hat tip to YAHOO!)
    function fileUpload() {
        var form = $form[0];

        if ($(':input[name=submit]', form).length) {
            alert('Error: Form elements must not be named "submit".');
            return;
        }

        var opts = $.extend({}, $.ajaxSettings, options);
		var s = jQuery.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts);

        var id = 'jqFormIO' + (new Date().getTime());
        var $io = $('<iframe id="' + id + '" name="' + id + '" src="about:blank" />');
        var io = $io[0];

        $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });

        var xhr = { // mock object
            aborted: 0,
            responseText: null,
            responseXML: null,
            status: 0,
            statusText: 'n/a',
            getAllResponseHeaders: function() {},
            getResponseHeader: function() {},
            setRequestHeader: function() {},
            abort: function() {
                this.aborted = 1;
                $io.attr('src','about:blank'); // abort op in progress
            }
        };

        var g = opts.global;
        // trigger ajax global events so that activity/block indicators work like normal
        if (g && ! $.active++) $.event.trigger("ajaxStart");
        if (g) $.event.trigger("ajaxSend", [xhr, opts]);

		if (s.beforeSend && s.beforeSend(xhr, s) === false) {
			s.global && jQuery.active--;
			return;
        }
        if (xhr.aborted)
            return;

        var cbInvoked = 0;
        var timedOut = 0;

        // add submitting element to data if we know it
        var sub = form.clk;
        if (sub) {
            var n = sub.name;
            if (n && !sub.disabled) {
                options.extraData = options.extraData || {};
                options.extraData[n] = sub.value;
                if (sub.type == "image") {
                    options.extraData[name+'.x'] = form.clk_x;
                    options.extraData[name+'.y'] = form.clk_y;
                }
            }
        }

        // take a breath so that pending repaints get some cpu time before the upload starts
        setTimeout(function() {
            // make sure form attrs are set
            var t = $form.attr('target'), a = $form.attr('action');

			// update form attrs in IE friendly way
			form.setAttribute('target',id);
			if (form.getAttribute('method') != 'POST')
				form.setAttribute('method', 'POST');
			if (form.getAttribute('action') != opts.url)
				form.setAttribute('action', opts.url);

            // ie borks in some cases when setting encoding
            if (! options.skipEncodingOverride) {
                $form.attr({
                    encoding: 'multipart/form-data',
                    enctype:  'multipart/form-data'
                });
            }

            // support timout
            if (opts.timeout)
                setTimeout(function() { timedOut = true; cb(); }, opts.timeout);

            // add "extra" data to form if provided in options
            var extraInputs = [];
            try {
                if (options.extraData)
                    for (var n in options.extraData)
                        extraInputs.push(
                            $('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />')
                                .appendTo(form)[0]);

                // add iframe to doc and submit the form
                $io.appendTo('body');
                io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
                form.submit();
            }
            finally {
                // reset attrs and remove "extra" input elements
				form.setAttribute('action',a);
                t ? form.setAttribute('target', t) : $form.removeAttr('target');
                $(extraInputs).remove();
            }
        }, 10);

        var nullCheckFlag = 0;

        function cb() {
            if (cbInvoked++) return;
            
            io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);

            var ok = true;
            try {
                if (timedOut) throw 'timeout';
                // extract the server response from the iframe
                var data, doc;

                doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;

                if ((doc.body == null || doc.body.innerHTML == '') && !nullCheckFlag) {
                    // in some browsers (cough, Opera 9.2.x) the iframe DOM is not always traversable when
                    // the onload callback fires, so we give them a 2nd chance
                    nullCheckFlag = 1;
                    cbInvoked--;
                    setTimeout(cb, 100);
                    return;
                }

                xhr.responseText = doc.body ? doc.body.innerHTML : null;
                xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
                xhr.getResponseHeader = function(header){
                    var headers = {'content-type': opts.dataType};
                    return headers[header];
                };

                if (opts.dataType == 'json' || opts.dataType == 'script') {
                    var ta = doc.getElementsByTagName('textarea')[0];
                    xhr.responseText = ta ? ta.value : xhr.responseText;
                }
                else if (opts.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
                    xhr.responseXML = toXml(xhr.responseText);
                }
                data = $.httpData(xhr, opts.dataType);
            }
            catch(e){
                ok = false;
                $.handleError(opts, xhr, 'error', e);
            }

            // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
            if (ok) {
                opts.success(data, 'success');
                if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);
            }
            if (g) $.event.trigger("ajaxComplete", [xhr, opts]);
            if (g && ! --$.active) $.event.trigger("ajaxStop");
            if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');

            // clean up
            setTimeout(function() {
                $io.remove();
                xhr.responseXML = null;
            }, 100);
        };

        function toXml(s, doc) {
            if (window.ActiveXObject) {
                doc = new ActiveXObject('Microsoft.XMLDOM');
                doc.async = 'false';
                doc.loadXML(s);
            }
            else
                doc = (new DOMParser()).parseFromString(s, 'text/xml');
            return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
        };
    };
};

/**
 * ajaxForm() provides a mechanism for fully automating form submission.
 *
 * The advantages of using this method instead of ajaxSubmit() are:
 *
 * 1: This method will include coordinates for <input type="image" /> elements (if the element
 *    is used to submit the form).
 * 2. This method will include the submit element's name/value data (for the element that was
 *    used to submit the form).
 * 3. This method binds the submit() method to the form for you.
 *
 * The options argument for ajaxForm works exactly as it does for ajaxSubmit.  ajaxForm merely
 * passes the options argument along after properly binding events for submit elements and
 * the form itself.
 */
$.fn.ajaxForm = function(options) {
    return this.ajaxFormUnbind().bind('submit.form-plugin',function() {
        $(this).ajaxSubmit(options);
        return false;
    }).each(function() {
        // store options in hash
        $(":submit,input:image", this).bind('click.form-plugin',function(e) {
            var form = this.form;
            form.clk = this;
            if (this.type == 'image') {
                if (e.offsetX != undefined) {
                    form.clk_x = e.offsetX;
                    form.clk_y = e.offsetY;
                } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
                    var offset = $(this).offset();
                    form.clk_x = e.pageX - offset.left;
                    form.clk_y = e.pageY - offset.top;
                } else {
                    form.clk_x = e.pageX - this.offsetLeft;
                    form.clk_y = e.pageY - this.offsetTop;
                }
            }
            // clear form vars
            setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 10);
        });
    });
};

// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
$.fn.ajaxFormUnbind = function() {
    this.unbind('submit.form-plugin');
    return this.each(function() {
        $(":submit,input:image", this).unbind('click.form-plugin');
    });

};

/**
 * formToArray() gathers form element data into an array of objects that can
 * be passed to any of the following ajax functions: $.get, $.post, or load.
 * Each object in the array has both a 'name' and 'value' property.  An example of
 * an array for a simple login form might be:
 *
 * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
 *
 * It is this array that is passed to pre-submit callback functions provided to the
 * ajaxSubmit() and ajaxForm() methods.
 */
$.fn.formToArray = function(semantic) {
    var a = [];
    if (this.length == 0) return a;

    var form = this[0];
    var els = semantic ? form.getElementsByTagName('*') : form.elements;
    if (!els) return a;
    for(var i=0, max=els.length; i < max; i++) {
        var el = els[i];
        var n = el.name;
        if (!n) continue;

        if (semantic && form.clk && el.type == "image") {
            // handle image inputs on the fly when semantic == true
            if(!el.disabled && form.clk == el)
                a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
            continue;
        }

        var v = $.fieldValue(el, true);
        if (v && v.constructor == Array) {
            for(var j=0, jmax=v.length; j < jmax; j++)
                a.push({name: n, value: v[j]});
        }
        else if (v !== null && typeof v != 'undefined')
            a.push({name: n, value: v});
    }

    if (!semantic && form.clk) {
        // input type=='image' are not found in elements array! handle them here
        var inputs = form.getElementsByTagName("input");
        for(var i=0, max=inputs.length; i < max; i++) {
            var input = inputs[i];
            var n = input.name;
            if(n && !input.disabled && input.type == "image" && form.clk == input)
                a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
        }
    }
    return a;
};

/**
 * Serializes form data into a 'submittable' string. This method will return a string
 * in the format: name1=value1&amp;name2=value2
 */
$.fn.formSerialize = function(semantic) {
    //hand off to jQuery.param for proper encoding
    return $.param(this.formToArray(semantic));
};

/**
 * Serializes all field elements in the jQuery object into a query string.
 * This method will return a string in the format: name1=value1&amp;name2=value2
 */
$.fn.fieldSerialize = function(successful) {
    var a = [];
    this.each(function() {
        var n = this.name;
        if (!n) return;
        var v = $.fieldValue(this, successful);
        if (v && v.constructor == Array) {
            for (var i=0,max=v.length; i < max; i++)
                a.push({name: n, value: v[i]});
        }
        else if (v !== null && typeof v != 'undefined')
            a.push({name: this.name, value: v});
    });
    //hand off to jQuery.param for proper encoding
    return $.param(a);
};

/**
 * Returns the value(s) of the element in the matched set.  For example, consider the following form:
 *
 *  <form><fieldset>
 *      <input name="A" type="text" />
 *      <input name="A" type="text" />
 *      <input name="B" type="checkbox" value="B1" />
 *      <input name="B" type="checkbox" value="B2"/>
 *      <input name="C" type="radio" value="C1" />
 *      <input name="C" type="radio" value="C2" />
 *  </fieldset></form>
 *
 *  var v = $(':text').fieldValue();
 *  // if no values are entered into the text inputs
 *  v == ['','']
 *  // if values entered into the text inputs are 'foo' and 'bar'
 *  v == ['foo','bar']
 *
 *  var v = $(':checkbox').fieldValue();
 *  // if neither checkbox is checked
 *  v === undefined
 *  // if both checkboxes are checked
 *  v == ['B1', 'B2']
 *
 *  var v = $(':radio').fieldValue();
 *  // if neither radio is checked
 *  v === undefined
 *  // if first radio is checked
 *  v == ['C1']
 *
 * The successful argument controls whether or not the field element must be 'successful'
 * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
 * The default value of the successful argument is true.  If this value is false the value(s)
 * for each element is returned.
 *
 * Note: This method *always* returns an array.  If no valid value can be determined the
 *       array will be empty, otherwise it will contain one or more values.
 */
$.fn.fieldValue = function(successful) {
    for (var val=[], i=0, max=this.length; i < max; i++) {
        var el = this[i];
        var v = $.fieldValue(el, successful);
        if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length))
            continue;
        v.constructor == Array ? $.merge(val, v) : val.push(v);
    }
    return val;
};

/**
 * Returns the value of the field element.
 */
$.fieldValue = function(el, successful) {
    var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
    if (typeof successful == 'undefined') successful = true;

    if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
        (t == 'checkbox' || t == 'radio') && !el.checked ||
        (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
        tag == 'select' && el.selectedIndex == -1))
            return null;

    if (tag == 'select') {
        var index = el.selectedIndex;
        if (index < 0) return null;
        var a = [], ops = el.options;
        var one = (t == 'select-one');
        var max = (one ? index+1 : ops.length);
        for(var i=(one ? index : 0); i < max; i++) {
            var op = ops[i];
            if (op.selected) {
				var v = op.value;
				if (!v) // extra pain for IE...
                	v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
                if (one) return v;
                a.push(v);
            }
        }
        return a;
    }
    return el.value;
};

/**
 * Clears the form data.  Takes the following actions on the form's input fields:
 *  - input text fields will have their 'value' property set to the empty string
 *  - select elements will have their 'selectedIndex' property set to -1
 *  - checkbox and radio inputs will have their 'checked' property set to false
 *  - inputs of type submit, button, reset, and hidden will *not* be effected
 *  - button elements will *not* be effected
 */
$.fn.clearForm = function() {
    return this.each(function() {
        $('input,select,textarea', this).clearFields();
    });
};

/**
 * Clears the selected form elements.
 */
$.fn.clearFields = $.fn.clearInputs = function() {
    return this.each(function() {
        var t = this.type, tag = this.tagName.toLowerCase();
        if (t == 'text' || t == 'password' || tag == 'textarea')
            this.value = '';
        else if (t == 'checkbox' || t == 'radio')
            this.checked = false;
        else if (tag == 'select')
            this.selectedIndex = -1;
    });
};

/**
 * Resets the form data.  Causes all form elements to be reset to their original value.
 */
$.fn.resetForm = function() {
    return this.each(function() {
        // guard against an input with the name of 'reset'
        // note that IE reports the reset function as an 'object'
        if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType))
            this.reset();
    });
};

/**
 * Enables or disables any matching elements.
 */
$.fn.enable = function(b) {
    if (b == undefined) b = true;
    return this.each(function() {
        this.disabled = !b
    });
};

/**
 * Checks/unchecks any matching checkboxes or radio buttons and
 * selects/deselects and matching option elements.
 */
$.fn.selected = function(select) {
    if (select == undefined) select = true;
    return this.each(function() {
        var t = this.type;
        if (t == 'checkbox' || t == 'radio')
            this.checked = select;
        else if (this.tagName.toLowerCase() == 'option') {
            var $sel = $(this).parent('select');
            if (select && $sel[0] && $sel[0].type == 'select-one') {
                // deselect all other options
                $sel.find('option').selected(false);
            }
            this.selected = select;
        }
    });
};

// helper fn for console logging
// set $.fn.ajaxSubmit.debug to true to enable debug logging
function log() {
    if ($.fn.ajaxSubmit.debug && window.console && window.console.log)
        window.console.log('[jquery.form] ' + Array.prototype.join.call(arguments,''));
};

})(jQuery);(function($){
 $.fn.validate = function(options) {
    
   var defaults = {
   req_prepend: " (*)",
   req_append: "*",
   tag: ".inputreq",
   script: "/design_enquiry_send.php",
   http: "/"
  };
  
  var options = $.extend(defaults, options);
    
  obj = $(this);
  
  var script = $(obj).attr('action');
   
  var oid = $(obj).attr('id');
  
  var msg_container = $(obj).find("#form_msgs");
  
  var captcha = $(obj).find("input#valid");
  
  var http = options.http;
  
  function tooltip(selector, selectname, atrribute){
$(obj).find(selector).each(function(i){
			if ($(this).attr(atrribute) != ""){
			$("body").append("<div class='"+selectname+"' id='"+selectname+i+"'>"+$(this).attr(atrribute)+"</div>");
			
			$(this).removeAttr(atrribute).mouseover(function(e){
					$("#"+selectname+i).css({opacity:0.85, display:"none", visibility:"visible"}).animate({"padding": "9px"}, 100).fadeIn(100);
			}).mousemove(function(e){
					$("#"+selectname+i).css({left:e.pageX+5, top:e.pageY+5});
			}).mouseout(function(){
					$("#"+selectname+i).css({display:"none", visibility:"hidden"});				  
			});
			
			
			}
		});
 	}
  
  function resetform()
  {
	
	$('#'+oid).each(function()
						 {

						this.reset();
							
						 });
	  
  }
  
  tooltip('a.help_tip', 'help_tip_container', 'title');
   
  $(obj).find(options.tag).each(function()
  {
	
  var required = $(this);
   
  $(required).parent().parent().prev().prev().append(options.req_prepend);
	
  });
  
  if(captcha.length > 0)
  {
  
  function new_captcha(container)
  {
	
   var str = "id=" + oid;
	
   $.ajax({
   type: "POST",
   url: options.http + "captcha_image.php", 
   data: str,
   cache: false,
   success: function(t)
   {
	   
	   if(container.length>0)
	   {
		
		$(container).find('img').remove();
		
	   }
	   
	   $(container).prepend(t);
	
   }
   
   });
   
   }
  
  $("#row_container_valid").before('<div class="row captcha" id="row_container_' + oid + '_captcha"><p>Can\'t Read This? <a href="#" id="' + oid + '_capt_refresh">Click Here</a> to Refresh.</p></div>');
  
  new_captcha('#row_container_' + oid + '_captcha');

  $('#' + oid + '_capt_refresh').click(function()
												{
												
												new_captcha('#row_container_' + oid + '_captcha');
												
												return false;

												});
							   
  }
   
  $(obj).submit(function()
  {
							
							if($("#form_msgs li").length>0)
							{
							
							$("#form_msgs li").remove();
							
							}
							
							$(obj).find(options.tag).each(function()
							{
								
							var val = $(this).val();
								
							var next = $(this).parent().next('span.req');
								
							$(this).removeClass('empty_input');
								
							if($(next))
							{
							$(next).remove();
							}
									 
							if(val == "")
							{
								
							$(this).addClass('empty_input');
								
							$(this).parent().after('<span class="system negative req">' + options.req_append + '</span>');
								
							}
								
							});
							
							var req = $('span.req');

							if(req.length == 0)
							{
								
							var check = "valid";
							
							var code;
							
							if(captcha.length > 0)
							{
								
							var captval = $(captcha).val();
														
							var datastr = "id=" + oid;
							
							var varurl = http + "validate_captcha.php?rand=" + Math.floor(Math.random()*5);
							   
							code = $.ajax({ type:"POST", url: varurl, data: datastr, async: false }).responseText;
							
							if(code != captval)
							check = 'invalid';
							else
							check = 'valid';
							
							}
							
							if(check == 'invalid')
							{
								
								alert("The validation does not match the captcha image, please try again");
								
								new_captcha('#row_container_' + oid + '_captcha');
								
							}
							else
							{
								
							$(obj).slideUp(400);
							
							$(obj).before("<div class='loading-container' style='display: none;'>Please Wait... Loading</div>");
							
							$(".loading-container").slideDown(400);
							
							var script_url;
							
							if(script.length > 0)
							{
								
								script_url = script;
								
							}
							else
							{
							
								script_url = options.script;
							
							}
						   
						    $(obj).ajaxSubmit({
			
							url: script_url,
							type: 'post', 
							success: function(xml){
									
									$('.loading-container').slideUp(400);
									
									$(obj).before("<div class='ajaxresponse' style='display: none;'></div>");
									$(".ajaxresponse").html(xml).slideDown(400);
									
									$(obj).fadeIn(400);
									
									resetform();
									
									new_captcha('#row_container_' + oid + '_captcha');
									
									$('.loading-container').remove();
								
								}
							});
							
							}
								
							}
							else
							{
							
							$('.empty_input:first').focus();
							
							}
							
							return false;
							
						  });
   
 };
})(jQuery);//jQuery Slideshow

(function($){
$.fn.slideshow = function(options) {
    
var defaults = {
speed: "6000",
active_class: "displayslide",
tag: 'a',
caption: 'No'
};
  
var options = $.extend(defaults, options);

var obj = $(this);

var gallery = function() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($(obj).find(options.tag + '.show')?  $(obj).find(options.tag + '.show') : $(obj).find(options.tag + ':first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $(obj).find(options.tag + ':first') :current.next()) : $(obj).find(options.tag + ':first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');
	
	var caption_pause = (options.speed/2);
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$(obj).find('div.caption').animate({opacity: 0.0}, { queue:false, duration:50 }).animate({height: '1px'}, { queue:true, duration:300 });
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$(obj).find('div.caption').animate({opacity: 1.0},100 ).animate({height: cap_height},500 ).animate({height: cap_height},caption_pause ).animate({height: '0px'},500 );
	
	//Display the content
	$(obj).find('div.content').html(caption);
	
}

//Set the opacity of all images to 0
$(obj).find(options.tag).css({opacity: 0.0});

//Get the first image and display it (set it to full opacity)
$(obj).find(options.tag + ':first').css({opacity: 1.0});

//Set the caption background to semi-transparent
$(obj).find('div.caption').css({opacity: 1.0});

//Resize the width of the caption according to the image width
$(obj).find('div.caption').css({width: $(obj).find(options.tag).find('img').css('width')});

//Get the caption of the first image from REL attribute and display it
$(obj).find('div.content').html($(obj).find(options.tag + ':first').find('img').attr('rel'))
.animate({opacity: 1.0}, 400);

var cap_height = '30px';
	
if(options.caption == 'No')
{

$(obj).find("div.caption").css("display", "none");
	
	cap_height = '0px';
	
}

if($(obj).find(options.tag).length>1)
{

//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
setInterval(gallery ,options.speed);

}

};
})(jQuery);//jQuery Slideshow

(function($){
$.fn.slidecaption = function(options) {
    
var defaults = {
tag: '.boxgrid'
};
  
var options = $.extend(defaults, options);

var obj = $(this);

var animation = $(obj).find(options.tag).attr('rel');

switch(animation)
{
 
     case "slidedown":
	 //Vertical Sliding
	 
     $(obj).find(options.tag).hover(function(){
         $("div.cover", this).stop().animate({top:'-'+$(this).height()+'px'},{queue:false,duration:300});  
     }, function() {  
         $("div.cover", this).stop().animate({top:'0px'},{queue:false,duration:300});  
     });
	 break;
	 
	 case "slideright":
     //Horizontal Sliding  
     $(obj).find(options.tag).hover(function(){  
         $("div.cover", this).stop().animate({left: $(this).width() + 'px'},{queue:false,duration:300});  
     }, function() {  
         $("div.cover", this).stop().animate({left:'0px'},{queue:false,duration:300});  
     });  
	 break;
	 
	 case "thecombo":
     //Diagnal Sliding  
     $(obj).find(options.tag).hover(function(){  
         $("div.cover", this).stop().animate({top: $(this).height()+'px', left: $(this).width()+'px'},{queue:false,duration:300});  
     }, function() {  
         $("div.cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});  
     });
	 break;
	 
	 case "peek":
     //Partial Sliding (Only show some of background)  
     $(obj).find(options.tag).hover(function(){  
         $("div.cover", this).stop().animate({top:'90px'},{queue:false,duration:160});  
     }, function() {  
         $("div.cover", this).stop().animate({top:'0px'},{queue:false,duration:160});  
     });  
	 break;
	 
	 case "captionfull":
     //Full Caption Sliding (Hidden to Visible)  
     $(obj).find(options.tag).hover(function(){  
         $("div.cover", this).stop().animate({top:'340px'},{queue:false,duration:160});  
     }, function() {  
         $("div.cover", this).stop().animate({top: $(this).height()+'px'},{queue:false,duration:160});  
     });  
	 break;
	 
	 case "caption":
     //Caption Sliding (Partially Hidden to Visible)  
     $(obj).find(options.tag).hover(function(){  
         $(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});  
     }, function() {  
         $(".cover", this).stop().animate({top:'220px'},{queue:false,duration:160});  
     });
	 break;
}

};
})(jQuery);/**
 * jQuery lightBox plugin
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * and adapted to me for use like a plugin from jQuery.
 * @name jquery-lightbox-0.5.js
 * @author Leandro Vieira Pinho - http://leandrovieira.com
 * @version 0.5
 * @date April 11, 2008
 * @category jQuery plugin
 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
 * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
 */
(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.8,fixedNavigation:false,imageLoading:'/images/lightbox-ico-loading.gif',imageBtnPrev:'/images/lightbox-btn-prev.gif',imageBtnNext:'/images/lightbox-btn-next.gif',imageBtnClose:'/images/lightbox-btn-close.gif',imageBlank:'/images/lightbox-blank.gif',containerBorderSize:10,containerResizeSpeed:400,txtImage:'Image',txtOf:'of',keyToClose:'c',keyToPrev:'p',keyToNext:'n',imageArray:[],activeImage:0},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false;}
function _start(objClicked,jQueryMatchedObj){$('embed, object, select').css({'visibility':'hidden'});_set_interface();settings.imageArray.length=0;settings.activeImage=0;if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));}else{for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));}}
while(settings.imageArray[settings.activeImage][0]!=objClicked.getAttribute('href')){settings.activeImage++;}
_set_image_to_view();}
function _set_interface(){$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'"></a></div></div></div></div>');var arrPageSizes=___getPageSize();$('#jquery-overlay').css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();$('#jquery-overlay,#jquery-lightbox').click(function(){_finish();});$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function(){_finish();return false;});$(window).resize(function(){var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]});});}
function _set_image_to_view(){$('#lightbox-loading').show();if(settings.fixedNavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}else{$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}
var objImagePreloader=new Image();objImagePreloader.onload=function(){$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);objImagePreloader.onload=function(){};};objImagePreloader.src=settings.imageArray[settings.activeImage][0];};function _resize_container_image_box(intImageWidth,intImageHeight){var intCurrentWidth=$('#lightbox-container-image-box').width();var intCurrentHeight=$('#lightbox-container-image-box').height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));var intDiffW=intCurrentWidth-intWidth;var intDiffH=intCurrentHeight-intHeight;$('#lightbox-container-image-box').animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){_show_image();});if((intDiffW==0)&&(intDiffH==0)){if($.browser.msie){___pause(250);}else{___pause(100);}}
$('#lightbox-container-image-data-box').css({width:intImageWidth});$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:intImageHeight+(settings.containerBorderSize*2)});};function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(function(){_show_image_data();_set_navigation();});_preload_neighbor_images();};function _show_image_data(){$('#lightbox-container-image-data-box').slideDown('fast');$('#lightbox-image-details-caption').hide();if(settings.imageArray[settings.activeImage][1]){$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();}
if(settings.imageArray.length>1){$('#lightbox-image-details-currentNumber').html(settings.txtImage+' '+(settings.activeImage+1)+' '+settings.txtOf+' '+settings.imageArray.length).show();}}
function _set_navigation(){$('#lightbox-nav').show();$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({'background':'transparent url('+settings.imageBlank+') no-repeat'});if(settings.activeImage!=0){if(settings.fixedNavigation){$('#lightbox-nav-btnPrev').css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnPrev').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}}
if(settings.activeImage!=(settings.imageArray.length-1)){if(settings.fixedNavigation){$('#lightbox-nav-btnNext').css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnNext').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}}
_enable_keyboard_navigation();}
function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent);});}
function _disable_keyboard_navigation(){$(document).unbind();}
function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27;}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE;}
key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(key=='x')||(keycode==escapeKey)){_finish();}
if((key==settings.keyToPrev)||(keycode==37)){if(settings.activeImage!=0){settings.activeImage=settings.activeImage-1;_set_image_to_view();_disable_keyboard_navigation();}}
if((key==settings.keyToNext)||(keycode==39)){if(settings.activeImage!=(settings.imageArray.length-1)){settings.activeImage=settings.activeImage+1;_set_image_to_view();_disable_keyboard_navigation();}}}
function _preload_neighbor_images(){if((settings.imageArray.length-1)>settings.activeImage){objNext=new Image();objNext.src=settings.imageArray[settings.activeImage+1][0];}
if(settings.activeImage>0){objPrev=new Image();objPrev.src=settings.imageArray[settings.activeImage-1][0];}}
function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});}
function ___getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};function ___getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;};function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date();}
while(curDate-date<ms);};return this.unbind('click').click(_initialize);};})(jQuery);var Mapifies;if(!Mapifies){Mapifies={}}Mapifies.MapObjects={};Mapifies.MapObjects.Set=function(B,A){var C=jQuery(B).attr("id");var D=new GMap2(B);Mapifies.MapObjects[C]=D;Mapifies.MapObjects[C].Options=A;return Mapifies.MapObjects[C]};Mapifies.MapObjects.Append=function(A,C,D){var B=jQuery(A).attr("id");Mapifies.MapObjects[B][C]=D};Mapifies.MapObjects.Get=function(A){return Mapifies.MapObjects[jQuery(A).attr("id")]};Mapifies.Initialise=function(B,A,F){function D(){return{language:"en",mapType:"map",mapCenter:[55.958858,-3.162302],mapZoom:12,mapControl:"small",mapEnableType:false,mapEnableOverview:false,mapEnableDragging:true,mapEnableInfoWindows:true,mapEnableDoubleClickZoom:false,mapEnableScrollZoom:false,mapEnableSmoothZoom:false,mapEnableGoogleBar:false,mapEnableScaleControl:false,mapShowjMapsIcon:true,debugMode:false}}A=jQuery.extend(D(),A);if(GBrowserIsCompatible()){var E=Mapifies.MapObjects.Set(B,A);var C=Mapifies.GetMapType(A.mapType);E.setCenter(new GLatLng(A.mapCenter[0],A.mapCenter[1]),A.mapZoom,C);if(A.mapShowjMapsIcon){Mapifies.AddScreenOverlay(B,{imageUrl:"http://hg.digitalspaghetti.me.uk/jmaps/raw-file/3228fade0b3c/docs/images/jmaps-mapicon.png",screenXY:[70,10],overlayXY:[0,0],size:[42,25]})}switch(A.mapControl){case"small":E.addControl(new GSmallMapControl());break;case"large":E.addControl(new GLargeMapControl());break}if(A.mapEnableType){E.addControl(new GMapTypeControl())}if(A.mapEnableOverview){E.addControl(new GOverviewMapControl())}if(!A.mapEnableDragging){E.disableDragging()}if(!A.mapEnableInfoWindows){E.disableInfoWindow()}if(A.mapEnableDoubleClickZoom){E.enableDoubleClickZoom()}if(A.mapEnableScrollZoom){E.enableScrollWheelZoom()}if(A.mapEnableSmoothZoom){E.enableContinuousZoom()}if(A.mapEnableGoogleBar){E.enableGoogleBar()}if(A.mapEnableScaleControl){E.addControl(new GScaleControl())}if(A.debugMode){console.log(Mapifies)}if(typeof F=="function"){return F(E,B,A)}}else{jQuery(B).text("Your browser does not support Google Maps.");return false}return};Mapifies.MoveTo=function(C,B,G){function E(){return{centerMethod:"normal",mapType:null,mapCenter:[],mapZoom:null}}var F=Mapifies.MapObjects.Get(C);B=jQuery.extend(E(),B);if(B.mapType){var D=Mapifies.GetMapType(B.mapType)}var A=new GLatLng(B.mapCenter[0],B.mapCenter[1]);switch(B.centerMethod){case"normal":F.setCenter(A,B.mapZoom,D);break;case"pan":F.panTo(A);break}if(typeof G=="function"){return G(A,B)}};Mapifies.SavePosition=function(B,A,D){var C=Mapifies.MapObjects.Get(B);C.savePosition();if(typeof D=="function"){return D(C)}};Mapifies.GotoSavedPosition=function(B,A,D){var C=Mapifies.MapObjects.Get(B);C.returnToSavedPosition();if(typeof D=="function"){return D(C)}};Mapifies.CreateKeyboardHandler=function(B,A,E){var C=Mapifies.MapObjects.Get(B);var D=new GKeyboardHandler(C);if(typeof E=="function"){return E(D)}};Mapifies.CheckResize=function(B,A,D){var C=Mapifies.MapObjects.Get(B);C.checkResize();if(typeof D=="function"){return D(B)}};Mapifies.SearchAddress=function(C,B,F){function D(){return{query:null,returnType:"getLatLng",cache:undefined,countryCode:"uk"}}var E=Mapifies.MapObjects.Get(C);B=jQuery.extend(D(),B);if(typeof E.Geocoder==="undefined"){if(typeof B.cache==="undefined"){var A=new GClientGeocoder()}else{var A=new GClientGeocoder(cache)}Mapifies.MapObjects.Append(C,"Geocoder",A);E=Mapifies.MapObjects.Get(C)}E.Geocoder[B.returnType](B.query,function(G){if(typeof F==="function"){return F(G,B)}});return};Mapifies.SearchDirections=function(D,I,H){function C(){return{query:null,panel:null,locale:"en_GB",travelMode:"driving",avoidHighways:false,getPolyline:true,getSteps:true,preserveViewport:false,clearLastSearch:false}}var G=Mapifies.MapObjects.Get(D);I=jQuery.extend(C(),I);var B={locale:I.locale,travelMode:I.travelMode,avoidHighways:I.avoidHighways,getPolyline:I.getPolyline,getSteps:I.getSteps,preserveViewport:I.preserveViewport};var A=$(I.panel).get(0);if(typeof G.Directions==="undefined"){Mapifies.MapObjects.Append(D,"Directions",new GDirections(G,A))}GEvent.addListener(G.Directions,"load",F);GEvent.addListener(G.Directions,"error",E);if(I.clearLastSearch){G.Directions.clear()}G.Directions.load(I.query,B);function F(){if(typeof H=="function"){return H(G.Directions,I)}}function E(){if(typeof H=="function"){return H(G.Directions,I)}}return};Mapifies.CreateAdsManager=function(C,B,F){function D(){return{publisherId:"",maxAdsOnMap:3,channel:0,minZoomLevel:6}}var E=Mapifies.MapObjects.Get(C);B=jQuery.extend(D(),B);var A={maxAdsOnMap:B.maxAdsOnMap,channel:B.channel,minZoomLevel:B.minZoomLevel};if(typeof E.AdsManager=="undefined"){Mapifies.MapObjects.Append(C,"AdsManager",new GAdsManager(E,B.publisherId,A))}if(typeof F=="function"){return F(E.AdsManager,B)}};Mapifies.AddFeed=function(B,A,F){function D(){return{feedUrl:null,mapCenter:[]}}var E=Mapifies.MapObjects.Get(B);A=jQuery.extend(D(),A);var C=new GGeoXml(A.feedUrl);E.addOverlay(C);if(A.mapCenter[0]&&A.mapCenter[1]){E.setCenter(new GLatLng(A.mapCenter[0],A.mapCenter[1]))}if(typeof F=="function"){return F(C,A)}return};Mapifies.RemoveFeed=function(A,B,D){var C=Mapifies.MapObjects.Get(A);C.removeOverlay(B);if(typeof D=="function"){return D(B)}return};Mapifies.AddGroundOverlay=function(B,A,F){function D(){return{overlaySouthWestBounds:undefined,overlayNorthEastBounds:undefined,overlayImage:undefined}}var E=Mapifies.MapObjects.Get(B);A=jQuery.extend(D(),A);var C=new GLatLngBounds(new GLatLng(A.overlaySouthWestBounds[0],A.overlaySouthWestBounds[1]),new GLatLng(A.overlayNorthEastBounds[0],A.overlayNorthEastBounds[1]));groundOverlay=new GGroundOverlay(A.overlayImage,C);E.addOverlay(groundOverlay);if(typeof F=="function"){return F(groundOverlay,A)}return};Mapifies.RemoveGroundOverlay=function(A,C,D){var B=Mapifies.MapObjects.Get(A);B.removeOverlay(C);if(typeof D==="function"){return D(C)}return};Mapifies.AddMarker=function(D,C,G){function E(){var H={pointLatLng:undefined,pointHTML:undefined,pointOpenHTMLEvent:"click",pointIsDraggable:false,pointIsRemovable:false,pointRemoveEvent:"dblclick",pointMinZoom:4,pointMaxZoom:17,pointIcon:undefined,centerMap:false,centerMoveMethod:"normal"};return H}var F=Mapifies.MapObjects.Get(D);C=jQuery.extend({},E(),C);var B={};if(typeof C.pointIcon=="object"){jQuery.extend(B,{icon:C.pointIcon})}if(C.pointIsDraggable){jQuery.extend(B,{draggable:C.pointIsDraggable})}if(C.centerMap){switch(C.centerMoveMethod){case"normal":F.setCenter(new GLatLng(C.pointLatLng[0],C.pointLatLng[1]));break;case"pan":F.panTo(new GLatLng(C.pointLatLng[0],C.pointLatLng[1]));break}}var A=new GMarker(new GLatLng(C.pointLatLng[0],C.pointLatLng[1]),B);if(C.pointHTML){GEvent.addListener(A,C.pointOpenHTMLEvent,function(){A.openInfoWindowHtml(C.pointHTML,{maxContent:C.pointMaxContent,maxTitle:C.pointMaxTitle})})}if(C.pointIsRemovable){GEvent.addListener(A,C.pointRemoveEvent,function(){F.removeOverlay(A)})}if(F.MarkerManager){F.MarkerManager.addMarker(A,C.pointMinZoom,C.pointMaxZoom)}else{F.addOverlay(A)}if(typeof G=="function"){return G(A,C)}return};Mapifies.RemoveMarker=function(B,A,D){var C=Mapifies.MapObjects.Get(B);C.removeOverlay(A);if(typeof D==="function"){return D(A)}return};Mapifies.CreateMarkerManager=function(C,A,G){function D(){return{markerManager:"GMarkerManager",borderPadding:100,maxZoom:17,trackMarkers:false}}var F=Mapifies.MapObjects.Get(C);A=jQuery.extend(D(),A);var E={borderPadding:A.borderPadding,maxZoom:A.maxZoom,trackMarkers:A.trackMarkers};var B=new window[A.markerManager](F,A);Mapifies.MapObjects.Append(C,"MarkerManager",B);if(typeof G=="function"){return G(B,A)}};Mapifies.AddPolygon=function(E,C,H){function F(){return{polygonPoints:[],polygonStrokeColor:"#000000",polygonStrokeWeight:5,polygonStrokeOpacity:1,polygonFillColor:"#ff0000",polygonFillOpacity:1,mapCenter:undefined,polygonClickable:true}}var G=Mapifies.MapObjects.Get(E);C=jQuery.extend(F(),C);var A={};if(!C.polygonClickable){A=jQuery.extend(A,{clickable:false})}if(typeof C.mapCenter!=="undefined"&&C.mapCenter[0]&&C.mapCenter[1]){G.setCenter(new GLatLng(C.mapCenter[0],C.mapCenter[1]))}var B=[];jQuery.each(C.polygonPoints,function(J,I){B.push(new GLatLng(I[0],I[1]))});var D=new GPolygon(B,C.polygonStrokeColor,C.polygonStrokeWeight,C.polygonStrokeOpacity,C.polygonFillColor,C.polygonFillOpacity,A);G.addOverlay(D);if(typeof H=="function"){return H(D,A,C)}return};Mapifies.RemovePolygon=function(B,A,D){var C=Mapifies.MapObjects.Get(B);C.removeOverlay(A);if(typeof D==="function"){return D(A)}return};Mapifies.AddPolyline=function(D,C,H){function F(){return{polylinePoints:[],polylineStrokeColor:"#ff0000",polylineStrokeWidth:10,polylineStrokeOpacity:1,mapCenter:[],polylineGeodesic:false,polylineClickable:true}}var G=Mapifies.MapObjects.Get(D);C=jQuery.extend(F(),C);var E={};if(C.polylineGeodesic){jQuery.extend(E,{geodesic:true})}if(!C.polylineClickable){jQuery.extend(E,{clickable:false})}if(C.mapCenter[0]&&C.mapCenter[1]){G.setCenter(new GLatLng(C.mapCenter[0],C.mapCenter[1]))}var B=[];jQuery.each(C.polylinePoints,function(J,I){B.push(new GLatLng(I[0],I[1]))});var A=new GPolyline(B,C.polylineStrokeColor,C.polylineStrokeWidth,C.polylineStrokeOpacity,E);G.addOverlay(A);if(typeof H=="function"){return H(A,E,C)}return};Mapifies.RemovePolyline=function(B,A,D){var C=Mapifies.MapObjects.Get(B);C.removeOverlay(A);if(typeof D==="function"){return D(A)}return};Mapifies.AddScreenOverlay=function(C,B,F){function D(){return{imageUrl:"",screenXY:[],overlayXY:[],size:[]}}var E=Mapifies.MapObjects.Get(C);B=jQuery.extend(D(),B);var A=new GScreenOverlay(B.imageUrl,new GScreenPoint(B.screenXY[0],B.screenXY[1]),new GScreenPoint(B.overlayXY[0],B.overlayXY[1]),new GScreenSize(B.size[0],B.size[1]));E.addOverlay(A);if(typeof F=="function"){return F(A,B)}};Mapifies.RemoveScreenOverlay=function(B,A,D){var C=Mapifies.MapObjects.Get(B);C.removeOverlay(A);if(typeof D==="function"){return D(A)}return};Mapifies.CreateStreetviewPanorama=function(E,D,H){function F(){return{overideContainer:"",latlng:[40.75271883902363,-73.98262023925781],pov:[]}}var G=Mapifies.MapObjects.Get(E);D=jQuery.extend(F(),D);var A=null;if(D.overideContainer!==""){A=jQuery(D.overideContainer).get(0)}else{A=jQuery(E).get(0)}var B={};if(D.pov.length>0){jQuery.extend(B,{pov:new GPov(D.latlng[0],D.latlng[1],D.latlng[2])})}if(D.latlng.length>0){jQuery.extend(B,{latlng:new GLatLng(D.latlng[0],D.latlng[1])})}var C=new GStreetviewPanorama(A,B);if(typeof H=="function"){return H(C,D)}return};Mapifies.RemoveStreetviewPanorama=function(B,A,D){var C=Mapifies.MapObjects.Get(B);A.remove();if(typeof D=="function"){return D(A)}return};Mapifies.AddTrafficInfo=function(B,A,F){function D(){return{mapCenter:[]}}var E=Mapifies.MapObjects.Get(B);A=jQuery.extend(D(),A);var C=new GTrafficOverlay;E.addOverlay(C);if(A.mapCenter[0]&&A.mapCenter[1]){E.setCenter(new GLatLng(A.mapCenter[0],A.mapCenter[1]))}if(typeof F=="function"){return F(C,A)}};Mapifies.RemoveTrafficInfo=function(A,B,D){var C=Mapifies.MapObjects.Get(A);C.removeOverlay(B);if(typeof D==="function"){return D(B)}return};Mapifies.SearchCode=function(A){switch(A){case G_GEO_SUCCESS:return{code:G_GEO_SUCCESS,success:true,message:"Success"};case G_GEO_UNKNOWN_ADDRESS:return{code:G_GEO_UNKNOWN_ADDRESS,success:false,message:"No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect"};break;case G_GEO_SERVER_ERROR:return{code:G_GEO_UNKNOWN_ADDRESS,success:false,message:"A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known."};break;case G_GEO_MISSING_QUERY:return{code:G_GEO_UNKNOWN_ADDRESS,success:false,message:"The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input."};break;case G_GEO_BAD_KEY:return{code:G_GEO_UNKNOWN_ADDRESS,success:false,message:"The given key is either invalid or does not match the domain for which it was given."};break;case G_GEO_BAD_REQUEST:return{code:G_GEO_UNKNOWN_ADDRESS,success:false,message:"A directions request could not be successfully parsed."};break;default:return{code:null,success:false,message:"An unknown error occurred."};break}};Mapifies.GetMapType=function(A){switch(A){case"map":A=G_NORMAL_MAP;break;case"sat":A=G_SATELLITE_MAP;break;case"hybrid":A=G_HYBRID_MAP;break}return A};Mapifies.GetTravelMode=function(A){switch(A){case"driving":A=G_TRAVEL_MODE_DRIVING;break;case"walking":A=G_TRAVEL_MODE_WALKING;break}return A};Mapifies.createIcon=function(A){function C(){return{iconImage:undefined,iconShadow:undefined,iconSize:undefined,iconShadowSize:undefined,iconAnchor:undefined,iconInfoWindowAnchor:undefined,iconPrintImage:undefined,iconMozPrintImage:undefined,iconPrintShadow:undefined,iconTransparent:undefined}}A=jQuery.extend(C(),A);var B=new GIcon(G_DEFAULT_ICON);if(A.iconImage){B.image=A.iconImage}if(A.iconShadow){B.shadow=A.iconShadow}if(A.iconSize){B.iconSize=A.iconSize}if(A.iconShadowSize){B.shadowSize=A.iconShadowSize}if(A.iconAnchor){B.iconAnchor=A.iconAnchor}if(A.iconInfoWindowAnchor){B.infoWindowAnchor=A.iconInfoWindowAnchor}return B};Mapifies.getCenter=function(A){var B=Mapifies.MapObjects.Get(A);return B.getCenter()};Mapifies.getBounds=function(A){var B=Mapifies.MapObjects.Get(A);return B.getBounds()};var Mapifies;if(!Mapifies){Mapifies={}}(function(A){A.fn.jmap=function(D,B,C){return this.each(function(){if(D=="init"&&typeof B=="undefined"){new Mapifies.Initialise(this,{},null)}else{if(D=="init"&&typeof B=="object"){new Mapifies.Initialise(this,B,C)}else{if(D=="init"&&typeof B=="function"){new Mapifies.Initialise(this,{},B)}else{if(typeof D=="object"||D==null){new Mapifies.Initialise(this,D,B)}else{try{new Mapifies[D](this,B,C)}catch(E){throw Error("Mapifies Function Does Not Exist")}}}}}})}})(jQuery);/* jQuery Translate plugin and related components */
/* http://code.google.com/p/jquery-translate/
 * Version: 1.3.7
 * License: MIT, GPL  (c) 2009 Balazs Endresz
 */
(function(d){var a,j,h,g=false,b=false,i=[];function e(){j=c.GL=google.language;h=j.Languages;g=true;var k;while(k=i.shift()){k()}}function f(){}function c(){this.extend(d.translate);delete this.defaults;delete this.fn}c.prototype={version:"1.3.7",translateInit:function(k,m){var l=this;this.options=m;m.from=this.toLanguageCode(m.from)||"";m.to=this.toLanguageCode(m.to)||"";if(m.fromOriginal&&m.nodes[0]){m.nodes.each(function(n){var o=d.translate.getData(this,m.from,m);if(!o){return false}k[n]=o})}if(typeof k==="string"){if(!m.comments){k=this.stripComments(k)}this.rawSource="<div>"+k+"</div>";this.isString=true}else{if(!m.comments){k=d.map(k,function(n){return d.translate.stripComments(n)})}this.rawSource="<div>"+k.join("</div><div>")+"</div>";this.isString=false}this.from=m.from;this.to=m.to;this.source=k;this.elements=m.nodes;this.rawTranslation="";this.translation=[];this.startPos=0;this.i=0;this.stopped=false;m.start.call(this,m.nodes[0]?m.nodes:k,m.from,m.to,m);if(m.timeout>0){this.timeout=setTimeout(function(){m.onTimeout.call(l,m.nodes[0]?m.nodes:k,m.from,m.to,m)},m.timeout)}(m.toggle&&m.nodes[0])?this._toggle():this.translate();return this},translate:function(){if(this.stopped){return}var t=this,k=this.options;this.rawSourceSub=this.truncate(this.rawSource.substr(this.startPos),1750);this.startPos+=this.rawSourceSub.length;var q=this.rawTranslation.length,u;while((u=this.rawTranslation.lastIndexOf("</div>",q))>-1){q=u-1;var v=this.rawTranslation.substr(0,q+1),s=v.match(/<div[> ]/gi),r=v.match(/<\/div>/gi);s=s?s.length:0;r=r?r.length:0;if(s!=r+1){continue}var m=d(this.rawTranslation.substr(0,q+7)),p=m.length,n=this.i;if(n==p){break}m.slice(n,p).each(function(l,o){(function(){if(this.stopped){return false}var y=d(o).html().replace(/^\s/,""),x=n+l,z=this.source,A=this.from.length<2&&this.detectedSourceLanguage||this.from;this.translation[x]=y;if(!k.nodes[0]){if(this.isString){this.translation=y}else{z=this.source[x]}k.each.call(this,x,y,z,A,this.to,k)}else{this.each(x,this.elements[x],y,this.source[x],A,this.to,k);k.each.call(this,x,this.elements[x],y,this.source[x],A,this.to,k)}this.i++}).call(t)});break}if(this.rawSourceSub.length>0){j.translate(this.rawSourceSub,this.from,this.to,function(l){(function(){if(l.error){return k.error.call(this,l.error,this.rawSourceSub,this.from,this.to,k)}this.rawTranslation+=l.translation||this.rawSourceSub;this.detectedSourceLanguage=l.detectedSourceLanguage;this.translate()}).call(t)});if(!k.nodes[0]){return}}else{if(!this.rawTranslation){return}var w=this.from.length<2&&this.detectedSourceLanguage||this.from;if(this.timeout){clearTimeout(this.timeout)}if(!k.nodes[0]){k.complete.call(this,this.translation,this.source,w,this.to,k)}else{k.complete.call(this,this.elements.end(),this.elements,this.translation,this.source,w,this.to,k)}}},stop:function(){if(this.stopped){return this}this.stopped=true;this.options.error.call(this,{message:"stopped"});return this}};d.translate=function(m,l,k,o){if(m==a){return new c()}if(d.isFunction(m)){return d.translate.ready(m,l)}var n=new c();return d.translate.ready(function(){return n.translateInit(m,d.translate._getOpt(l,k,o))},false,n)};d.translate.fn=d.translate.prototype=c.prototype;d.translate.fn.extend=d.translate.extend=d.extend;d.translate.extend({stripComments:function(k){return k.replace(/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)>/g,"")},truncate:function(q,l){var m,u,r,p,o,s,k=encodeURIComponent(q);for(m=0;m<10;m++){try{s=decodeURIComponent(k.substr(0,l-m))}catch(n){continue}if(s){break}}return(!(u=/<(?![^<]*>)/.exec(s)))?((!(r=/>\s*$/.exec(s)))?((p=/[\.\?\!;:](?![^\.\?\!;:]*[\.\?\!;:])/.exec(s))?((o=/>(?![^>]*<)/.exec(s))?(p.index>o.index?s.substring(0,p.index+1):s.substring(0,o.index+1)):s.substring(0,p.index+1)):s):s):s.substring(0,u.index)},getLanguages:function(t,s){if(t==a||(s==a&&!t)){return h}var r={},m=s,p=h;if(s){p=d.translate.getLanguages(t)}else{if(typeof t==="object"){m=t}}if(m){for(var q=0,n=m.length,k,o;q<n;q++){k=d.translate.toLanguageCode(m[q]);for(o in p){if(k===p[o]){r[o]=p[o]}}}}else{for(var o in h){if(j.isTranslatable(h[o])){r[o]=h[o]}}}return r},toLanguage:function(m,n){for(var k in h){if(m===k||m===h[k]||m.toUpperCase()===k||m.toLowerCase()===h[k].toLowerCase()){return n==="lowercase"?k.toLowerCase():n==="capitalize"?k.charAt(0).toUpperCase()+k.substr(1).toLowerCase():k}}},toLanguageCode:function(k){return h.a||h[d.translate.toLanguage(k)]},same:function(l,k){return l===k||d.translate.toLanguageCode(l)===d.translate.toLanguageCode(k)},isTranslatable:function(k){return j.isTranslatable(d.translate.toLanguageCode(k))},getBranding:function(l,k,m){return d(j.getBranding(l,k,m))},load:function(l,m,k){b=true;function n(){google.load(m||"language",k||"1",{callback:e})}(typeof google!=="undefined"&&google.load)?n():d.getScript("http://www.google.com/jsapi?"+(l?"key="+l:""),n);return d.translate},ready:function(k,m,l){g?k():i.push(k);if(!b&&!m){d.translate.load()}return l||d.translate},_getOpt:function(l,k,r,q){var p,n,m={};if(typeof l==="object"){m=l}else{if(!k&&!r){n=l}if(!r&&k){if(typeof k==="object"){n=l;m=k}else{p=l;n=k}}if(l!=a&&k&&r){p=l;n=k;m=r}m.from=p||m.from||"";m.to=n||m.to||""}if(m.fromOriginal){m.toggle=true}if(m.toggle){m.data=true}if(m.async===true){m.async=2}return d.extend({},d.translate._defaults,(q?d.fn.translate.defaults:d.translate.defaults),m)},_defaults:{comments:false,start:f,error:f,each:f,complete:f,onTimeout:f,timeout:0,from:"",to:"",nodes:[],walk:true,returnAll:false,replace:true,rebind:true,data:true,setLangAttr:false,subject:true,not:"",altAndVal:true,async:false,toggle:false,fromOriginal:false}});d.translate.defaults=d.extend({},d.translate._defaults)})(jQuery);(function(b){function a(f,d){var g=f.css("text-align");f.css("direction",d);if(g==="right"){f.css("text-align","left")}if(g==="left"){f.css("text-align","right")}}function c(e,f){var g=e.nodeName.toUpperCase(),d=g==="INPUT"&&b.attr(e,"type").toLowerCase();return typeof f.subject==="string"?f.subject:f.altAndVal&&(g==="IMG"||d==="image")?"alt":f.altAndVal&&({text:1,button:1,submit:1})[d]?"value":g==="TEXTAREA"?"value":"html"}b.translate.fn._toggle=function(){var f=this,g=this.options,e=g.nodes,h=g.to,d=false;e.each(function(j){f.i=j;var l=b(this),k=f.getData(this,h,g);if(!k){return !(d=true)}f.translation.push(k);f.setLangAttr(l,h,g);f.replace(l,k,g);g.each.call(f,j,f.elements[j],k,f.source[j],f.from,h,g)});!d?g.complete.call(this,e.end(),e,f.translation,this.source,this.from,this.to,g):this.translate()};b.translate.extend({each:function(f,h,d,g,m,l,k){var j=b(h);b.translate.setData(h,d,g,m,l,k);b.translate.replace(j,d,k);b.translate.setLangAttr(j,l,k)},getData:function(d,g,f){var e=b.data(d,"translation");return e&&e[g]&&e[g][c(d,f)]},setData:function(g,d,f,k,j,i){if(!i.data){return}var e=c(g,i),h=b.data(g,"translation");h=h||b.data(g,"translation",{});(h[k]=h[k]||{})[e]=f;(h[j]=h[j]||{})[e]=d;b.data(g,"translation."+k+"."+e,f);b.data(g,"translation."+j+"."+e,d)},replace:function(i,g,j){if(!j.replace){return}if(typeof j.subject==="string"){return i.attr(j.subject,g)}var k=i[0].nodeName.toUpperCase(),h=k==="INPUT"&&b.attr(i[0],"type").toLowerCase();if(j.to==="ar"){a(i,"rtl")}else{if(i.css("direction")==="rtl"){a(i,"ltr")}}if(j.altAndVal&&(k==="IMG"||h==="image")){i.attr("alt",g)}else{if(j.altAndVal&&({text:1,button:1,submit:1})[h]){i.val(g)}else{if(k==="TEXTAREA"){i.val(g)}else{if(j.rebind){var d=i.find("*").not("script"),f=b("<div/>").html(g);b.translate.copyEvents(d,f.find("*"));i.html(f.contents())}else{i.html(g)}}}}},setLangAttr:function(d,g,f){if(f.setLangAttr){d.attr(f.setLangAttr===true?"lang":f.setLangAttr,g)}},copyEvents:function(e,d){d.each(function(g){var k=e[g];if(!this||!k){return false}if(({SCRIPT:1,NOSCRIPT:1,STYLE:1,OBJECT:1,IFRAME:1})[k.nodeName.toUpperCase()]){return true}var f=b.data(k,"events");if(!f){return true}for(var j in f){for(var h in f[j]){b.event.add(this,j,f[j][h],f[j][h].data)}}})}});b.fn.translate=function(e,d,h){var f=b.translate._getOpt(e,d,h,true),g=b.extend({},b.translate._defaults,b.fn.translate.defaults,f,{complete:function(j,i){f.nodes=j;b.translate(i,f)},each:function(){}});if(this.nodesContainingText){return this.nodesContainingText(g)}f.nodes=this;b.translate(b.map(this,function(i){return b(i).html()||b(i).val()}),f);return this};b.fn.translate.defaults=b.extend({},b.translate._defaults)})(jQuery);(function(a){a.translate.ui=a.translate.fn.ui=function(f,d,i){var h="",g="",e="";if(i){g="<"+i+">";e="</"+i+">"}a.each(a.translate.getLanguages(true),function(b,c){h+=("<"+d+">"+g+b.charAt(0)+b.substring(1).toLowerCase()+e+"</"+d+">")});return a("<"+f+' class="jq-translate-ui">'+h+"</"+f+">")}})(jQuery);(function(a){a.translate.fn.progress=function(b,d){if(!this.i){this.pr=0}this.pr+=this.source[this.i].length;var c=100*this.pr/(this.rawSource.length-(11*(this.i+1)));if(b){var f=a(b);if(!this.i&&!f.hasClass("ui-progressbar")){f.progressbar(d)}f.progressbar("option","value",c)}return c}})(jQuery);(function(b){function a(){}a.prototype={init:function(e,d){this.textArray=[];this.elements=[];this.options=d;this.jquery=e;this.n=-1;if(d.async===true){d.async=2}if(d.not){e=e.not(d.not);e=e.add(e.find("*").not(d.not)).not(b(d.not).find("*"))}else{e=e.add(e.find("*"))}this.jq=e;this.jql=this.jq.length;return this.process()},process:function(){this.n++;var i=this,d=this.options,p="",h=false,g=false,f=this.jq[this.n],k,m,j;if(this.n==this.jql){j=this.jquery.pushStack(this.elements,"nodesContainingText");d.complete.call(j,j,this.textArray);if(d.returnAll===false&&d.walk===false){return this.jquery}return j}if(!f){return this.process()}k=b(f);var n=f.nodeName.toUpperCase(),l=n==="INPUT"&&b.attr(f,"type").toLowerCase();if(({SCRIPT:1,NOSCRIPT:1,STYLE:1,OBJECT:1,IFRAME:1})[n]){return this.process()}if(typeof d.subject==="string"){p=k.attr(d.subject)}else{if(d.altAndVal&&(n==="IMG"||l==="image")){p=k.attr("alt")}else{if(d.altAndVal&&({text:1,button:1,submit:1})[l]){p=k.val()}else{if(n==="TEXTAREA"){p=k.val()}else{m=f.firstChild;if(d.walk!==true){g=true}else{while(m){if(m.nodeType==1){g=true;break}m=m.nextSibling}}if(!g){p=k.text()}else{if(d.walk!==true){h=true}m=f.firstChild;while(m){if(m.nodeType==3&&m.nodeValue.match(/\S/)!==null){if(m.nodeValue.match(/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)>/)!==null){if(m.nodeValue.match(/(\S+(?=.*<))|(>(?=.*\S+))/)!==null){h=true;break}}else{h=true;break}}m=m.nextSibling}if(h){p=k.html().replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,"");this.jq=this.jq.not(k.find("*"))}}}}}}if(!p){return this.process()}this.elements.push(f);if(d.comments===false){p=this.stripComments(p)}this.textArray.push(p);d.each.call(f,this.elements.length-1,f,p);if(d.async){setTimeout(function(){i.process()},d.async);return this.jquery}else{return this.process()}},stripComments:function(d){return d.replace(/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)>/g,"")}};b.fn.nodesContainingText=function(d){d=b.extend({},c,b.fn.nodesContainingText.defaults,d);return new a().init(this,d)};var c={not:"",async:false,each:function(){},complete:function(){},comments:false,returnAll:true,walk:true,altAndVal:false,subject:true};b.fn.nodesContainingText.defaults=c})(jQuery);// JavaScript Document
/**
 * 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;
    }
};/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */

;(function($){
	$.fn.superfish = function(op){

		var sf = $.fn.superfish,
			c = sf.c,
			$arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),
			over = function(){
				var $$ = $(this), menu = getMenu($$);
				clearTimeout(menu.sfTimer);
				$$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function(){
				var $$ = $(this), menu = getMenu($$), o = sf.op;
				clearTimeout(menu.sfTimer);
				menu.sfTimer=setTimeout(function(){
					o.retainPath=($.inArray($$[0],o.$path)>-1);
					$$.hideSuperfishUl();
					if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
				},o.delay);	
			},
			getMenu = function($menu){
				var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
				sf.op = sf.o[menu.serial];
				return menu;
			},
			addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
			
		return this.each(function() {
			var s = this.serial = sf.o.length;
			var o = $.extend({},sf.defaults,op);
			o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
				$(this).addClass([o.hoverClass,c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
			});
			sf.o[s] = sf.op = o;
			
			$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
				if (o.autoArrows) addArrow( $('>a:first-child',this) );
			})
			.not('.'+c.bcClass)
				.hideSuperfishUl();
			
			var $a = $('a',this);
			$a.each(function(i){
				var $li = $a.eq(i).parents('li');
				$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
			});
			o.onInit.call(this);
			
		}).each(function() {
			var menuClasses = [c.menuClass];
			if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
			$(this).addClass(menuClasses.join(' '));
		});
	};

	var sf = $.fn.superfish;
	sf.o = [];
	sf.op = {};
	sf.IE7fix = function(){
		var o = sf.op;
		if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
			this.toggleClass(sf.c.shadowClass+'-off');
		};
	sf.c = {
		bcClass     : 'sf-breadcrumb',
		menuClass   : 'sf-js-enabled',
		anchorClass : 'sf-with-ul',
		arrowClass  : 'sf-sub-indicator',
		shadowClass : 'sf-shadow'
	};
	sf.defaults = {
		hoverClass	: 'sfHover',
		pathClass	: 'overideThisToUse',
		pathLevels	: 1,
		delay		: 800,
		animation	: {opacity:'show'},
		speed		: 'normal',
		autoArrows	: true,
		dropShadows : true,
		disableHI	: false,		// true disables hoverIntent detection
		onInit		: function(){}, // callback functions
		onBeforeShow: function(){},
		onShow		: function(){},
		onHide		: function(){}
	};
	$.fn.extend({
		hideSuperfishUl : function(){
			var o = sf.op,
				not = (o.retainPath===true) ? o.$path : '';
			o.retainPath = false;
			var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility','hidden');
			o.onHide.call($ul);
			return this;
		},
		showSuperfishUl : function(){
			var o = sf.op,
				sh = sf.c.shadowClass+'-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility','visible');
			sf.IE7fix.call($ul);
			o.onBeforeShow.call($ul);
			$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
			return this;
		}
	});

})(jQuery);/*
 * jQuery blockUI plugin
 * Version 2.23 (21-JUN-2009)
 * @requires jQuery v1.2.3 or later
 *
 * Examples at: http://malsup.com/jquery/block/
 * Copyright (c) 2007-2008 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Thanks to Amir-Hossein Sobhi for some excellent contributions!
 */

;(function($) {

if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
    alert('blockUI requires jQuery v1.2.3 or later!  You are using v' + $.fn.jquery);
    return;
}

$.fn._fadeIn = $.fn.fadeIn;

// this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
// retarded userAgent strings on Vista)
var mode = document.documentMode || 0;
var setExpr = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);
var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !mode;

// global $ methods for blocking/unblocking the entire page
$.blockUI   = function(opts) { install(window, opts); };
$.unblockUI = function(opts) { remove(window, opts); };

// convenience method for quick growl-like notifications  (http://www.google.com/search?q=growl)
$.growlUI = function(title, message, timeout, onClose) {
	var $m = $('<div class="growlUI"></div>');
	if (title) $m.append('<h1>'+title+'</h1>');
	if (message) $m.append('<h2>'+message+'</h2>');
	if (timeout == undefined) timeout = 3000;
    $.blockUI({
		message: $m, fadeIn: 700, fadeOut: 1000, centerY: false,
		timeout: timeout, showOverlay: false,
		onUnblock: onClose, 
		css: $.blockUI.defaults.growlCSS
    });
};

// plugin method for blocking element content
$.fn.block = function(opts) {
    return this.unblock({ fadeOut: 0 }).each(function() {
        if ($.css(this,'position') == 'static')
            this.style.position = 'relative';
        if ($.browser.msie)
            this.style.zoom = 1; // force 'hasLayout'
        install(this, opts);
    });
};

// plugin method for unblocking element content
$.fn.unblock = function(opts) {
    return this.each(function() {
        remove(this, opts);
    });
};

$.blockUI.version = 2.23; // 2nd generation blocking at no extra cost!

// override these in your code to change the default behavior and style
$.blockUI.defaults = {
    // message displayed when blocking (use null for no message)
    message:  '<h1>Please wait...</h1>',

    // styles for the message when blocking; if you wish to disable
    // these and use an external stylesheet then do this in your code:
    // $.blockUI.defaults.css = {};
    css: {
        padding:        0,
        margin:         0,
        width:          '30%',
        top:            '40%',
        left:           '35%',
        textAlign:      'center',
        color:          '#000',
        border:         '3px solid #aaa',
        background:		'none',
        cursor:         'wait'
    },

    // styles for the overlay
    overlayCSS:  {
        backgroundColor: '#000',
        opacity:          0.4,
        cursor:          'wait'
    },

	// styles applied when using $.growlUI
	growlCSS: {
		width:    '350px',
		top:      '10px',
		left:     '',
		right:    '10px',
	    border:   'none',
	    padding:  '5px',
	    opacity:   0.6,
		cursor:    null,
	    color:    '#fff',
	    backgroundColor: '#000',
	    '-webkit-border-radius': '10px',
	    '-moz-border-radius':    '10px'
	},
	
	// IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
	// (hat tip to Jorge H. N. de Vasconcelos)
	iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',

	// force usage of iframe in non-IE browsers (handy for blocking applets)
	forceIframe: false,

    // z-index for the blocking overlay
    baseZ: 1000,

    // set these to true to have the message automatically centered
    centerX: true, // <-- only effects element blocking (page block controlled via css above)
    centerY: true,

    // allow body element to be stetched in ie6; this makes blocking look better
    // on "short" pages.  disable if you wish to prevent changes to the body height
    allowBodyStretch: true,

	// enable if you want key and mouse events to be disabled for content that is blocked
	bindEvents: true,

    // be default blockUI will supress tab navigation from leaving blocking content
    // (if bindEvents is true)
    constrainTabKey: true,

    // fadeIn time in millis; set to 0 to disable fadeIn on block
    fadeIn:  200,

    // fadeOut time in millis; set to 0 to disable fadeOut on unblock
    fadeOut:  400,

	// time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
	timeout: 0,

	// disable if you don't want to show the overlay
	showOverlay: true,

    // if true, focus will be placed in the first available input field when
    // page blocking
    focusInput: true,

    // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
    applyPlatformOpacityRules: true,

    // callback method invoked when unblocking has completed; the callback is
    // passed the element that has been unblocked (which is the window object for page
    // blocks) and the options that were passed to the unblock call:
    //     onUnblock(element, options)
    onUnblock: null,

    // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
    quirksmodeOffsetHack: 4
};

// private data and functions follow...

var pageBlock = null;
var pageBlockEls = [];

function install(el, opts) {
    var full = (el == window);
    var msg = opts && opts.message !== undefined ? opts.message : undefined;
    opts = $.extend({}, $.blockUI.defaults, opts || {});
    opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
    var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
    msg = msg === undefined ? opts.message : msg;

    // remove the current block (if there is one)
    if (full && pageBlock)
        remove(window, {fadeOut:0});

    // if an existing element is being used as the blocking content then we capture
    // its current place in the DOM (and current display style) so we can restore
    // it when we unblock
    if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
        var node = msg.jquery ? msg[0] : msg;
        var data = {};
        $(el).data('blockUI.history', data);
        data.el = node;
        data.parent = node.parentNode;
        data.display = node.style.display;
        data.position = node.style.position;
		if (data.parent)
			data.parent.removeChild(node);
    }

    var z = opts.baseZ;

    // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
    // layer1 is the iframe layer which is used to supress bleed through of underlying content
    // layer2 is the overlay layer which has opacity and a wait cursor (by default)
    // layer3 is the message content that is displayed while blocking

    var lyr1 = ($.browser.msie || opts.forceIframe) 
    	? $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>')
        : $('<div class="blockUI" style="display:none"></div>');
    var lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
    var lyr3 = full ? $('<div class="blockUI blockMsg blockPage" style="z-index:'+z+';display:none;position:fixed"></div>')
                    : $('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>');

    // if we have a message, style it
    if (msg)
        lyr3.css(css);

    // style the overlay
    if (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform)))
        lyr2.css(opts.overlayCSS);
    lyr2.css('position', full ? 'fixed' : 'absolute');

    // make iframe layer transparent in IE
    if ($.browser.msie || opts.forceIframe)
        lyr1.css('opacity',0.0);

    $([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);

    // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
    var expr = setExpr && (!$.boxModel || $('object,embed', full ? null : el).length > 0);
    if (ie6 || expr) {
        // give body 100% height
        if (full && opts.allowBodyStretch && $.boxModel)
            $('html,body').css('height','100%');

        // fix ie6 issue when blocked element has a border width
        if ((ie6 || !$.boxModel) && !full) {
            var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
            var fixT = t ? '(0 - '+t+')' : 0;
            var fixL = l ? '(0 - '+l+')' : 0;
        }

        // simulate fixed position
        $.each([lyr1,lyr2,lyr3], function(i,o) {
            var s = o[0].style;
            s.position = 'absolute';
            if (i < 2) {
                full ? s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"')
                     : s.setExpression('height','this.parentNode.offsetHeight + "px"');
                full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
                     : s.setExpression('width','this.parentNode.offsetWidth + "px"');
                if (fixL) s.setExpression('left', fixL);
                if (fixT) s.setExpression('top', fixT);
            }
            else if (opts.centerY) {
                if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
                s.marginTop = 0;
            }
			else if (!opts.centerY && full) {
				var top = (opts.css && opts.css.top) ? parseInt(opts.css.top) : 0;
				var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
                s.setExpression('top',expression);
			}
        });
    }

    // show the message
	if (msg) {
		lyr3.append(msg);
		if (msg.jquery || msg.nodeType)
			$(msg).show();
	}

	if (($.browser.msie || opts.forceIframe) && opts.showOverlay)
		lyr1.show(); // opacity is zero
	if (opts.fadeIn) {
		if (opts.showOverlay)
			lyr2._fadeIn(opts.fadeIn);
		if (msg)
			lyr3.fadeIn(opts.fadeIn);
	}
	else {
		if (opts.showOverlay)
			lyr2.show();
		if (msg)
			lyr3.show();
	}

    // bind key and mouse events
    bind(1, el, opts);

    if (full) {
        pageBlock = lyr3[0];
        pageBlockEls = $(':input:enabled:visible',pageBlock);
        if (opts.focusInput)
            setTimeout(focus, 20);
    }
    else
        center(lyr3[0], opts.centerX, opts.centerY);

	if (opts.timeout) {
		// auto-unblock
		var to = setTimeout(function() {
			full ? $.unblockUI(opts) : $(el).unblock(opts);
		}, opts.timeout);
		$(el).data('blockUI.timeout', to);
	}
};

// remove the block
function remove(el, opts) {
    var full = el == window;
	var $el = $(el);
    var data = $el.data('blockUI.history');
	var to = $el.data('blockUI.timeout');
	if (to) {
		clearTimeout(to);
		$el.removeData('blockUI.timeout');
	}
    opts = $.extend({}, $.blockUI.defaults, opts || {});
    bind(0, el, opts); // unbind events
    var els = full ? $('body').children().filter('.blockUI') : $('.blockUI', el);

    if (full)
        pageBlock = pageBlockEls = null;

    if (opts.fadeOut) {
        els.fadeOut(opts.fadeOut);
        setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut);
    }
    else
        reset(els, data, opts, el);
};

// move blocking element back into the DOM where it started
function reset(els,data,opts,el) {
    els.each(function(i,o) {
        // remove via DOM calls so we don't lose event handlers
        if (this.parentNode)
            this.parentNode.removeChild(this);
    });

    if (data && data.el) {
        data.el.style.display = data.display;
        data.el.style.position = data.position;
		if (data.parent)
			data.parent.appendChild(data.el);
        $(data.el).removeData('blockUI.history');
    }

    if (typeof opts.onUnblock == 'function')
        opts.onUnblock(el,opts);
};

// bind/unbind the handler
function bind(b, el, opts) {
    var full = el == window, $el = $(el);

    // don't bother unbinding if there is nothing to unbind
    if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
        return;
    if (!full)
        $el.data('blockUI.isBlocked', b);

	// don't bind events when overlay is not in use or if bindEvents is false
    if (!opts.bindEvents || (b && !opts.showOverlay)) 
		return;

    // bind anchors and inputs for mouse and key events
    var events = 'mousedown mouseup keydown keypress';
    b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler);

// former impl...
//    var $e = $('a,:input');
//    b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
};

// event handler to suppress keyboard/mouse events when blocking
function handler(e) {
    // allow tab navigation (conditionally)
    if (e.keyCode && e.keyCode == 9) {
        if (pageBlock && e.data.constrainTabKey) {
            var els = pageBlockEls;
            var fwd = !e.shiftKey && e.target == els[els.length-1];
            var back = e.shiftKey && e.target == els[0];
            if (fwd || back) {
                setTimeout(function(){focus(back)},10);
                return false;
            }
        }
    }
    // allow events within the message content
    if ($(e.target).parents('div.blockMsg').length > 0)
        return true;

    // allow events for content that is not being blocked
    return $(e.target).parents().children().filter('div.blockUI').length == 0;
};

function focus(back) {
    if (!pageBlockEls)
        return;
    var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
    if (e)
        e.focus();
};

function center(el, x, y) {
    var p = el.parentNode, s = el.style;
    var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
    var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
    if (x) s.left = l > 0 ? (l+'px') : '0';
    if (y) s.top  = t > 0 ? (t+'px') : '0';
};

function sz(el, p) {
    return parseInt($.css(el,p))||0;
};

})(jQuery);