IE='\v'=='v';


function  getPageSize() {

windowWidth = document.compatMode=='CSS1Compat'?document.documentElement.clientWidth:document.body.clientWidth;
windowHeight = document.compatMode=='CSS1Compat'?document.documentElement.clientHeight:document.body.clientHeight;

}





var currentState = "NONE"; 
var previousState = "NONE"; 


var player = null;
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
	addListeners();

}


function addListeners() {
	if (player) { 
		player.addModelListener("STATE", "stateListener");
	} else {
		setTimeout("addListeners()",100);
	}
}


function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
	currentState = obj.newstate; 
	previousState = obj.oldstate; 

if (currentState == "PLAYING") {
$("#arrow_left,#arrow_right").css("display","none");
$("#body_over,#totus_over").fadeTo(350,zatemnenie);
}
if (currentState == "PAUSED" | currentState == "COMPLETED") {
$("#body_over,#totus_over").fadeTo(350,0, function (){
$("#body_over,#totus_over").css("display","none");
$("#arrow_left,#arrow_right").css("display","block");
});
}

/*
	var tmp = document.getElementById("stat");
	if (tmp) { 
		tmp.innerHTML = "current state: " + currentState + 
		"<br>previous state: " + previousState; 
	}
*/
}




function createPlayer() {
var so = new SWFObject('assets/site/images/player.swf','flash_player','640','360','9');

so.addParam("allowfullscreen","true");
so.addParam("stretching","none");
so.addParam("wmode","transparent");
//so.addVariable("screencolor","ffffff");
//so.addVariable("backcolor","000000");
so.addVariable("autostart", "flase");
so.addVariable("displayclick", "fullscreen"); //Can be play, link, fullscreen, none, mute, next. When set to none, the handcursor is also not shown. 
so.addVariable("controlbar","over"); // Can be over, bottom, none
//so.addVariable("controlbarsize","32"); // Height of the controlbar in pixels

so.addVariable("duration", video_duration);

so.addVariable("skin","assets/site/images/stylish.swf");
so.addVariable("file",file_video);
so.addVariable("image",file_img);

so.write('main_video');

}


function fultxt() {
$("#video_full_quote").fadeIn(750);
$("#video_short_quote").fadeOut(750);
$("#video_quote").animate({height: "268px"}, 750);
$("#video_info table").animate({top: "+=180px"}, 750);
}


function arrFade(what) {
$(what).fadeTo(1000,0.3, function(){
$(what).fadeTo(1000,1, function(){
arrFade(what);
});
});
}

/*----------------------------- go -----------------------------*/

$(document).ready(function () {
createPlayer();


getPageSize();
if (windowHeight < 882 ) windowHeight = 882;
$("#body_over").css({'width':windowWidth,'height':windowHeight});


$(window).resize(function(){
getPageSize();
if (windowHeight < 882 ) windowHeight = 882;
$("#body_over").css({'width':windowWidth,'height':windowHeight});
});


//alert($("#thumb_video_place .thumb_video").size());

$("#thumb_video_place").load("index.php?id=14&except="+except+"&tpl=thumb_video"+"&parent=16", function(){



thumb_video_size = $(".thumb_video").size();
Dtvs = (thumb_video_size > 9)? 5:1;
if (thumb_video_size > 5) $("#arrow_left,#arrow_right").css("display","block");
$("#thumb_video_place").width((thumb_video_size+1)*180);



$(".thumb_video").hover (
function(){
$(".thumb_video_title,.thumb_video_quote span",this).css("color","#3e3e3e");
},
function(){
$(".thumb_video_quote_click",this).css("background","none");
$(".thumb_video_title,.thumb_video_quote span",this).css("color","#b4b3b2");
});

$(".thumb_video").click( function() {
$(".thumb_video_quote_click",this).css("background-color","#f3c964");
$(".thumb_video_title",this).css("color","#f3c964");
});

});     //-------end of ajax-load-------

$("#arrow_left").click( function() {
if (!$("#thumb_video_place .thumb_video:first").is(":animated")) {

for (i=0;i<Dtvs;i++){
$("#thumb_video_place .thumb_video").css("left",-180*i);
$("#thumb_video_place .thumb_video:last").prependTo($("#thumb_video_place"));
}
$("#thumb_video_place .thumb_video").animate({left: "+="+180*Dtvs+"px"}, 750);

}
});



$("#arrow_right").click( function() {
if (!$("#thumb_video_place .thumb_video:first").is(":animated")) {

var tvs = thumb_video_size;
$("#thumb_video_place .thumb_video").animate({left: "-="+180*Dtvs+"px"}, 750, function(){
tvs--;
if (tvs == 0) {
 for (i=0;i<Dtvs;i++){
 $("#thumb_video_place .thumb_video:first").appendTo($("#thumb_video_place"));
 }
$("#thumb_video_place .thumb_video").css("left",180);
}
});
}
});


});



$(window).load(function () {
arrFade("#arrow_left");
arrFade("#arrow_right");
});
