var IE = document.all;

var t1, t2;
function none(opasity, id) {
	fid = id;
	disappear = opasity;
	if(disappear > 0){
		clearTimeout(t1);
		disappear -= 0.05;
		getElement(fid).style.opacity = disappear;
		getElement(fid).style.filter='alpha(opacity='+disappear*100+')';
		t2=setTimeout('none(disappear, fid)',30);
	}
	//IE ? getElement(id).filters[0].apply() : "";
}

function block(opasity ,id) {
	fid = id; 
	appear = opasity;
	if(appear < 1){
		clearTimeout(t2);
		appear += 0.05;
		getElement(fid).style.opacity = appear;
		getElement(fid).style.filter='alpha(opacity='+appear*100+')';
		t1=setTimeout('block(appear, fid)',30);
	}
	//IE ? getElement(id).filters[0].play() : "";
}

function setBrand() {
	if (getElement("brandJumper") && getElement("brandList")) {
		var
			jumper = getElement("brandJumper"),
			list = getElement("brandList");

		IE ? list.filters[0].apply() : "";
		if (jumper.className == "") {
			jumper.className = "on";
			list.className = "on";
		} else {
			jumper.className = "";
			list.className = "";
		}
		IE ? list.filters[0].play() : "";
	}
	return false;
}

function setNews(position) {
	if (getElement("newsItem") && position && newsArray.length > 1 && typeof(newsCurrent) != "undefined") {
		
		newsCurrent += position;
		
		if (newsCurrent < 0) {
			newsCurrent = newsArray.length - 1;
		} else {
			if (newsCurrent > newsArray.length - 1) {
				newsCurrent = 0;
			}
		}
		
		none(1, "newsItem");
		
		if (newsArray[newsCurrent]["src"] != "") {
			getElement("newsImage").style.backgroundImage = "url('" + newsArray[newsCurrent]["src"] + "')";
			getElement("newsImage").style.display = "block";
		} else {
			getElement("newsImage").style.backgroundImage = "none";
			getElement("newsImage").style.display = "none";
		}
		
		getElement("newsImage").setAttribute("href", newsArray[newsCurrent]["href"]);
		getElement("newsTitle").setAttribute("href", newsArray[newsCurrent]["href"]);
		getElement("newsTitle").innerHTML = newsArray[newsCurrent]["title"];
		
		if (newsArray[newsCurrent]["description"] != "") {
			getElement("newsDescription").innerHTML = newsArray[newsCurrent]["description"];
			getElement("newsDescription").style.display = "block";
		} else {
			getElement("newsDescription").innerHTML = "";
			getElement("newsDescription").style.display = "none";
		}
		
		getElement("newsDate").innerHTML = newsArray[newsCurrent]["date"];
		
		block(0, "newsItem");
		
	}
	return false;
}

function setTestimonials(position) {
	if (getElement("testimonialsItem") && position && testimonialsArray.length > 1 && typeof(testimonialsCurrent) != "undefined") {
		
		testimonialsCurrent += position;
		
		if (testimonialsCurrent < 0) {
			testimonialsCurrent = testimonialsArray.length - 1;
		} else {
			if (testimonialsCurrent > testimonialsArray.length - 1) {
				testimonialsCurrent = 0;
			}
		}
		
		none(1, "testimonialsItem");
		
		if (testimonialsArray[testimonialsCurrent]["src"] != "") {
			getElement("testimonialsImage").style.backgroundImage = "url('" + testimonialsArray[testimonialsCurrent]["src"] + "')";
			getElement("testimonialsImage").style.display = "block";
		} else {
			getElement("testimonialsImage").style.backgroundImage = "none";
			getElement("testimonialsImage").style.display = "none";
		}
		
		getElement("testimonialsImage").setAttribute("href", testimonialsArray[testimonialsCurrent]["href"]);
		getElement("testimonialsTitle").setAttribute("href", testimonialsArray[testimonialsCurrent]["href"]);
		getElement("testimonialsTitle").innerHTML = testimonialsArray[testimonialsCurrent]["title"];
		
		if (testimonialsArray[testimonialsCurrent]["description"] != "") {
			getElement("testimonialsDescription").innerHTML = testimonialsArray[testimonialsCurrent]["description"];
			getElement("testimonialsDescription").style.display = "block";
		} else {
			getElement("testimonialsDescription").innerHTML = "";
			getElement("testimonialsDescription").style.display = "none";
		}
		
		block(0, "testimonialsItem");
		
	}
	return false;
}

function setArticles(position) {
	if (getElement("articlesItem") && position && articlesArray.length > 1 && typeof(articlesCurrent) != "undefined") {
		
		articlesCurrent += position;
		
		if (articlesCurrent < 0) {
			articlesCurrent = articlesArray.length - 1;
		} else {
			if (articlesCurrent > articlesArray.length - 1) {
				articlesCurrent = 0;
			}
		}
			
		none(1, "articlesItem");
		
		getElement("articlesTitle").setAttribute("href", articlesArray[articlesCurrent]["href"]);
		getElement("articlesTitle").innerHTML = articlesArray[articlesCurrent]["title"];
		
		if (articlesArray[articlesCurrent]["description"] != "") {
			getElement("articlesDescription").innerHTML = articlesArray[articlesCurrent]["description"] +
				'<BR /><A hRef="' + articlesArray[articlesCurrent]["href"] +
			'">Read more...</A>';
			getElement("articlesDescription").style.display = "block";

		} else {
			getElement("articlesDescription").innerHTML = '<BR /><A hRef="' + articlesArray[articlesCurrent]["href"] +
			'">Read more...</A>';
			getElement("articlesDescription").style.display = "block";
		}
		
		block(0, "articlesItem");

	}
	return false;
}

function setDeals(position) {
	if (getElement("dealsItem") && position && dealsArray.length > 1 && typeof(dealsCurrent) != "undefined") {
		
		dealsCurrent += position;
		
		if (dealsCurrent < 0) {
			dealsCurrent = dealsArray.length - 1;
		} else {
			if (dealsCurrent > dealsArray.length - 1) {
				dealsCurrent = 0;
			}
		}
		
		none(1, "dealsItem");
		
		if (dealsArray[dealsCurrent]["steerSpecial"] == true) {
			getElement("steerSpecial").style.display = "block";
		} else {
			getElement("steerSpecial").style.display = "none";
		}
		
		getElement("dealsImage_Data").setAttribute("href", dealsArray[dealsCurrent]["href"]);
		if (dealsArray[dealsCurrent]["src"] != "") {
			getElement("dealsImage_Data").style.backgroundImage = "url('" + dealsArray[dealsCurrent]["src"] + "')";
			getElement("dealsImage_Data").setAttribute("title", dealsArray[dealsCurrent]["title"]);
		} else {
			getElement("dealsImage_Data").style.backgroundImage = "url('/i/empty-product.gif')";
			getElement("dealsImage_Data").setAttribute("title", "Product picture not available");
		}
		
		if (dealsArray[dealsCurrent]["priceNow"] != "") {
			if (dealsArray[dealsCurrent]["priceOld"] != "") {
				getElement("dealsPriceOld").innerHTML = dealsArray[dealsCurrent]["priceOld"];
				getElement("dealsPriceOld").style.display = "inline";
			} else {
				getElement("dealsPriceOld").innerHTML = "";
				getElement("dealsPriceOld").style.display = "none";
			}
			if (dealsArray[dealsCurrent]["priceNow"] != "") {
				getElement("dealsPriceNow").innerHTML = dealsArray[dealsCurrent]["priceNow"];
				getElement("dealsPriceNow").style.display = "inline";
			} else {
				getElement("dealsPriceNow").innerHTML = "";
				getElement("dealsPriceNow").style.display = "none";
			}
			if (dealsArray[dealsCurrent]["steer"] != "") {
				getElement("steerData").innerHTML = dealsArray[dealsCurrent]["steer"];
				getElement("steer").style.display = "block";
			} else {
				getElement("steerData").innerHTML = "";
				getElement("steer").style.display = "none";
			}
			getElement("dealsBasket_Data").setAttribute("href", dealsArray[dealsCurrent]["href"]);
			getElement("dealsPrice").style.display = "block";
		} else {
			getElement("dealsDescription").innerHTML = "";
			getElement("dealsPrice").style.display = "none";
		}
		
		getElement("dealsTitle_Data").setAttribute("href", dealsArray[dealsCurrent]["href"]);
		getElement("dealsTitle_Data").innerHTML = dealsArray[dealsCurrent]["title"];
		
		if (dealsArray[dealsCurrent]["description"] != "") {
			getElement("dealsDescription").innerHTML = dealsArray[dealsCurrent]["description"];
			getElement("dealsDescription").style.display = "block";
		} else {
			getElement("dealsDescription").innerHTML = "";
			getElement("dealsDescription").style.display = "none";
		}
		
		if (dealsArray[dealsCurrent]["discount"] != "") {
			getElement("dealsDiscount").innerHTML = dealsArray[dealsCurrent]["discount"];
			getElement("dealsDiscount").style.display = "block";
		} else {
			getElement("dealsDiscount").innerHTML = "";
			getElement("dealsDiscount").style.display = "none";
		}
		
		block(0, "dealsItem");

	}
	return false;
}

function setAlso(position) {
	if (getElement("alsoItem") && position && alsoArray.length > 3) {

		for (var i = 0; i < alsoCurrent.length; i++) {
			alsoCurrent[i] += position;
		
			if (alsoCurrent[i] < 0) {
				alsoCurrent[i] = alsoArray.length - 1;
			} else {
				if (alsoCurrent[i] > alsoArray.length - 1) {
					alsoCurrent[i] = 0;
				}
			}
		}

		IE ? (getElement("alsoCase").filters[0].motion = (position == 1 ? "Reverse" : "Forward")) : "";
		IE ? getElement("alsoCase").filters[0].apply() : "";
		
		for (var i = 0; i < alsoCurrent.length; i++) {
		
			if (alsoArray[alsoCurrent[i]]["steerSpecial"] == true) {
				getElement("steerSpecial" + i + "_Also").style.display = "block";
			} else {
				getElement("steerSpecial" + i + "_Also").style.display = "none";
			}
			
			getElement("alsoImage" + i + "_Data").setAttribute("href", alsoArray[alsoCurrent[i]]["href"]);
			
			if (alsoArray[alsoCurrent[i]]["src"] != "") {
				getElement("alsoImage" + i + "_Data").style.backgroundImage = "url('" + alsoArray[alsoCurrent[i]]["src"] + "')";
				getElement("alsoImage" + i + "_Data").setAttribute("title", alsoArray[alsoCurrent[i]]["title"]);
			} else {
				getElement("alsoImage" + i + "_Data").style.backgroundImage = "url('/i/empty-product.gif')";
				getElement("alsoImage" + i + "_Data").setAttribute("title", "Product picture not available");
			}
			
			if (alsoArray[alsoCurrent[i]]["priceNow"] != "") {
				if (alsoArray[alsoCurrent[i]]["priceOld"] != "") {
					getElement("alsoPriceOld" + i).innerHTML = alsoArray[alsoCurrent[i]]["priceOld"];
					getElement("alsoPriceOld" + i).style.display = "inline";
				} else {
					getElement("alsoPriceOld" + i).innerHTML = "";
					getElement("alsoPriceOld" + i).style.display = "none";
				}
				if (alsoArray[alsoCurrent[i]]["priceNow"] != "") {
					getElement("alsoPriceNow" + i).innerHTML = alsoArray[alsoCurrent[i]]["priceNow"];
					getElement("alsoPriceNow" + i).style.display = "inline";
				} else {
					getElement("alsoPriceNow" + i).innerHTML = "";
					getElement("alsoPriceNow" + i).style.display = "none";
				}
				if (alsoArray[alsoCurrent[i]]["steer"] != "") {
					getElement("steerData" + i + "_Also").innerHTML = alsoArray[alsoCurrent[i]]["steer"];
					getElement("steer" + i + "_Also").style.display = "block";
				} else {
					getElement("steerData" + i + "_Also").innerHTML = "";
					getElement("steer" + i + "_Also").style.display = "none";
				}
				getElement("alsoBasket" + i + "_Data").setAttribute("href", alsoArray[alsoCurrent[i]]["href"]);
				getElement("alsoPrice" + i).style.display = "block";
			} else {
				getElement("alsoDescription" + i).innerHTML = "";
				getElement("alsoPrice" + i).style.display = "none";
			}
			
			getElement("alsoTitle" + i + "_Data").setAttribute("href", alsoArray[alsoCurrent[i]]["href"]);
			getElement("alsoTitle" + i + "_Data").innerHTML = alsoArray[alsoCurrent[i]]["title"];
			
			if (alsoArray[alsoCurrent[i]]["description"] != "") {
				getElement("alsoDescription" + i).innerHTML = alsoArray[alsoCurrent[i]]["description"];
				getElement("alsoDescription" + i).style.display = "block";
			} else {
				getElement("alsoDescription" + i).innerHTML = "";
				getElement("alsoDescription" + i).style.display = "none";
			}
			
			if (alsoArray[alsoCurrent[i]]["discount"] != "") {
				getElement("alsoDiscount" + i).innerHTML = alsoArray[alsoCurrent[i]]["discount"];
				getElement("alsoDiscount" + i).style.display = "block";
			} else {
				getElement("alsoDiscount" + i).innerHTML = "";
				getElement("alsoDiscount" + i).style.display = "none";
			}
			
		}

		IE ? getElement("alsoCase").filters[0].play() : "";
	}
	return false;
}

//	try {
//		document.body.attachEvent('onselectstart', function () {return false});
//	} catch (e) {
//	}


