﻿var image1 = new Image();
image1.src = "images/iScrollL.png";
var image2 = new Image();
image2.src = "images/iScrollLo.png";
var image3 = new Image();
image3.src = "images/iScrollR.png";
var image4 = new Image();
image4.src = "images/iScrollRo.png";

$(document).ready(function() {
	// hide divs
	try {
	    if (!myVideoChannel) myVideoChannel = "";
	    var thePlayerFrame = document.getElementById(myVideoChannel);
	    if (!myEmbedUrl) myEmbedUrl = "";
	}catch(e){
	}
	
	
	/*$.each($("#videosList a"),function(){
	    
	    // remove href if javascript is enabled
	    
	    $(this).attr("href","javascript:vlClick('"+this.id+"');");
	});*/
	
	$(".listDetails").click(function(){
		// hide all divs, and show sibling
		currentO = $("#videosList div:visible");
		currentO.hide();
		currentO.parent("li").removeClass("selected");
		$(this).next("div").show();
		$(this).parent("li").addClass("selected");
	});
	
    $("#videosList .bluebutton").click(function(){
		// change iframe source, read attribute
		//if (thePlayerFrame){
    		//thePlayerFrame.src = myEmbedUrl +  $(this).attr("videoID");
	        // jump to top
	        window.scrollTo(0,0);
	       // return false;
	    //}
	});
		
	if (document.getElementById("specsTable")){
    	
	    // sync height of grid
//	    var i = 0;
//         $("#specsTable td:first-child").each(function(){
//            h1 = parseInt($("#lphProducts span:eq("+i+")").height());
//            h2 = parseInt($(this).height());
//            // set height to larger value
//            newH = (h1 > h2) ? h1 : h2;
//            //$("#lphProducts span:eq("+i+")").height(newH);
//            //$(this).height(newH);
//            i++;
//           // 
//         });
        var lpnL = $("#lphL");
        var lpnR = $("#lphR");
        lpnR.hover(
        function(){
            this.className = "rOver";
        },function(){
            this.className = "";
        });
        lpnL.hover(
        function(){
            this.className = "lOver";
        },function(){
            this.className = "";
        });
        
        if ($.browser.mozilla) $("#specsTable td").addClass("ffTd");
        else if (parseInt($.browser.version) <= 7 && $.browser.msie) $("#specsTable td").addClass("ieTd");
        
        
         
         var lpnHeight = $("#lphProducts").height();
	     lpnL.height(lpnHeight);
	     lpnR.height(lpnHeight);
	     
	    
	   
	    // change this to document.onscroll, change position
	   var topValue;
	    $(window).scroll(function(){
	       
	        topValue = document.documentElement.scrollTop;
	        //lpnL.animate({"backgroundPosition" : "0 "+ parseInt(topValue)}, "slow", "swing");
	        //lpnR.animate({"backgroundPosition" : "0 "+ parseInt(topValue)}, "slow", "swing");
	        if (topValue > (lpnHeight-150)) topValue = lpnHeight-150;
	        lpnL.css("background-position","0 "+ parseInt(topValue) +"px");
	        lpnR.css("background-position","right "+ parseInt(topValue) +"px");
	        
	    });
	   
	        //newValue = e.pageY - 550;
	      
	   
    	var lphSpecs = $("#lphSpecs");
	    lpnR.click(function(){
	       lphSpecs.animate({scrollLeft : "+=200px"}, "fast");	
	    });
	    lpnL.click(function(){
	        lphSpecs.animate({scrollLeft : "-=200px"}, "fast");	
	    });
	    $("#spGo").click(function(){
	        // read min and max of all three fields
	        var spPrice = $("#spPrice option:selected");
	        var spProcessor = $("#spProcessor option:selected");
	        var spHarddrive = $("#spHarddrive option:selected");
    	    
	        spPriceMin = parseInt(spPrice.attr("min"));
	        spPriceMax = parseInt(spPrice.attr("max"));
	        spProcessorMin = parseFloat(spProcessor.attr("min"));
	        spProcessorMax = parseFloat(spProcessor.attr("max"));
	        spHarddriveMin = parseInt(spHarddrive.attr("min"));
	        spHarddriveMax = parseInt(spHarddrive.attr("max"));
    	    
	        var j=0; // loop thru headers this is the easiest way
    	    
	        $("#specsTable tr[priceValue]").each(function(){
	            priceValue= parseInt($(this).attr("priceValue"));
	            harddriveValue = parseInt($(this).attr("harddriveValue"));
	            processorValue = parseFloat($(this).attr("processorValue"));
                // apply all
                if (priceValue > spPriceMin &&
                    priceValue <= spPriceMax &&
                    harddriveValue > spHarddriveMin &&
                    harddriveValue <= spHarddriveMax &&
                    processorValue > spProcessorMin &&
                    processorValue <= spProcessorMax){
                    
                    $(this).show();
                    $("#lphProducts div:eq("+j+")").show();
                 }else{
                    $(this).hide();
                    $("#lphProducts div:eq("+j+")").hide();
                  }
                  j++;
              
            });
            // update lphProducts height
            lpnHeight = $("#lphProducts").height();
            lpnL.height(lpnHeight);
	        lpnR.height(lpnHeight);
	        window.scrollBy(0,-1);
	    });
	}

});

