//////////////////////////////////////////////////////
// SlideShow V2 with Auto Play function    			//
// and a news scroller								//
// Developed by Eng. Mohammed Yehia Abdul Mottalib  //
// http://www.dahabtech.com							//
// Mobile: (+20) 10 3930 361 OR (+20) 14 5325 822	//
// Landline: (+20) 69 3642 312						//
// Address: Masbat - Salah El Din Centre			//
// *************************************************//
// Developed for free use			                //
// Feel free to use this effect						//
// Date: 15th May 2011                              //
// Copyrights 2010 | Dahab TEchnology				//
//////////////////////////////////////////////////////

// ======================================================= //
//  Album Effect (doesn't require any changes in the CSS)  //
// ======================================================= //

$(function() {

	var nImgs = $("div[class*=blockBlue]").length - 1;
	var counter = nImgs;
	var minm = 0;
	var zindex = parseInt($("div[class*=blockBlue]:eq(" + counter + ")").css(
			"z-index"), 10) - 1;
	var xleft = parseInt(
			$("div[class*=blockBlue]:eq(" + counter + ")").width(), 10) + 50;
	var duration = 7;

	$("#bannerTitle").animate({
		opacity : 0.8
	}, "normal", "swing");
	var header = $("div[class*=blockBlue]:eq(" + nImgs + ")").attr("title");
	var description = $("div[class*=blockBlue]:eq(" + nImgs + ") img").attr(
			"title");
	$("#bannerTitle").html(
			"<h1>" + header + "</h1>" + "<p>" + description + "</p>");
	setInterval(play, duration * 1000);

	function play() {
		var imgToPreview = ((counter - 1) < 0) ? nImgs : (counter - 1);
		var header = $("div[class*=blockBlue]:eq(" + imgToPreview + ")").attr(
				"title");
		var description = $(
				"div[class*=blockBlue]:eq(" + imgToPreview + ") img").attr(
				"title");
		$("#bannerTitle").slideToggle(
				"normal",
				"linear",
				function() {
					$(this).html(
							"<h1>" + header + "</h1>" + "<p>" + description
									+ "</p>");
					$(this).slideToggle("normal", "linear");
				});
		// TESTING PURPOSES: alert (description);
		$("div[class*=blockBlue]:eq(" + counter + ")").animate({
			left : xleft,
			top : "-50",
			opacity : 0
		}, "normal", "swing", function() {
			$(this).css("z-index", zindex--);
			$(this).css({
				left : "0",
				top : "0",
				opacity : 1
			});
			(counter == minm) ? counter = nImgs : counter--;
		});
	};
});

/*
 * ======================================================= // // Fade Effect
 * (doesn't require any changes in the CSS) //
 * 
 * 
 * $(function() {
 * 
 * var nImgs = $("div[class*=blockBlue]").length - 1; var counter = nImgs; var
 * minm = 0; var zindex = parseInt($("div[class*=blockBlue]:eq(" + counter +
 * ")").css("z-index"), 10) - 1; var xleft =
 * parseInt($("div[class*=blockBlue]:eq(" + counter + ")").width(), 10) + 50;
 * var duration = 5;
 * 
 * setInterval(play, duration * 1000);
 * 
 * function play() { $("div[class*=blockBlue]:eq(" + counter + ")").animate({
 * opacity: "0" }, "normal", "swing", function() { $("div[class*=blockBlue]:eq(" +
 * counter + ")").css("z-index", zindex--); $("div[class*=blockBlue]:eq(" +
 * counter + ")").css("opacity", 1); (counter == minm) ? counter = nImgs :
 * counter--; }); }; }); //
 * =======================================================
 */
