
jQuery(function( $ ){
	var sizes = getWindowSizes();	
	
	var height_body=sizes[1];	
	var min_height_body=$('.all').height();	
	if (height_body<min_height_body) {$('body').height(min_height_body);} else {$('body').height(height_body);}

	$('.lightbox').lightBox();
	
	var el = $("ul > .scroll-interval").length;
	$('ul.blocks').css('width', $('ul.blocks li').outerWidth()*el+'px');
});

function getWindowSizes() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return [myWidth,myHeight];
}

function galItemClickInit() {
	RUZEE.ShadedBorder.create({ corner: 40, border: 1 }).render($('.gallery_video'));
	
	$('.gallery_video_paginator .item').removeClass('active');
	$('.gallery_video_paginator .item_01').addClass('active');
	
	var videoNumber=$('.gallery_video').attr('id');
	setVideo(VideoIdentifieres[videoNumber+'_0'], 560, 315);
	var Paginator=0;
	var oldPaginator=0;
	
	$('.gallery_video_paginator .item').click(function(){
			$('.gallery_video_paginator .item').removeClass('active');
			var items = $($(this).parent()).children('.gallery_video_paginator .item');
			$(this).addClass('active');
			Paginator=getIndexOf(items,this);
		if (oldPaginator!=Paginator) {
			var nVideo=videoNumber + '_' + Paginator;
			setVideo(VideoIdentifieres[nVideo], 560, 315);
			oldPaginator=Paginator;
		}
	});
}

var VideoIdentifieres = new Array();
VideoIdentifieres ['video_aion_0'] = 'qI-7Z7mlU9g';
VideoIdentifieres ['video_aion_1'] = 'bB7raYCqs2E';
VideoIdentifieres ['video_aion_2'] = 'XjFJyrin92Q';
VideoIdentifieres ['video_aion_3'] = 'lgFRyfdEQE4';

function getIndexOf(arr,obj) {
	for (var i=0;i<arr.length;i++) {
		if (arr[i]==obj) return i;
	}
	return -1;
}

function setVideo(id, w, h) {
	$('.gallery_show').empty().append('<div class="gallery_show_play" id="gallery_show_play" />');
	//$('.gallery_show_play').html(generateVideoHTML(id, w, h));
	generateVideoHTML(id, w, h);
}
function generateVideoHTML(id,w,h) {
 // Lets Flash from another domain call JavaScript
var params = { allowScriptAccess: "always" };
// The element id of the Flash embed
var atts = { id: id };
 swfobject.embedSWF("http://www.youtube.com/v/" + id + "&enablejsapi=1&playerapiid=" + id + "&autoplay=1", 
                   "gallery_show_play", w, h, "8", null, null, params, atts);
}
    
function stopVideo() {
	$('#gallery_show_play').empty();
}
  
