;
/* AGGREGATED JS FILE: sites/all/modules/rc/media_upload/include/swfobject.js */
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
;
/* AGGREGATED JS FILE: sites/all/modules/rc/media_upload/include/kaltura_player_controller.js */
Delegate = function () {
};

Delegate.create = function (/*Object*/ scope, /*Function*/ method ) {
	var f = function () {
		return method.apply (scope, arguments);
	}
	return f;
};


KalturaPlayerController = function (playerId) {
	this.playerId = playerId;
	this.currentKshowId = -1;
	this.currentEntryId = -1;
	this.commands = Array();
};

KalturaPlayerController.prototype = {
	insertMedia: function (kshowId, entryId, autoStart) {
		this.queue("insertMedia", kshowId, entryId, autoStart);
		this.currentKshowId = kshowId;
		this.currentEntryId = entryId;
	},
	
	insertEntry: function (entryId, autoStart) {
		this.insertMedia(-1, entryId, autoStart);
	},
	
	insertKShow: function (kshowId, autoStart) {
		this.insertMedia(kshowId, -1, autoStart);
	},
	
	pause: function () {
		this.queue("pauseMedia");
	},
	
	stop: function () {
		this.queue("stopMedia");
	},
	
	play: function () {
		this.queue("playMedia");
	},
	
	seek: function (time) {
		this.queue("seekMedia", time);
	}, 
	
	queue: function () {
		if (arguments.length > 0) { // first argument is the method name and is mandatory
			var method = arguments[0];
			var args = Array.prototype.slice.call(arguments, [1]); // shift to remove the method name from the array
			this.commands.push({ method: method, args: args });
			this.invoke();
		}
	},
	
	invoke: function () {
		this.playerElement = document.getElementById(this.playerId);

		// no commands in queue
		if (!this.commands || this.commands.length == 0)
			return;
	
		var command = this.commands[0];
		var method = command.method;
		var args = command.args;
		
		if (this.playerElement && this.playerElement[method]) {
			// apply is not possible on external interface functions, so we'll do this with a switch
			switch (args.length) {
				case 1:
					this.playerElement[method](args[0]);
					break;
				case 2:
					this.playerElement[method](args[0], args[1]);
					break;
				case 3:
					this.playerElement[method](args[0], args[1], args[2]);
					break;
				case 4:
					this.playerElement[method](args[0], args[1], args[2], args[2]);
					break;
				default:
					this.playerElement[method]();
					break; 	
			}

			this.commands.shift();
		}
		else {
			var f = Delegate.create(this, this.invoke);
			setTimeout(f, 200);
		}
	},
	
	reload: function () {
		this.insertMedia(this.currentKshowId, this.currentEntryId, true);
	}
};
;
/* AGGREGATED JS FILE: common/jquery/form.js */
/*
 * jQuery form plugin
 * @requires jQuery v1.0.3
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: form.js 12 2007-04-29 15:20:16Z edia $
 * Version: .97
 */

/**
 * ajaxSubmit() provides a mechanism for submitting an HTML form using AJAX.
 *
 * ajaxSubmit accepts a single argument which can be either a success callback function
 * or an options Object.  If a function is provided it will be invoked upon successful
 * completion of the submit and will be passed the response from the server.
 * If an options Object is provided, the following attributes are supported:
 *
 *  target:   Identifies the element(s) in the page to be updated with the server response.
 *            This value may be specified as a jQuery selection string, a jQuery object,
 *            or a DOM element.
 *            default value: null
 *
 *  url:      URL to which the form data will be submitted.
 *            default value: value of form's 'action' attribute
 *
 *  type:     The method in which the form data should be submitted, 'GET' or 'POST'.
 *            default value: value of form's 'method' attribute (or 'GET' if none found)
 *
 *  beforeSubmit:  Callback method to be invoked before the form is submitted.
 *            default value: null
 *
 *  success:  Callback method to be invoked after the form has been successfully submitted
 *            and the response has been returned from the server
 *            default value: null
 *
 *  dataType: Expected dataType of the response.  One of: null, 'xml', 'script', or 'json'
 *            default value: null
 *
 *  semantic: Boolean flag indicating whether data must be submitted in semantic order (slower).
 *            default value: false
 *
 *  resetForm: Boolean flag indicating whether the form should be reset if the submit is successful
 *
 *  clearForm: Boolean flag indicating whether the form should be cleared if the submit is successful
 *
 *
 * The 'beforeSubmit' callback can be provided as a hook for running pre-submit logic or for
 * validating the form data.  If the 'beforeSubmit' callback returns false then the form will
 * not be submitted. The 'beforeSubmit' callback is invoked with three arguments: the form data
 * in array format, the jQuery object, and the options object passed into ajaxSubmit.
 * The form data array takes the following form:
 *
 *     [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
 *
 * If a 'success' callback method is provided it is invoked after the response has been returned
 * from the server.  It is passed the responseText or responseXML value (depending on dataType).
 * See jQuery.ajax for further details.
 *
 *
 * The dataType option provides a means for specifying how the server response should be handled.
 * This maps directly to the jQuery.httpData method.  The following values are supported:
 *
 *      'xml':    if dataType == 'xml' the server response is treated as XML and the 'after'
 *                   callback method, if specified, will be passed the responseXML value
 *      'json':   if dataType == 'json' the server response will be evaluted and passed to
 *                   the 'after' callback, if specified
 *      'script': if dataType == 'script' the server response is evaluated in the global context
 *
 *
 * Note that it does not make sense to use both the 'target' and 'dataType' options.  If both
 * are provided the target will be ignored.
 *
 * The semantic argument can be used to force form serialization in semantic order.
 * This is normally true anyway, unless the form contains input elements of type='image'.
 * If your form must be submitted with name/value pairs in semantic order and your form
 * contains an input of type='image" then pass true for this arg, otherwise pass false
 * (or nothing) to avoid the overhead for this logic.
 *
 *
 * When used on its own, ajaxSubmit() is typically bound to a form's submit event like this:
 *
 * $("#form-id").submit(function() {
 *     $(this).ajaxSubmit(options);
 *     return false; // cancel conventional submit
 * });
 *
 * When using ajaxForm(), however, this is done for you.
 *
 * @example
 * $('#myForm').ajaxSubmit(function(data) {
 *     alert('Form submit succeeded! Server returned: ' + data);
 * });
 * @desc Submit form and alert server response
 *
 *
 * @example
 * var options = {
 *     target: '#myTargetDiv'
 * };
 * $('#myForm').ajaxSubmit(options);
 * @desc Submit form and update page element with server response
 *
 *
 * @example
 * var options = {
 *     success: function(responseText) {
 *         alert(responseText);
 *     }
 * };
 * $('#myForm').ajaxSubmit(options);
 * @desc Submit form and alert the server response
 *
 *
 * @example
 * var options = {
 *     beforeSubmit: function(formArray, jqForm) {
 *         if (formArray.length == 0) {
 *             alert('Please enter data.');
 *             return false;
 *         }
 *     }
 * };
 * $('#myForm').ajaxSubmit(options);
 * @desc Pre-submit validation which aborts the submit operation if form data is empty
 *
 *
 * @example
 * var options = {
 *     url: myJsonUrl.php,
 *     dataType: 'json',
 *     success: function(data) {
 *        // 'data' is an object representing the the evaluated json data
 *     }
 * };
 * $('#myForm').ajaxSubmit(options);
 * @desc json data returned and evaluated
 *
 *
 * @example
 * var options = {
 *     url: myXmlUrl.php,
 *     dataType: 'xml',
 *     success: function(responseXML) {
 *        // responseXML is XML document object
 *        var data = $('myElement', responseXML).text();
 *     }
 * };
 * $('#myForm').ajaxSubmit(options);
 * @desc XML data returned from server
 *
 *
 * @example
 * var options = {
 *     resetForm: true
 * };
 * $('#myForm').ajaxSubmit(options);
 * @desc submit form and reset it if successful
 *
 * @example
 * $('#myForm).submit(function() {
 *    $(this).ajaxSubmit();
 *    return false;
 * });
 * @desc Bind form's submit event to use ajaxSubmit
 *
 *
 * @name ajaxSubmit
 * @type jQuery
 * @param options  object literal containing options which control the form submission process
 * @cat Plugins/Form
 * @return jQuery
 * @see formToArray
 * @see ajaxForm
 * @see $.ajax
 * @author jQuery Community
 */
jQuery.fn.ajaxSubmit = function(options) {
    if (typeof options == 'function')
        options = { success: options };

    options = jQuery.extend({
        url:  this.attr('action') || window.location,
        type: this.attr('method') || 'GET'
    }, options || {});

    var a = this.formToArray(options.semantic);

    // give pre-submit callback an opportunity to abort the submit
    if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) return this;

    // fire vetoable 'validate' event
    var veto = {};
    jQuery.event.trigger('form.submit.validate', [a, this, options, veto]);
    if (veto.veto)
        return this;

    var q = jQuery.param(a);//.replace(/%20/g,'+');

    if (options.type.toUpperCase() == 'GET') {
        options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
        options.data = null;  // data is null for 'get'
    }
    else
        options.data = q; // data is the query string for 'post'

    var $form = this, callbacks = [];
    if (options.resetForm) callbacks.push(function() { $form.resetForm(); });
    if (options.clearForm) callbacks.push(function() { $form.clearForm(); });

    // perform a load on the target only if dataType is not provided
    if (!options.dataType && options.target) {
        var oldSuccess = options.success || function(){};
        callbacks.push(function(data, status) {
            jQuery(options.target).attr("innerHTML", data).evalScripts().each(oldSuccess, [data, status]);
        });
    }
    else if (options.success)
        callbacks.push(options.success);

    options.success = function(data, status) {
        for (var i=0, max=callbacks.length; i < max; i++)
            callbacks[i](data, status);
    };

    // are there files to upload?
    var files = jQuery('input:file', this).fieldValue();
    var found = false;
    for (var j=0; j < files.length; j++)
        if (files[j]) 
            found = true;

    if (options.iframe || found) // options.iframe allows user to force iframe mode
        fileUpload();
    else
        jQuery.ajax(options);

    // fire 'notify' event
    jQuery.event.trigger('form.submit.notify', [this, options]);
    return this;


    // private function for handling file uploads (hat tip to YAHOO!)
    function fileUpload() {
        var form = $form[0];
        var opts = jQuery.extend({}, jQuery.ajaxSettings, options);
        
        var id = 'jqFormIO' + jQuery.fn.ajaxSubmit.counter++;
        var $io = jQuery('<iframe id="' + id + '" name="' + id + '" />');
        var io = $io[0];
        var op8 = jQuery.browser.opera && window.opera.version() < 9;
        if (jQuery.browser.msie || op8) io.src = 'javascript:false;document.write("");';
        $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });

        // make sure form attrs are set
        form.method = 'POST';
        form.encoding ? form.encoding = 'multipart/form-data' : form.enctype = 'multipart/form-data';

        var xhr = { // mock object
            responseText: null,
            responseXML: null,
            status: 0,
            statusText: 'n/a',
            getAllResponseHeaders: function() {},
            getResponseHeader: function() {},
            setRequestHeader: function() {}
        };
        
        var g = opts.global;
        // trigger ajax global events so that activity/block indicators work like normal
        if (g && ! jQuery.active++) jQuery.event.trigger("ajaxStart");
        if (g) jQuery.event.trigger("ajaxSend", [xhr, opts]);
        
        var cbInvoked = 0;
        var timedOut = 0;
        
        // take a breath so that pending repaints get some cpu time before the upload starts
        setTimeout(function() {
            $io.appendTo('body');
            // jQuery's event binding doesn't work for iframe events in IE
            io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
            form.action = opts.url;
            var t = form.target;
            form.target = id;

            // support timout
            if (opts.timeout)
                setTimeout(function() { timedOut = true; cb(); }, opts.timeout);

            form.submit();
            form.target = t; // reset
        }, 10);
        
        function cb() {
            if (cbInvoked++) return;
            
            io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);

            var ok = true;
            try {
                if (timedOut) throw 'timeout';
                // extract the server response from the iframe
                var data, doc;
                doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
                xhr.responseText = doc.body ? doc.body.innerHTML : null;
                xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
                
                if (opts.dataType == 'json' || opts.dataType == 'script') {
                    var ta = doc.getElementsByTagName('textarea')[0];
                    data = ta ? ta.value : xhr.responseText;
                    if (opts.dataType == 'json')
                        eval("data = " + data);
                    else
                        jQuery.globalEval(data);
                }
                else if (opts.dataType == 'xml') {
                    data = xhr.responseXML;
                    if (!data && xhr.responseText != null)
                        data = toXml(xhr.responseText);
                }
                else {
                    data = xhr.responseText;
                }
            }
            catch(e){
                ok = false;
                jQuery.handleError(opts, xhr, 'error', e);
            }

            // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
            if (ok) {
                opts.success(data, 'success');
                if (g) jQuery.event.trigger("ajaxSuccess", [xhr, opts]);
            }
            if (g) jQuery.event.trigger("ajaxComplete", [xhr, opts]);
            if (g && ! --jQuery.active) jQuery.event.trigger("ajaxStop");
            if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');

            // clean up
            setTimeout(function() { 
                $io.remove(); 
                xhr.responseXML = null;
            }, 100);
        };
        
        function toXml(s, doc) {
            if (window.ActiveXObject) {
                doc = new ActiveXObject('Microsoft.XMLDOM');
                doc.async = 'false';
                doc.loadXML(s);
            }
            else
                doc = (new DOMParser()).parseFromString(s, 'text/xml');
            return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
        }
    };
};
jQuery.fn.ajaxSubmit.counter = 0; // used to create unique iframe ids

/**
 * ajaxForm() provides a mechanism for fully automating form submission.
 *
 * The advantages of using this method instead of ajaxSubmit() are:
 *
 * 1: This method will include coordinates for <input type="image" /> elements (if the element
 *    is used to submit the form).
 * 2. This method will include the submit element's name/value data (for the element that was
 *    used to submit the form).
 * 3. This method binds the submit() method to the form for you.
 *
 * Note that for accurate x/y coordinates of image submit elements in all browsers
 * you need to also use the "dimensions" plugin (this method will auto-detect its presence).
 *
 * The options argument for ajaxForm works exactly as it does for ajaxSubmit.  ajaxForm merely
 * passes the options argument along after properly binding events for submit elements and
 * the form itself.  See ajaxSubmit for a full description of the options argument.
 *
 *
 * @example
 * var options = {
 *     target: '#myTargetDiv'
 * };
 * $('#myForm').ajaxSForm(options);
 * @desc Bind form's submit event so that 'myTargetDiv' is updated with the server response
 *       when the form is submitted.
 *
 *
 * @example
 * var options = {
 *     success: function(responseText) {
 *         alert(responseText);
 *     }
 * };
 * $('#myForm').ajaxSubmit(options);
 * @desc Bind form's submit event so that server response is alerted after the form is submitted.
 *
 *
 * @example
 * var options = {
 *     beforeSubmit: function(formArray, jqForm) {
 *         if (formArray.length == 0) {
 *             alert('Please enter data.');
 *             return false;
 *         }
 *     }
 * };
 * $('#myForm').ajaxSubmit(options);
 * @desc Bind form's submit event so that pre-submit callback is invoked before the form
 *       is submitted.
 *
 *
 * @name   ajaxForm
 * @param  options  object literal containing options which control the form submission process
 * @return jQuery
 * @cat    Plugins/Form
 * @type   jQuery
 * @see    ajaxSubmit
 * @author jQuery Community
 */
jQuery.fn.ajaxForm = function(options) {
    return this.each(function() {
        jQuery("input:submit,input:image,button:submit", this).click(function(ev) {
            var $form = this.form;
            $form.clk = this;
            if (this.type == 'image') {
                if (ev.offsetX != undefined) {
                    $form.clk_x = ev.offsetX;
                    $form.clk_y = ev.offsetY;
                } else if (typeof jQuery.fn.offset == 'function') { // try to use dimensions plugin
                    var offset = jQuery(this).offset();
                    $form.clk_x = ev.pageX - offset.left;
                    $form.clk_y = ev.pageY - offset.top;
                } else {
                    $form.clk_x = ev.pageX - this.offsetLeft;
                    $form.clk_y = ev.pageY - this.offsetTop;
                }
            }
            // clear form vars
            setTimeout(function() {
                $form.clk = $form.clk_x = $form.clk_y = null;
                }, 10);
        })
    }).submit(function(e) {
        jQuery(this).ajaxSubmit(options);
        return false;
    });
};


/**
 * formToArray() gathers form element data into an array of objects that can
 * be passed to any of the following ajax functions: $.get, $.post, or load.
 * Each object in the array has both a 'name' and 'value' property.  An example of
 * an array for a simple login form might be:
 *
 * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
 *
 * It is this array that is passed to pre-submit callback functions provided to the
 * ajaxSubmit() and ajaxForm() methods.
 *
 * The semantic argument can be used to force form serialization in semantic order.
 * This is normally true anyway, unless the form contains input elements of type='image'.
 * If your form must be submitted with name/value pairs in semantic order and your form
 * contains an input of type='image" then pass true for this arg, otherwise pass false
 * (or nothing) to avoid the overhead for this logic.
 *
 * @example var data = $("#myForm").formToArray();
 * $.post( "myscript.cgi", data );
 * @desc Collect all the data from a form and submit it to the server.
 *
 * @name formToArray
 * @param semantic true if serialization must maintain strict semantic ordering of elements (slower)
 * @type Array<Object>
 * @cat Plugins/Form
 * @see ajaxForm
 * @see ajaxSubmit
 * @author jQuery Community
 */
jQuery.fn.formToArray = function(semantic) {
    var a = [];
    if (this.length == 0) return a;

    var form = this[0];
    var els = semantic ? form.getElementsByTagName('*') : form.elements;
    if (!els) return a;
    for(var i=0, max=els.length; i < max; i++) {
        var el = els[i];
        var n = el.name;
        if (!n) continue;

        if (semantic && form.clk && el.type == "image") {
            // handle image inputs on the fly when semantic == true
            if(!el.disabled && form.clk == el)
                a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
            continue;
        }
        var v = jQuery.fieldValue(el, true);
        if (v === null) continue;
        if (v.constructor == Array) {
            for(var j=0, jmax=v.length; j < jmax; j++)
                a.push({name: n, value: v[j]});
        }
        else
            a.push({name: n, value: v});
    }

    if (!semantic && form.clk) {
        // input type=='image' are not found in elements array! handle them here
        var inputs = form.getElementsByTagName("input");
        for(var i=0, max=inputs.length; i < max; i++) {
            var input = inputs[i];
            var n = input.name;
            if(n && !input.disabled && input.type == "image" && form.clk == input)
                a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
        }
    }
    return a;
};


/**
 * Serializes form data into a 'submittable' string. This method will return a string
 * in the format: name1=value1&amp;name2=value2
 *
 * The semantic argument can be used to force form serialization in semantic order.
 * If your form must be submitted with name/value pairs in semantic order then pass
 * true for this arg, otherwise pass false (or nothing) to avoid the overhead for
 * this logic (which can be significant for very large forms).
 *
 * @example var data = $("#myForm").formSerialize();
 * $.ajax('POST', "myscript.cgi", data);
 * @desc Collect all the data from a form into a single string
 *
 * @name formSerialize
 * @param semantic true if serialization must maintain strict semantic ordering of elements (slower)
 * @type String
 * @cat Plugins/Form
 * @see formToArray
 * @author jQuery Community
 */
jQuery.fn.formSerialize = function(semantic) {
    //hand off to jQuery.param for proper encoding
    return jQuery.param(this.formToArray(semantic));
};


/**
 * Serializes all field elements in the jQuery object into a query string.
 * This method will return a string in the format: name1=value1&amp;name2=value2
 *
 * The successful argument controls whether or not serialization is limited to
 * 'successful' controls (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
 * The default value of the successful argument is true.
 *
 * @example var data = $("input").formSerialize();
 * @desc Collect the data from all successful input elements into a query string
 *
 * @example var data = $(":radio").formSerialize();
 * @desc Collect the data from all successful radio input elements into a query string
 *
 * @example var data = $("#myForm :checkbox").formSerialize();
 * @desc Collect the data from all successful checkbox input elements in myForm into a query string
 *
 * @example var data = $("#myForm :checkbox").formSerialize(false);
 * @desc Collect the data from all checkbox elements in myForm (even the unchecked ones) into a query string
 *
 * @example var data = $(":input").formSerialize();
 * @desc Collect the data from all successful input, select, textarea and button elements into a query string
 *
 * @name fieldSerialize
 * @param successful true if only successful controls should be serialized (default is true)
 * @type String
 * @cat Plugins/Form
 */
jQuery.fn.fieldSerialize = function(successful) {
    var a = [];
    this.each(function() {
        var n = this.name;
        if (!n) return;
        var v = jQuery.fieldValue(this, successful);
        if (v && v.constructor == Array) {
            for (var i=0,max=v.length; i < max; i++)
                a.push({name: n, value: v[i]});
        }
        else if (v !== null && typeof v != 'undefined')
            a.push({name: this.name, value: v});
    });
    //hand off to jQuery.param for proper encoding
    return jQuery.param(a);
};


/**
 * Returns the value(s) of the element in the matched set.  For example, consider the following form:
 *
 *  <form><fieldset>
 *      <input name="A" type="text" />
 *      <input name="A" type="text" />
 *      <input name="B" type="checkbox" value="B1" />
 *      <input name="B" type="checkbox" value="B2"/>
 *      <input name="C" type="radio" value="C1" />
 *      <input name="C" type="radio" value="C2" />
 *  </fieldset></form>
 *
 *  var v = $(':text').fieldValue();
 *  // if no values are entered into the text inputs
 *  v == ['','']
 *  // if values entered into the text inputs are 'foo' and 'bar'
 *  v == ['foo','bar']
 *
 *  var v = $(':checkbox').fieldValue();
 *  // if neither checkbox is checked
 *  v === undefined
 *  // if both checkboxes are checked
 *  v == ['B1', 'B2']
 *
 *  var v = $(':radio').fieldValue();
 *  // if neither radio is checked
 *  v === undefined
 *  // if first radio is checked
 *  v == ['C1']
 *
 * The successful argument controls whether or not the field element must be 'successful'
 * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
 * The default value of the successful argument is true.  If this value is false the value(s)
 * for each element is returned.
 *
 * Note: This method *always* returns an array.  If no valid value can be determined the
 *       array will be empty, otherwise it will contain one or more values.
 *
 * @example var data = $("#myPasswordElement").fieldValue();
 * alert(data[0]);
 * @desc Alerts the current value of the myPasswordElement element
 *
 * @example var data = $("#myForm :input").fieldValue();
 * @desc Get the value(s) of the form elements in myForm
 *
 * @example var data = $("#myForm :checkbox").fieldValue();
 * @desc Get the value(s) for the successful checkbox element(s) in the jQuery object.
 *
 * @example var data = $("#mySingleSelect").fieldValue();
 * @desc Get the value(s) of the select control
 *
 * @example var data = $(':text').fieldValue();
 * @desc Get the value(s) of the text input or textarea elements
 *
 * @example var data = $("#myMultiSelect").fieldValue();
 * @desc Get the values for the select-multiple control
 *
 * @name fieldValue
 * @param Boolean successful true if only the values for successful controls should be returned (default is true)
 * @type Array<String>
 * @cat Plugins/Form
 */
jQuery.fn.fieldValue = function(successful) {
    for (var val=[], i=0, max=this.length; i < max; i++) {
        var el = this[i];
        var v = jQuery.fieldValue(el, successful);
        if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length))
            continue;
        v.constructor == Array ? jQuery.merge(val, v) : val.push(v);
    }
    return val;
};

/**
 * Returns the value of the field element.
 *
 * The successful argument controls whether or not the field element must be 'successful'
 * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
 * The default value of the successful argument is true.  If the given element is not
 * successful and the successful arg is not false then the returned value will be null.
 *
 * Note: If the successful flag is true (default) but the element is not successful, the return will be null
 * Note: The value returned for a successful select-multiple element will always be an array.
 * Note: If the element has no value the return value will be undefined.
 *
 * @example var data = jQuery.fieldValue($("#myPasswordElement")[0]);
 * @desc Gets the current value of the myPasswordElement element
 *
 * @name fieldValue
 * @param Element el The DOM element for which the value will be returned
 * @param Boolean successful true if value returned must be for a successful controls (default is true)
 * @type String or Array<String> or null or undefined
 * @cat Plugins/Form
 */
jQuery.fieldValue = function(el, successful) {
    var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
    if (typeof successful == 'undefined') successful = true;

    if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
        (t == 'checkbox' || t == 'radio') && !el.checked ||
        (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
        tag == 'select' && el.selectedIndex == -1))
            return null;

    if (tag == 'select') {
        var index = el.selectedIndex;
        if (index < 0) return null;
        var a = [], ops = el.options;
        var one = (t == 'select-one');
        var max = (one ? index+1 : ops.length);
        for(var i=(one ? index : 0); i < max; i++) {
            var op = ops[i];
            if (op.selected) {
                // extra pain for IE...
                var v = jQuery.browser.msie && !(op.attributes['value'].specified) ? op.text : op.value;
                if (one) return v;
                a.push(v);
            }
        }
        return a;
    }
    return el.value;
};


/**
 * Clears the form data.  Takes the following actions on the form's input fields:
 *  - input text fields will have their 'value' property set to the empty string
 *  - select elements will have their 'selectedIndex' property set to -1
 *  - checkbox and radio inputs will have their 'checked' property set to false
 *  - inputs of type submit, button, reset, and hidden will *not* be effected
 *  - button elements will *not* be effected
 *
 * @example $('form').clearForm();
 * @desc Clears all forms on the page.
 *
 * @name clearForm
 * @type jQuery
 * @cat Plugins/Form
 * @see resetForm
 */
jQuery.fn.clearForm = function() {
    return this.each(function() {
        jQuery('input,select,textarea', this).clearFields();
    });
};

/**
 * Clears the selected form elements.  Takes the following actions on the matched elements:
 *  - input text fields will have their 'value' property set to the empty string
 *  - select elements will have their 'selectedIndex' property set to -1
 *  - checkbox and radio inputs will have their 'checked' property set to false
 *  - inputs of type submit, button, reset, and hidden will *not* be effected
 *  - button elements will *not* be effected
 *
 * @example $('.myInputs').clearFields();
 * @desc Clears all inputs with class myInputs
 *
 * @name clearFields
 * @type jQuery
 * @cat Plugins/Form
 * @see clearForm
 */
jQuery.fn.clearFields = jQuery.fn.clearInputs = function() {
    return this.each(function() {
        var t = this.type, tag = this.tagName.toLowerCase();
        if (t == 'text' || t == 'password' || tag == 'textarea')
            this.value = '';
        else if (t == 'checkbox' || t == 'radio')
            this.checked = false;
        else if (tag == 'select')
            this.selectedIndex = -1;
    });
};


/**
 * Resets the form data.  Causes all form elements to be reset to their original value.
 *
 * @example $('form').resetForm();
 * @desc Resets all forms on the page.
 *
 * @name resetForm
 * @type jQuery
 * @cat Plugins/Form
 * @see clearForm
 */
jQuery.fn.resetForm = function() {
    return this.each(function() {
        // guard against an input with the name of 'reset'
        // note that IE reports the reset function as an 'object'
        if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType))
            this.reset();
    });
};

;
/* AGGREGATED JS FILE: sites/all/modules/rc/media_upload/media_upload_common.js */

var kaltura_swf_url = null;
var kaltura_local_callback = '';
var kaltura_local_selected_nids = [];
var kaltura_local_selected_entryids = [];
var kaltura_local_selected_kshow_ids = [];
var kaltura_local_selected_youtube_ids = [];
var kaltura_local_field = {};
var kaltura_local_tags_form = {};
var kaltura_local_field_name = '';
var kaltura_local_object = {};


function media_upload_select_media(vars,field_name,ui_url,callback,default_tab)
{
	kaltura_local_selected_nids=[];
	kaltura_local_selected_entryids=[];
	kaltura_local_field=$(this).find('[@name='+field_name+']');
	kaltura_local_field_name=field_name;
	 
	if (kaltura_local_field.val() != ''){
		kaltura_local_selected_nids = kaltura_local_field.val().split(',');
		kaltura_local_selected_entryids = $(this).find('[@name='+field_name+'_entries]').val().split(',');
	}
	
	if (callback) kaltura_local_callback = callback;
	else kaltura_local_callback = '';
	
	kaltura_swf_url=ui_url;
	
	if (!default_tab)
		default_tab = 'browse-tab';
	//var multiple = $('[@name='+field_name+'_type]').val();
	var media_type = $(this).find('[@name='+field_name+'_type]').val();
	var multiple = parseInt($(this).find('[@name='+field_name+'_multiple]').val());
	
	$('#generic_modal').bind('jqm_close',function(event,jqm_handle){
					$('#media_upload_main_tabs').expire();
	});
	
	var init=true;
	$('#media_upload_main_tabs').livequery(function(){
																							var draw=function(tab,media_type){
																								var container=$(tab).parents('.tabs_container:eq(0)').find('.tab_content_wrapper:eq(0)').children('[@tag=' + $(tab).attr('tag') + ']')
																								switch($(tab).attr('tag'))
																								{
																									case 'novebox-tab':
																										var media_owner='share';
																									break;
																									
																									default:
																										var media_owner='my';
																								}
																								if(!init)
																									media_upload_drow_items(container,media_type,media_owner,multiple);																	
																							}
																							
																						// establish initial open tabs

																							$('#media_upload_owner_tabs2 h2[@tag=novebox-tab]').bind('tab_enter',function(){
																								draw(this,'image');
																							});
																							$('#media_upload_owner_tabs2 h2[@tag=my-stuff-tab]').bind('tab_enter',function(){
																								draw(this,'image');
																							});
																							$('#media_upload_owner_tabs1 h2[@tag=novebox-tab]').bind('tab_enter',function(){
																								draw(this,'video');
																							});
																							$('#media_upload_owner_tabs1 h2[@tag=my-stuff-tab]').bind('tab_enter',function(){
																								draw(this,'video');
																							});
																							
																							$('#media_upload_content_tabs h2[@tag=browse-video-tab]').bind('tab_enter',function(){
																								kaltura_local_selected_nids=[];
																								kaltura_local_selected_entryids=[];																							
																								draw(get_active_tab_handle('media_upload_owner_tabs1'),'video');
																							});
																							$('#media_upload_content_tabs h2[@tag=browse-image-tab]').bind('tab_enter',function(){
																								kaltura_local_selected_nids=[];
																								kaltura_local_selected_entryids=[];																																																																							
																								draw(get_active_tab_handle('media_upload_owner_tabs2'),'image');
																							});
																							
																							$('#media_upload_main_tabs h2[@tag=browse-tab]').bind('tab_enter',function(){
																								get_active_tab_handle('media_upload_content_tabs').click();
																							});

																							$('#media_upload_main_tabs h2[@tag=upload-tab]').bind('tab_exit',function(){
																								$('#media_upload .media_upload_form_wrap').remove();
																								$('#media_upload_kaltura_object').show();
																							});
																																																																																					
																							$('#media_upload_main_tabs h2[@tag='+default_tab+']').click();
																							init=false;
																							
																							$('#media_upload_owner_tabs1 .media_browse_search_form input[@type=button]').click(function(){draw(get_active_tab_handle('media_upload_owner_tabs1'),'video')});
																							$('#media_upload_owner_tabs2 .media_browse_search_form input[@type=button]').click(function(){draw(get_active_tab_handle('media_upload_owner_tabs2'),'image')});
																							
																			});

	var inner_html='';
										
	kaltura_local_object = create_modal(inner_html,rc.t('Media manager'),{show:5},'',{modal:true,ajax:'/media_upload/tab_content/'+media_type+'/'+default_tab},{'overflow-y':'auto','width':750, 'height':680},'', function(){
		
			//Changed flash
			
			//media_upload_write_CW('media_upload_kaltura_object',vars,680,360);
			var flashVersion = getFlashVersion().split(',').shift(); 
			if (flashVersion < 10)
			{
				var flashHtml = '<div class="download_flash"><a href="http://get.adobe.com/flashplayer/" target="_black">'+rc.t('Para cargar fotos y videos necesitas usar la última versión de Flash. Haz click aquí.')+'</a></div>';
				$('#media_upload_kaltura_object').html(flashHtml);
			}
			else
			{
				media_upload_write_CW('media_upload_kaltura_object',vars,680,360);
			}
			
			//Changed
			//$('#image_form').css({'opacity':'1'});
			$('#image_form').css({'visibility':'visible'});
			$('.insert_image').css({'opacity':'1'});
			$('.loading').hide();
			//$('.yui-toolbar-group-textflow').show();
			
	});
		
}

function media_upload_write_CW(write_to_id,vars,width,height)
{
	var kso = new SWFObject(kaltura_swf_url, write_to_id + '_swf', width, height, "9", "#000000");
  kso.addParam("flashVars", vars);
  kso.addParam("wmode", "transparent");
  kso.addParam("allowScriptAccess", "always");
  kso.addParam("allowFullScreen", "TRUE");
  kso.addParam("allowNetworking", "all");
  kso.write(write_to_id);
}



function media_upload_drow_items(container,media_type,media_owner,multiple,action_url){

	$('.media_browse_media_caser',container).html(getImg('big_jqm_loader'));
	$.ajax({
		type: "POST",
		url: action_url ? action_url : url('media_upload/getref/'+media_owner+'/'+media_type+'/'+$('.media_browse_search_box',container).val()),
		data: "nids="+kaltura_local_selected_nids.join(','),
		//dataType: "json",
		success: function(data){
			$('.media_browse_media_caser',container).html(data);
			media_upload_go2page(container,media_type,media_owner,multiple);

			$('.media_upload_items_wrapper .media_item',container).click(function (){
				var t = $(this);
				var nid = t.attr('rel');
				var entryid = t.attr('entry');
				var kshow_id = t.attr('kshow_id');
				var youtube_id = t.attr('youtube_id');								
				if (multiple){
					var pos = in_array(nid,kaltura_local_selected_nids);
					if (pos < 0){
						kaltura_local_selected_nids.push(nid);
						kaltura_local_selected_entryids.push(entryid);
						kaltura_local_selected_kshow_ids.push(kshow_id);
						kaltura_local_selected_youtube_ids.push(youtube_id);						
						t.addClass('selected');
					}
					else {
						array_remove(pos, kaltura_local_selected_nids);
						array_remove(pos, kaltura_local_selected_entryids);
						array_remove(pos, kaltura_local_selected_kshow_ids);
						array_remove(pos, kaltura_local_selected_youtube_ids);						
						t.removeClass('selected');
					}					
				}
				else {
					kaltura_local_selected_nids = [];
					kaltura_local_selected_entryids = [];
					kaltura_local_selected_kshow_ids = [];
					kaltura_local_selected_youtube_ids = [];
					
					kaltura_local_selected_nids.push(nid);
					kaltura_local_selected_entryids.push(entryid);
					kaltura_local_selected_kshow_ids.push(kshow_id);
					kaltura_local_selected_youtube_ids.push(youtube_id);
										
					var cur_sel=t.parents('.media_upload_items_wrapper').find('.media_item.selected').get(0);
					if(this==cur_sel)
						t.removeClass('selected');
					else
					{
						if(cur_sel)
							$(cur_sel).removeClass('selected');					
						t.addClass('selected');
					}
				}
			});
		}
	});
}



function media_upload_go2page(container,media_type,media_owner,multiple) 
{

	$('.pager a',container).click(function(event){
		event.preventDefault();

		media_upload_drow_items(container,media_type,media_owner,multiple,$(this).attr('href'));

	});		
}

function onContributionWizardAfterAddEntry() {
	var tburl='';// = 'media_upload/manage_upload';
	for (var tmp in arguments[0]){
		if (arguments[0][tmp]['entryId']){
			tburl += arguments[0][tmp]['entryId']+'|';
		}
	}
	$.ajax({
		type: "GET",
		url: url('media_upload/manage_upload')+'/'+tburl.substr(0,tburl.length-1),
		//data: "entryids="+tburl.substr(0,tburl.length-1),
		dataType: "json",
		
		error:function(data){$('#media_upload').prepend('<span>Unknown error occured.</span>');},
		
		success: function(data){
			$('#media_upload_kaltura_object').hide();
			$('#media_upload').append('<div class="media_upload_form_wrap"><div class="media_upload_tagging">'+data.html+'</div></div>');
			Drupal.autocompleteAutoAttach();
			
			$('#media_upload #edit-cancel').click(function(event){
				event.preventDefault();
				var nids=$('#media-upload-manage-upload-form  input[@name=nids]').val();
				$('#media_upload .media_upload_form_wrap').remove();
				$('#media_upload_kaltura_object').show();
				
				$.ajax({
					type: "POST",
					url: url('media_upload/delref'),
					data: "nids="+nids,
					dataType: "html",
					success: function(data){
						clog('ok');
					},
					error: function(data){
						clog('error');
					}
				});				
			});
			
			$('a.tagme').next().hide();
			
			$('a.tagme').click(function () {
				$(this).next().show();
				$(this).hide();
			});
			
			$('#media-upload-manage-upload-form .item_caser input[@type=text]').click(function(){$(this).unbind('focus'); $(this).val('');});			
			$('#media-upload-manage-upload-form .item_caser textarea').click(function(){$(this).unbind('focus'); $(this).val('');});			

			$('#media-upload-manage-upload-form').ajaxForm({
					beforeSubmit: function(){
							var errors = '';
							var t = $('#media-upload-manage-upload-form');
							t.find('div.error').remove();
							t.find('input[@type!=hidden].required').each(function (){
								$(this).removeClass('error');
								if ($(this).val() == '' || $(this).val() == null){
									errors += '<li>'+rc.t("Title is required")+'</li>';
									$(this).addClass('error');
								}
							});
							
							if (errors != ''){
								t.prepend('<div class="error"><ul>'+errors+'</ul></div>');
								return false;
							}
					
							return true;
					},
					url:url('media_upload/manage_upload'),
			  	clearForm: false ,
			  	dataType: "json",
			  	error: function(data){$('#media-upload-manage-upload-form').prepend('<span>Unknown error occured.</span>');},
					success : function (data){
						if (data.error == 0)
						{
							var nids = $('.media_upload_tagging [@name=nids]').val();
							var entryids = $('.media_upload_tagging [@name=entryids]').val();

							
							$('media_upload_tagging').remove();
							$('#media_upload_kaltura_object').show();
							nids = nids.split(',');
							for (var i in nids){
								kaltura_local_selected_nids.push(nids[i]);
								kaltura_local_selected_entryids.push(entryids[i]);

							}
							
							var media_type=$('.media_upload_tagging input[@name=media_type]').val();							
							if(media_type)
							{
									$('#media_upload_main_tabs h2[@tag=browse-tab]').click();
									$('#media_upload_content_tabs h2[@tag=browse-'+media_type+'-tab]').click();
									if(media_type=='image')
										$('#media_upload_owner_tabs2 h2[@tag=my-stuff-tab]').click();
									else
										$('#media_upload_owner_tabs1 h2[@tag=my-stuff-tab]').click();								
							}
							else
								$('#media_upload_main_tabs h2[@tag=browse-tab]').click();
						}
						else {						
							$('#media-upload-manage-upload-form').find('div.error').remove();
							$('#media-upload-manage-upload-form').prepend(data.html);
						}
					}
			  });

		}
	});
}

function media_upload_select_video_single(){
	var settings = Drupal.settings.kflashvarsvideo;
	var field_name = 'editor_media_upload_video'+(editor_count++);
	
	var fields = '<input type="hidden" name="'+field_name+'">'
							+'<input type="hidden" name="'+field_name+'_type" value="video">'
							+'<input type="hidden" name="'+field_name+'_multiple" value="0">';

	// I just pushed it into the body , if you have a better place to append it to then change it
	$('body').append(fields);
	var inst=this;
	var editor_selected_video_callback=function editor_selected_video_callback(selected_nids,selected_entryids,field_name)
	{
		if(selected_nids[0])
		{
			var kaltura_tag = Drupal.settings.kaltura_tag;
			kaltura_tag=kaltura_tag.replace(/\/\]/,' nid="'+selected_nids[0]+'" /]');
		  inst.execCommand('inserthtml', '<div>'+kaltura_tag+'</div>');
	  }
	}	
	
	var close_media_popup=function(){
	  inst.toolbar.set('disabled', false); 
		inst.toolbar.resetAllButtons();
	  inst._focusWindow();	
	}
	
	$('#generic_modal').bind('jqm_close',close_media_popup);
	media_upload_select_media(settings,field_name,Drupal.settings.ksettings.ui_url_video,editor_selected_video_callback);
}


function getFlashVersion(){ 
  // ie 
  try { 
    try { 
      // avoid fp6 minor version lookup issues 
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
      try { axo.AllowScriptAccess = 'always'; } 
      catch(e) { return '6,0,0'; } 
    } catch(e) {} 
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
  // other browsers 
  } catch(e) { 
    try { 
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ 
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; 
      } 
    } catch(e) {} 
  } 
  return '0,0,0'; 
} 

function get_item_dimensions(nid)
{
	var ajax_url = '/media_upload/image/dimensions/' + nid;
	//alert(ajax_url);
	//return;

	$('.mi_' + nid).html('<div class="mini_loading"></div>');
	
	$.ajax({
  	type: "GET",
  	url: ajax_url,
  	dataType: "html",
  	success: function (data) {
			  	
  		$('.mi_' + nid).fadeOut('slow', function(){
  			$('.mi_' + nid).html(data).fadeIn('slow');
  		});
  		
  		$('.mi_' + nid).removeAttr("onclick");
  		
  		return false;
  	}
  });
  return false;
}
;
/* AGGREGATED JS FILE: sites/all/modules/rc/media_upload/media_upload.js */
var editor_count = 0;

$().ready(function(){
		$('.selected_media_item_link').livequery('click',function (){ 
			var t = $(this);
			media_upload_remove_item(t);
		});
})

/*
 * The commented code below is used to allow changing the width & height of the image
 * at the small window that pops up from YUI Editor when you click Add Image , it basically should
 * act on every change in one of the two textboxes(width & height) , retrieve the current image path from a text box , parse it and get the entry id from the link
 * then recreate the link with that entry id and the new width and height set in the textbox
 * It works as it should but if needs to be tested more before committed to production
 * Please uncomment it , test it and upload :)
 */

/* $('input#edit-body_insertimage_width').livequery('change',function(){	
	var _url = $('#edit-body_insertimage_url').get(0).value;
	var width = this.value;
	var height = $('input#edit-body_insertimage_height').get(0).value;
	
	var entryId = getEntryFromUrl(_url);
	if (entryId!=''){
		var thumbUrl = getThumbnailUrl(entryId,width,height);
	
		$('#edit-body_insertimage_url').get(0).value = thumbUrl;
	}
});

$('input#edit-body_insertimage_height').livequery('change',function(){	
	var _url = $('#edit-body_insertimage_url').get(0).value;

	var width = $('input#edit-body_insertimage_width').get(0).value;
	var height = this.value;	

	var entryId = getEntryFromUrl(_url);
	if (entryId!=''){
		var thumbUrl = getThumbnailUrl(entryId,width,height);
	
		$('#edit-body_insertimage_url').get(0).value = thumbUrl;
	}
});*/

function getEntryFromUrl(_url){
	if (typeof(_url)=='undefined')
		return '';
		
	// I guess this could be improved a bit since the URL is pretty static , change it if you want
	var re = /entry_id\/(.{1,10})\//;
	var match = re.exec(_url);
	if (match!=null){
		return match[1];
	}
	
	return '';
}

/*
 * Generates a URL for an Image by entryID from the Kaltura CDN
 */
function getThumbnailUrl(entryId,width,height){
	
	if (typeof(entryId)=='undefined')
		return false;
		
	if (typeof(Drupal.settings.ksettings)=='undefined')
		return '';
		
	if (typeof(Drupal.settings.ksettings.kurl)=='undefined' ||
			typeof(Drupal.settings.ksettings.kpartner)=='undefined' ||
			typeof(Drupal.settings.ksettings.ksubpartner)=='undefined')
		return '';
		
	if (typeof(width)=='undefined'){
		width = '631';
	}
	
	if (typeof(height)=='undefined'){
		height = '';
	}
	
	var _url = Drupal.settings.ksettings.kurl;
	var partner_id = Drupal.settings.ksettings.kpartner;
	var subpartner_id = Drupal.settings.ksettings.ksubpartner;
	
	var ret_url = _url+'/p/'+partner_id+'/sp/'+subpartner_id+'/thumbnail/entry_id/'+entryId+'/width/'+width+'/height/'+height+'/type/2/bgcolor/000000'
	
	return ret_url;	
}

/**
 * This function is called when clicking the 'browse' button from the YUI Editor Interface , should load the Media Upload Modal
 */
function editor_get_media(){
  
	$('.loading').show();
	//$('#image_form').css({'opacity':'0.1'});
	$('.insert_image').css({'opacity':'0.1'});
	$('#image_form').css({'visibility':'hidden'});
	//$('.yui-toolbar-group-textflow').hide();
	
	//$('.loading').css({'opacity':'1'});
	
	var settings = Drupal.settings.kflashvarsimage;
	var field_name = 'editor_media_upload_'+(editor_count++);
	
	var fields = '<input type="hidden" name="'+field_name+'">'
							+'<input type="hidden" name="'+field_name+'_type" value="image">'
							+'<input type="hidden" name="'+field_name+'_multiple" value="0">';

	// I just pushed it into the body , if you have a better place to append it to then change it
	$('body').append(fields);

	media_upload_select_media(settings,field_name,Drupal.settings.ksettings.ui_url_image,editor_selected_callback);	

}



/**
 * This is a callback as passed to the 'media_upload_select_media' function
 * it is called upon clicking the finish button on the media upload(when selecting items)
 * It gets an array of selected nids , selected entry_ids and the original field name(the one that triggered the media_upload)
 * @param {} selected_nids
 * @param {} selected_entryids
 * @param {} field_name
 */
function editor_selected_callback(selected_nids,selected_entryids,field_name,selected_kshow_ids,selected_youtube_urls){

	var _url =get_media_url(0,selected_nids,selected_entryids,selected_kshow_ids,selected_youtube_urls,'631w','','631');
	
	$('#edit-body_insertimage_url').get(0).value = _url;
	
	var ajax_url = '/media_upload/image/dimensions/' + selected_nids;
	
		$.ajax({
	  	type: "GET",
	  	url: ajax_url,
	  	dataType: "html",
	  	success: function (data) {
			
			dim = data.split('X');
			$('input#edit-body_insertimage_width').get(0).value = dim[0];
			$('input#edit-body_insertimage_height').get(0).value = dim[1];
			
	  	}
	  });
	
}
    
function onContributionWizardClose(modified) {

  if (modified == "0") {
  	clog('notmod',arguments);
    //setTimeout("window.top.kalturaCloseModalBox();", 0);
  } else { 
  	clog('mod',arguments);
    //setTimeout("window.top.kalturaRefreshTop();", 0);
  }
  return;
}
    



function media_upload_upload_media(vars,upload_id){

	var inner_html = ['<div id="media_upload" style="padding: 20px"></div>'].join('');
	create_modal(inner_html,rc.t('Media manager'),{show:5},'',{modal:true},{'overflow-y':'auto','width':750, 'height':600},'', function(){
	});

}



function media_upload_select_items(){
	kaltura_local_field.val(kaltura_local_selected_nids.join(','));
	$('[@name='+kaltura_local_field_name+'_entries]').val(kaltura_local_selected_entryids.join(','));
	kaltura_local_object.close();
	

	if (kaltura_local_callback != ''){
		window.kaltura_local_callback(kaltura_local_selected_nids,kaltura_local_selected_entryids,kaltura_local_field_name,kaltura_local_selected_kshow_ids,kaltura_local_selected_youtube_ids);
	}
	else {
		media_upload_drow_selected_items(kaltura_local_selected_nids,kaltura_local_selected_entryids,kaltura_local_field_name,kaltura_local_selected_kshow_ids,kaltura_local_selected_youtube_ids);
	}
}


function get_media_url(ind,nids,entryids,kshow_ids,youtube_urls,preset,h,w)
{
	var url='';
	if(entryids[ind]!='0')
		url='http://cdn.kaltura.com/p/0/thumbnail/entry_id/'+entryids[ind]+'/width/'+w+'/height/'+h;
	else if(kshow_ids[ind]!='0')
		url='/files/imagecache/'+preset+'/'+kshow_ids[ind];
	else if(youtube_urls[ind]!='0')
	{
		url='/files/imagecache/'+preset+'/'+youtube_urls[ind];
	}
	else
		url='/files/imagecache/'+preset+'/'+nids[ind];

	return url; 
}

function media_upload_drow_selected_items(nids,entryids,field_name,kshow_ids,youtube_urls)
{
	var html = '';
	for (var i=0;i<nids.length;i++){
		html += ['<div class="selected_media_item">',
							'<div><img src="'+get_media_url(i,nids,entryids,kshow_ids,youtube_urls,'90x90','90','90')+'" /></div>',
							'<div><a class="selected_media_item_link" nid="'+nids[i]+'" fieldname="'+field_name+'">'+rc.t('Remove')+'</a></div>',
						'</div>'].join('');
	}
	$('.'+field_name).html(html);
}

function media_upload_remove_item(t)
{
	var nid = t.attr('nid');
	var field_name = t.attr('fieldname');
	var nids = $('[@name='+field_name+']').val().split(',');
	var entries = $('[@name='+field_name+'_entries]').val().split(',');
	var pos = in_array(nid,nids);
	if (pos >= 0){
		t.parents('.selected_media_item').remove();
		array_remove(pos, nids);
		array_remove(pos, entries);
		$('[@name='+field_name+']').val(nids.join(','));
		$('[@name='+field_name+'_entries]').val(entries.join(','));
	}
}



;
/* AGGREGATED JS FILE: misc/autocomplete.js */
// $Id: autocomplete.js 6594 2009-02-26 07:46:41Z amitk $

/**
 * Attaches the autocomplete behaviour to all required fields
 */
var acdb = {};
Drupal.autocompleteAutoAttach = function () {
  $('input.autocomplete').each(function () {
    var uri = this.value;
    if (!acdb[uri]) {
      acdb[uri] = new Drupal.ACDB(uri);
    }
		var input = $('input[@id="' + this.id.substr(0, this.id.length - 13) + '"][@rel="' + this.getAttribute('rel') + '"][@type="text"]');
		input.attr('autocomplete', 'OFF');
		$(input.get(0).form).submit(Drupal.autocompleteSubmit);
		new Drupal.jsAC(input.get(0), acdb[uri]);
  });
}

/**
 * Prevents the form from submitting if the suggestions popup is open
 * and closes the suggestions popup when doing so.
 */
Drupal.autocompleteSubmit = function () {
  return $('#autocomplete').each(function () {
    this.owner.hidePopup();
  }).size() == 0;
}

/**
 * An AutoComplete object
 */
Drupal.jsAC = function (input, db) {
  var ac = this;
  ac.input = input;
  ac.db = db;
  
  $(ac.input)
    .keydown(function (event) { return ac.onkeydown(this, event); })
    .keyup(function (event) { ac.onkeyup(this, event) })
    .blur(function () { ac.hidePopup(); ac.db.cancel(); });
};

/**
 * Handler for the "keydown" event
 */
Drupal.jsAC.prototype.onkeydown = function (input, e) {
  if (!e) {
    e = window.event;
  }
  switch (e.keyCode) {
    case 40: // down arrow
      this.selectDown();
      return false;
    case 38: // up arrow
      this.selectUp();
      return false;
    default: // all other keys
      return true;
  }
}

/**
 * Handler for the "keyup" event
 */
Drupal.jsAC.prototype.onkeyup = function (input, e) {
  if (!e) {
    e = window.event;
  }
  switch (e.keyCode) {
    case 16: // shift
    case 17: // ctrl
    case 18: // alt
    case 20: // caps lock
    case 33: // page up
    case 34: // page down
    case 35: // end
    case 36: // home
    case 37: // left arrow
    case 38: // up arrow
    case 39: // right arrow
    case 40: // down arrow
      return true;

    case 9:  // tab
    case 13: // enter
    case 27: // esc
      this.hidePopup(e.keyCode);
      return true;

    default: // all other keys
      if (input.value.length > 0)
        this.populatePopup();
      else
        this.hidePopup(e.keyCode);
      return true;
  }
}

/**
 * Puts the currently highlighted suggestion into the autocomplete field
 */
Drupal.jsAC.prototype.select = function (node) {
  this.input.value = node.autocompleteValue;
}

/**
 * Highlights the next suggestion
 */
Drupal.jsAC.prototype.selectDown = function () {
  if (this.selected && this.selected.nextSibling) {
    this.highlight(this.selected.nextSibling);
  }
  else {
    var lis = $('li', this.popup);
    if (lis.size() > 0) {
      this.highlight(lis.get(0));
    }
  }
}

/**
 * Highlights the previous suggestion
 */
Drupal.jsAC.prototype.selectUp = function () {
  if (this.selected && this.selected.previousSibling) {
    this.highlight(this.selected.previousSibling);
  }
}

/**
 * Highlights a suggestion
 */
Drupal.jsAC.prototype.highlight = function (node) {
  if (this.selected) {
    $(this.selected).removeClass('selected');
  }
  $(node).addClass('selected');
  this.selected = node;
}

/**
 * Unhighlights a suggestion
 */
Drupal.jsAC.prototype.unhighlight = function (node) {
  $(node).removeClass('selected');
  this.selected = false;
}

/**
 * Hides the autocomplete suggestions
 */
Drupal.jsAC.prototype.hidePopup = function (keycode) {
  // Select item if the right key or mousebutton was pressed
  if (this.selected && ((keycode && keycode != 46 && keycode != 8 && keycode != 27) || !keycode)) {
    this.input.value = this.selected.autocompleteValue;
  }
  // Hide popup
  var popup = this.popup;
  if (popup) {
    this.popup = null;
    $(popup).fadeOut('fast', function() { $(popup).remove(); });
  }
  this.selected = false;
}

/**
 * Positions the suggestions popup and starts a search
 */
Drupal.jsAC.prototype.populatePopup = function () {
  // Show popup
  if (this.popup) {
    $(this.popup).remove();
  }
  this.selected = false;
  this.popup = document.createElement('div');
  this.popup.id = 'autocomplete';
  this.popup.owner = this;

  var iheight = 0;
	var temp = ($(this.input).next())[0];
  ($(this.input).parent()[0]).style.position = 'relative';
  //$('#edit-field-kaltura-wizard-key').css ({ visibility: 'hidden'});
  $(this.input).parent().children().each ( function() { 
  	if (this==temp)
  	 return; 
  iheight +=this.offsetHeight;
   })
  
  

  var l = getPageCoords(this.input).x;
  $(this.popup).css({
    width: (this.input.offsetWidth - 4) +'px',
    display: 'none',
    position: 'absolute',
    //marginTop: this.input.offsetHeight +'px',
    //left: this.input.offsetLeft || 0
    top: iheight+'px',
    left: 0,
    zIndex: 1000
  });
  $(this.input).before(this.popup);

  // Do search
  this.db.owner = this;
  this.db.search(this.input.value);
}

function getPageCoords (element) {
var coords = { x: 0, y: 0 };
while (element) {
coords.x += element.offsetLeft;
coords.y += element.offsetTop;
element = element.offsetParent;
}
return coords;
}
/**
 * Fills the suggestion popup with any matches received
 */
Drupal.jsAC.prototype.found = function (matches) {
  // If no value in the textfield, do not show the popup.
  if (!this.input.value.length) {
    return false;
  }

  // Prepare matches
  var ul = document.createElement('ul');
  var ac = this;
  for (key in matches) {
    var li = document.createElement('li');
    $(li)
      .html('<div>'+ matches[key] +'</div>')
      .mousedown(function () { ac.select(this); })
      .mouseover(function () { ac.highlight(this); })
      .mouseout(function () { ac.unhighlight(this); });
    li.autocompleteValue = key;
    $(ul).append(li);
  }

  // Show popup with matches, if any
  if (this.popup) {
    if (ul.childNodes.length > 0) {
      $(this.popup).empty().append(ul).show();
    }
    else {
      $(this.popup).css({visibility: 'hidden'});
      this.hidePopup();
    }
  }
}

Drupal.jsAC.prototype.setStatus = function (status) {
  switch (status) {
    case 'begin':
      $(this.input).addClass('throbbing');
      break;
    case 'cancel':
    case 'error':
    case 'found':
      $(this.input).removeClass('throbbing');
      break;
  }
}

/**
 * An AutoComplete DataBase object
 */
Drupal.ACDB = function (uri) {
  this.uri = uri;
  this.delay = 300;
  this.cache = {};
}

/**
 * Performs a cached and delayed search
 */
Drupal.ACDB.prototype.search = function (searchString) {
  var db = this;
  this.searchString = searchString;

  // See if this key has been searched for before
  if (this.cache[searchString]) {
    return this.owner.found(this.cache[searchString]);
  }

  // Initiate delayed search
  if (this.timer) {
    clearTimeout(this.timer);
  }
  this.timer = setTimeout(function() {
    db.owner.setStatus('begin');

    // Ajax GET request for autocompletion
    $.ajax({
      type: "GET",
      url: db.uri +'/'+ Drupal.encodeURIComponent(searchString),
      success: function (data) {
        // Parse back result
        var matches = Drupal.parseJson(data);
        if (typeof matches['status'] == 'undefined' || matches['status'] != 0) {
          db.cache[searchString] = matches;
          // Verify if these are still the matches the user wants to see
          if (db.searchString == searchString) {
            db.owner.found(matches);
          }
          db.owner.setStatus('found');
        }
      },
      error: function (xmlhttp) {
        alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ db.uri);
      }
    });
  }, this.delay);
}

/**
 * Cancels the current autocomplete request
 */
Drupal.ACDB.prototype.cancel = function() {
  if (this.owner) this.owner.setStatus('cancel');
  if (this.timer) clearTimeout(this.timer);
  this.searchString = '';
}

// Global Killswitch
if (Drupal.jsEnabled) {
  $(document).ready(Drupal.autocompleteAutoAttach);
}

;
/* AGGREGATED JS FILE: modules/contact/contact.js */
$().ready(function (){
	$('#footer_links a[@href="/contact"]').click(function(){contactus_form(this);return false;});
	$('.contact_us').click(function(){contactus_form(this);return false;});
});


function contactus_form(t){
	form_url = url('contact');

	var jq_add_show = create_modal('',rc.t('Contact Us'),{show:5},'',{ ajax: form_url,modal:true},{'overflow-y':'auto','width':555, 'height':450},'', function(){
		if ($(t).attr('rel')){
			$('form#contact-mail-page select[@name=cid]').val($(t).attr('rel')); 
		}
		round_contact();
	});
	return false;
}

function round_contact(){
	if ($('form#contact-mail-page').length){
	  var _options = {
			success : cuResponse
		};
  	
  	$('form#contact-mail-page #edit-submit').click(function(){
  		$('#contactErrorSpan').hide();
  		return send_contact();
  	})
  	
  	$('form#contact-mail-page').submit(function() {
  			$('#contactErrorSpan').hide();
  			$('form#contact-mail-page').loader_icon('contact_loader');
				$(this).ajaxSubmit(_options);
				return false;
		});
	}
//gTrackEvent('Contact Us',"Init",'Opened the contact us box')
	gTrackEvent('/contactus/init');	
}

function send_contact(){
	var req_msg = rc.t('Fill the required fields please');
	var _valid = Utils.reqValid('#contact-mail-page',req_msg);

	if (_valid){
  	return true;
	} else {
		return false;
	}
}

function cuResponse(data){
	$('form#contact-mail-page').stop_loader_icon();
	if (data=='success'){
//	gTrackEvent('/contactus/success');	
		gTrackEvent('/contactus/success');	
		var msg = "<div class='snp_success'>"+rc.t('Your message has been sent')+"</div>";
		$('form#contact-mail-page').remove();
		$('#contactErrorSpan')
			.removeClass('error')
			.empty()
			.append(msg)
			.show();
			
		var uuid = $('div.contact-submit').attr('summary');
		
		$('#'+uuid+' .sbutton-content').html(rc.t('Close'));
		$('#'+uuid+' .contact-submit').unbind('click');
		$('#'+uuid+' .sbutton').unbind('click');
		$('#'+uuid+'.sbutton-hover').click(function (){ create_modal_object[0].close(); });
		$('#'+uuid+'.sbutton').click(function (){ create_modal_object[0].close(); }); 
	}else{
		$('#contactErrorSpan')
			.empty()
			.append(data)
			.show();
			
	}
}
;
/* AGGREGATED JS FILE: sites/all/modules/rc/add_to_my_stuff/add_to_my_stuff.js */
function do_something(action,nid) {
	alert(action + nid);
}

$(document).ready(function() {
	$('.my_stuff').livequery(function(){
		$(this).click(addToMyStuff);
	})
});

function addToMyStuff(){
    var _nid = $(this)[0].attributes.nid.value;
    my_stuff_link(_nid);
}

function my_stuff_link(_nid) {
	var my_stuff =  create_modal(rc.t('Please wait'),rc.t('Add to my stuff'),{show:5},'',{ ajax_rc: url('ajax/my_stuff/list/json/' + _nid),modal:true},{'overflow-y':'auto','width':600,'height':480},'', my_stuff_link_show_callback);
}

function my_stuff_link_show_callback() {
	//change this variable if u want to choose multipule items to add to
	var multi = false;
	
	//$('div#modal_body').corner('10px','transparent');
	$('div#modal_body #my_stuff_content .stuff_before_content').corner(10,"tr transparent");
	$('#jq_status_bar .footer').prepend('<div class="choose">'+rc.t('Add')+'</div>');
	$('#jq_status_bar .footer .choose').sbutton({css:{width: '100px', 'float':'right' },click:add_to_my_stuff_choose, 'color': 'green'});
	
	/*
	$('#my_stuff_content .stuff_main .stuff_main_tab .stuff_link').mouseover(function(){
		$(this).addClass('chosen');
	})
	$('#my_stuff_content .stuff_main .stuff_main_tab .stuff_link').mouseout(function(){
		$(this).removeClass('chosen');
	})
	*/
	$('#my_stuff_content .stuff_main .stuff_main_tab .stuff_link').click(function(){
		if (multi) {
			$(this).find('.img_wrap').toggleClass('chosen');
		} else {
			var chosen = $(this);
			$(this).parents('.stuff_main').find('.stuff_link .img_wrap').each(function(){
				$(this).removeClass('chosen');
			})
			$(this).find('.img_wrap').addClass('chosen');
		}
	})
}

function add_to_my_stuff_choose() {
	var media_nid = $('#my_stuff_container').attr('nid');
	var items = new Array();
	$('#my_stuff_content .stuff_main .stuff_main_tab .stuff_link .img_wrap.chosen').each(function(){
		var nid = $(this).parents('.stuff_link').attr('class').match(/(?:nid_)([0-9]+)/)[1];
		items.push(nid);
	})
	
	if (items.length == 0) {
		alert(rc.t('Please choose an item'));
		return false;
	} else {
		$('#my_stuff_container #my_stuff_content').hide();
		$('#my_stuff_container .s_rounded_footer_pink').hide();
		$('#my_stuff_container #my_stuff_post_send').show();
		
		$.ajax({
			type: "POST",
			url: '/ajax/my_stuff/add/'+media_nid,
			data: {
				"add2nids[]": items
			},
			dataType: "json",
			success: function(json){
				if(!json.error) {
					$('#my_stuff_working').hide();
					$('#my_stuff_msg').show();
					$('#jq_status_bar .footer .sbutton-content').text(rc.t('Close'));
					$('#jq_status_bar .footer .sbutton').click(function(){
						create_modal_object[0].close();
					})
				} else {
					create_modal_object[0].close();
					if (obj.message) {
						var text;
						for (i in message) {
							text += message[i]+": "+error_nids[i]+"\n";
						}
						alert(text);
					}
				}
			}
		})
	}
}

function add_to_my_stuff(media,parent,callback) {
  //clog(this);
	if(callback == undefined) {
		callback = function(obj) {
			if(!obj.error) {
				alert(rc.t('The media was added to your content'));
				create_modal_object[0].close();
				//window.location.reload();
			} else {
				create_modal_object[0].close();
				if (obj.message) alert(obj.message);
				//rc_alert(obj.message);
			}
		}
	}
	$.ajax({
			  type: "GET",
			  url: url('ajax/my_stuff/add/' + media + '/' + parent),
			  dataType: "json",
			  success: callback
			});
}

function add2mystuff_display_tab(tab) {
	$('.stuff_main_tab').each(function(){
		if ($(this).id() == tab)
			$(this).show();
		else 
			$(this).hide();
	})
	$('.stuff_tab_title').each(function(){
		if ($(this).id() == tab)
			$(this).addClass('active');
		else 
			$(this).removeClass('active');
	})
}
;
/* AGGREGATED JS FILE: modules/rc/article/article.js */


$(document).ready(function() {
	var referrer = document.referrer;
	guest = false;
	
	if (referrer==undefined || referrer=="")
		guest = true;
	else {
		
		if (location.host==undefined || location.host=="")
			guest = true;
		else {
			var dotpos = location.host.indexOf('.');
			if (dotpos==-1)
				guest = true;
			else {
				var domain = location.host.substr(dotpos+1);
				var matches = referrer.match(/\w+:\/\/([a-zA-Z0-9-_.]+)\/?/);
				//var pos = referrer.indexOf(domain);'http:\/\/\w+/'
				if (matches.length < 2)
					guest = true;
				else {
					if (matches[1].indexOf(domain) == -1)
						guest = true;
					else
						guest = false;
				}
	
				if (guest==true)
					$('#nbl_buzzback').attr('href','/');
				else
					$('#nbl_buzzback').attr('href','javascript:history.go(-1)');			
			}
		}
	}
	
	if ($('.args-news-search').length)
		$('.articles_pager SPAN A').livequery('click',get_search_results);
	else
		$('.articles_pager SPAN A').livequery('click',get_articles);
		
});


function get_articles() {
	var _t = $(this), _url = _t.attr('rel');
	
	$('#news_sec_left_page .tab_content').fadeTo("slow",0.3);
	
	$.ajax({
  	type: "GET",
  	url: _url,
  	dataType: "html",
  	success: function (data) {

  		$('#news_sec_left_page .tab_content').html(data);
			
			$('#news_sec_left_page .tab_content').fadeTo("slow",1);
			
  		return false;
  	}
  });
  return false;
}



function get_search_results() {
	var _t = $(this), _url = _t.attr('rel');
	
	var search_string, search_date_from, search_date_to, search_geo;
	
	search_string = $('#hidden_string').text();
	search_date_from = $('#hidden_date_from').text();
	search_date_to = $('#hidden_date_to').text();
	search_geo = $('#hidden_geo').text();
	
	$('#news_sec_left_page .articles_group_box .tab_content').fadeTo("slow",0.3);
	
	$.ajax({
  	type: "GET",
  	url: _url,
	
	data: { search_string: search_string, 
			search_date_from: search_date_from, 
			search_date_to: search_date_to, 
			search_geo: search_geo },
			
  	dataType: "html",
  	success: function (data) {

  		$('#news_sec_left_page .articles_group_box .tab_content').html(data);
			
			$('#news_sec_left_page .articles_group_box .tab_content').fadeTo("slow",1);
			
  		return false;
  	}
  });
  return false;
}



function art_get_image(obj){
	var list = '';
	for(var i=0;i<obj.nodes.length;i++){
		list += obj.nodes[i].nid + ",";
	}
	$('#edit-attached-media')[0].value = list;
	return true;
}

;
/* AGGREGATED JS FILE: modules/rc/usr/profile_basic.js */


$().ready(function(){		
	if ($('.user-profile-moments-blogs').length > 0){		
		$('.user-profile-moments-blogs .blog_entry:even').addClass('even');
		$('.user-profile-moments-blogs .blog_entry:odd').addClass('odd');		
	}
});

function refresh_page_after_media_upload()
{
	document.location.reload(true);
}

;
/* AGGREGATED JS FILE: modules/rc/misc/js/form_validate.js */

$().ready(function (){
	var pathname = window.location.pathname;

	 
	// uncomment line below to allow checking for all admin pages
	// if ((pathname.indexOf('/admin')) != -1)
	if (pathname!='/admin/user/access')
		$('.form-validate').each( function (){ set_validate_form(this); });
});

//check full form for require fields and for special fields
function set_validate_form(obj){
	validate_req_fix(obj);
	$(obj).submit(function (ev) {
		if (!validate_form($(obj).id())) ev.preventDefault();
	});
}
function validate_req_fix(obj){
	var fields = $(obj).find('input[@type!=hidden].required');
	for (var i=0;i<fields.length;i++){
		if (typeof $(fields).eq(i).attr('validate') != 'undefined')
			$(fields).eq(i).attr('validate','required'+' '+$(fields).eq(i).attr('validate'));
		else $(fields).eq(i).attr('validate','required');
	}
}
function validate_form(obj){
	obj = $('#'+obj);
	$(obj).find('.msg').each(function (){ $(this).hide();$(this).html(''); });
	$(obj).find('input[@type!=hidden].msg-error').each(function (){ $(this).removeClass('msg-error'); });

	var errors = {};
	
	var fields = $(obj).find('select,input[@type!=hidden]');
	
	for (var i=0;i<fields.length;i++){
		var field = $(fields).eq(i);
		if (typeof $(field).attr('validate') != 'undefined'){
			var validate_funcs = $(field).attr('validate').split(' ');
			for (var j=0;j<validate_funcs.length;j++){
				var validate_func = validate_funcs[j];			
				var func_name = 'validate_'+validate_func;

				var tmp;
				if (tmp = window[func_name](form_get_field_title(field),form_get_field_value(field))){
					$(field).addClass('msg-error');
					errors[$(field).attr('name')] = tmp;
					j = 999999;
				}
			}
		}
	}
	return form_check_for_errors(obj,errors);
}
function form_check_for_errors(obj,errors){
	var i=0;
	var html='';
	for (var error in errors){
		i++;
		if ($(obj).find('.msg.'+error).length > 0)
			$(obj).find('.msg.'+error).show().html(errors[error]);
		html += '<li>'+errors[error]+'</li>';
	}
	if (i < 1) return true;

	html = '<ul id="msg-errors">'+html+'</ul>';
	validate_drow_errors(html);
	return false;
}
function form_get_field_title(obj){
	if (typeof $(obj).attr('title') != 'undefined')
		return $(obj).attr('title');
	return $(obj).attr('name');
}
function form_get_field_value(obj){
	switch($(obj).attr('type')){
		case "checkbox":
			if ($(obj)[0].checked) return 1;//return val, if require its ok
			else return ''; // return empty
			break;
		case "radio":
			var radios = $(obj).parents('.form-item').parent().find('[@type=radio]');// get the naber radios
			for(var i=0;i<radios.length;i++)
				if ($(radios).eq(i)[0].checked) return 1;//return val, if require its ok
			return '';// return empty
		break;
		default:
			return $(obj).val();
			break;
	}
}




function validate_drow_errors(html){
	var scrolly = typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement.scrollTop;
	var jq_login = create_modal(html,rc.t('There are errors in the form'),{show:5},'',{ ajax: this.href,modal:true},{'overflow-y':'auto','width':500,'height':300, 'position':'absolute','top':scrolly+15});
//	$('#modal_body').append(html);
	// BUGFIX: 0000042
	//$('<input type="button" value="'+rc.t('Close')+'" onclick="create_modal_object[0].close()"/>').appendTo('#jq_status_bar .footer').sbutton(Utils.tmpl.buttons.w50frp);
	//$('#modal_body').corner('10px','transparent');
	$('#jq_status_bar').prepend(html_button(rc.t('Close'),'close_errors_jqm','create_modal_object[0].close();','green'));
}

/************	some global validate funcs		**************/
function validate_required(title,val){
	if (val == '' || val == null || typeof val == 'undefined') {
		//special case of the terms of use (in registration form)
		if (title =='agree') { 
			return rc.t('You must accept the terms and conditions');
		}
		return rc.t("The field '%0' is required",[title]);
	}
}
function validate_mail(title,email_address){
  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  if (!reg1.test(email_address) && reg2.test(email_address));// if syntax is valid
  else return rc.t('E-mail address is not valid');
}





;
/* AGGREGATED JS FILE: modules/statistics/add_view_ajax.js */
// If you add this page you must add a div named pagenid containing the nid 
//  you want the view to be added to like <div id='pagenid' class='hidden'>[nid]</div>
 

$().ready(function (){
	if ($('a.rc_login').length){
		add_view_ajax();
	}
});

function add_view_ajax() {
	if(typeof(pagenid)=='number' && pagenid>0){
		ajax_url = url("stats/add_view_ajax/"+pagenid);
		$.post(ajax_url);			
	}
}
;
/* AGGREGATED JS FILE: modules/rc/comments/novecomments.js */



$().ready(function () {
	$('.comments_header').after($('#comments .box .content'));
	$('#comments .box').remove();
	$('#comment-form').prepend([
		'<div class="close">',
			'<img onclick="$(this).parents(\'#comment-form\').hide(500)" src="/modules/rc/comments/im/x.gif" />',
		'</div>',
		'<div class="comment_add_title">',
			rc.t('Your comment:'),
		'</div>'
	].join(''));
	$('#comment-form').append([
		'<div class="nove_btn nove_btn_green comment_submit">',
			'<div class="nove_btn_content">'+rc.t('ADD')+'</div>',
		'</div>',
		'<div class="clearfloat"></div>'
	].join(''));
	$('#comment-form').attr('orig_action',$('#comment-form').attr('action'));
	
	$('.comments_active_btn').click(function () {
		var comment_form=$('#comment-form').remove();
		comment_form.hide();		
		$(this).parent().next().append(comment_form);
		$('#comment-form').attr('action',$('#comment-form').attr('orig_action'));
		comment_form.show(500);
	});
	
	$('.comment_submit').click(function () { $(this).parent().find('#edit-submit').click(); });
	$('#comments .single_comment:odd').css('background-color','#333F3F');
	
	
	//AJAX PAGER
	$('.comment_ajax_pager a').livequery('click',function () {
		var t = $(this);
		$.ajax({
			type: "GET",
			url: url(t.attr('rel')),
			dataType: "html",
			success: function(data){
				t.parents('#comments').after(data).remove();
			}
		});
		return false;
	});
	
	
	$('a.comment_replay').click(function(event){
		event.preventDefault();
		
		var comment_form=$('#comment-form').remove();		
		$(this).parents('.comment_content_caser:eq(0)').append(comment_form);
		comment_form.attr('action',$(this).attr('href'));					
		comment_form.show();
			
			
	});	
});






















;
/* AGGREGATED JS FILE: modules/rc/misc/addthis.js */
var addthis_config = {
	services_compact: 'email, facebook, twitter, more',
	services_exclude: 'print',
	ui_language: 'es'
	};

/*	
var addthis_localize = {
    share_caption: "Share Novebox",
    email_caption: "Email",
    email: "Email",
    favorites: "Favorites", 
    more: "More" 
};
*/ 
;
/* AGGREGATED JS FILE: modules/rc/misc/js/tab.js */
$().ready(function (){
	$('.tabs_content_caser .tabs_caser .tab').click(function () {
		var t = $(this);
		
		t.parents('.tabs_content_caser').find('a.title').removeClass('default');
		t.parents('.tabs_content_caser').find('a.title[@tag='+t.attr('tag')+']').addClass('default');
		
		t.parent().children().removeClass('default');
		t.addClass('default');
		$('.content[@tag='+t.attr('tag')+']').parent().children().removeClass('default');
		$('.content[@tag='+t.attr('tag')+']').addClass('default');
		
		if ($('.footer_inner[@tag='+t.attr('tag')+']').length) {
			$('.footer_inner[@tag='+t.attr('tag')+']').parent().children().removeClass('default');
			$('.footer_inner[@tag='+t.attr('tag')+']').addClass('default');		
		}
	})
	
	var tab_click=function(){$(this).click(function(){
		var t = $(this), tag = t.attr('tag'), container = t.parents('.tabs_container').eq(0);		
		if (t.is('.default') || $('a',t).length>0)
		{ 
			$(t).trigger("tab_enter");
			return;
		}
		// switch classes on titles
		var old_tab=t.parents('.tab_titles_wrapper').eq(0).children('.default').removeClass('default');
		t.addClass('default');
		
		// switch classes on content
	//	clog(this,container.find('.tab_content_wrapper').eq(0).find('.default').eq(0));
		container.find('.tab_content_wrapper').eq(0).children('.default').removeClass('default');
		container.find('.tab_content_wrapper').eq(0).children('[@tag=' + tag + ']').addClass('default');
		
		// switch classes on footers
		container.find('.tab_footers_wrapper').eq(0).children('.default').removeClass('default');
		container.find('.tab_footers_wrapper').eq(0).children('[@tag=' + tag + ']').addClass('default');
		
		if(old_tab)
			$(old_tab).trigger("tab_exit");
		$(t).trigger("tab_enter");
		
	})
	};
		
	$('.tabs_container .tab_titles_wrapper .tab_title_singletab').livequery(tab_click);
	$('.tabs_container .tab_titles_wrapper .tab_title').livequery(tab_click);
	
})

function get_active_tab_handle(container_id)
{
	return $('#'+container_id+' .tab_titles_wrapper:eq(0) .default').eq(0);
}

;
/* AGGREGATED JS FILE: modules/rc/news/admin_manage_tabs.js */
$().ready(function () {
	// Added or condition to allow managing tabs in article black design(enovela) since we removed nbl_blog on that page
	if ( ($('.nbl_blog.s_block').length || $('.enovela_article').length ) && $('.tabs ul.tabs.primary').length) { 
		$('div.tabs').hide();
		$('div.tabs').after($('<div class="tabs_handler">'+rc.t('Show Menu')+'</div>'));
		$('.tabs_handler').click(function(){
		$('div.tabs').toggle();
		}); 
		/*$('.tabs ul.tabs.primary').hide();
		$('.tabs ul.tabs.primary').after('<span> | <a onclick="$(\'.tabs ul.tabs.primary\').show(); $(this).parent().remove();">'+rc.t('Manage')+'</a></span>');
		$('.nbl_blog.s_block').append('<span> | <a onclick="$(\'.tabs ul.tabs.primary\').show(); $(this).parent().remove();">'+rc.t('Manage')+'</a></span>');*/
	} 
});



;
/* AGGREGATED JS FILE: sites/all/modules/internet/jquery_update/collapse-fix.js */
// $Id: collapse-fix.js 502 2007-07-18 14:21:30Z barakb $
// redefining toggleFieldset for compatibility with later versions of JQuery
Drupal.toggleFieldset = function(fieldset) {
  if ($(fieldset).is('.collapsed')) {
    var content = $('> div', fieldset).hide();
    $(fieldset).removeClass('collapsed');
    content.slideDown( {
    duration: 300, // THE FIX
      complete: function() {
        // Make sure we open to height auto
        $(this).css('height', 'auto');
        Drupal.collapseScrollIntoView(this.parentNode);
        this.parentNode.animating = false;
      },
      step: function() {
         // Scroll the fieldset into view
        Drupal.collapseScrollIntoView(this.parentNode);
      }
    });
    if (typeof Drupal.textareaAttach != 'undefined') {
      // Initialize resizable textareas that are now revealed
      Drupal.textareaAttach(null, fieldset);
    }
  }
  else {
    var content = $('> div', fieldset).slideUp('medium', function() {
      $(this.parentNode).addClass('collapsed');
      this.parentNode.animating = false;
    });
  }
}
