﻿/*
 * ********************************************
 * @author        Dimitar Roustchev
 * @date          2010-03
 * @copyright     2010 Dimitar Roustchev
 * ********************************************
 */

// Gallery scrollable //
function fetchItems() {  
	var timeStamp = new Date().getTime();
	$.get(	"soap2html.php",
			{time: timeStamp},
							function(data){
								var api = $("div.scrollable").scrollable()
								api.getItemWrap().append(data);
								api.reload();
								api.nextPage();
							});
}
function scrollPrev() {
	var api = $("div.scrollable").scrollable();	
	api.prevPage();
	if (api.getPageIndex() == 0) {
		$("a.browse.left").addClass("disabled");
		return;		
	};	
}
function scrollNext() {
	var api = $("div.scrollable").scrollable();
	if (api.getPageIndex() == (api.getSize()/api.getConf().size)-1) {
		fetchItems();
		return;		
	}
	api.nextPage();
	if (api.getPageIndex() != 0) {
		$("a.browse.left").removeClass("disabled");
		return;		
	};	
}

// UI effects //
function unmarkRest(pl_entry){
	$('.pl_entry').each(function(i) {
	$(this).removeClass('active');
	$(this).removeClass('prev');
	return;
	});
};
function markActive(pl_entry){
	unmarkRest(pl_entry);
	$(pl_entry).addClass('active');
	$(pl_entry).prev().addClass('prev');
};
	
// Video player interaction //
function nextVideo($videoID, $videos){
	videoID = $videoID;
	videos = $videos;
	videoID ++;
	if(videoID == videos.length){
		videoID = 0;
	}
	playVideo(videoID, videos);
}
function playVideo($videoID, $videos){
	videoID = $videoID;
	videos = $videos;
	sendToNonverBlaster("switch:" + videos[videoID]);
}
// temp
function getSub($this) {
	var temp = $this.attr("href");
	temp = temp.split("#");
	var sub = temp[1];
	return sub;
}
function showSub($sub) {
	$sub = "." + $sub;
	$($sub).parent().children().hide();
	$($sub).fadeIn(900);
}
	
