


//<!--
var arrCategoryName = new Array();
var arrCategories = new Array();
var boxType;

var firstActive=true;
function displayInfo(id){
	if(document.getElementById('spanActiveInfo')){
		if(firstActive){
			if (boxType==2) {
				var tmpStr = "<table width=260 height=110 border=0 cellpadding=0 cellspacing=4 class=tableGreyFrame>\n"
				tmpStr += "<tr>\n"
				tmpStr += "	<td class=txtContent valign=middle align=center width=100><img src=\"\" border=0 name=\"imgActiveImage\" id=\"imgActiveImage\"></td>\n"
				tmpStr += "	<td width=10></td>\n"
				tmpStr += "	<td valign=middle><img src=\"\" border=0  id=\"imgActiveModelD\" name=\"imgActiveModelD\" height=18 ></td>\n"
				tmpStr += "</tr>\n"
				tmpStr += "</table>\n"

				if(document.getElementById('compareVS')) document.getElementById('compareVS').style.visibility="";
				if(document.getElementById('compareButton')) document.getElementById('compareButton').style.visibility="";
			} else {

			var tmpStr = 	"<table width=316 height=110 border=0 cellpadding=0 cellspacing=4 class=tableGreyFrame>\n";
				tmpStr += 	"<tr><td class=txtContent valign=middle align=center width=100>\n";
				tmpStr +=	"<a href=\"\" name=\"imgActiveLink\" id=\"imgActiveLink\">\n";
				tmpStr +=	"<img src=\"images/layout/pixel.gif\" border=0 name=\"imgBrandLogo\" id=\"imgBrandLogo\"><br>\n";
				tmpStr +=	"<img src=\"images/layout/pixel.gif\" border=0 name=\"imgActiveImage\" id=\"imgActiveImage\"></a></td>\n";
				tmpStr +=	"<td width=10><img src=\"images/layout/pixel.gif\" width=10 height=1 border=0></td><td valign=top>\n";
				tmpStr +=	"<img src=\"images/layout/pixel.gif\" border=0 id=\"imgActiveModelD\" name=\"imgActiveModelD\" height=18><br>";
				tmpStr +=	"<table border=0 cellpadding=0 cellspacing=0 height=92 width=100%><tr>\n";
				tmpStr +=	"<td class=txtContent id=\"spanActiveDesc\" name=\"spanActiveDesc\" valign=top></td></tr>\n";
				tmpStr +=	"<tr><td valign=bottom align=right><a name=\"buttonLink\" id=\"buttonLink\">\n";
				tmpStr +=	"<img src=\"" + gotoButton + "\" border=0 style=\"border: 1px solid #CCCCCC\" height=19></a></td></tr></table></td></tr></table>\n";
			}
			document.getElementById('spanActiveInfo').innerHTML = tmpStr;
			preload('pixel','images/layout/pixel.gif');
		}

		if(document.getElementById('imgBrandLogo')){
			if(arrBrandLogo[id] != "") imgSwap('imgBrandLogo','imgBrandLogo'+id);
			else imgSwap('imgBrandLogo','pixel');
		}
		
		if(document.getElementById('imgActiveImage')) imgSwap('imgActiveImage','imgProdBig'+id);

		if(document.getElementById('imgActiveLink')) document.getElementById('imgActiveLink').href=arrLinks[id];
		if(document.getElementById('buttonLink')) document.getElementById('buttonLink').href=arrLinks[id];

		if(document.getElementById('imgActiveModelD')) imgSwap('imgActiveModelD','imgProdModelD'+id);

		if(document.getElementById('spanActiveDesc')) document.getElementById('spanActiveDesc').innerHTML = arrProductDesc[id];
	}
	firstActive = false;
}

var tmpActionText = ""
function updateActionText(text){
	if(tmpActionText != text){
		document.getElementById('actiontext').innerHTML = text;
		document.getElementById('actiontext').style.left = (sliderWidth/2)-(parseInt(document.getElementById('actiontext').offsetWidth)/2);	
	}
	tmpActionText = text;
}

var slide=false;
function overStartSlide(blnAction, dir){
	if(blnAction){
		if (!slide) {
			if (!moving)
				moveTo(stopPos-prodMaxWidth*dir); 
			slide = true;
		}
	}else{
		slide = false;
	}
}

function startSlideRight(){
    moveTo(stopPos+prodMaxWidth);    
}

function startSlideLeft(){
    moveTo(stopPos-prodMaxWidth);
}

function moveTo(pos2) {
	var tmpLength = 0;
	if(prodCounter == -1) tmpLength = arrProducts.length;
	else tmpLength = prodCounter;

	var tmpValue = (-(pos2/prodMaxWidth)+1);
	var tmpValue2 = tmpValue+(prodDisplayed-1);
	if(tmpLength<tmpValue2) tmpValue2 = tmpLength;

	if(tmpLength > prodDisplayed) updateActionText("<span class=txtContent UNSELECTABLE=\"on\">"+txtShowingProduct+" <b>"+tmpValue+"</b>"+txtTo+" <b>"+tmpValue2+"</b>"+txtOfTotal+" <b>"+tmpLength+"</b> "+txtProducts+"</span>");
	else updateActionText("<span class=txtContent UNSELECTABLE=\"on\">" + topText + "</span>");		

	stopPos = pos2;

    if(stopPos >= 0) hide("leftarrow");
    else show("leftarrow");

    //if(stopPos <= -(parseInt(document.getElementById('area').offsetWidth)-(sliderDisplayWidth+prodSpacerWidth))) hide("rightarrow");
    if(stopPos <= -((tmpLength*(prodSpacerWidth+prodWidth))-(sliderDisplayWidth+prodSpacerWidth))) hide("rightarrow");
    else show("rightarrow");    

    if (!moving) {
		moving = true;
	    timerID = setInterval("doSlide()",13);
	}
}

var stopPos=0;
var speed=0;
var sumSpeed=0;
var moving=false;
var timerID = 0;

function doSlide(){
	areaobj = document.getElementById('area');
	left = areaobj.offsetLeft;
	dir = (left<stopPos)?-1:1;
	left += speed;
	var distance = Math.abs(left-stopPos);

	if(distance<Math.abs(sumSpeed+(speed-dir))) {
		if(slide) {
			compPos = stopPos-prodMaxWidth*dir;
			
			if(prodCounter==-1) tmpAreaWidth = arrProducts.length*prodMaxWidth;
			else tmpAreaWidth = prodCounter*prodMaxWidth;
			
			if(tmpAreaWidth-(sliderDisplayWidth-prodMaxWidth)>-compPos && compPos<=0){
				moveTo(compPos);
			}else
				sumSpeed-=(speed+=dir);
		}else
			sumSpeed-=(speed+=dir);
	}else
		if(Math.abs(speed)<maxSpeed || (speed!=0 && Math.max(-1,Math.min(1,speed)) != dir*-1))
			sumSpeed+=(speed-=dir);

	if((absSpeed=Math.abs(speed))<2)
		sumSpeed = speed;

    areaobj.style.left = left;

	if(!(distance>0 || absSpeed>1)) {
		clearInterval(timerID);
	    moving = false;
	    sumSpeed=speed=0;
	    maxSpeed=secondaryMaxSpeed;
	}
}

var arrProductOrder = new Array();
var prodCounter = -1;
var useDropdown = true;

function showProductsByCategory(obj){
	if(document.getElementById('spanActiveInfo')){
		document.getElementById('spanActiveInfo').innerHTML = imgHeader;
		firstActive	 = true;
	}
	maxSpeed=segmentMaxSpeed;
	prodCounter = 0;
	for(var i = 0; i < arrProducts.length; i++){
		if (Segment==-1)
			Segment = obj.value;
		if(Segment!= -1){
			var temp = false;
        
			for(var j = 0; j < arrCategories[Segment].length; j++){
				if(arrCategories[Segment][j] == arrCatId[i]){
					temp = true;
					break;
				}
			}
			if(temp){
				document.getElementById("product_"+i).style.display = "inline";
			}
			else{
				document.getElementById("product_"+i).style.display = "none";
			}
		}
		else{
			document.getElementById("product_"+i).style.display = "inline";
		}
		if(document.getElementById("product_"+i).style.display == "inline") arrProductOrder[i] = prodCounter++;
	}
	speed=0;
	Segment=-1;
	init();
}

function imageLoad(imgName) {
    var factor = 0;
    var Ymax = prodHeight;
    var Xmax = prodWidth;
    var Y = (oLarge=eval("document.getElementById('" + imgName + "')")).height;
    var X = oLarge.width;
    
    var Ys = .2*(Y *= factor = Math.min(Ymax/Y, Math.min(Xmax/X,1)));
    var Xs = .2*(X *= factor);
    
    oLarge.height = Y;
    oLarge.width = X;
}

function initImageLoad(){
    for(var i = 0; i < arrProducts.length; i++){ 
        imageLoad("i"+i);
    }
}

function printSlider(){
    var strSliderStart = "<div id=\"slider\">\n";
    var strSliderEnd = "</div>\n";

    var strActionText = "<div id=\"actiontext\"></div>\n";
    
    var strDropdown = "";
    if(useDropdown){
        var strDropdown = "<form name=\"form\">\n";
        strDropdown += "<select name=\"category\" id=\"category\" class=txtContent onchange=\"showProductsByCategory(this)\">\n";
        strDropdown += "<option value=\"-1\">" + dropdownName + "</option>\n";    
    
		for(var i = 0; i < arrCategories.length; i++){
			strDropdown += "<option value="+i;
			if (i==Segment)	strDropdown+=" selected";
			strDropdown += ">"+arrCategoryName[i]+"</option>\n"
	    }
	        strDropdown += "</select>\n";
	        strDropdown += "</form>\n";

		if(document.getElementById('dropdownSelector')) document.getElementById('dropdownSelector').innerHTML = strDropdown;
    }
	    
    var strLeftarrow = "<div id=\"leftarrow\">\n";
    strLeftarrow += "<img src=\""+imgArrowLeft+"\" width=30 height=35 border=0 id=arrowleft name=arrowleft onmouseover=\"overStartSlide(true,-1);imgSwap('arrowleft','img_arrowleft_w')\" onmouseout=\"overStartSlide(false,0);imgSwap('arrowleft','img_arrowleft')\" onfocus=\"this.blur()\">\n";
    strLeftarrow += "</div>\n";
    strLeftarrow += "<script"+">preload('img_arrowleft','"+imgArrowLeft+"');preload('img_arrowleft_w','"+imgArrowLeftActive+"');</"+"script>"; 
     
    var strRightarrow = "<div id=\"rightarrow\">";
    strRightarrow += "<img src=\""+imgArrowRight+"\" width=30 height=35 border=0 id=arrowright name=arrowright onmouseover=\"overStartSlide(true,1);imgSwap('arrowright','img_arrowright_w')\" onmouseout=\"overStartSlide(false,0);imgSwap('arrowright','img_arrowright')\" onfocus=\"this.blur()\">\n";
    strRightarrow += "</div>\n";
    strRightarrow += "<script"+">preload('img_arrowright','"+imgArrowRight+"');preload('img_arrowright_w','"+imgArrowRightActive+"');</"+"script>";     
         
    var strContainerStart = "<div id=\"container\">\n";
    var strContainerEnd = "</div>\n";

    var strAreaStart = "<div id=\"area\">\n";
    var strAreaEnd = "</div>\n";   
   
    var strProducts = "";
    strProducts = "<table height=150 border=0 cellpadding=0 cellspacing=0>\n";
    strProducts += "<tr>\n";    
    
    for(var i = 0; i < arrProducts.length; i++){
        strProducts += "<td valign=bottom height=150>\n";
        strProducts += "<span name=\"product_"+i+"\" id=\"product_"+i+"\" style=\"display: inline\">\n";
        strProducts += "<table width="+prodMaxWidth+" border=0 cellpadding=0 cellspacing=0>\n";
        strProducts += "<tr>\n";
        strProducts += "<td valign=top>\n";
        strProducts += "<table width=100% border=0 cellpadding=0 cellspacing=0>\n";
        strProducts += "<tr>\n";
        strProducts += "<td align=center valign=top><a href=\""+arrLinks[i]+"\" target=\""+arrTargets[i]+"\" onmouseover=\"displayInfo("+i+");\"><img src=\""+arrProducts[i]+"\" border=0 alt=\""+arrProductText[i]+"\" id=\"i"+i+"\" name=\"i"+i+"\"></a></td>\n";
        strProducts += "</tr>\n";
        strProducts += "<tr>\n";
        strProducts += "<td align=center valign=middle height=35 class=txtContent><span style=\"width:"+prodMaxWidth+"px;text-overflow: ellipsis;overflow:hidden;\">"+arrProductText[i]+"</span></td>\n";
        strProducts += "</tr>\n";
        strProducts += "</table>\n";
        strProducts += "<script"+">preload('imgProdModelD"+i+"','"+arrProductModelD[i]+"');preload('imgBrandLogo"+i+"','"+arrBrandLogo[i]+"');preload('imgProdBig"+i+"','"+arrProductsBig[i]+"');</"+"script>\n";
        strProducts += "</td>\n";
        strProducts += "<td valign=top>\n";
        strProducts += "<table border=0 cellpadding=0 cellspacing=0>\n";
        strProducts += "<tr>\n";
        strProducts += "<td width="+prodSpacerWidth+" height=1></td>\n";
        strProducts += "</tr>\n";
        strProducts += "</table>\n";
        strProducts += "</td>\n";
        strProducts += "</tr>\n";
        strProducts += "</table>\n";
        strProducts += "</span>\n";
        strProducts += "</td>\n";

        arrProductOrder[i] = i;        
    }
      
    strProducts += "</tr>\n";
    strProducts += "</table>\n";

    var strOut = strSliderStart + strActionText + strLeftarrow + strRightarrow + strContainerStart + strAreaStart + strProducts + strAreaEnd + strContainerEnd + strSliderEnd;

    document.write(strOut);
}

function init(){
	if(Segment!=-1) showProductsByCategory(document.getElementById('category'));

	document.getElementById('area').style.top = 0;

	if(prodCounter==-1) document.getElementById('area').style.left = -arrProducts.length*prodMaxWidth;
	else document.getElementById('area').style.left = -prodCounter*prodMaxWidth;

	//document.getElementById('container').style.width = arrProducts.length*prodMaxWidth;     

	if(parseInt(document.getElementById('area').offsetWidth) < parseInt(sliderDisplayWidth+prodSpacerWidth)){
		hide("leftarrow");
		hide("rightarrow");
	}
	else{
		show("rightarrow");
		hide("leftarrow");        
	}
	
	if(prodCounter==-1) {
		if(arrProducts.length<prodDisplayed)
			moveTo(sliderDisplayWidth/2-arrProducts.length*prodMaxWidth/2);
		else
			moveTo(0);
	} else {
		if(prodCounter<prodDisplayed)
			moveTo(sliderDisplayWidth/2-prodCounter*prodMaxWidth/2);
		else
			moveTo(0);
	}	
}
// --> 
