var $j = jQuery.noConflict();
$j(document).ready(function() {

$j('.view_film_list').live('click', function() {
var ID=$j(this).attr('id');
ID=ID.substring(15, ID.length);

if($j('#view_film_list_con_'+ID).css('display')=='none'){
$j('#view_film_list_con_'+ID).fadeIn();
}
else
{
$j('#view_film_list_con_'+ID).fadeOut();
}


});


$j('.v_f_by_venue').live('click', function() {

$j('.ven_films_list_con').fadeOut();
var ID=$j(this).attr('id');
var myID=$j(this).attr('id');

ID=ID.substring(13, ID.length);
$j.post(
    // see tip #1 for how we declare global javascript variables
    MyAjax.ajaxurl,
    {
        // here we declare the parameters to send along with the request
        // this means the following action hooks will be fired:
        // wp_ajax_nopriv_myajax-submit and wp_ajax_myajax-submit
        action : 'list_films_in_ven',
        ID:ID,
        // other parameters can be added along with "action"
        postID : MyAjax.postID
    },
    function( response ) {

      $j('#v_f_by_venue_con_'+ID).append(response); 
     
          
   });
$j('#v_f_by_venue_con_'+ID).fadeIn();




});

$j('.v_f_by_director').live('click', function() {

var ID=$j(this).attr('id');
var myID=$j(this).attr('id');

ID=ID.substring(13, ID.length);

$j.post(
    // see tip #1 for how we declare global javascript variables
    MyAjax.ajaxurl,
    {
        // here we declare the parameters to send along with the request
        // this means the following action hooks will be fired:
        // wp_ajax_nopriv_myajax-submit and wp_ajax_myajax-submit
        action : 'list_films_by_dir',
        ID:ID,
        // other parameters can be added along with "action"
        postID : MyAjax.postID
    },
    function( response ) {
    
      //$j('#v_f_by_venue_con_'+ID).html(response);     
    $j('#primary').append(response);
    
    }
);




});








$j('.gloss_programme_videos_link').live('click', function() {

var ID=$j(this).attr('id');
var baseurl=$j('#gloss_blog_url').val();

ID=ID.substring(27, ID.length);
var vid_elm='gloss_programme_video_con_'+ID;
var vid_url=$j('#gloss_programme_hidden_video_url_'+ID).val();
var image_url=$j('#gloss_programme_hidden_image_url_'+ID).val();
if(vid_url!='none'){

$j('#'+vid_elm).html('<a class="gloss_close_vid">X</a><div class="gloss_vid_con"><div id="gloss_flash_container_'+ID+'">Loading the player ...</div></div>'
+'<script type="text/javascript"> jwplayer("gloss_flash_container_'+ID+'").setup({'
+'flashplayer: "'+baseurl+'flash_player/player.swf", file: "'+vid_url+'", height: 395, width: 700,'
+"'controlbar': 'bottom'"
+'});'
+'</script>');
}

$j('#'+vid_elm).fadeIn('slow');
 

});

$j('.gloss_cust_nav').live('click', function() {
var ID=$j(this).attr('id');
var myID=$j(this).attr('id');
$j('#gloss_cust_nav_1').css({'color':'#555'});
    $j('#gloss_cust_nav_2').css({'color':'#555'});
    $j('#gloss_cust_nav_3').css({'color':'#555'});
    $j('#'+myID).css({'color':'red'});
ID=ID.substring(15, ID.length);
$j('#primary').fadeOut('fast');
$j.post(
    // see tip #1 for how we declare global javascript variables
    MyAjax.ajaxurl,
    {
        // here we declare the parameters to send along with the request
        // this means the following action hooks will be fired:
        // wp_ajax_nopriv_myajax-submit and wp_ajax_myajax-submit
        action : 'change_films_list',
        ID:ID,
        // other parameters can be added along with "action"
        postID : MyAjax.postID
    },
    function( response ) {
    $j('#primary').html('');
    
    
    
    $j('#primary').html(response);
    $j('#primary').fadeIn('fast');              
    }
);


});


$j('.gloss_close_vid').live('click', function() {
$j(this).parent().html('');

});
$j('#s').focus(function (){

$j(this).attr('value','');
});

$j('#s').blur(function (){

$j(this).attr('value','Search..');
});

$j('#gloss_event_slider_navigation_right').click(function(){


$j('.gloss_nav_slide_con').each(function(index) {

if($j(this).css('display')=='block'){
var ID=$j(this).attr('id');
ID=ID.substring(20, ID.length);

if(ID<$j('.gloss_nav_slide_con').length){
ID=parseInt(ID);
$j('#gloss_nav_slide_con_'+ID).fadeOut(function() {
    
  $j('#gloss_nav_slide_con_'+(ID+1)).fadeIn();
});
}
}

});


});


$j('#gloss_event_slider_navigation_left').click(function(){



$j('.gloss_nav_slide_con').each(function(index) {

if($j(this).css('display')=='block'){
var ID=$j(this).attr('id');
ID=ID.substring(20, ID.length);
if(ID>1){
ID=parseInt(ID);
$j('#gloss_nav_slide_con_'+ID).fadeOut(function() {
    
  $j('#gloss_nav_slide_con_'+(ID-1)).fadeIn();
});
}
}

});


});



function dothisshit(){


var current_post=new Array();

current_post[0]=$j('#fpw_current_post_0').val();
current_post[1]=$j('#fpw_current_post_1').val();
current_post[2]=$j('#fpw_current_post_2').val();


$j.each(current_post, function(i, l) {


$j.post(
    // see tip #1 for how we declare global javascript variables
    MyAjax.ajaxurl,
    {
        // here we declare the parameters to send along with the request
        // this means the following action hooks will be fired:
        // wp_ajax_nopriv_myajax-submit and wp_ajax_myajax-submit
        action : 'change_fp_w',
        current_post:current_post[i],
        widget_num:i,
        // other parameters can be added along with "action"
        postID : MyAjax.postID
    },
    function( response ) {
   
       
      $j('#gloss_fp_wrapper_inner_'+[i]).fadeOut(function () {
      	var old_url=$j('#fpw_cat_link_'+[i]).val();
      	$j('#gloss_fp_wrapper_inner_'+[i]).html(response);
      	var new_cat_link=$j('#fpw_cat_link_'+[i]).val();
  
      	
      	$j('.sub_nav_item_'+[i]).each(function(index) {
      	
      	if($j(this).attr('href')==new_cat_link){
      	$j(this).addClass('gloss_sub_nav_selected');
      	}
      	else{
      	$j(this).removeClass('gloss_sub_nav_selected');
      	}
      	});
      	
       $j('#gloss_fp_wrapper_inner_'+[i]).fadeIn();
    });	
        
    }
);
});//end of foreach


}





/*$j(window).load(function() { 
 
    var InfiniteRotator =
    {
        init: function()
        {
            
            var initialFadeIn = 1000;
 
            
            var itemInterval = 10000;
 
            
            var fadeTime = 2500;
 			
 			
           
           	
           var currentItems=[];
           
			
          
            var infiniteLoop = setInterval(function(){
            	
            	dothisshit();
            	
 
			    
               
 
            }, itemInterval);
        }
    };
 
    InfiniteRotator.init();
 
});*/
});//end of document.ready
