// JavaScript Document
var IE = document.all?true:false


function ScrollerContent (width) {
	
	
	var width = width;
	var image_arr = Array();
	var current_img = -1;
	var container = "";
	
	var img_cont = "";
	
	
	var step_right = 578;
	
	
	var load_cont;


	this.init = function (input_container) {
		container = input_container;
		
		var cont = document.createElement("div");
		
		var left = document.createElement("div");
		left.style.cssFloat = "left";
		left.style.styleFloat = "left";
		
		var left_img = document.createElement("img");
		left_img.src = path+"images/scroll/content_left.jpg";
		left.appendChild(left_img);
		left.style.cursor = "pointer";
		if (IE) {
			left.onclick = this.moveLeft	
		}
		else {
			left.addEventListener("click", this.moveLeft, true);	
		}
		

		
		cont.appendChild(left);
		
		
		var div = document.createElement("div");
		div.style.width = width+"px";
		div.style.backgroundColor = "#e6e9eb";
		div.style.borderBottom = "1px solid #d0d6d8";
		div.style.borderTop = "1px solid #d0d6d8";
		div.style.height = "161px";
		div.style.cssFloat = "left";
		div.style.styleFloat = "left";
		div.style.overflow = "hidden";
		div.style.position = "relative";
		
		cont.appendChild(div);
		
		img_cont = document.createElement("div");
		img_cont.style.width = "6000px";
		img_cont.style.padding = "17px";
		img_cont.style.position = "absolute";

		
		div.appendChild(img_cont);
		
		var right = document.createElement("div");
		right.style.cssFloat = "right";
		right.style.styleFloat = "right";
		var right_img = document.createElement("img");
		right_img.src = path+"images/scroll/content_right.jpg";
		right.appendChild(right_img);
		right.style.cursor = "pointer";
		if (IE) {
			right.onclick = this.moveRight	
		}
		else {
			right.addEventListener("click", this.moveRight, true);	
		}
		
		cont.appendChild(right);
		
		
		var clear = document.createElement("div");
		clear.style.clear = "both";
		clear.style.height = "0px";
		cont.appendChild(clear);
		
		document.getElementById(container).appendChild(cont);
		
		
	}
	
	this.moveLeft = function () {
		var total = $(load_cont).attr("offsetWidth")+20;
		
		var current = parseInt($(img_cont).css("left").replace("px", ""));

		
		if (current + step_right < 0) {
			current = current+step_right
			$(img_cont).animate({
								left: current+"px"
								}, 500, "easeOutBounce");
		}
		else {
			current = 0;
			$(img_cont).animate({
								left: current+"px"
								}, 500, "easeOutBounce");			
		}	
	}
	
	this.moveRight = function () {
		var total = $(load_cont).attr("offsetWidth")+20;
		var current = parseInt($(img_cont).css("left").replace("px", ""));
		
		if (current < 0) {
			current = current * -1;	
		}
		if (current + step_right < total-width) {
			current = current+step_right;
			$(img_cont).animate({
								left: -1*current+"px"
								}, 500, "easeOutBounce");
		}
		else {
			current = total-width;
			$(img_cont).animate({
								left: -1*current+"px"
								}, 500, "easeOutBounce");			
		}
	}
	
	this.loadContent = function (page, param) {
		$.post(
		   
		   	 page,
		   { param: param},
		   
		   function (data) {
				load_cont = document.createElement("div");
				load_cont.style.cssFloat = "left";
				load_cont.style.styleFloat = "left";
				
				var temp = data.split("@");
				
				for (i = 0; i < temp.length; i++) {
					if (temp[i] != "") {
						
						var inner_temp = temp[i].split("#");
						
							
							var cont = document.createElement("div");
							cont.className = "content_listing";
							cont.style.cssFloat = "left";
							cont.style.styleFloat = "left";
							cont.style.marginRight = "16px";
							
							var img_a = document.createElement("a");
							
							var img = document.createElement("img");
							if (inner_temp[0] == "none") {
								img.src = path+"resize/resize_scroller_car.php?img=../images/default.jpg";
							}
							else {
								img.src = path+"resize/resize_scroller_car.php?img="+inner_temp[0];	
							}
							img.border = "0";
							
							img_a.href = path+inner_temp[3];
							
							img_a.appendChild(img);
							
							cont.appendChild(img_a);
							
							var div = document.createElement("div");
							div.style.paddingTop = "5px";
							
							var car_title = document.createElement("div");
							car_title.style.marginBottom = "5px";
							
							var read_more = document.createElement("a");
							read_more.href = path+inner_temp[3];
							read_more.innerHTML = inner_temp[1];
							read_more.className = "red_link";
							car_title.appendChild(read_more);
							
							div.appendChild(car_title);
							
							read_more = document.createElement("a");
							read_more.href = path+inner_temp[3];
							read_more.innerHTML = inner_temp[2];
							read_more.className = "button";
							
							
							div.appendChild(read_more);
							
							cont.appendChild(div);
							
							load_cont.appendChild(cont);
							
							
							
							
					}
				}
				img_cont.appendChild(load_cont);
				
				var clear = document.createElement("div");
				clear.style.clear = "both";
				clear.style.height = "0px";
				
				img_cont.appendChild(clear);

				
		   },
		   "html"
		   )
	}
	

}



//New ScrollerContent Function



function ScrollerContent2 (width) {
	
	
	var width = width;
	var image_arr = Array();
	var current_img = -1;
	var container = "";
	
	var img_cont = "";
	
	
	var step_right = 578;
	
	
	var load_cont;


	this.init = function (input_container) {
		container = input_container;
		
		var cont = document.createElement("div");
		
		var left = document.createElement("div");
		left.style.cssFloat = "left";
		left.style.styleFloat = "left";
		
		var left_img = document.createElement("img");
		left_img.src = path+"images/scroll/content_left2.jpg";
		left.appendChild(left_img);
		left.style.cursor = "pointer";
		
		if (IE) {
			left.onclick = this.moveLeft	
		}
		else {
			left.addEventListener("click", this.moveLeft, true);	
		}
		

		
		cont.appendChild(left);
		
		
		var div = document.createElement("div");
		div.style.width = width+"px";
		div.style.height = "161px";
		div.style.cssFloat = "left";
		div.style.styleFloat = "left";
		div.style.overflow = "hidden";
		div.style.position = "relative";
		
		cont.appendChild(div);
		
		img_cont = document.createElement("div");
		img_cont.style.width = "6000px";
		img_cont.style.padding = "17px";
		img_cont.style.position = "absolute";

		
		div.appendChild(img_cont);
		
		var right = document.createElement("div");
		right.style.cssFloat = "right";
		right.style.styleFloat = "right";
		var right_img = document.createElement("img");
		right_img.src = path+"images/scroll/content_right2.jpg";
		right.appendChild(right_img);
		right.style.cursor = "pointer";
		if (IE) {
			right.onclick = this.moveRight	
		}
		else {
			right.addEventListener("click", this.moveRight, true);	
		}
		
		cont.appendChild(right);
		
		
		var clear = document.createElement("div");
		clear.style.clear = "both";
		clear.style.height = "0px";
		cont.appendChild(clear);
		
		document.getElementById(container).appendChild(cont);
		
		
	}
	
	this.moveLeft = function () {
		var total = $(load_cont).attr("offsetWidth")+20;
		
		var current = parseInt($(img_cont).css("left").replace("px", ""));

		
		if (current + step_right < 0) {
			current = current+step_right
			$(img_cont).animate({
								left: current+"px"
								}, 500, "easeOutBounce");
		}
		else {
			current = 0;
			$(img_cont).animate({
								left: current+"px"
								}, 500, "easeOutBounce");			
		}	
	}
	
	this.moveRight = function () {
		var total = $(load_cont).attr("offsetWidth")+20;
		var current = parseInt($(img_cont).css("left").replace("px", ""));
		
		if (current < 0) {
			current = current * -1;	
		}
		if (current + step_right < total-width) {
			current = current+step_right;
			$(img_cont).animate({
								left: -1*current+"px"
								}, 500, "easeOutBounce");
		}
		else {
			current = total-width;
			$(img_cont).animate({
								left: -1*current+"px"
								}, 500, "easeOutBounce");			
		}
	}
	
	this.loadContent = function (page, param) {
		$.post(
		   
		   	 page,
		   { param: param},
		   
		   function (data) {
				load_cont = document.createElement("div");
				load_cont.style.cssFloat = "left";
				load_cont.style.styleFloat = "left";
				
				var temp = data.split("@");
				
				for (i = 0; i < temp.length; i++) {
					if (temp[i] != "") {
						
						var inner_temp = temp[i].split("#");
						
							
							var cont = document.createElement("div");
							cont.className = "content_listing";
							cont.style.cssFloat = "left";
							cont.style.styleFloat = "left";
							cont.style.marginRight = "16px";
							
							var img_a = document.createElement("a");
							
							var img = document.createElement("img");
							if (inner_temp[0] == "none") {
								img.src = path+"resize/resize_scroller_car.php?img=../images/default.jpg";
							}
							else {
								img.src = path+"resize/resize_scroller_car.php?img="+inner_temp[0];	
							}
							img.border = "0";
							
							img_a.href = path+inner_temp[3];
							
							img_a.appendChild(img);
							
							cont.appendChild(img_a);
							
							var div = document.createElement("div");
							div.style.paddingTop = "5px";
							
							var car_title = document.createElement("div");
							car_title.style.marginBottom = "5px";
							
							var read_more = document.createElement("a");
							read_more.href = path+inner_temp[3];
							read_more.innerHTML = inner_temp[1];
							read_more.className = "red_link";
							car_title.appendChild(read_more);
							
							div.appendChild(car_title);
							
							read_more = document.createElement("a");
							read_more.href = path+inner_temp[3];
							read_more.innerHTML = inner_temp[2];
							read_more.className = "button";
							
							
							div.appendChild(read_more);
							
							cont.appendChild(div);
							
							load_cont.appendChild(cont);
							
							
							
							
					}
				}
				img_cont.appendChild(load_cont);
				
				var clear = document.createElement("div");
				clear.style.clear = "both";
				clear.style.height = "0px";
				
				img_cont.appendChild(clear);

				
		   },
		   "html"
		   )
	}
	

}
