var scrollLeft = 0;
var lastitem = 6;
var hozmove  = 0;
var videoid = 0;

function mediaslide(){
	var media = $( "#media1" );	
	var lHeight = $(window).height();
	
	$( "#media1" ).height(lHeight);
	
	if (media.css('display') == 'none'){
		
		$(document).ready(function() {			
			$(".indexflash").fadeOut('fast');
			$(".footerblock").fadeOut('fast');
			$("#footermedia").fadeIn('fast');
			$("footermedia_player").html('');
			$('#media1').stop().show("slide", { direction: 'down' }, 1200 )
		});
	}
	else{
		$(document).ready(function() {
			$(".indexflash").fadeIn('fast');
			$(".footerblock").fadeIn(3000);
			$("#footermedia").fadeOut('fast');
			$("footermedia_player").html('');
			
			$('#media1').stop().hide("slide", { direction: 'down' }, 1200 )
		});
	}
}
function mediaslideLink(linkUrl){
	var media = $( "#media1" );	
	var lHeight = $(window).height();
	
	$( "#media1" ).height(lHeight);
	
	$(document).ready(function() {
			$(".indexflash").fadeIn('fast');
			$(".footerblock").fadeIn(3000);
			$("#footermedia").fadeOut('fast');
			$("footermedia_player").html('');
			
			$('#media1').stop().hide("slide", { direction: 'down' }, 1200 )
	});
	window.location.href="/"+linkUrl+".html";
}


function defaultmedia(cat2,cat3,img1){
	scrollLeft = 0;
	
	$('#loading1').css( {display: 'block'});
	
	$(document).ready(function() {
   		$.ajax(
		 {
			 type: "post",
			 url: "/cfc/remote.cfc",
			 cache:false,
			 data: {
			 method: "fncFooterMedia",returnFormat: 'json',  cat2:cat2, cat3:cat3, img1:img1
			 
		 },
		
		 dataType: "json",
		
		 
		
		 success: function( r ){ 

			setTimeout(function(){ 	
			
			$('#loading1').css( {display: 'none'});
			
			$('#footermedia').html( r.MEDIAFOOTER);
			},2000)
		 
		 		
		 	
		 },
		 
			 error: function( r, strError ){
			 	//alert(strError)
			 }
		});	 
	});
}


          
function scrollme(direction){

        
          recordcount = $('#txtVideoCount').val();
          numberperpage = 5;
     
          numberOfPages = Math.floor(recordcount/numberperpage);
          remained = recordcount%numberperpage;
        
         //alert(numberOfPages)
          
          if ((numberOfPages-1) < 0)
          {
          numberOfPages = 1;
          }
          
          rightPoint = -(((numberOfPages-1) * numberperpage * 193) + (remained * 193));
    	      
         
          if (recordcount > 5){
	          if(direction == "left"){
				
	            if(scrollLeft <= rightPoint){	 
				
					return;
				}
		
				scrollLeft = scrollLeft - 193;
				$('#scrollme').animate({"margin-left": "-=193px"}, 500, function() {});
	          }
	          
	          else{
	            
	                   if(scrollLeft >= 0){
	                     //$('.smallover').css({ display:'none'});
	                      return;
	                   }
	                   
	                   scrollLeft = scrollLeft + 193;
	                   
	                   // Left Button
	                   $('#scrollme').animate({marginLeft: "+=193px"}, 500, function() {});
	          }
	       }
}




	
function scrollmenu(direction,recordcount,numberperpage){
	
	numberOfPages = Math.floor(recordcount/numberperpage);
	remained = recordcount%numberperpage;
	
	if ((numberOfPages-1) < 0)
	{
	 numberOfPages = 1;
	}
	
	rightPoint = -(((numberOfPages-1) * numberperpage * 160) + (remained * 160));
	
	
	if (recordcount > 6)
	{
	
	
		if(direction =="left"){
			
		if(scrollLeft <= rightPoint){			
				return;
			}
			
			lastitem += 1;
			
			
			scrollLeft = scrollLeft - 160;
			$('#scrollmenu').animate({"margin-left": "-=160px"}, 500, function() {});
		}
		
		else{
		
			if(scrollLeft >= 0){
				return;
			}
			
			lastitem -= 1;
			
			scrollLeft = scrollLeft + 160;
			
			// Left Button
			$('#scrollmenu').animate({"margin-left": "+=160px"}, 500, function() {});
		}
		
	}
	
	obj = $("#scrollmenu > div");
	length = $("#scrollmenu > div").length;
	
	for (i=0;i<length;i++)
	{
	 if ($("#scrollmenu > div")[i].className == "nav_holder_on" || $("#scrollmenu > div")[0].className == "nav_holder_end_on")
	 {
	  $("#scrollmenu > div")[i].className = "nav_holder_on";
	 
	 }
	 else
	 {
	  $("#scrollmenu > div")[i].className = "nav_holder"; 
	 }	
	}
	
	if ($(".nav_holder")[lastitem-1].className == "nav_holder_on" || $(".nav_holder")[lastitem-1].className == "nav_holder_end_on")
	{
	 $(".nav_holder")[lastitem-1].className = "nav_holder_end_on";
	}
	else
	{
	 $(".nav_holder")[lastitem-1].className = "nav_holder_end";
	
	}
	
}

function scrollHoz(direction,hozcount,recordcount){
	
	numberperpage = 9
	numberOfPages = Math.floor(recordcount/numberperpage);
	remained = recordcount%numberperpage;
	
	
	
	if ((numberOfPages-1) < 0)
	{
	 numberOfPages = 1;
	}
	
	rightPoint = -(((numberOfPages-1) * numberperpage * 100) + (remained * 100));
	
	
	if (recordcount > 9)
	{
	
	
		if(direction =="left"){
			
		if(scrollLeft <= rightPoint){			
				return;
			}
			
			lastitem += 1;
			
			
			scrollLeft = scrollLeft - 100;
			$('#scrollHoz').animate({"margin-left": "-=100px"}, 500, function() {});
		}
		
		else{
		
			if(scrollLeft >= 0){
				return;
			}
			
			lastitem -= 1;
			
			scrollLeft = scrollLeft + 100;
			
			// Left Button
			$('#scrollHoz').animate({"margin-left": "+=100px"}, 500, function() {});
		}
		
	}
	
}

function hoverimageover(id){

	iname = 'smallover_'+id;
	document.getElementById(iname).style.display = 'block';	
}

function hoverimageof(id){
	iname = 'smallover_'+id
	
	if(id != videoid){
		document.getElementById(iname).style.display = 'none';	
	}
}

function hoverimageset(id){
	videoid = id;
	iname = 'smallover_'+id;
	smallovername = '#smallover_' + id;
	smallproductname = '#smallproduct_' + id;
	
	$(smallproductname).css({border: '3px solid red'})
	$(smallovername).css({ display:'block'})
}

function showVideoPlayer(gallery_id,isimage,isfooter)
{


 	$(document).ready(function() {
   		$('#loading1').css( {display: 'block'});
   		
   		$.ajax(
		 {
			 type: "post",
			 url: "/cfc/remote.cfc",
			 cache:false,
			 data: {
			 method: "fncShowVideoPlayer",returnFormat: 'json',  gallery_id:gallery_id,isimage:isimage,isfooter:isfooter
			 
		 },
		
		 dataType: "json",
		
		 
		
		 success: function( r ){ 
		 	videoid = gallery_id;
		 	smallproductname = '#smallproduct_' + gallery_id;
		 	smallovername = '#smallover_' + gallery_id;
		 	
		 	$('.smallproduct').css({border: '3px solid #666'})
		 	$(smallproductname).css({border: '3px solid red'})
		 
		 	
		 	$('.smallover').css({ display:'none'});
		 	$(smallovername).css({ display:'block'});
		 
		 	if(isfooter == 1) {

				if($('.footermedia_image').length){
					
					$('.footermedia_image').html("");
					$('.footermedia_image').html(r.HTML);
				}
				
				else{
					$('.footermedia_holder').html("");
					$('.footermedia_holder').html(r.HTML);
				}
				
				
			}
			else{
				
				$('.content_player').html("");
				$('.content_player').html(r.HTML);
			}
			
			
			$('#loading1').css( {display: 'none'});
		 
		 },
		 
			 error: function( r, strError ){
			 	alert(strError)
			 }
		});	 
	});
}
function showVideoPlayer2(gallery_id,isimage,isfooter,height,width,uid)
{


 	$(document).ready(function() {
   		$('#loading1').css( {display: 'block'});
   		
   		$.ajax(
		 {
			 type: "post",
			 url: "/cfc/remote.cfc",
			 cache:false,
			 data: {
			 method: "fncShowVideoPlayer",returnFormat: 'json',  gallery_id:gallery_id,isimage:isimage,isfooter:isfooter,height:height,width:width,inline:1
			 
		 },
		
		 dataType: "json",
		
		 
		
		 success: function( r ){ 
		 
		 	smallproductname = '#smallproduct_' + gallery_id;
		 	
		 	$('.smallproduct').css({border: '1px solid #2D2A2A'})
		 	$(smallproductname).css({border: '1px solid red'})
		
				$('#content_player_inner_'+uid).html("");
				$('#content_player_'+uid).html("");
				$('#content_player_'+uid).html(r.HTML);
	
			
			
			$('#loading1').css( {display: 'none'});
		 
		 },
		 
			 error: function( r, strError ){
			 	alert(strError)
			 }
		});	 
	});
}
/*
function updateFancyboxLinks()
{

$(".fancybox").each(function(i,b) {
 width = 0;
 height= 0;

 a = $(".fancybox")[i].href.split("?")[1].split('&');


 for (s=0;s<a.length;s++)
 {
  keyvalue = a[s].split("=");
  key = keyvalue[0];

  if (key == "width")
  {
   width = keyvalue[1];
  } 


  if (key == "height")
  {
   height = keyvalue[1];
  } 

 }

 $($(".fancybox")[i]).fancybox({

						'width'				: width+"px",
						'height'			: height+"px",


					'type'				: 'iframe'
					});


}
);


}
*/










