jQuery.fn.jqUploader = function(options) {
    return this.each(function(index) {
        var $this = jQuery(this);
				// fetch label value if any, otherwise set a default one
				var $thisForm =  $this.parents("form");
				var $thisInput = $("input[type='file']",$this);
				var $thisLabel = $("label",$this);
				var containerId = $this.attr("id") || 'jqUploader-'+index;
				var startMessage = ($thisLabel.text() =='') ? 'Please select a file:' : $thisLabel.text();
				// get form action attribute value as upload script, appending to it a variable telling the script that this is an upload only functionality
				var actionURL = $thisForm.attr("action");
				// adds a var setting jqUploader to 1, so you can use it for serverside processing
				var prepender = (actionURL.lastIndexOf("?") != -1) ? "&": "?";
				actionURL = actionURL+prepender+'jqUploader=1';
				// check if max file size is set in html form
				var maxFileSize = $("input[name='MAX_FILE_SIZE']", $(this.form)).val();
				var opts = jQuery.extend({
            width:            320,
            height:           85,
            version:          8, // version 8+ of flash player required to run jqUploader
            background:       'FFFFFF', // background color of flash file
            src:              'jqUploader.swf',
						uploadScript:     actionURL,
						afterScript:      '', // if this is empty, jqUploader will replace the upload swf by a hidden input element
						varName:	        $thisInput.attr("name"),  //this holds the variable name of the file input field in your html form
						allowedExt:	      '*.jpg; *.jpeg; *.mp4; *.png', // allowed extensions
						allowedExtDescr:  'Images (*.jpg; *.mp4; *.jpeg; *.png)',
						params:           {},
            flashvars:        {},
            hideSubmit:       true,
						barColor:		      '0000CC',
                        width:              '600',
						maxFileSize:      maxFileSize,
						startMessage:     startMessage,
						errorSizeMessage: 'File is too big!',
						validFileMessage: 'now click Upload to proceed',
						progressMessage: 'Please wait, uploading ',
						endMessage:    'You\'re all done'
						}, options || {}
				);
				// disable form submit button
				if (opts.hideSubmit==true) {
					$("*[type='submit']",this.form).hide();
				}
				
				// THIS WILL BE EXECUTED IN THE USECASE THAT THERE IS NO REDIRECTION TO BE DONE AFTER UPLOAD
				TerminateJQUploader = function(containerId,filename,varname, hideSubmit, endMessage){
					$this= $('#'+containerId).empty();
					//$this.text('').append('<span style="color:#00CC00">Upload of <strong>'+filename+'</strong> finished!</span><input name="'+varname+'" type="hidden" id="'+varname+'" value="'+filename+'"/>');
					$this.text('').append('<span style="color:#00CC00"><div style="margin-left:200px"><img src="http://www.onelight.tv/styles/onelight/layout/inc/images/videoupload.png" height="100" /><div></span><input name="'+varname+'" type="hidden" id="'+varname+'" value="'+filename+'"/>');
                    var myForm = $this.parents("form");
					myForm.submit(function(){return true});
					$("*[type='submit']",myForm).show();
                    

				}
		
				//TODO : ADD PARAMS THE JQUERY_FLASH PLUGIN WAY
				
				var myParams = '';
				for (var p in opts.params){
						myParams += p+'='+opts.params[p]+',';
				}
				myParams = myParams.substring(0, myParams.length-1);
				// this functions interfaces with the jquery flash plugin 
				function jqUploader_replace(htmlOptions) {
							 var $el = $('<div id="'+containerId+'" class="flash-replaced"><div class="alt">'+this.innerHTML+'</div></div>');
							 $el.prepend($.fn.flash.transform(htmlOptions));
							 $('div.alt',$el).hide();
							 jQuery(this).after($el).remove();
				};
				//$this.after($el).remove();
				jQuery(this).flash({
											src: opts.src,
											width: opts.width,
											height: opts.height,
											id:'movie_player-'+index,
											bgcolor:'#'+opts.background,
											flashvars: {
												containerId: containerId, 
												uploadScript: opts.uploadScript,
												afterScript: opts.afterScript,
												allowedExt: opts.allowedExt,
												allowedExtDescr: opts.allowedExtDescr,
												varName :  opts.varName,
												barColor : opts.barColor,
												maxFileSize :opts.maxFileSize,
												startMessage : opts.startMessage,
												errorSizeMessage : opts.errorSizeMessage,
												validFileMessage : opts.validFileMessage,
												progressMessage : opts.progressMessage,
												endMessage: opts.endMessage
											},
											params: myParams
										},
										{
											version: opts.version,
											update: false
										},
										jqUploader_replace
					);
		});
};

$(document).ready(function(){
	$(".jqUploader").jqUploader({
				background:						"ffffff",
				width:                             '390',
				height:								'100',
				barColor:							"A0A0A0",
				allowedExt:     			"*.avi; *.jpg; *.flv; *.jpeg; *.mov; *.avi; *.264; *.wmv; *.vid; *.mp4; *.png",
				allowedExtDescr: 			"what you want",
				params: 							{quality:'low'},
				validFileMessage: 		'',
				progressMessage:        'Uploading',
				endMessage: 					'Erorr, file name contains special characters!',
				hideSubmit: 					true,
				uploadScript: 'http://www.onelight.tv/jqupload_handle.php',
				endHtml:       '<strong style="text-decoration:underline">Upload finished!</sstrong>'
		});		
	
});

$(document).ready(function(){
		
		$("#uploadtype").val('js');
		jQuery('.mycarousel').jcarousel({visible : 4, scroll: 4});
	
});

function sTT() {
		$('html, body').animate({scrollTop:0}, 0); 
};

var baseurl = 'http://www.onelight.tv';
var imageurl = 'http://www.onelight.tv';

 $(document).ready(function(){

		$(".jcarousel-skin-tango a").hover(function() {
			$(this).next("em").animate({opacity: "show", bottom: "-100", left: "0"}, "slow");
		}, function() {
			$(this).next("em").animate({opacity: "hide", bottom: "-100", left: "0"}, "fast");
		});
				
		
		var currwidth;
		window.onresize = function(){
		if(currwidth != document.documentElement.clientWidth)
		{
			windowSize(currwidth)	
		}
		currwidth = document.documentElement.clientWidth;
}
		windowSize();
	$(".loginJump").click(function() {
		$("#headerLogin").css("display","block");
	});	
	$(".closeBox").click(function() {
		$("#headerLogin").css("display","none");
	});	
	 $(".openExtra").click(function() {
        $("#extraMenu").slideDown(520);
		$(".openExtra").css('display', 'none');
		$(".closeExtra").css('display', 'inline');
		$(".menuTopRight").animate({top: "80px"}, 500);
      });
      $(".closeExtra").click(function () {
        $("#extraMenu").slideUp(520);
		$(".openExtra").css('display', 'inline');
		$(".closeExtra").css('display', 'none');
		$(".menuTopRight").animate({top: "0"}, 500);
      });
    
	$("#centerClose").click(function() {
		$("#center").slideUp("slow");
		$("#centerClose").css('display', 'none');
		$("#centerOpen").css('display', 'block');
	});	
	$("#centerOpen").click(function() {
		$("#center").slideDown("slow");
		$("#centerClose").css('display', 'block');
		$("#centerOpen").css('display', 'none');
	});
	$(".toBigPlayer").click(function() {
		$("#hugeplayer").animate({ 
        width: "720px",
		height: "700px",
        margin: "0 auto",
		display: "block"
      }, 1500 );
		$("#center").css('display', 'none');
	});
	$(".goToBigPlayer").click(function() {
		$(".playerTD").css("width","810px");
		$(".playerTD").css("height","480px");
		$("#videoplayer").css("height","480px");
		$("#videoplayer").css("width","810px");
		$(".informationFrame").css("height","480px");
		$(".goToBigPlayer").css("display","none");
		$(".goToSmallPlayer").css("display","block");
	});	
	$(".goToSmallPlayer").click(function() {
		$(".playerTD").css("width","520px");
		$(".playerTD").css("height","320px");
		$(".iTable").css("height","320px");
		$("#videoplayer").css("height","320px");
		$("#videoplayer").css("width","520px");
		$(".informationFrame").css("height","280px");
		$(".goToSmallPlayer").css("display","none");
		$(".goToBigPlayer").css("display","block");
	});	
	});
   function closeBox(toClose) {
    document.getElementById(toClose).style.display = "none";
	};

jQuery(document).ready(function() {

     
  
         
         
     
         
         
     

     var width = 0;
     var visible_ = 0;
     
     width = document.documentElement.offsetWidth;
     visible_ = Math.round((width-80)/265);
            
            
    jQuery('.first-and-second-carousel').jcarousel({visible: visible_, scroll: visible_});
    
    $('.jcarousel-clip').css({'width':width-80});
    $('.jcarousel-skin-tango').css({'width':width});
	
    
	$(window).bind("resize", function(){
    		
            width = document.documentElement.offsetWidth;
            visible_ = Math.round((width-80)/265);
            
            $('.jcarousel-clip').css({'width':width-80});
            $('.jcarousel-skin-tango').css({'width':width});
            
            jQuery('.first-and-second-carousel').jcarousel({visible: visible_ , scroll: visible_});
		});
});

$(document).ready(function(){
	$(".saveButton").click(function () { 					   
		$(".saveButton").hide();
		$(".gotoVideos").css({'display' : 'block', 'width' : '160px'});

	});
});

 $(".uploadSideBar").idTabs(function(id,list,set){ 
                    $("a",set).removeClass("selected") 
                    .filter("[href='"+id+"']",set).addClass("selected"); 
                    for(i in list) 
                      $(list[i]).hide(); 
                    $(id).fadeIn(); 
                    return false; 
                  }); 
		