// JavaScript Document

function hasNextPlaylistVideo(id_film){
	
	
	jQuery.get(document.location.href,  { next_video: 1,id_film: id_film },  function(data){  if(data!=1) document.location.href = data;  }	);
	
}


function setOffset(Top, Left){
	
	
	jQuery.get(document.location.href,  { setOffset: 1, scrollTop: Top,scrollLeft: Left },  function(data){}	);
	
}


function togglePlaylist(stat){
	
	
	jQuery.get(document.location.href,  { togglePlaylist: 1,playlist_status: stat },  function(data){}	);
	
}

function addFavorited(id_film){
	jQuery('#addFavorited_'+id_film).hide();
	jQuery('#deleteFavorited_'+id_film).show();
	
	jQuery.post(document.location.href,  { act: 'addFavorited',film_id: id_film },  function(data){  }	);
	
}


function deleteFavorited(id_film){
	try{
	jQuery('#deleteFavorited_'+id_film).hide();
	jQuery('#addFavorited_'+id_film).show();
	} catch(err) {
		
	}
	jQuery.post(document.location.href,  { act: 'deleteFavorited',film_id: id_film },  function(data){    }	);
}



function addPlaylist(id_film,href,src,titlu_film){
	jQuery('#addPlaylist_'+id_film).hide();
	jQuery('#deletePlaylist_'+id_film).show();
	window.playlist_number += 1;
	jQuery('#hp_fb_like_wrapper').css('height','120px');
	window.carousel_trasabilitate[ id_film ] = window.playlist_number; 
	jQuery('#playlist_'+id_film).val('1');
	jQuery('.total_video_playlist').html(window.playlist_number);
	
	/*
	<li><a onmouseover="jQuery('#div_playlist_<?php print $j;?>').css('color','red');" onmouseout="jQuery('#div_playlist_<?php print $j;?>').css('color','white');" href="<?php echo $global_root; ?>/filme/<?php print $re_playlist['id_film'];?>-<?php print cleanLink($re_playlist['titlu_film']);?>"><img src="<?php echo $playlist_image; ?>" border="0"  width="100"  /><div id="div_playlist_<?php print $j++;?>" style="color:#FFFFFF;font-size:10px;"><?php print wrapDesc2(cleanOutput($re_playlist['titlu_film']),10,40);?></div></a></li>
	*/
	
	/*var html = ''+
			   '<li>'+
			   		'<a href="'+href+'?playlist=1">'+
			   			'<img src="'+src+'" border="0" width="100" />'+
						'<div id="div_playlist_'+id_film+'" style="color:#FFFFFF;font-size:10px;">'+titlu_film+'</div>'+
					'</a>'+
					'<img id="delete_playlist_icon_'+id_film+'" onclick="jQuery(this).parent().remove();deletePlaylist('+id_film+');" style="position:absolute;right:0px;margin-top:0px;background-color:#000000;cursor:pointer;" src="http://help.adobe.com/en_US/flashbuilder/using/images/delete_icon.png" width=15 />'+
			   '</li>'+
			   '';*/
			   
			   
		var html = ''+
			     ' <li style="width:290px;display:block;">'+
     '<div style="width: 290px;position:relative;">'+
     '<a onmouseover="jQuery(\'#div_playlist_'+id_film+'\').css(\'color\',\'red\');" onmouseout="jQuery(\'#div_playlist_'+id_film+'\').css(\'color\',\'white\');" href="'+href+'?playlist=1" style="cursor:pointer;">'+
     ' <div style="width:10px;float:left;color:#FFFFFF;font-size:14px;font-weight:bold;position:absolute;left:11px;top:30px;text-align:center;">'+window.playlist_number+'</div>'+
          ' <div style="color:#FFFFFF;font-weight:bold;float: right;  width: 53%;height: 75px;position:relative;">'+
		  ' <div style="position:relative;text-align:center;vertical-align:middle;top:20px;">'+titlu_film+''+
          ' </div>'+
          ' </div>'+
		  '</a>'+
          '<div style="float: right;  width: 106px;">'+
		  '<a onmouseover="jQuery(\'#div_playlist_'+id_film+'\').css(\'color\',\'red\');" onmouseout="jQuery(\'#div_playlist_'+id_film+'\').css(\'color\',\'white\');" href="'+href+'?>?playlist=1" style="cursor:pointer;">'+
		  	'<img align="right"; src="'+src+'" border="0" width="106" height="75"  />'+
		'</a>'+
			'<img id="delete_playlist_icon_'+id_film+'" onclick="jQuery(this).parent().parent().parent().remove();jQuery(this).parent().parent().parent().toggle();deletePlaylist('+id_film+');" style="position:absolute;right:0px;margin-top:0px;background-color:#000000;" src="http://help.adobe.com/en_US/flashbuilder/using/images/delete_icon.png" width="15" />'+
			
			'</div>'+

      '</div>'+
	  '</li>'+
	    '';	   
			   
			   
	
	
	jQuery('#mycarousel').jcarousel('add', window.playlist_number, html);
	
	
	
	jQuery.post(document.location.href,  { act: 'addPlaylist',film_id: id_film },  function(data){   }	);
	
	
	
}


function deletePlaylist(id_film){
	
	jQuery('#playlist_'+id_film).attr("checked", false);
	try{
	
	jQuery('#deletePlaylist_'+id_film).hide();
	jQuery('#addPlaylist_'+id_film).show();
	jQuery('#playlist_'+id_film).val('0');
	window.playlist_number--;
	jQuery('.total_video_playlist').html(window.playlist_number);

	jQuery('.jcarousel-item-'+window.carousel_trasabilitate[id_film]).remove();
	
	} catch(err) {
		
	}
	jQuery.post(document.location.href,  { act: 'deletePlaylist',film_id: id_film },  function(data){  }	);
	
}

function addRecomandate(id_film){
	jQuery('#addRecomandate_'+id_film).hide();
	jQuery('#deleteRecomandate_'+id_film).show();
	jQuery('#recomandate_'+id_film).val('1');

	
	jQuery.post(document.location.href,  { act: 'addRecomandate',film_id: id_film },  function(data){   }	);
	
	
	
}

function deleteRecomandate(id_film){
	
	jQuery('#recomandate_'+id_film).attr("checked", false);
	try{
	
	jQuery('#deleteRecomandate_'+id_film).hide();
	jQuery('#addRecomandate_'+id_film).show();
	jQuery('#recomandate_'+id_film).val('0');

	
	} catch(err) {
		
	}
	jQuery.post(document.location.href,  { act: 'deleteRecomandate',film_id: id_film },  function(data){  }	);
	
}

function clickListener(o) {
	window.location.href = document.getElementById('preview_'+o.id).innerHTML;
}


if (!String.prototype.replaceWideWithBasicASCII) {
	String.prototype.replaceWideWithBasicASCII = function() {
		// Unicode Block 'Halfwidth and Fullwidth Forms' => Unicode Block 'Basic Latin'
		// http://www.fileformat.info/info/unicode/block/halfwidth_and_fullwidth_forms/index.htm
		var str = this;
		str=str.replace(/／/gi, "/");
		str=str.replace(/﹡/gi, "*");
		//str=str.replace(/”/gi, "\"");
		//str=str.replace(/΄/gi, "'");
		str=str.replace(/％/gi, "%");
		str=str.replace(/＆/gi, "&");
		str=str.replace(/＋/gi, "+");
		str=str.replace(/＼/gi, "\\");
		str=str.replace(/＄/gi, "$");
		str=str.replace(/＜/gi, "<");
		str=str.replace(/＞/gi, ">");
		str=str.replace(/＝/gi, "=");
		str=str.replace(/？/gi, "?");
		str=str.replace(/＃/gi, "#");
		str=str.replace(/？/gi, "?");	
		//str=str.replace(/＂/gi, "\"");	
		str=str.replace(/＂/gi, "”");	
		//str=str.replace(/＇/gi, "'");
		str=str.replace(/＇/gi, "΄");
		return str;
	};
}
