$jQuery = jQuery.noConflict();
$jQuery(document).ready(function(){
	$jQuery.superbox();

	$jQuery("#catLinksThumbs").hide();
	$jQuery("#catLinksThumbs").load("load_cat_thumbs.php", function(){
		$jQuery(".wordingPink").hide();
		$jQuery(".wording").hide();
		$jQuery("#catLinksThumbs").fadeIn(2000, function(){
			$jQuery(".wordingPink").show();
			$jQuery(".wording").show();
		});
		$jQuery('a#thumbBox1').cycle({ 
			fx:      'fade', 
			speed:    2000, 
			timeout:  2000 
		});
		$jQuery('a#thumbBox2').cycle({ 
			fx:      'fade', 
			speed:    2000, 
			timeout:  3500 
		});
		$jQuery('a#thumbBox3').cycle({ 
			fx:      'fade', 
			speed:    2000, 
			timeout:  4500 
		});
		$jQuery('a#thumbBox4').cycle({ 
			fx:      'fade', 
			speed:    2000, 
			timeout:  5500 
		});
		$jQuery('a#thumbBox5').cycle({ 
			fx:      'fade', 
			speed:    2000, 
			timeout:  6500 
		});
		$jQuery('a#thumbBox6').cycle({ 
			fx:      'fade', 
			speed:    2000, 
			timeout:  7500 
		});
		$jQuery('a#thumbBox7').cycle({ 
			fx:      'fade', 
			speed:    2000, 
			timeout:  8500 
		});
		$jQuery('a#thumbBox8').cycle({ 
			fx:      'fade', 
			speed:    2000, 
			timeout:  9500 
		});		
		$jQuery('a#thumbBox20').cycle({ 
			fx:      'fade', 
			speed:    2000, 
			timeout:  2000 
		});
		
		$jQuery('div.thumbBox').hover(function(){ 
			$id = $jQuery(this).attr("id");
			$jQuery("a#thumbBox" + $id).cycle('pause');
			$jQuery("a#thumbBox" + $id).fadeTo("fast", 0.2);
		},
		function(){
			$id = $jQuery(this).attr("id");
			$jQuery("a#thumbBox" + $id).cycle('resume');
			$jQuery("a#thumbBox" + $id).fadeTo("fast", 1);
		});
		$jQuery('.thumbBox').hide();
		$jQuery('.thumbBox').fadeIn(2000);
	});

	$jQuery('.keepInTouch').addClass("greyFormVal");
	$jQuery('.keepInTouch').val("enter email address");
	$jQuery('.keepInTouch').focus(function(){
		// is the value  "enter email address"
		$val = $jQuery(this).val();
		if ($val == "enter email address"){
			$jQuery(this).val("");
			$jQuery(this).removeClass("greyFormVal");
		}
	});

	/*@cc_on
	   @if (@_win32){
		   $jQuery('li.dropdown').hover(function(){ 
				$jQuery("ul.submenu").show();
				$jQuery("div#moviePane").css("position", "relative");
				$jQuery("div#moviePane").css("z-index", "-1");
				
				$jQuery("div#largePane").css("position", "relative");
				$jQuery("div#largePane").css("z-index", "-1");
				$jQuery("div.subcats").css("position", "relative");
				$jQuery("div.subcats").css("z-index", "-1");
			},
			function(){
				$jQuery("ul.submenu").hide();
				$jQuery("div#moviePane").css("position", "relative");
				$jQuery("div#moviePane").css("z-index", "+1");
				
				$jQuery("div#largePane").css("z-index", "+1");
				$jQuery("div.subcats").css("z-index", "+2");
			});
			
			
	   }
	   @else{
			 $jQuery('li.dropdown').hover(function(){ 
				$jQuery("ul.submenu").show();
				$jQuery("div#moviePane").css("position", "relative");
				$jQuery("div#moviePane").css("z-index", "-1");
			},
			function(){
				$jQuery("ul.submenu").hide();
				$jQuery("div#moviePane").css("position", "relative");
				$jQuery("div#moviePane").css("z-index", "+1");
			});
	   @end
	@*/
	$jQuery('.thumbBox').hide();
	$jQuery('.wording').hide();
	$jQuery('.thumbBox').fadeIn(2000, function(){
		$jQuery('.wording').show();   
	});
	
	$jQuery('div.thumbBox').hover(function(){ 
		$id = $jQuery(this).attr("id");
		//$jQuery("div#vidThumbLinks a#thumbBox" + $id).fadeTo("fast", 0.2);
	},
	function(){
		//$jQuery("div#vidThumbLinks a#thumbBox" + $id).fadeTo("fast", 1);
	});
	
	$jQuery('#vidPLayer').hide();
	$jQuery('#vidPLayer').fadeIn(3000);
	$jQuery("div#vidThumbLinks").fadeIn("slow");
	
	$jQuery('#newsletterButton').click(function(){
	$email = $jQuery("input.keepInTouch").val();
	  $jQuery.ajax({
		   type: "POST",
		   url: "newsletter_signup_ajax.php",
		   data: "email="+$email,
		   success: function(msg){
			 //alert("Category deleted.");
			 //$jQuery("span#cat-"+$id).fadeOut("slow");
			if (msg == "email not valid"){
				alert("Sorry.  The email address you entered is not valid.  Please try again.");
			}
			else{
				alert("Thank you for your interest in Azur TV, you will receive confirmation e mail shortly.");
			}
		   },
		   error: function(){
			  alert("An error has been encountered. We have been unable to sign you up.  Please try again later");   
		   }
		 });
		return false;
	});
	
	
	/*////////////////////////////////////////////////////////////////////////////
		ADMIN STUFF
	/////////////////////////////////////////////////////////////////////////////*/
	$jQuery('a.deleteCat').click(function(){
		$id = $jQuery(this).attr("id");
		var conf = confirm("Are you sure you want to delete this category? ");
		if (conf){
			// make an ajax call to delete the category
			 $jQuery.ajax({
			   type: "POST",
			   url: "../admin/includes/delete_cat.php",
			   data: "id="+$id,
			   success: function(msg){
				 //alert("Category deleted.");
				 $jQuery("span#cat-"+$id).fadeOut("slow");
			   },
			   error: function(){
				  alert("An error has been encountered.  Unable to delete category");   
			   }
			 });
		}
	});
	
	/*$jQuery('input#changeVideo').click(function(){
		$vid = $jQuery("input.video").val();
		$path = $jQuery("input.path").val();
		$action = $jQuery("input.action").val();
		//alert("PATH: " + $path);
		$jQuery.ajax({
		   type: "POST",
		   url: $action,
		   data: "vid="+$vid+"&path="+$path,
		   success: function(html){
			
			 alert("Video Uploaded Successfully" + html);
			 $jQuery("#vidNameTitle").hide();
			 $jQuery("#vidNameTitle").html("CURRENT VIDEO:");
			 $jQuery("#vidNameTitle").fadeIn("slow");
			 
			 $jQuery("#vidName").hide();
			 $jQuery("#vidName").html($vid);
			 $jQuery("#vidName").fadeIn("slow");
		   },
		   error: function(){
			  alert("An error has been encountered.");   
		   }
		 });
		return false;
	});*/
	/*$action = $jQuery("input.action").val();
	$vid = $jQuery("input.video").attr("id");
	$id = $jQuery("input.vid_id").val();
	$path = $jQuery("input.path").val();
	
	new AjaxUpload('#upload_video', {
	  // Location of the server-side upload script
	  action: $action,
	  // File upload name
	  name: 'vid',
	  // Additional data to send
	  data: {
		path : $path
	  },
	  // Submit file after selection
	  autoSubmit: true,
	  // The type of data that you're expecting back from the server.
	  // Html (text) and xml are detected automatically.
	  // Only useful when you are using json data as a response.
	  // Set to "json" in that case.
	  responseType: false,
	  // Fired after the file is selected
	  // Useful when autoSubmit is disabled
	  // You can return false to cancel upload
	  // @param file basename of uploaded file
	  // @param extension of that file
	  onChange: function(file, extension){},
	  // Fired before the file is uploaded
	  // You can return false to cancel upload
	  // @param file basename of uploaded file
	  // @param extension of that file
	  onSubmit: function(file, extension) { 
	  	$jQuery('#upload_video').html("Uploading....");
	  },
	  // Fired when file upload is completed
	  // WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
	  // @param file basename of uploaded file
	  // @param response server response
	  onComplete: function(file, response) { 
		$jQuery('#currentVid').html(response);
		if($vid == ""){
			$jQuery('input.video').val(response);
		}else{
			$jQuery('input#' + $vid).val(response);
		}
		$jQuery('#upload_video').html("Upload complete!");
		alert("Video successfully uploaded.  Don't forget to save your changes.");
		// updatr the video table
	  }
	});
	
	$vid = $jQuery("input.video").attr("id");
	$id = $jQuery("input.vid_id").val();
	$promoPath = $jQuery("input.promoPath").val();
	
	new AjaxUpload('#uploadPromoVid', {
	  // Location of the server-side upload script
	  action: $action,
	  // File upload name
	  name: 'vid',
	  // Additional data to send
	  data: {
		path : $promoPath
	  },
	  // Submit file after selection
	  autoSubmit: true,
	  // The type of data that you're expecting back from the server.
	  // Html (text) and xml are detected automatically.
	  // Only useful when you are using json data as a response.
	  // Set to "json" in that case.
	  responseType: false,
	  // Fired after the file is selected
	  // Useful when autoSubmit is disabled
	  // You can return false to cancel upload
	  // @param file basename of uploaded file
	  // @param extension of that file
	  onChange: function(file, extension){},
	  // Fired before the file is uploaded
	  // You can return false to cancel upload
	  // @param file basename of uploaded file
	  // @param extension of that file
	  onSubmit: function(file, extension) { 
	  	//alert("SUBMIT");
		$jQuery('#uploadPromoVid').html("Uploading....");
	  },
	  // Fired when file upload is completed
	  // WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
	  // @param file basename of uploaded file
	  // @param response server response
	  onComplete: function(file, response) { 
		$jQuery('#promoVidUpload').html(response);
		$jQuery('input#promoVideo').val(response);
		
		$jQuery('#uploadPromoVid').html("Upload complete!");
		alert("Video successfully uploaded.  Don't forget to save your changes.");
		// updatr the video table
	  }
	});*/
	
	$jQuery("input.save_banners").click(function(){
		//var vidids = $jQuery('input.uploadids').val();
		alert(vidids);										 
	});
	
	/*new AjaxUpload("#upload_video_"+ vid_id + "", {
	  // Location of the server-side upload script
	  action: $action,
	  // File upload name
	  name: 'vid',
	  // Additional data to send
	  data: {
		path : $path
	  },
	  // Submit file after selection
	  autoSubmit: true,
	  // The type of data that you're expecting back from the server.
	  // Html (text) and xml are detected automatically.
	  // Only useful when you are using json data as a response.
	  // Set to "json" in that case.
	  responseType: false,
	  // Fired after the file is selected
	  // Useful when autoSubmit is disabled
	  // You can return false to cancel upload
	  // @param file basename of uploaded file
	  // @param extension of that file
	  onChange: function(file, extension){},
	  // Fired before the file is uploaded
	  // You can return false to cancel upload
	  // @param file basename of uploaded file
	  // @param extension of that file
	  onSubmit: function(file, extension) { 
	  	$jQuery('#upload_video').html("Uploading....");
	  },
	  // Fired when file upload is completed
	  // WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
	  // @param file basename of uploaded file
	  // @param response server response
	  onComplete: function(file, response) { 
		$jQuery('#currentVid').html(response);
		if($vid == ""){
			$jQuery('input.video').val(response);
		}else{
			$jQuery('input#' + $vid).val(response);
		}
		$jQuery('#upload_video').html("Upload complete!");
		alert("Video successfully uploaded.  Don't forget to save your changes.");
		// updatr the video table
	  }
	});*/

	
	$jQuery('a.deleteVideoLink').click(function(){
		// get the id of the video
		$id = (this).attr("id");
		// run an ajax call to delete the movie
		$jQuery.ajax({
		   type: "POST",
		   url: 'admin/includes/delete_video.php',
		   data: "id="+$id,
		   success: function(html){
			   $jQuery("#videoRow-" + $id).fadeOut("slow");
		   },
		   error: function(){
			   alert("An error has been encountered, please try again later.");
		   }
		});
		return false;
	});
	/*////////////////////////////////////////////////////////////////////////////
		END ADMIN STUFF
	/////////////////////////////////////////////////////////////////////////////*/
	
	$jQuery('span#player').hover(function(){ 
		$jQuery('#playerSkin').fadeIn("slow");
	},
	function(){
		jQuery('#playerSkin').fadeOut("slow");
	});
	
});
