// JavaScript Document


jQuery.fn.paginateList = function(opts) { 

	opts = jQuery.extend({
		itemsPerPage:10,
		btnHolder:"#btnHolder",
		startPage:0,
		btnLabel:"page",
		callback:function(){return false;}
	},opts||{});
 
		//opts.startPage = (!opts.startPage || opts.startPage < 0)?1:opts.startPage;
		opts.itemsPerPage = (!opts.itemsPerPage || opts.itemsPerPage < 0)?1:opts.itemsPerPage;
		opts.btnLabel = (!opts.btnLabel)?1:opts.btnLabel;

		var tgt="#"+$(this).attr("id");
		var items = $(this).children(".toPage");
		var totChildren = items.size();
		var totPages = numPages();
		
 		$(tgt).children(".toPage").hide();
 		$(tgt).children(".toPage:lt("+(opts.itemsPerPage)+")").show();
		
	//	$("#feedback").append("<li>"+tgt+" "+totChildren+" "+totPages+"</li>");

		var pageButtons = "";
		
		var i;
		
		for(i=0;i<totPages;i++){
			pageButtons +="/<a class=\"pageIcon\" href=\"#\" ><span> "+(i+1)+" </span></a>";
		}
		if(totPages>1){
			$("#btnHolder").html(opts.btnLabel+pageButtons);		
			$("#btnHolder").children("a:eq("+(opts.startPage)+")").addClass("activePage");
		}
//alert(tgt);

		$("#btnHolder").children("a").click(function(){
		 	var gotoPage = $(this).children("span").text()-1;
			var s = (opts.itemsPerPage*gotoPage)-1;
			var e = (s+opts.itemsPerPage)+1;
			showRange(s,e);
			$("#btnHolder").children("a").removeClass("activePage");
			$(this).addClass("activePage");
		//	alert(s+" "+e);
			return false;
		});
		
		function numPages() {
			return Math.ceil(totChildren/opts.itemsPerPage);
		}
		
		function showRange(a,b) {
			$(tgt).children(".toPage").hide();
		//	$(tgt).children(".toPage:lt("+b+")").filter(":gt("+a+")").show();
			$(tgt).children(".toPage:lt("+b+")").filter(":gt("+a+")").fadeIn(200);
		}
};


jQuery.fn.fadeToggle = function(speed, easing, callback) { 
   return this.animate({opacity: 'toggle'}, speed, easing, callback); 
};

function resizeItem(){
	
	alert("1");
	//$("#"+tgt).css("height",h);
	
  
}
 
function setPlayingStyle(tgt, section, newH){
	
	//alert("'"+tgt+"' '"+section+"'")
	
	//$(".openClose *").removeClass("playingThisVideo");
	$("a.videoInfoDiv").removeClass("playingThisVideo");
	//$("#"+section+" div").removeClass("playingThisVideo");
	
	$("#"+tgt).addClass("playingThisVideo");
	
	//$("#feedback").append("<li>#"+tgt+"</li>"); 
	
	if(newH){
	//	alert("nH:"+newH)
		//$("#flashVideoHolder").height(newH);
		
		newH += "px";
		document.getElementById("flashVideoHolder").style.height = newH;
		
	}
 //	return false;
 
}

 
function processColour(val){
	var valConverted;
	
	//requires jquery.colour.js
	
	/*if($.isHexadecimalColor(val)){
		valConverted = $.fmtColor(val,'hexadecimal');		
		//alert("isHexadecimalColor "+val+" "+valConverted);
		return valConverted;
	}else if($.isRGBColor(val)){
		valConverted = $.fmtColor(val,'hexadecimal');
		//alert("isRGBColor "+val+" "+valConverted);
		return valConverted
	}else if($.isColor(val)){
		valConverted = $.fmtColor(val,'hexadecimal');
		//alert("isColor "+val+" "+valConverted);
		return valConverted;
	}*/
	 
}


