/*------------------------------------------------------------------------------------------------------------------------------------*/
/*  jquery.hoverIntent.minified.js   */
/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

/*------------------------------------------------------------------------------------------------------------------------------------*/
/*  jquery.form-validation-and-hints.js   */
/**
 *  2009, icograma.com 
 *  Licensed under GPL license (http://www.opensource.org/licenses/gpl-license.php).
 *  @version 0.201
 *
 *  DEMO: http://www.icograma.com/form-validation-and-hints/
 *  
 */


/* --- TO SET --- */
// Prefix used to hook CSS classes to the script 
classprefix = 'verify'; // <input class="verifyInteger" type="text" name="mail" />

// Set your validation rules 
function isTypeValidExt( classprefix, type, value ) {
    /* RULE EXAMPLE (Accept only integer values)
    if( type == classprefix + 'Integer' ) {
        return ( ( value.match(/^[\d|,|\.|\s]*$/) ) && ( value != '' ) );
    } 
    */
    return true;
}






var annoy=true;
function debug(msg){if(annoy){annoy=confirm(msg);};}

/* --- DOCUMEN READY --- */
$(document).ready(function(){
    mustCheck = true;

    $("."+classprefix+"Cancel").click(function(event){
        mustCheck = false;
    });
    
    // HINTS: Add *title hints to form elements
    for( var i=0; i < document.forms.length; i++) {
        var fe = document.forms[i].elements;    
        for ( var j=0; j < fe.length; j++ ) {
            if( (fe[j]).title.indexOf("**")==0 ) {
                if( (fe[j]).value == "" || (fe[j]).value == titleHint ) {
                    var titleHint = (fe[j]).title.substring(2);
                    (fe[j]).value = titleHint;
                }
            } else if( ( (fe[j]).type == "text" || (fe[j]).type == "password" ) && (fe[j]).title.indexOf("*")==0 ) {
                addHint( (fe[j]) );
                $(fe[j]).blur(function(event){ addHint(this); });
                $(fe[j]).focus(function(event){ removeHint(this); });
            }
        }
    }

    // VALIDATION:
    $("FORM").submit(function(event){
        if(mustCheck) {
            // Prevent submit if validation fails
            if( !checkForm(this) ) {
                event.preventDefault();
            };
        } else {
            mustCheck = !mustCheck;
        }
    });
}); // end jQuery $(document).ready



/* --- FUNCTIONS --- */
function addHint(field) {
    var titleHint = field.title.substring(1);
    if( field.value == "" || field.value == titleHint ) {
            //in "password" inputs, set to "text" to show hint, preserve type in class attribute
            if( field.type == "password" ) {
                $( field ).addClass("password");
                var newObject = changeInputType( field, "text" )//returns false for non-ie
            } //end type == "password"
            $(field).addClass("hint");
            field.value = titleHint;            
    } //end value==""
} //end addHint


function removeHint(field) { //only on INPUT.text items 
    /*if( field.type == "text" && field.title.indexOf("*")==0 ) {*/
        var titleHint = field.title.substring(1);
        if( field.value == "" || field.value == titleHint ) {
            $(field).removeClass('hint');
            field.value="";         
            //re-set password type if appropiate
            if($(field).hasClass("password")) {
                var newObject = changeInputType( field, "password" ); //returns false for non-ie
                if(newObject) { ///IE, element was replaced: reset focus
                    $(newObject).focus();
                    $(newObject).select();
                }
            }//end hasClass("password")
        }//end value == titleHint
    //}//end what.title 
}//end rmhint


function changeInputType(oldObject, oType) {
//based on http://arjansnaterse.nl/changing-type-attribute-in-ie
//used to simulate change of INPUT type in IE
    if(!document.all){
        oldObject.type = oType;
        return false;
    }else{
    //ie can't change INPUT's type, must create new element
        /*
        newObject = $(oldObject).clone(true);
        //newObject.type = oType;
        $(newObject).attr('type');
        $(newObject).insertBefore(oldObject);
        debug(newObject);
        return newObject;
        */
      var newObject = document.createElement('input');
      newObject.type = oType;
      if(oldObject.size) newObject.size = oldObject.size;
      if(oldObject.title) newObject.title = oldObject.title;
      if(oldObject.value) newObject.value = oldObject.value;
      if(oldObject.name) newObject.name = oldObject.name;
      if(oldObject.id) newObject.id = oldObject.id;
      if(oldObject.className) newObject.className = oldObject.className;
      oldObject.parentNode.replaceChild(newObject,oldObject);
      //live()
      return newObject;
  }//end document.all
}

function checkForm(form) {
    var send = true;
    var password = '';
    radioGroups = Array();

    $( form ).removeClass ( "haserrors" );

    //inputs = $(form).find('INPUT[class*="' + classprefix + '"]');
    inputs = $(form).find('INPUT[class*="' + classprefix + '"], .required INPUT, .required TEXTAREA, .required SELECT');
    
    $.each(inputs, function(i, val) {  
        input = $(val);
        if( input.attr('offsetWidth') != 0 ) {

            switch(input.attr('type')) {

                case 'select-one':
                    if( input.get(0)[ input.attr('selectedIndex') ].text == '') {
                        if( send ) moveTo(input);
                        showErrorOn( input );
                        send = false;
                    }
                break;
                
                case 'radio':
                    if( window.radioGroups[ input.attr('name') ] === undefined ) radioGroups[input.attr('name')] = new Array();
                    radioGroups[input.attr('name')][ radioGroups[ input.attr('name') ].length ] = input;
                break;
                
                case 'checkbox':
                    if( !input.attr('checked') ) {
                        if( send ) moveTo(input);
                        showErrorOn( input );
                        send = false;
                    }
                break;
                
                case 'file':
                    if( !isFilled(input) ) {
                        if( send ) moveTo(input);
                        showErrorOn( input );
                        send = false;
                    }
                break;

                case 'password':
                    if( input.hasClass( classprefix + 'PasswordConfirm' ) ) {
                        if( input.val() != password ) {
                            if( send ) moveTo(input);
                            showErrorOn( input );
                            send = false;
                        }
                        break;
                    } else {
                        password = input.val();
                    }

                case 'textarea':
                case 'text':
                    if( ( isFilled(input) || isRequired(input) ) && ( !isValid(input) ) ) {
                        if( send ) moveTo(input);
                        showErrorOn( input );
                        send = false;
                    }
                break;

                default:
                break;
            }
        }       
    });
    for ( var i in radioGroups ) {
        for ( var j in radioGroups[i] ) {
            if( radioGroups[i][j].attr('checked') ) {
                break;
            }
        }
        if( !radioGroups[i][j].attr('checked') ) {
            for ( var j in radioGroups[i] ) {
                if( send ) moveTo( radioGroups[i][j] );
                showErrorOn( radioGroups[i][j] );
            }
            send = false;
        }
    } 
    return send;
}

function isRequired(input) {
    return input.parents( ".required" ).length != 0;
}

function isFilled(input) {
    hintText = '';
    //clear HINTs before validation
    if( input.attr('title').indexOf("**")==0) {
        var hintText = input.attr('title').substring(2);
    } else if( input.attr('title').indexOf("*")==0) {
        var hintText = input.attr('title').substring(1);
    }//end clear hints
    return input.val() != hintText && input.val() != '' ;
}

function isValid( input ) {
    if( !isFilled(input) ) return false;
    string = input.attr('class');
    value = input.val();
    start = string.indexOf(classprefix);
    type = '';
    result = true;
    while(result) {
        if( 
            start == -1 || 
            string.charAt( (start+classprefix.length) ) == ' ' || 
            string.charAt( (start+classprefix.length) ) != string.charAt( (start+classprefix.length) ).toUpperCase() 
        ) { 
            break;
        } else {
            for( i=start; i < string.length; i++ ) {
                if(string.charAt(i) == ' ') {
                    break;
                }
                type += string.charAt(i);
            }
            if( !isTypeValid( type, value ) ) {
                result = false;
                break;
            }
            start = string.indexOf(classprefix,start+1);
        }
    }   
    return result;
}

function isTypeValid( type, value ) {

    if( type == classprefix + 'Text' ) {
        return true;
    }
    
    if( type == classprefix + 'Integer' ) {
        return ( ( value.match(/^[\d|,|\.|\s]*$/) ) && ( value != '' ) );
    }
    
    if( type == classprefix + 'Url' ) {
        return ( value.match( /^(https?:\/\/)?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+\/?)$/ ) );
    }
    
    if( type == classprefix + 'MultipleWords' ) {
        return value.match(/^.*[^^]\s[^$].*$/);
    }
    
    if( type == classprefix + 'Check' ) {
        return value;
    }
    
    if( type == classprefix + 'Mail' ) {
        if( value.indexOf("@example.com")>-1){return false;};
        var emailFilter=/^.+@.+\..{2,}$/;
        var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
        if(!(emailFilter.test(value))||value.match(illegalChars)){return(false);}else{return (true);}
        return false;
    }

    if(typeof isTypeValidExt == 'function') {
        fr = isTypeValidExt( classprefix, type, value );
        if( isTypeValidExt( classprefix, type, value ) === false ) {
            return false;
        } else {
            return true;
        }
    }
    return true;
}

function moveTo( input ) {
    /*var targetOffset = input.offset().top - 40;
    $('html,body').animate({scrollTop: targetOffset}, 200 );*/
    input.get(0).focus();
}

function showErrorOn( input ) {
    input.bind('focus.rmErrorClass', function(){
        rmErrorClass( this );
    });
    input.bind('mousedown.rmErrorClass', function(){
        rmErrorClass( this );
    });
    input.bind('keydown.rmErrorClass', function(){
        rmErrorClass( this );
    }); 
    input.addClass( "error" );
    input.parents( ".required, .field, TR" ).addClass( "error" );
}

function rmErrorClass( elm ) {
    var etag=$(elm).parents(".error");
    var eform = $(elm).parents( 'FORM' );
    $(elm).removeClass("error");
    $(elm).unbind('.rmErrorClass'); //no further clicks will trigger rmErrorClass();
    if(etag){ $(etag).removeClass( "error" ); };
}



/*------------------------------------------------------------------------------------------------------------------------------------*/
/* jquery.cookie.js */
/*jslint browser: true */ /*global jQuery: true */

/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 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
 *
 */

// TODO JsDoc

/**
 * Create a cookie with the given key 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 key The key 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 key.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String key The key 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 (key, value, options) {

    // key and value given, set cookie...
    if (arguments.length > 1 && (value === null || typeof value !== "object")) {
        options = jQuery.extend({}, options);

        if (value === null) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? String(value) : encodeURIComponent(String(value)),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};


/*------------------------------------------------------------------------------------------------------------------------------------*/
/* jquery.newsticker.pack.js */
/*
 *
 * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * Version 2.0
 * Demo: http://www.texotela.co.uk/code/jquery/newsticker/
 *
 * $LastChangedDate$
 * $Rev$
 *
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(1($){$.9.D=$.9.g=1(b){b=b||p;i=1(a){j(a);a.4=$("r",a);a.4.q(":o(0)").l().C();a.5=0;h(a)};h=1(a){a.m=t(1(){f(a)},b)};j=1(a){s(a.m)};8=1(a){a.3=7};d=1(a){a.3=c};f=1(a){e(a.3)6;a.3=7;$(a.4[a.5]).n("k",1(){$(2).l();a.5=++a.5%(a.4.B());$(a.4[a.5]).z("k",1(){a.3=c})})};2.y(1(){e(2.x.w()!="A")6;i(2)}).v("g").u(1(){8(2)},1(){d(2)});6 2}})(E);',41,41,'|function|this|pause|items|currentitem|return|true|pauseTicker|fn|||false|resumeTicker|if|doTick|ticker|startTicker|initTicker|stopTicker|slow|hide|tickfn|fadeOut|eq|4000|not|li|clearInterval|setInterval|hover|addClass|toLowerCase|nodeName|each|fadeIn|ul|size|end|newsTicker|jQuery'.split('|'),0,{}))


/*------------------------------------------------------------------------------------------------------------------------------------*/
/*
Copyright (C) 2010 Damir Ribaric

This file is part of nTicker.

nTicker 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, or (at your option) any later version.

nTicker 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.

You should have received a copy of the GNU General Public
License along with nTicker; see the file COPYING.  If not,
write to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA 02110-1301, USA.
*/
;(function(jQuery)
{
    var NTicker=function(options, obj)
    {
        var attributes=
        {
            position: 0,
            
            originalChildrenNum: obj.children().length,
            originalChildrenWidth: 0,
            
            childrenNum: 0,
            childrenWidth: 0,
            
            tickerTimeoutHandle: null,
            tickerFunction: function() {},
            
            isHoverStop: false
        };
        
        attributes.childrenNum=2*attributes.originalChildrenNum;
            
        // pokupim djecu
        var newClonedChildren =  obj.children().clone();
        
        // dodam klasu da znam koji su kopije (iako mi to za sada nije bitno)
        //newClonedChildren.each( function(ix)
        //                  {
        //                      var o=jQuery(this);
        //                      o.addClass('nTicker_copy');
        //                  }
        //              );
        
        // dodam na kraj
        obj.append( newClonedChildren );
        
        // racunam ukupnu sirinu tickera
        obj.children().each( function(ix)
                            {
                                attributes.childrenWidth += jQuery(this).outerWidth();
                            }
                        );
        // polovicna sirina tickera
        attributes.originalChildrenWidth = attributes.childrenWidth / 2;
        
        // postavim ukupnu sirinu
        obj.css( 'width' , attributes.childrenWidth);
        
        // DOM element tickera
        var domObj=obj.get(0);
        
        // fja za horiz ticker scroll
        function startTickerHoriz()
        {
            if(options.speed < 0 )
            {
                // s lijeva na desno
                if(attributes.position <= 0)
                {
                    obj.prepend( obj.children().slice(-attributes.originalChildrenNum) );
                    attributes.position = attributes.originalChildrenWidth;
                }
                
                attributes.position += options.speed;
                
                domObj.style.left = (-1*attributes.position) + 'px';    
            }
            else if(options.speed > 0 )
            {
                // s desna na lijevo
                
                if( attributes.position >= attributes.originalChildrenWidth)
                {
                    obj.append( obj.children().slice(0, attributes.originalChildrenNum) );
                    attributes.position = 0;
                }
                
                attributes.position += options.speed;
                
                domObj.style.left = (-1*attributes.position) + 'px';
            }

            attributes.tickerTimeoutHandle = setTimeout( attributes.tickerFunction, options.interval );
        }
        
        // ovu fju koristim za ticker - za sada imam smo jednu :(
        attributes.tickerFunction=startTickerHoriz;
        
        function hoverStop()
        {
            if( attributes.tickerTimeoutHandle )
            {
                attributes.isHoverStop=true;
                clearTimeout( attributes.tickerTimeoutHandle );
                attributes.tickerTimeoutHandle=null;
            }
        };
        
        function hoverStart()
        {
            if(attributes.isHoverStop && !attributes.tickerTimeoutHandle)
            {
                attributes.isHoverStop=false;
                attributes.tickerFunction();
            }
        };
        
        
        // da li se ticker zaustavlja na hover?
        if(options.stopOnHover)
        {
            obj.hover(hoverStop, hoverStart);
        }
        
        ////////////////////////////////////////////////////////////
        // pokreni ticker
        attributes.tickerFunction();
        ////////////////////////////////////////////////////////////
        
        
        ////////////////////////// public functions
        
        this.setSpeed=function(speed)
        {
            options.speed=speed;
            return obj;
        };
        
        this.stop=function()
        {
            if( attributes.tickerTimeoutHandle )
            {
                clearTimeout( attributes.tickerTimeoutHandle );
                attributes.tickerTimeoutHandle=null;
            }
        };
        
        this.start=function()
        {
            if(!attributes.tickerTimeoutHandle)
            {
                attributes.tickerFunction();
            }   
        };
        
        this.increaseSpeed=function()
        {
            options.speed++;
        };
        
        this.decreaseSpeed=function()
        {
            options.speed--;
        };
        
        this.toggleDirection=function()
        {
            options.speed*=-1;
        };
        
        this.getSpeed=function()
        {
            return options.speed;
        };
    };
    
    jQuery.fn.nTicker=function(opt, arg1, arg2)
    {
        return this.each(
                        function() 
                        {
                            var obj = jQuery(this);
                            var options=jQuery.extend( {}, jQuery.fn.nTicker.defaults, opt );
        
                            // creating a new AutoCompleteEx object and attach to the element's data, if not already attached
                            var data=obj.data('nTicker_object');
                            if (!data)
                            {
                                obj.data('nTicker_object', new NTicker(options, obj));
                            }
                            else if(typeof(data[opt])=='function')
                            {
                                data[opt](arg1, arg2);
                            }
                        }
                    );   //End Each JQ Element
    };
    
    jQuery.fn.nTicker.defaults =
    {
        speed: 1,
        interval: 30,
        stopOnHover: true
    };
})(jQuery);

/*------------------------------------------------------------------------------------------------------------------------------------*/
/* jquery.modal.js */
/*
 * jqModal - Minimalist Modaling with jQuery
 * (http : //dev.iceburg.net/jquery/jqModal/)
 *
 * Copyright(c)2007, 2008 Brice Burgess < bhb @ iceburg.net >
 * Dual licensed under the MIT and GPL licenses :
 * http : //www.opensource.org/licenses/mit-license.php
 * http : //www.gnu.org/licenses/gpl.html
 *
 * $Version : 03 / 01 / 2009 + r14
 */
    (function ($) {
            $.fn.jqm = function (o) {
                var p = {
                    overlay : 50,
                    overlayClass : 'jqmOverlay',
                    closeClass : 'jqmClose',
                    trigger : '.jqModal',
                    ajax : F,
                    ajaxText : '',
                    target : F,
                    modal : F,
                    toTop : F,
                    onShow : F,
                    onHide : F,
                    onLoad : F
                };
                return this.each(function () {
                        if (this._jqm)
                            return H[this._jqm].c = $.extend({}, H[this._jqm].c, o);
                        s++;
                        this._jqm = s;
                        H[s] = {
                            c : $.extend(p, $.jqm.params, o),
                            a : F,
                            w : $(this).addClass('jqmID' + s),
                            s : s
                        };
                        if (p.trigger)
                            $(this).jqmAddTrigger(p.trigger);
                    });
            };
            
            $.fn.jqmAddClose = function (e) {
                return hs(this, e, 'jqmHide');
            };
            $.fn.jqmAddTrigger = function (e) {
                return hs(this, e, 'jqmShow');
            };
            $.fn.jqmShow = function (t) {
                return this.each(function () {
                        t = t || window.event;
                        $.jqm.open(this._jqm, t);
                    });
            };
            $.fn.jqmHide = function (t) {
                return this.each(function () {
                        t = t || window.event;
                        $.jqm.close(this._jqm, t)
                    });
            };
            
            $.jqm = {
                hash : {},
                open : function (s, t) {
                    var h = H[s],
                    c = h.c,
                    cc = '.' + c.closeClass,
                    z = (parseInt(h.w.css('z-index'))),
                    z = (z > 0) ? z : 3000,
                    o = $('<div></div>').css({
                                height : '100%',
                                width : '100%',
                                position : 'fixed',
                                left : 0,
                                top : 0,
                                'z-index' : z - 1,
                                opacity : c.overlay / 100
                            });
                    if (h.a)
                        return F;
                    h.t = t;
                    h.a = true;
                    h.w.css('z-index', z);
                    if (c.modal) {
                        if (!A[0])
                            L('bind');
                        A.push(s);
                    } else if (c.overlay > 0)
                        h.w.jqmAddClose(o);
                    else
                        o = F;
                    
                    h.o = (o) ? o.addClass(c.overlayClass).prependTo('body') : F;
                    if (ie6) {
                        $('html,body').css({
                                height : '100%',
                                width : '100%'
                            });
                        if (o) {
                            o = o.css({
                                        position : 'absolute'
                                    })[0];
                            for (var y in{
                                    Top : 1,
                                    Left : 1
                                })
                                o.style.setExpression(y.toLowerCase(), "(_=(document.documentElement.scroll" + y + " || document.body.scroll" + y + "))+'px'");
                        }
                    }
                    
                    if (c.ajax) {
                        var r = c.target || h.w,
                        u = c.ajax,
                        r = (typeof r == 'string') ? $(r, h.w) : $(r),
                        u = (u.substr(0, 1) == '@') ? $(t).attr(u.substring(1)) : u;
                        r.html(c.ajaxText).load(u, function () {
                                if (c.onLoad)
                                    c.onLoad.call(this, h);
                                if (cc)
                                    h.w.jqmAddClose($(cc, h.w));
                                e(h);
                            });
                    } else if (cc)
                        h.w.jqmAddClose($(cc, h.w));
                    
                    if (c.toTop && h.o)
                        h.w.before('<span id="jqmP' + h.w[0]._jqm + '"></span>').insertAfter(h.o);
                    (c.onShow) ? c.onShow(h) : h.w.show();
                    e(h);
                    return F;
                },
                close : function (s) {
                    var h = H[s];
                    if (!h.a)
                        return F;
                    h.a = F;
                    if (A[0]) {
                        A.pop();
                        if (!A[0])
                            L('unbind');
                    }
                    if (h.c.toTop && h.o)
                        $('#jqmP' + h.w[0]._jqm).after(h.w).remove();
                    if (h.c.onHide)
                        h.c.onHide(h);
                    else {
                        h.w.hide();
                        if (h.o)
                            h.o.remove();
                    }
                    return F;
                },
                params : {}
                
            };
            var s = 0,
            H = $.jqm.hash,
            A = [],
            ie6 = $.browser.msie && ($.browser.version == "6.0"),
            F = false,
            i = $('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({
                        opacity : 0
                    }),
            e = function (h) {
                if (ie6)
                    if (h.o)
                        h.o.html('<p style="width:100%;height:100%"/>').prepend(i);
                    else if (!$('iframe.jqm', h.w)[0])
                        h.w.prepend(i);
                f(h);
            },
            f = function (h) {
                try {
                    $(':input:visible', h.w)[0].focus();
                } catch (_) {}
                
            },
            L = function (t) {
                $()[t]("keypress", m)[t]("keydown", m)[t]("mousedown", m);
            },
            m = function (e) {
                var h = H[A[A.length - 1]],
                r = (!$(e.target).parents('.jqmID' + h.s)[0]);
                if (r)
                    f(h);
                return !r;
            },
            hs = function (w, t, c) {
                return w.each(function () {
                        var s = this._jqm;
                        $(t).each(function () {
                                if (!this[c]) {
                                    this[c] = [];
                                    $(this).click(function () {
                                            for (var i in{
                                                    jqmShow : 1,
                                                    jqmHide : 1
                                                })
                                                for (var s in this[i])
                                                    if (H[this[i][s]])
                                                        H[this[i][s]].w[i](this);
                                            return F;
                                        });
                                }
                                this[c].push(s);
                            });
                    });
            };
        })(jQuery);  


/*------------------------------------------------------------------------------------------------------------------------------------*/
/*jquery.select_skin.js */
/*
 * jQuery select element skinning
 * version: 1.0.4 (03/03/2009)
 * @requires: jQuery v1.2 or later
 * adapted from Derek Harvey code
 *   http://www.lotsofcode.com/javascript-and-ajax/jquery-select-box-skin.htm
 * Licensed under the GPL license:
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Copyright 2009 Colin Verot
 */


(function ($) {

    $.fn.select_skin = function (w) {
        return $(this).each(function(i) {
            s = $(this);

            if (!s.attr('multiple')) {
                // create the container
                s.wrap('<div class="cmf-skinned-select"></div>');
                c = s.parent();
                c.children().before('<div class="cmf-skinned-text">&nbsp;</div>').each(function() {
                    if (this.selectedIndex >= 0) $(this).prev().text(this.options[this.selectedIndex].innerHTML)
                });
                c.width(s.outerWidth()-2);
                c.height(s.outerHeight()-2);

                // skin the container
                c.css('background-color', s.css('background-color'));
                c.css('color', s.css('color'));
                c.css('font-size', s.css('font-size'));
                c.css('font-family', s.css('font-family'));
                c.css('font-style', s.css('font-style'));
                c.css('position', 'relative');

                // hide the original select
                s.css( { 'opacity': 0,  'position': 'relative', 'z-index': 100 } );

                // get and skin the text label
                var t = c.children().prev();
                t.height(c.outerHeight()-s.css('padding-top').replace(/px,*\)*/g,"")-s.css('padding-bottom').replace(/px,*\)*/g,"")-t.css('padding-top').replace(/px,*\)*/g,"")-t.css('padding-bottom').replace(/px,*\)*/g,"")-2);
                t.width(c.innerWidth()-s.css('padding-right').replace(/px,*\)*/g,"")-s.css('padding-left').replace(/px,*\)*/g,"")-t.css('padding-right').replace(/px,*\)*/g,"")-t.css('padding-left').replace(/px,*\)*/g,"")-c.innerHeight());
                t.css( { 'opacity': 100, 'overflow': 'hidden', 'position': 'absolute', 'text-indent': '0px', 'z-index': 1, 'top': 0, 'left': 0 } );

                // add events
                c.children().click(function() {
                    t.text( (this.options.length > 0 && this.selectedIndex >= 0 ? this.options[this.selectedIndex].innerHTML : '') );
                });
                c.children().change(function() {
                    t.text( (this.options.length > 0 && this.selectedIndex >= 0 ? this.options[this.selectedIndex].innerHTML : '') );
                });
             }
        });
    }
}(jQuery));


/*
 * Style File - jQuery plugin for styling file input elements
 *  
 * Copyright (c) 2007-2008 Mika Tuupola
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Based on work by Shaun Inman
 *   http://www.shauninman.com/archive/2007/09/10/styling_file_inputs_with_css_and_the_dom
 *
 * Revision: $Id: jquery.filestyle.js 303 2008-01-30 13:53:24Z tuupola $
 *
 */

(function($) {
    
    $.fn.filestyle = function(options) {
                
        /* TODO: This should not override CSS. */
        var settings = {
            width : 250
        };
                
        if(options) {
            $.extend(settings, options);
        };
                        
        return this.each(function() {
            
            var self = this;
            var wrapper = $("<div>")
                            .addClass('browse_button')
                            /*
                            .css({
                                "width": settings.imagewidth + "px",
                                "height": settings.imageheight + "px",
                                "background": "url(" + settings.image + ") 0 0 no-repeat",
                                "background-position": "right",
                                "display": "inline",
                                "position": "absolute",
                                "overflow": "hidden"
                            });
                            */
                            
            var filename = $('<input class="file">')
                             .addClass($(self).attr("class"))
                             .css({
                                 "display": "inline",
                                 "width": settings.width + "px"
                             });

            $(self).before(filename);
            $(self).wrap(wrapper);

            $(self).css({
                        "position": "relative",
                        "height": settings.imageheight + "px",
                        "width": settings.width + "px",
                        "display": "inline",
                        "cursor": "pointer",
                        "opacity": "0.0"
                    });

            if ($.browser.mozilla) {
                if (/Win/.test(navigator.platform)) {
                    $(self).css("margin-left", "-142px");                    
                } else {
                    $(self).css("margin-left", "-168px");                    
                };
            } else {
                $(self).css("margin-left", settings.imagewidth - settings.width + "px");                
            };

            $(self).bind("change", function() {
                filename.val($(self).val());
            });
      
        });
        

    };
    
})(jQuery);


/*------------------------------------------------------------------------------------------------------------------------------------*/
/* jquery.media.js */
/*
 * jQuery Media Plugin for converting elements into rich media content.
 *
 * Examples and documentation at: http://malsup.com/jquery/media/
 * Copyright (c) 2007-2010 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
 *
 * @author: M. Alsup
 * @version: 0.96 (23-MAR-2011)
 * @requires jQuery v1.1.2 or later
 * $Id: jquery.media.js 2460 2007-07-23 02:53:15Z malsup $
 *
 * Supported Media Players:
 *  - Flash
 *  - Quicktime
 *  - Real Player
 *  - Silverlight
 *  - Windows Media Player
 *  - iframe
 *
 * Supported Media Formats:
 *   Any types supported by the above players, such as:
 *   Video: asf, avi, flv, mov, mpg, mpeg, mp4, qt, smil, swf, wmv, 3g2, 3gp
 *   Audio: aif, aac, au, gsm, mid, midi, mov, mp3, m4a, snd, rm, wav, wma
 *   Other: bmp, html, pdf, psd, qif, qtif, qti, tif, tiff, xaml
 *
 * Thanks to Mark Hicken and Brent Pedersen for helping me debug this on the Mac!
 * Thanks to Dan Rossi for numerous bug reports and code bits!
 * Thanks to Skye Giordano for several great suggestions!
 * Thanks to Richard Connamacher for excellent improvements to the non-IE behavior!
 */
;(function($) {

var lameIE = $.browser.msie && $.browser.version < 9;

/**
 * Chainable method for converting elements into rich media.
 *
 * @param options
 * @param callback fn invoked for each matched element before conversion
 * @param callback fn invoked for each matched element after conversion
 */
$.fn.media = function(options, f1, f2) {
    if (options == 'undo') {
        return this.each(function() {
            var $this = $(this);
            var html = $this.data('media.origHTML');
            if (html)
                $this.replaceWith(html);
        });
    }
    
    return this.each(function() {
        if (typeof options == 'function') {
            f2 = f1;
            f1 = options;
            options = {};
        }
        var o = getSettings(this, options);
        // pre-conversion callback, passes original element and fully populated options
        if (typeof f1 == 'function') f1(this, o);

        var r = getTypesRegExp();
        var m = r.exec(o.src.toLowerCase()) || [''];

        o.type ? m[0] = o.type : m.shift();
        for (var i=0; i < m.length; i++) {
            fn = m[i].toLowerCase();
            if (isDigit(fn[0])) fn = 'fn' + fn; // fns can't begin with numbers
            if (!$.fn.media[fn])
                continue;  // unrecognized media type
            // normalize autoplay settings
            var player = $.fn.media[fn+'_player'];
            if (!o.params) o.params = {};
            if (player) {
                var num = player.autoplayAttr == 'autostart';
                o.params[player.autoplayAttr || 'autoplay'] = num ? (o.autoplay ? 1 : 0) : o.autoplay ? true : false;
            }
            var $div = $.fn.media[fn](this, o);

            $div.css('backgroundColor', o.bgColor).width(o.width);
            
            if (o.canUndo) {
                var $temp = $('<div></div>').append(this);
                $div.data('media.origHTML', $temp.html()); // store original markup
            }
            
            // post-conversion callback, passes original element, new div element and fully populated options
            if (typeof f2 == 'function') f2(this, $div[0], o, player.name);
            break;
        }
    });
};

/**
 * Non-chainable method for adding or changing file format / player mapping
 * @name mapFormat
 * @param String format File format extension (ie: mov, wav, mp3)
 * @param String player Player name to use for the format (one of: flash, quicktime, realplayer, winmedia, silverlight or iframe
 */
$.fn.media.mapFormat = function(format, player) {
    if (!format || !player || !$.fn.media.defaults.players[player]) return; // invalid
    format = format.toLowerCase();
    if (isDigit(format[0])) format = 'fn' + format;
    $.fn.media[format] = $.fn.media[player];
    $.fn.media[format+'_player'] = $.fn.media.defaults.players[player];
};

// global defautls; override as needed
$.fn.media.defaults = {
    standards:  true,       // use object tags only (no embeds for non-IE browsers)
    canUndo:    true,       // tells plugin to store the original markup so it can be reverted via: $(sel).mediaUndo()
    width:      400,
    height:     400,
    autoplay:   0,          // normalized cross-player setting
    bgColor:    '#ffffff',  // background color
    params:     { wmode: 'transparent'},    // added to object element as param elements; added to embed element as attrs
    attrs:      {},         // added to object and embed elements as attrs
    flvKeyName: 'file',     // key used for object src param (thanks to Andrea Ercolino)
    flashvars:  {},         // added to flash content as flashvars param/attr
    flashVersion:   '7',    // required flash version
    expressInstaller: null, // src for express installer

    // default flash video and mp3 player (@see: http://jeroenwijering.com/?item=Flash_Media_Player)
    flvPlayer:   'mediaplayer.swf',
    mp3Player:   'mediaplayer.swf',

    // @see http://msdn2.microsoft.com/en-us/library/bb412401.aspx
    silverlight: {
        inplaceInstallPrompt: 'true', // display in-place install prompt?
        isWindowless:         'true', // windowless mode (false for wrapping markup)
        framerate:            '24',   // maximum framerate
        version:              '0.9',  // Silverlight version
        onError:              null,   // onError callback
        onLoad:               null,   // onLoad callback
        initParams:           null,   // object init params
        userContext:          null    // callback arg passed to the load callback
    }
};

// Media Players; think twice before overriding
$.fn.media.defaults.players = {
    flash: {
        name:        'flash',
        title:       'Flash',
        types:       'flv,mp3,swf',
        mimetype:    'application/x-shockwave-flash',
        pluginspage: 'http://www.adobe.com/go/getflashplayer',
        ieAttrs: {
            classid:  'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
            type:     'application/x-oleobject',
            codebase: 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + $.fn.media.defaults.flashVersion
        }
    },
    quicktime: {
        name:        'quicktime',
        title:       'QuickTime',
        mimetype:    'video/quicktime',
        pluginspage: 'http://www.apple.com/quicktime/download/',
        types:       'aif,aiff,aac,au,bmp,gsm,mov,mid,midi,mpg,mpeg,mp4,m4a,psd,qt,qtif,qif,qti,snd,tif,tiff,wav,3g2,3gp',
        ieAttrs: {
            classid:  'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
            codebase: 'http://www.apple.com/qtactivex/qtplugin.cab'
        }
    },
    realplayer: {
        name:         'real',
        title:        'RealPlayer',
        types:        'ra,ram,rm,rpm,rv,smi,smil',
        mimetype:     'audio/x-pn-realaudio-plugin',
        pluginspage:  'http://www.real.com/player/',
        autoplayAttr: 'autostart',
        ieAttrs: {
            classid: 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'
        }
    },
    winmedia: {
        name:         'winmedia',
        title:        'Windows Media',
        types:        'asx,asf,avi,wma,wmv',
        mimetype:     $.browser.mozilla && isFirefoxWMPPluginInstalled() ? 'application/x-ms-wmp' : 'application/x-mplayer2',
        pluginspage:  'http://www.microsoft.com/Windows/MediaPlayer/',
        autoplayAttr: 'autostart',
        oUrl:         'url',
        ieAttrs: {
            classid:  'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6',
            type:     'application/x-oleobject'
        }
    },
    // special cases
    img: {
        name:  'img',
        title: 'Image',
        types: 'gif,png,jpg'
    },
    iframe: {
        name:  'iframe',
        types: 'html,pdf'
    },
    silverlight: {
        name:  'silverlight',
        types: 'xaml'
    }
};

//
//  everything below here is private
//


// detection script for FF WMP plugin (http://www.therossman.org/experiments/wmp_play.html)
// (hat tip to Mark Ross for this script)
function isFirefoxWMPPluginInstalled() {
    var plugs = navigator.plugins;
    for (var i = 0; i < plugs.length; i++) {
        var plugin = plugs[i];
        if (plugin['filename'] == 'np-mswmp.dll')
            return true;
    }
    return false;
}

var counter = 1;

for (var player in $.fn.media.defaults.players) {
    var types = $.fn.media.defaults.players[player].types;
    $.each(types.split(','), function(i,o) {
        if (isDigit(o[0])) o = 'fn' + o;
        $.fn.media[o] = $.fn.media[player] = getGenerator(player);
        $.fn.media[o+'_player'] = $.fn.media.defaults.players[player];
    });
};

function getTypesRegExp() {
    var types = '';
    for (var player in $.fn.media.defaults.players) {
        if (types.length) types += ',';
        types += $.fn.media.defaults.players[player].types;
    };
    return new RegExp('\\.(' + types.replace(/,/ig,'|') + ')\\b');
};

function getGenerator(player) {
    return function(el, options) {
        return generate(el, options, player);
    };
};

function isDigit(c) {
    return '0123456789'.indexOf(c) > -1;
};

// flatten all possible options: global defaults, meta, option obj
function getSettings(el, options) {
    options = options || {};
    var $el = $(el);
    var cls = el.className || '';
    // support metadata plugin (v1.0 and v2.0)
    var meta = $.metadata ? $el.metadata() : $.meta ? $el.data() : {};
    meta = meta || {};
    var w = meta.width  || parseInt(((cls.match(/\bw:(\d+)/)||[])[1]||0)) || parseInt(((cls.match(/\bwidth:(\d+)/)||[])[1]||0));
    var h = meta.height || parseInt(((cls.match(/\bh:(\d+)/)||[])[1]||0)) || parseInt(((cls.match(/\bheight:(\d+)/)||[])[1]||0))

    if (w) meta.width   = w;
    if (h) meta.height = h;
    if (cls) meta.cls = cls;
    
    // crank html5 style data attributes
    var dataName = 'data-';
    for (var i=0; i < el.attributes.length; i++) {
        var a = el.attributes[i], n = $.trim(a.name);
        var index = n.indexOf(dataName);
        if (index === 0) {
            n = n.substring(dataName.length);
            meta[n] = a.value;
        }
    }

    var a = $.fn.media.defaults;
    var b = options;
    var c = meta;

    var p = { params: { bgColor: options.bgColor || $.fn.media.defaults.bgColor } };
    var opts = $.extend({}, a, b, c);
    $.each(['attrs','params','flashvars','silverlight'], function(i,o) {
        opts[o] = $.extend({}, p[o] || {}, a[o] || {}, b[o] || {}, c[o] || {});
    });

    if (typeof opts.caption == 'undefined') opts.caption = $el.text();

    // make sure we have a source!
    opts.src = opts.src || $el.attr('href') || $el.attr('src') || 'unknown';
    return opts;
};

//
//  Flash Player
//

// generate flash using SWFObject library if possible
$.fn.media.swf = function(el, opts) {
    if (!window.SWFObject && !window.swfobject) {
        // roll our own
        if (opts.flashvars) {
            var a = [];
            for (var f in opts.flashvars)
                a.push(f + '=' + opts.flashvars[f]);
            if (!opts.params) opts.params = {};
            opts.params.flashvars = a.join('&');
        }
        return generate(el, opts, 'flash');
    }

    var id = el.id ? (' id="'+el.id+'"') : '';
    var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
    var $div = $('<div' + id + cls + '>');

    // swfobject v2+
    if (window.swfobject) {
        $(el).after($div).appendTo($div);
        if (!el.id) el.id = 'movie_player_' + counter++;

        // replace el with swfobject content
        swfobject.embedSWF(opts.src, el.id, opts.width, opts.height, opts.flashVersion,
            opts.expressInstaller, opts.flashvars, opts.params, opts.attrs);
    }
    // swfobject < v2
    else {
        $(el).after($div).remove();
        var so = new SWFObject(opts.src, 'movie_player_' + counter++, opts.width, opts.height, opts.flashVersion, opts.bgColor);
        if (opts.expressInstaller) so.useExpressInstall(opts.expressInstaller);

        for (var p in opts.params)
            if (p != 'bgColor') so.addParam(p, opts.params[p]);
        for (var f in opts.flashvars)
            so.addVariable(f, opts.flashvars[f]);
        so.write($div[0]);
    }

    if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
    return $div;
};

// map flv and mp3 files to the swf player by default
$.fn.media.flv = $.fn.media.mp3 = function(el, opts) {
    var src = opts.src;
    var player = /\.mp3\b/i.test(src) ? $.fn.media.defaults.mp3Player : $.fn.media.defaults.flvPlayer;
    var key = opts.flvKeyName;
    src = encodeURIComponent(src);
    opts.src = player;
    opts.src = opts.src + '?'+key+'=' + (src);
    var srcObj = {};
    srcObj[key] = src;
    opts.flashvars = $.extend({}, srcObj, opts.flashvars );
    return $.fn.media.swf(el, opts);
};

//
//  Silverlight
//
$.fn.media.xaml = function(el, opts) {
    if (!window.Sys || !window.Sys.Silverlight) {
        if ($.fn.media.xaml.warning) return;
        $.fn.media.xaml.warning = 1;
        alert('You must include the Silverlight.js script.');
        return;
    }

    var props = {
        width: opts.width,
        height: opts.height,
        background: opts.bgColor,
        inplaceInstallPrompt: opts.silverlight.inplaceInstallPrompt,
        isWindowless: opts.silverlight.isWindowless,
        framerate: opts.silverlight.framerate,
        version: opts.silverlight.version
    };
    var events = {
        onError: opts.silverlight.onError,
        onLoad: opts.silverlight.onLoad
    };

    var id1 = el.id ? (' id="'+el.id+'"') : '';
    var id2 = opts.id || 'AG' + counter++;
    // convert element to div
    var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
    var $div = $('<div' + id1 + cls + '>');
    $(el).after($div).remove();

    Sys.Silverlight.createObjectEx({
        source: opts.src,
        initParams: opts.silverlight.initParams,
        userContext: opts.silverlight.userContext,
        id: id2,
        parentElement: $div[0],
        properties: props,
        events: events
    });

    if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
    return $div;
};

//
// generate object/embed markup
//
function generate(el, opts, player) {
    var $el = $(el);
    var o = $.fn.media.defaults.players[player];

    if (player == 'iframe') {
        o = $('<iframe' + ' width="' + opts.width + '" height="' + opts.height + '" >');
        o.attr('src', opts.src);
        o.css('backgroundColor', o.bgColor);
    }
    else if (player == 'img') {
        o = $('<img>');
        o.attr('src', opts.src);
        opts.width && o.attr('width', opts.width);
        opts.height && o.attr('height', opts.height);
        o.css('backgroundColor', o.bgColor);
    }
    else if (lameIE) {
        var a = ['<object width="' + opts.width + '" height="' + opts.height + '" '];
        for (var key in opts.attrs)
            a.push(key + '="'+opts.attrs[key]+'" ');
        for (var key in o.ieAttrs || {}) {
            var v = o.ieAttrs[key];
            if (key == 'codebase' && window.location.protocol == 'https:')
                v = v.replace('http','https');
            a.push(key + '="'+v+'" ');
        }
        a.push('></ob'+'ject'+'>');
        var p = ['<param name="' + (o.oUrl || 'src') +'" value="' + opts.src + '">'];
        for (var key in opts.params)
            p.push('<param name="'+ key +'" value="' + opts.params[key] + '">');
        var o = document.createElement(a.join(''));
        for (var i=0; i < p.length; i++)
            o.appendChild(document.createElement(p[i]));
    }
    else if (opts.standards) {
        // Rewritten to be standards compliant by Richard Connamacher
        var a = ['<object type="' + o.mimetype +'" width="' + opts.width + '" height="' + opts.height +'"'];
        if (opts.src) a.push(' data="' + opts.src + '" ');
        if ($.browser.msie) {
            for (var key in o.ieAttrs || {}) {
                var v = o.ieAttrs[key];
                if (key == 'codebase' && window.location.protocol == 'https:')
                    v = v.replace('http','https');
                a.push(key + '="'+v+'" ');
            }
        }
        a.push('>');
        a.push('<param name="' + (o.oUrl || 'src') +'" value="' + opts.src + '">');
        for (var key in opts.params) {
            if (key == 'wmode' && player != 'flash') // FF3/Quicktime borks on wmode
                continue;
            a.push('<param name="'+ key +'" value="' + opts.params[key] + '">');
        }
        // Alternate HTML
        a.push('<div><p><strong>'+o.title+' Required</strong></p><p>'+o.title+' is required to view this media. <a href="'+o.pluginspage+'">Download Here</a>.</p></div>');
        a.push('</ob'+'ject'+'>');
    }
     else {
            var a = ['<embed width="' + opts.width + '" height="' + opts.height + '" style="display:block"'];
            if (opts.src) a.push(' src="' + opts.src + '" ');
            for (var key in opts.attrs)
                a.push(key + '="'+opts.attrs[key]+'" ');
            for (var key in o.eAttrs || {})
                a.push(key + '="'+o.eAttrs[key]+'" ');
            for (var key in opts.params) {
                if (key == 'wmode' && player != 'flash') // FF3/Quicktime borks on wmode
                    continue;
                a.push(key + '="'+opts.params[key]+'" ');
            }
            a.push('></em'+'bed'+'>');
        }   
    // convert element to div
    var id = el.id ? (' id="'+el.id+'"') : '';
    var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
    var $div = $('<div' + id + cls + '>');
    $el.after($div).remove();
    (lameIE || player == 'iframe' || player == 'img') ? $div.append(o) : $div.html(a.join(''));
    if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
    return $div;
};


})(jQuery);


/*------------------------------------------------------------------------------------------------------------------------------------*/
/* jquery.validate.js */
/*
 * jQuery validation plug-in pre-1.5.2
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.validate.js 6243 2009-02-19 11:40:49Z joern.zaefferer $
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

(function($) {

$.extend($.fn, {
    // http://docs.jquery.com/Plugins/Validation/validate
    validate: function( options ) {
        
        // if nothing is selected, return nothing; can't chain anyway
        if (!this.length) {
            options && options.debug && window.console && console.warn( "nothing selected, can't validate, returning nothing" );
            return;
        }
        
        // check if a validator for this form was already created
        var validator = $.data(this[0], 'validator');
        if ( validator ) {
            return validator;
        }
        
        validator = new $.validator( options, this[0] );
        $.data(this[0], 'validator', validator); 
        
        if ( validator.settings.onsubmit ) {
        
            // allow suppresing validation by adding a cancel class to the submit button
            this.find("input, button").filter(".cancel").click(function() {
                validator.cancelSubmit = true;
            });
        
            // validate the form on submit
            this.submit( function( event ) {
                if ( validator.settings.debug )
                    // prevent form submit to be able to see console output
                    event.preventDefault();
                    
                function handle() {
                    if ( validator.settings.submitHandler ) {
                        validator.settings.submitHandler.call( validator, validator.currentForm );
                        return false;
                    }
                    return true;
                }
                    
                // prevent submit for invalid forms or custom submit handlers
                if ( validator.cancelSubmit ) {
                    validator.cancelSubmit = false;
                    return handle();
                }
                if ( validator.form() ) {
                    if ( validator.pendingRequest ) {
                        validator.formSubmitted = true;
                        return false;
                    }
                    return handle();
                } else {
                    validator.focusInvalid();
                    return false;
                }
            });
        }
        
        return validator;
    },
    // http://docs.jquery.com/Plugins/Validation/valid
    valid: function() {
        if ( $(this[0]).is('form')) {
            return this.validate().form();
        } else {
            var valid = false;
            var validator = $(this[0].form).validate();
            this.each(function() {
                valid |= validator.element(this);
            });
            return valid;
        }
    },
    // attributes: space seperated list of attributes to retrieve and remove
    removeAttrs: function(attributes) {
        var result = {},
            $element = this;
        $.each(attributes.split(/\s/), function(index, value) {
            result[value] = $element.attr(value);
            $element.removeAttr(value);
        });
        return result;
    },
    // http://docs.jquery.com/Plugins/Validation/rules
    rules: function(command, argument) {
        var element = this[0];
        
        if (command) {
            var settings = $.data(element.form, 'validator').settings;
            var staticRules = settings.rules;
            var existingRules = $.validator.staticRules(element);
            switch(command) {
            case "add":
                $.extend(existingRules, $.validator.normalizeRule(argument));
                staticRules[element.name] = existingRules;
                if (argument.messages)
                    settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
                break;
            case "remove":
                if (!argument) {
                    delete staticRules[element.name];
                    return existingRules;
                }
                var filtered = {};
                $.each(argument.split(/\s/), function(index, method) {
                    filtered[method] = existingRules[method];
                    delete existingRules[method];
                });
                return filtered;
            }
        }
        
        var data = $.validator.normalizeRules(
        $.extend(
            {},
            $.validator.metadataRules(element),
            $.validator.classRules(element),
            $.validator.attributeRules(element),
            $.validator.staticRules(element)
        ), element);
        
        // make sure required is at front
        if (data.required) {
            var param = data.required;
            delete data.required;
            data = $.extend({required: param}, data);
        }
        
        return data;
    }
});

// Custom selectors
$.extend($.expr[":"], {
    // http://docs.jquery.com/Plugins/Validation/blank
    blank: function(a) {return !$.trim(a.value);},
    // http://docs.jquery.com/Plugins/Validation/filled
    filled: function(a) {return !!$.trim(a.value);},
    // http://docs.jquery.com/Plugins/Validation/unchecked
    unchecked: function(a) {return !a.checked;}
});


$.format = function(source, params) {
    if ( arguments.length == 1 ) 
        return function() {
            var args = $.makeArray(arguments);
            args.unshift(source);
            return $.format.apply( this, args );
        };
    if ( arguments.length > 2 && params.constructor != Array  ) {
        params = $.makeArray(arguments).slice(1);
    }
    if ( params.constructor != Array ) {
        params = [ params ];
    }
    $.each(params, function(i, n) {
        source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
    });
    return source;
};

// constructor for validator
$.validator = function( options, form ) {
    this.settings = $.extend( {}, $.validator.defaults, options );
    this.currentForm = form;
    this.init();
};

$.extend($.validator, {

    defaults: {
        messages: {},
        groups: {},
        rules: {},
        errorClass: "error",
        errorElement: "label",
        focusInvalid: true,
        errorContainer: $( [] ),
        errorLabelContainer: $( [] ),
        onsubmit: true,
        ignore: [],
        ignoreTitle: false,
        onfocusin: function(element) {
            this.lastActive = element;
                
            // hide error label and remove error class on focus if enabled
            if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
                this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass );
                this.errorsFor(element).hide();
            }
        },
        onfocusout: function(element) {
            if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
                this.element(element);
            }
        },
        onkeyup: function(element) {
            if ( element.name in this.submitted || element == this.lastElement ) {
                this.element(element);
            }
        },
        onclick: function(element) {
            if ( element.name in this.submitted )
                this.element(element);
        },
        highlight: function( element, errorClass ) {
            $( element ).addClass( errorClass );
        },
        unhighlight: function( element, errorClass ) {
            $( element ).removeClass( errorClass );
        }
    },

    // http://docs.jquery.com/Plugins/Validation/Validator/setDefaults
    setDefaults: function(settings) {
        $.extend( $.validator.defaults, settings );
    },

    messages: {
        required: "This field is required.",
        remote: "Please fix this field.",
        email: "Please enter a valid email address.",
        url: "Please enter a valid URL.",
        date: "Please enter a valid date.",
        dateISO: "Please enter a valid date (ISO).",
        dateDE: "Bitte geben Sie ein gültiges Datum ein.",
        number: "Please enter a valid number.",
        numberDE: "Bitte geben Sie eine Nummer ein.",
        digits: "Please enter only digits",
        creditcard: "Please enter a valid credit card number.",
        equalTo: "Please enter the same value again.",
        accept: "Please enter a value with a valid extension.",
        maxlength: $.format("Please enter no more than {0} characters."),
        minlength: $.format("Please enter at least {0} characters."),
        rangelength: $.format("Please enter a value between {0} and {1} characters long."),
        range: $.format("Please enter a value between {0} and {1}."),
        max: $.format("Please enter a value less than or equal to {0}."),
        min: $.format("Please enter a value greater than or equal to {0}.")
    },
    
    autoCreateRanges: false,
    
    prototype: {
        
        init: function() {
            this.labelContainer = $(this.settings.errorLabelContainer);
            this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
            this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
            this.submitted = {};
            this.valueCache = {};
            this.pendingRequest = 0;
            this.pending = {};
            this.invalid = {};
            this.reset();
            
            var groups = (this.groups = {});
            $.each(this.settings.groups, function(key, value) {
                $.each(value.split(/\s/), function(index, name) {
                    groups[name] = key;
                });
            });
            var rules = this.settings.rules;
            $.each(rules, function(key, value) {
                rules[key] = $.validator.normalizeRule(value);
            });
            
            function delegate(event) {
                var validator = $.data(this[0].form, "validator");
                validator.settings["on" + event.type] && validator.settings["on" + event.type].call(validator, this[0] );
            }
            $(this.currentForm)
                .delegate("focusin focusout keyup", ":text, :password, :file, select, textarea", delegate)
                .delegate("click", ":radio, :checkbox", delegate);

            if (this.settings.invalidHandler)
                $(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
        },

        // http://docs.jquery.com/Plugins/Validation/Validator/form
        form: function() {
            this.checkForm();
            $.extend(this.submitted, this.errorMap);
            this.invalid = $.extend({}, this.errorMap);
            if (!this.valid())
                $(this.currentForm).triggerHandler("invalid-form", [this]);
            this.showErrors();
            return this.valid();
        },
        
        checkForm: function() {
            this.prepareForm();
            for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
                this.check( elements[i] );
            }
            return this.valid(); 
        },
        
        // http://docs.jquery.com/Plugins/Validation/Validator/element
        element: function( element ) {
            element = this.clean( element );
            this.lastElement = element;
            this.prepareElement( element );
            this.currentElements = $(element);
            var result = this.check( element );
            if ( result ) {
                delete this.invalid[element.name];
            } else {
                this.invalid[element.name] = true;
            }
            if ( !this.numberOfInvalids() ) {
                // Hide error containers on last error
                this.toHide = this.toHide.add( this.containers );
            }
            this.showErrors();
            return result;
        },

        // http://docs.jquery.com/Plugins/Validation/Validator/showErrors
        showErrors: function(errors) {
            if(errors) {
                // add items to error list and map
                $.extend( this.errorMap, errors );
                this.errorList = [];
                for ( var name in errors ) {
                    this.errorList.push({
                        message: errors[name],
                        element: this.findByName(name)[0]
                    });
                }
                // remove items from success list
                this.successList = $.grep( this.successList, function(element) {
                    return !(element.name in errors);
                });
            }
            this.settings.showErrors
                ? this.settings.showErrors.call( this, this.errorMap, this.errorList )
                : this.defaultShowErrors();
        },
        
        // http://docs.jquery.com/Plugins/Validation/Validator/resetForm
        resetForm: function() {
            if ( $.fn.resetForm )
                $( this.currentForm ).resetForm();
            this.submitted = {};
            this.prepareForm();
            this.hideErrors();
            this.elements().removeClass( this.settings.errorClass );
        },
        
        numberOfInvalids: function() {
            return this.objectLength(this.invalid);
        },
        
        objectLength: function( obj ) {
            var count = 0;
            for ( var i in obj )
                count++;
            return count;
        },
        
        hideErrors: function() {
            this.addWrapper( this.toHide ).hide();
        },
        
        valid: function() {
            return this.size() == 0;
        },
        
        size: function() {
            return this.errorList.length;
        },
        
        focusInvalid: function() {
            if( this.settings.focusInvalid ) {
                try {
                    $(this.findLastActive() || this.errorList.length && this.errorList[0].element || []).filter(":visible").focus();
                } catch(e) {
                    // ignore IE throwing errors when focusing hidden elements
                }
            }
        },
        
        findLastActive: function() {
            var lastActive = this.lastActive;
            return lastActive && $.grep(this.errorList, function(n) {
                return n.element.name == lastActive.name;
            }).length == 1 && lastActive;
        },
        
        elements: function() {
            var validator = this,
                rulesCache = {};
            
            // select all valid inputs inside the form (no submit or reset buttons)
            // workaround $Query([]).add until http://dev.jquery.com/ticket/2114 is solved
            return $([]).add(this.currentForm.elements)
            .filter(":input")
            .not(":submit, :reset, :image, [disabled]")
            .not( this.settings.ignore )
            .filter(function() {
                !this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this);
            
                // select only the first element for each name, and only those with rules specified
                if ( this.name in rulesCache || !validator.objectLength($(this).rules()) )
                    return false;
                
                rulesCache[this.name] = true;
                return true;
            });
        },
        
        clean: function( selector ) {
            return $( selector )[0];
        },
        
        errors: function() {
            return $( this.settings.errorElement + "." + this.settings.errorClass, this.errorContext );
        },
        
        reset: function() {
            this.successList = [];
            this.errorList = [];
            this.errorMap = {};
            this.toShow = $([]);
            this.toHide = $([]);
            this.formSubmitted = false;
            this.currentElements = $([]);
        },
        
        prepareForm: function() {
            this.reset();
            this.toHide = this.errors().add( this.containers );
        },
        
        prepareElement: function( element ) {
            this.reset();
            this.toHide = this.errorsFor(element);
        },
    
        check: function( element ) {
            element = this.clean( element );
            
            // if radio/checkbox, validate first element in group instead
            if (this.checkable(element)) {
                element = this.findByName( element.name )[0];
            }
            
            var rules = $(element).rules();
            var dependencyMismatch = false;
            for( method in rules ) {
                var rule = { method: method, parameters: rules[method] };
                try {
                    var result = $.validator.methods[method].call( this, element.value.replace(/\r/g, ""), element, rule.parameters );
                    
                    // if a method indicates that the field is optional and therefore valid,
                    // don't mark it as valid when there are no other rules
                    if ( result == "dependency-mismatch" ) {
                        dependencyMismatch = true;
                        continue;
                    }
                    dependencyMismatch = false;
                    
                    if ( result == "pending" ) {
                        this.toHide = this.toHide.not( this.errorsFor(element) );
                        return;
                    }
                    
                    if( !result ) {
                        this.formatAndAdd( element, rule );
                        return false;
                    }
                } catch(e) {
                    this.settings.debug && window.console && console.log("exception occured when checking element " + element.id
                         + ", check the '" + rule.method + "' method");
                    throw e;
                }
            }
            if (dependencyMismatch)
                return;
            if ( this.objectLength(rules) )
                this.successList.push(element);
            return true;
        },
        
        // return the custom message for the given element and validation method
        // specified in the element's "messages" metadata
        customMetaMessage: function(element, method) {
            if (!$.metadata)
                return;
            
            var meta = this.settings.meta
                ? $(element).metadata()[this.settings.meta]
                : $(element).metadata();
            
            return meta && meta.messages && meta.messages[method];
        },
        
        // return the custom message for the given element name and validation method
        customMessage: function( name, method ) {
            var m = this.settings.messages[name];
            return m && (m.constructor == String
                ? m
                : m[method]);
        },
        
        // return the first defined argument, allowing empty strings
        findDefined: function() {
            for(var i = 0; i < arguments.length; i++) {
                if (arguments[i] !== undefined)
                    return arguments[i];
            }
            return undefined;
        },
        
        defaultMessage: function( element, method) {
            return this.findDefined(
                this.customMessage( element.name, method ),
                this.customMetaMessage( element, method ),
                // title is never undefined, so handle empty string as undefined
                !this.settings.ignoreTitle && element.title || undefined,
                $.validator.messages[method],
                "<strong>Warning: No message defined for " + element.name + "</strong>"
            );
        },
        
        formatAndAdd: function( element, rule ) {
            var message = this.defaultMessage( element, rule.method );
            if ( typeof message == "function" ) 
                message = message.call(this, rule.parameters, element);
            this.errorList.push({
                message: message,
                element: element
            });
            this.errorMap[element.name] = message;
            this.submitted[element.name] = message;
        },
        
        addWrapper: function(toToggle) {
            if ( this.settings.wrapper )
                toToggle = toToggle.add( toToggle.parents( this.settings.wrapper ) );
            return toToggle;
        },
        
        defaultShowErrors: function() {
            for ( var i = 0; this.errorList[i]; i++ ) {
                var error = this.errorList[i];
                this.settings.highlight && this.settings.highlight.call( this, error.element, this.settings.errorClass );
                this.showLabel( error.element, error.message );
            }
            if( this.errorList.length ) {
                this.toShow = this.toShow.add( this.containers );
            }
            if (this.settings.success) {
                for ( var i = 0; this.successList[i]; i++ ) {
                    this.showLabel( this.successList[i] );
                }
            }
            if (this.settings.unhighlight) {
                for ( var i = 0, elements = this.validElements(); elements[i]; i++ ) {
                    this.settings.unhighlight.call( this, elements[i], this.settings.errorClass );
                }
            }
            this.toHide = this.toHide.not( this.toShow );
            this.hideErrors();
            this.addWrapper( this.toShow ).show();
        },
        
        validElements: function() {
            return this.currentElements.not(this.invalidElements());
        },
        
        invalidElements: function() {
            return $(this.errorList).map(function() {
                return this.element;
            });
        },
        
        showLabel: function(element, message) {
            var label = this.errorsFor( element );
            if ( label.length ) {
                // refresh error/success class
                label.removeClass().addClass( this.settings.errorClass );
            
                // check if we have a generated label, replace the message then
                label.attr("generated") && label.html(message);
            } else {
                // create label
                label = $("<" + this.settings.errorElement + "/>")
                    .attr({"for":  this.idOrName(element), generated: true})
                    .addClass(this.settings.errorClass)
                    .html(message || "");
                if ( this.settings.wrapper ) {
                    // make sure the element is visible, even in IE
                    // actually showing the wrapped element is handled elsewhere
                    label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
                }
                if ( !this.labelContainer.append(label).length )
                    this.settings.errorPlacement
                        ? this.settings.errorPlacement(label, $(element) )
                        : label.insertAfter(element);
            }
            if ( !message && this.settings.success ) {
                label.text("");
                typeof this.settings.success == "string"
                    ? label.addClass( this.settings.success )
                    : this.settings.success( label );
            }
            this.toShow = this.toShow.add(label);
        },
        
        errorsFor: function(element) {
            return this.errors().filter("[for='" + this.idOrName(element) + "']");
        },
        
        idOrName: function(element) {
            return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
        },

        checkable: function( element ) {
            return /radio|checkbox/i.test(element.type);
        },
        
        findByName: function( name ) {
            // select by name and filter by form for performance over form.find("[name=...]")
            var form = this.currentForm;
            return $(document.getElementsByName(name)).map(function(index, element) {
                return element.form == form && element.name == name && element  || null;
            });
        },
        
        getLength: function(value, element) {
            switch( element.nodeName.toLowerCase() ) {
            case 'select':
                return $("option:selected", element).length;
            case 'input':
                if( this.checkable( element) )
                    return this.findByName(element.name).filter(':checked').length;
            }
            return value.length;
        },
    
        depend: function(param, element) {
            return this.dependTypes[typeof param]
                ? this.dependTypes[typeof param](param, element)
                : true;
        },
    
        dependTypes: {
            "boolean": function(param, element) {
                return param;
            },
            "string": function(param, element) {
                return !!$(param, element.form).length;
            },
            "function": function(param, element) {
                return param(element);
            }
        },
        
        optional: function(element) {
            return !$.validator.methods.required.call(this, $.trim(element.value), element) && "dependency-mismatch";
        },
        
        startRequest: function(element) {
            if (!this.pending[element.name]) {
                this.pendingRequest++;
                this.pending[element.name] = true;
            }
        },
        
        stopRequest: function(element, valid) {
            this.pendingRequest--;
            // sometimes synchronization fails, make sure pendingRequest is never < 0
            if (this.pendingRequest < 0)
                this.pendingRequest = 0;
            delete this.pending[element.name];
            if ( valid && this.pendingRequest == 0 && this.formSubmitted && this.form() ) {
                $(this.currentForm).submit();
            } else if (!valid && this.pendingRequest == 0 && this.formSubmitted) {
                $(this.currentForm).triggerHandler("invalid-form", [this]);
            }
        },
        
        previousValue: function(element) {
            return $.data(element, "previousValue") || $.data(element, "previousValue", previous = {
                old: null,
                valid: true,
                message: this.defaultMessage( element, "remote" )
            });
        }
        
    },
    
    classRuleSettings: {
        required: {required: true},
        email: {email: true},
        url: {url: true},
        date: {date: true},
        dateISO: {dateISO: true},
        dateDE: {dateDE: true},
        number: {number: true},
        numberDE: {numberDE: true},
        digits: {digits: true},
        creditcard: {creditcard: true}
    },
    
    addClassRules: function(className, rules) {
        className.constructor == String ?
            this.classRuleSettings[className] = rules :
            $.extend(this.classRuleSettings, className);
    },
    
    classRules: function(element) {
        var rules = {};
        var classes = $(element).attr('class');
        classes && $.each(classes.split(' '), function() {
            if (this in $.validator.classRuleSettings) {
                $.extend(rules, $.validator.classRuleSettings[this]);
            }
        });
        return rules;
    },
    
    attributeRules: function(element) {
        var rules = {};
        var $element = $(element);
        
        for (method in $.validator.methods) {
            var value = $element.attr(method);
            if (value) {
                rules[method] = value;
            }
        }
        
        // maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
        if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
            delete rules.maxlength;
        }
        
        return rules;
    },
    
    metadataRules: function(element) {
        if (!$.metadata) return {};
        
        var meta = $.data(element.form, 'validator').settings.meta;
        return meta ?
            $(element).metadata()[meta] :
            $(element).metadata();
    },
    
    staticRules: function(element) {
        var rules = {};
        var validator = $.data(element.form, 'validator');
        if (validator.settings.rules) {
            rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
        }
        return rules;
    },
    
    normalizeRules: function(rules, element) {
        // handle dependency check
        $.each(rules, function(prop, val) {
            // ignore rule when param is explicitly false, eg. required:false
            if (val === false) {
                delete rules[prop];
                return;
            }
            if (val.param || val.depends) {
                var keepRule = true;
                switch (typeof val.depends) {
                    case "string":
                        keepRule = !!$(val.depends, element.form).length;
                        break;
                    case "function":
                        keepRule = val.depends.call(element, element);
                        break;
                }
                if (keepRule) {
                    rules[prop] = val.param !== undefined ? val.param : true;
                } else {
                    delete rules[prop];
                }
            }
        });
        
        // evaluate parameters
        $.each(rules, function(rule, parameter) {
            rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
        });
        
        // clean number parameters
        $.each(['minlength', 'maxlength', 'min', 'max'], function() {
            if (rules[this]) {
                rules[this] = Number(rules[this]);
            }
        });
        $.each(['rangelength', 'range'], function() {
            if (rules[this]) {
                rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
            }
        });
        
        if ($.validator.autoCreateRanges) {
            // auto-create ranges
            if (rules.min && rules.max) {
                rules.range = [rules.min, rules.max];
                delete rules.min;
                delete rules.max;
            }
            if (rules.minlength && rules.maxlength) {
                rules.rangelength = [rules.minlength, rules.maxlength];
                delete rules.minlength;
                delete rules.maxlength;
            }
        }
        
        // To support custom messages in metadata ignore rule methods titled "messages"
        if (rules.messages) {
            delete rules.messages
        }
        
        return rules;
    },
    
    // Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
    normalizeRule: function(data) {
        if( typeof data == "string" ) {
            var transformed = {};
            $.each(data.split(/\s/), function() {
                transformed[this] = true;
            });
            data = transformed;
        }
        return data;
    },
    
    // http://docs.jquery.com/Plugins/Validation/Validator/addMethod
    addMethod: function(name, method, message) {
        $.validator.methods[name] = method;
        $.validator.messages[name] = message;
        if (method.length < 3) {
            $.validator.addClassRules(name, $.validator.normalizeRule(name));
        }
    },

    methods: {

        // http://docs.jquery.com/Plugins/Validation/Methods/required
        required: function(value, element, param) {
            // check if dependency is met
            if ( !this.depend(param, element) )
                return "dependency-mismatch";
            switch( element.nodeName.toLowerCase() ) {
            case 'select':
                var options = $("option:selected", element);
                return options.length > 0 && ( element.type == "select-multiple" || ($.browser.msie && !(options[0].attributes['value'].specified) ? options[0].text : options[0].value).length > 0);
            case 'input':
                if ( this.checkable(element) )
                    return this.getLength(value, element) > 0;
            default:
                return $.trim(value).length > 0;
            }
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/remote
        remote: function(value, element, param) {
            if ( this.optional(element) )
                return "dependency-mismatch";
            
            var previous = this.previousValue(element);
            
            if (!this.settings.messages[element.name] )
                this.settings.messages[element.name] = {};
            this.settings.messages[element.name].remote = typeof previous.message == "function" ? previous.message(value) : previous.message;
            
            param = typeof param == "string" && {url:param} || param; 
            
            if ( previous.old !== value ) {
                previous.old = value;
                var validator = this;
                this.startRequest(element);
                var data = {};
                data[element.name] = value;
                $.ajax($.extend(true, {
                    url: param,
                    mode: "abort",
                    port: "validate" + element.name,
                    dataType: "json",
                    data: data,
                    success: function(response) {
                        if ( response ) {
                            var submitted = validator.formSubmitted;
                            validator.prepareElement(element);
                            validator.formSubmitted = submitted;
                            validator.successList.push(element);
                            validator.showErrors();
                        } else {
                            var errors = {};
                            errors[element.name] =  response || validator.defaultMessage( element, "remote" );
                            validator.showErrors(errors);
                        }
                        previous.valid = response;
                        validator.stopRequest(element, response);
                    }
                }, param));
                return "pending";
            } else if( this.pending[element.name] ) {
                return "pending";
            }
            return previous.valid;
        },

        // http://docs.jquery.com/Plugins/Validation/Methods/minlength
        minlength: function(value, element, param) {
            return this.optional(element) || this.getLength($.trim(value), element) >= param;
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/maxlength
        maxlength: function(value, element, param) {
            return this.optional(element) || this.getLength($.trim(value), element) <= param;
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/rangelength
        rangelength: function(value, element, param) {
            var length = this.getLength($.trim(value), element);
            return this.optional(element) || ( length >= param[0] && length <= param[1] );
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/min
        min: function( value, element, param ) {
            return this.optional(element) || value >= param;
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/max
        max: function( value, element, param ) {
            return this.optional(element) || value <= param;
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/range
        range: function( value, element, param ) {
            return this.optional(element) || ( value >= param[0] && value <= param[1] );
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/email
        email: function(value, element) {
            // contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
            return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);
        },
    
        // http://docs.jquery.com/Plugins/Validation/Methods/url
        url: function(value, element) {
            // contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
            return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/date
        date: function(value, element) {
            return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
        },
    
        // http://docs.jquery.com/Plugins/Validation/Methods/dateISO
        dateISO: function(value, element) {
            return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);
        },
    
        // http://docs.jquery.com/Plugins/Validation/Methods/dateDE
        dateDE: function(value, element) {
            return this.optional(element) || /^\d\d?\.\d\d?\.\d\d\d?\d?$/.test(value);
        },
    
        // http://docs.jquery.com/Plugins/Validation/Methods/number
        number: function(value, element) {
            return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);
        },
    
        // http://docs.jquery.com/Plugins/Validation/Methods/numberDE
        numberDE: function(value, element) {
            return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:,\d+)?$/.test(value);
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/digits
        digits: function(value, element) {
            return this.optional(element) || /^\d+$/.test(value);
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/creditcard
        // based on http://en.wikipedia.org/wiki/Luhn
        creditcard: function(value, element) {
            if ( this.optional(element) )
                return "dependency-mismatch";
            // accept only digits and dashes
            if (/[^0-9-]+/.test(value))
                return false;
            var nCheck = 0,
                nDigit = 0,
                bEven = false;

            value = value.replace(/\D/g, "");

            for (n = value.length - 1; n >= 0; n--) {
                var cDigit = value.charAt(n);
                var nDigit = parseInt(cDigit, 10);
                if (bEven) {
                    if ((nDigit *= 2) > 9)
                        nDigit -= 9;
                }
                nCheck += nDigit;
                bEven = !bEven;
            }

            return (nCheck % 10) == 0;
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/accept
        accept: function(value, element, param) {
            param = typeof param == "string" ? param : "png|jpe?g|gif";
            return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i")); 
        },
        
        // http://docs.jquery.com/Plugins/Validation/Methods/equalTo
        equalTo: function(value, element, param) {
            return value == $(param).val();
        }
        
    }
    
});

})(jQuery);

// ajax mode: abort
// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() 
;(function($) {
    var ajax = $.ajax;
    var pendingRequests = {};
    $.ajax = function(settings) {
        // create settings for compatibility with ajaxSetup
        settings = $.extend(settings, $.extend({}, $.ajaxSettings, settings));
        var port = settings.port;
        if (settings.mode == "abort") {
            if ( pendingRequests[port] ) {
                pendingRequests[port].abort();
            }
            return (pendingRequests[port] = ajax.apply(this, arguments));
        }
        return ajax.apply(this, arguments);
    };
})(jQuery);

// provides cross-browser focusin and focusout events
// IE has native support, in other browsers, use event caputuring (neither bubbles)

// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target 

// provides triggerEvent(type: String, target: Element) to trigger delegated events
;(function($) {
    $.each({
        focus: 'focusin',
        blur: 'focusout'    
    }, function( original, fix ){
        $.event.special[fix] = {
            setup:function() {
                if ( $.browser.msie ) return false;
                this.addEventListener( original, $.event.special[fix].handler, true );
            },
            teardown:function() {
                if ( $.browser.msie ) return false;
                this.removeEventListener( original,
                $.event.special[fix].handler, true );
            },
            handler: function(e) {
                arguments[0] = $.event.fix(e);
                arguments[0].type = fix;
                return $.event.handle.apply(this, arguments);
            }
        };
    });
    $.extend($.fn, {
        delegate: function(type, delegate, handler) {
            return this.bind(type, function(event) {
                var target = $(event.target);
                if (target.is(delegate)) {
                    return handler.apply(target, arguments);
                }
            });
        },
        triggerEvent: function(type, target) {
            return this.triggerHandler(type, [$.event.fix({ type: type, target: target })]);
        }
    })
})(jQuery);


/*------------------------------------------------------------------------------------------------------------------------------------*/
/* toHTTP.js 
$(document).ready(function(){
    $('a').each(function(key,val){
        if ($(this).attr('href').indexOf('http') == -1 && $(this).attr('href').indexOf('#') == -1) {
            $(this).attr('href','http://' + document.domain + $(this).attr('href'));
        }
    })
});*/

/*------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------*/




















