<!--

	// defining the global variables
	var active = 1;
	var slideDelay = true;
	var manualNavigation = false;
	var interval = 6000;
	var autorepeat;
	var fadeSpeed = 300;
	var slideSpeed = 500;

	// setting the div positions in "slideItems" and "slideLinks"
	function homepageFramework() {
		
		// getting the count of divs placed in "slideItems"
		index = ($('#slideItems > div').length);
		
		// looping through the slide items
		jQuery("#slideItems div").each(function(i)
		{
			// setting the position of slideItems by giving left margin
			jQuery(this).css('left', (i*716) + 'px').show();
			
			// setting the position of slideLinks by giving the left margin
			$('#slideLinks div').eq(i).css('left', (i*160) + 'px').show();
		});
	}
	
	function renderNavigation() {
		/* regular nav link icon (open (unselected) square): */
		$('#slideItems > div').each(function(n){			
			$('#navigationRow').append('<span class="navigation_box_frame" style="left: ' + parseInt((n*15)+100) + 'px;"><a href="javascript:showSlide(' + (n+1) + ');" name="Left Nav Box ' + (n+1) + '"></a></span>');
			//alert($('#navigationRow').html());
		});
		var numberOfStories = $('#slideItems > div').size();

		/* selected nav link icon (square) */
		//var shadePos = $('#navigationRow > span.navigation_box_frame:eq(0)').position().left;
		//$('#navigationRow').append('<span id="navigation_box_core" style="left: ' + shadePos + 'px;"></span>');

		$('#navigationRow a').bind('click',onClickFunctions)
		.filter(':eq(0)').bind('click',showPrevious).end()
		.filter(':eq(1)').bind('click',showNext).end()
	}

	
	function onClickFunctions() {manualNavigation = true;}
	
	function showSlide(e) {((active == index)) ? slide(e) : slide(e);}

	function showPrevious() {
		var e;
		(active == 1) ? e = index : e = (active-1);
		showSlide(e);
	}
	function showNext() {
		var e;
		(active == index) ? e = 1 : e = (active+1);
		showSlide(e);
	}

	
	function autoAdvance() { // autopush until it gets to the index page.
		
		/*if (active == index) { return; }*/ /* disabled for continuous rotation */
		(autorepeat) ? clearTimeout(autorepeat) : '';
		if ( manualNavigation == false ) {
			(slideDelay == false) ? showNext() : '';
			slideDelay = false;
			autorepeat = setTimeout(autoAdvance,interval);
		}
	}

	function updateNavigation(e){
		$('.navigation ul > li').removeClass("active");
		$('.navigation ul > li.' + e).addClass("active");
		var href = $("#slider_banner_data").find(".offer").eq(e-1).find("a").attr("href");
		$(".slide-items-trp-corners").attr("href", href);
	}

	function slide(e) {
		var incomingPosImage = $('#slideItems > div:nth-child(' + e + ')').position().left;
		var incomingPosText = $('#slideLinks > div:nth-child(' + e + ')').position().left;
		updateNavigation(e);
		$('#slideItems').animate({ left: -incomingPosImage },slideSpeed,function(){ active = e; });
		$('#slideLinks').animate({ left: -incomingPosText },slideSpeed);
	}
	function move(e) {
		var incomingPosImage = $('#slideItems > div:nth-child(' + e + ')').position().left;
		var incomingPosText = $('#slideLinks > div:nth-child(' + e + ')').position().left;
		$('#slideItems').css('left',-incomingPosImage);
		$('#slideLinks').css('left',-incomingPosText);
	}
	function fadeIndex(e) {
		updateNavigation(e);
		$('#pageWrapper').fadeOut(fadeSpeed,function(){
			if (e == index) {
				$('#slideItemsWrap').hide();
				$('#slideLinks').hide();
				$('#slideLinksIndex').show();
				$('#viewAll').show().css('left',0);
			} else {
				$('#slideLinksIndex').hide();
				$('#viewAll').css('left',-770);
				$('#slideItemsWrap').show(1,function(){ move(e); });
				$('#slideLinks').show();
			}
			$('#pageWrapper').fadeIn(fadeSpeed,function(){ active = e; });
		});
	}
	
	$(document).ready(function(){
		// gets main wrapper object
		var oContentBox = $("#slider_banner_data");
		//if it's exists  
		if (oContentBox.length > 0){
			oContentBox.hide();
			var imghref = $("#slider_banner_data").find(".offer").eq(0).find("a").attr("href");
			var sHtml = '<div class="content_box box_3col_2row">' + 
							'<div id="pageWrapper">' +
								'<div id="slider_wrapper">' +
									'<div id="navigationRow"></div>' +
									'<div id="slideItemsWrap" class="banner_image">' +
										'<div id="slideItems"></div>' +
										'<a class="slide-items-trp-corners" href="' + imghref + '"></a>' +
									'</div>' +
									'<div id="text_wrapper" class="slider_info">' +
										'<div class="navigation">' +
											'<ul>' +
											'</ul>' +
										'</div>' +
										'<div id="slideLinks">' +
										'</div>' +
									'</div>' +
								'</div>' +
								'<span></span>' +
								'<div style="clear: both;"></div>' +
							'</div>' +
						'</div>';
						
			
			oContentBox.after(sHtml);
			var oslideItems = $("#slideItems");
			oContentBox.find(".offer").each(function(i){
				var img = $(this).find("img").attr("src");
				var link = $(this).find("a");
				var href = link.attr("href"); 
				var title = $(this).find("h3");
				var price = $(this).find(".price"); 
				var desc = $(this).find(".description");
				
				$("#slideItems").append("<div><a href=\"" + href  + "\"><img src=\"" + img + "\" ></a></div>");
				var j = i + 1;
				$(".navigation ul").append("<li class=\"" + j.toString() + "\"><a href=\"javascript:showSlide("+ j.toString() +");\">" + title.text() + "</a></li>")
				if (price.length > 0){
					$("#slideLinks").append("<div class=\"slider_item_content\">" +
												"<p>" + desc.html().toString() + "</p>" +
												"<p class=\"price\">" + price.html().toString() + "</p>" +
												"<a href=\"" + href  + "\" class=\"icon_arrow\">" + link.text().toString() + "</a>" +
											"</div>");
				}
				else{
					$("#slideLinks").append("<div class=\"slider_item_content\">" +
												"<p class=\"desc\">" + desc.html().toString() + "</p>" +
												"<a href=\"" + href  + "\" class=\"icon_arrow\">" + link.text().toString() + "</a>" +
											"</div>");
				}
				
				
			});
			$('.navigation ul li.1').addClass("active");
		
			homepageFramework();
			renderNavigation();
			autoAdvance();
			$("#pageWrapper").mouseover(function(){
				clearTimeout(autorepeat);
			}).mouseout(function(){
				autorepeat = setTimeout(autoAdvance,interval);
			});
			
		}
	});
//-->