// JavaScript Document
var bflag = false;
var catName, cat_detailH, imgName, folderName;
var vtxCatGalleryImg = new Array();
var vtxCatGalleryId = new Array();
var vtxhdArray = new Array();
var param1, param2, param3, param4, param5, param6, imgProp;
var flag =  t2Flag = t1Flag ="F";
var flag = false;
var imgWidth=320; var imgHeight=180;
var cat_detailG=catPlay1=cat_preview="";
var timerHD, bgid, selectedHeader;
var addImgPos=1;
var bgimg1, bgimg2, bgimg3, bgimg4, bgimg5, bgimg6, bgimg7, bgimg8,bgimg9,bgimg10,bgimg11,bgimg12,bgimg13,bgimg14,bgimg15,bgimg16,bgimg17,bgimg18,bgimg19,bgimg20,bgimg21,bgimg22,bgimg23,bgimg24 = new Image();

bgimg1 = "/_images/products/VideoTraxxHD/1/features_bgimg_1.jpg";
bgimg2 = "/_images/products/VideoTraxxHD/1/features_bgimg_2.jpg";
bgimg3 = "/_images/products/VideoTraxxHD/1/features_bgimg_3.jpg";
bgimg4 = "/_images/products/VideoTraxxHD/1/features_bgimg_4.jpg";
bgimg5 = "/_images/products/VideoTraxxHD/1/features_bgimg_5.jpg";
bgimg6 = "/_images/products/VideoTraxxHD/1/features_bgimg_6.jpg";
bgimg7 = "/_images/products/VideoTraxxHD/1/features_bgimg_7.jpg";
bgimg8 = "/_images/products/VideoTraxxHD/1/features_bgimg_8.jpg";
bgimg9 = "/_images/products/VideoTraxxHD/1/features_bgimg_9.jpg";
bgimg10 = "/_images/products/VideoTraxxHD/1/features_bgimg_10.jpg";
bgimg11 = "/_images/products/VideoTraxxHD/1/features_bgimg_11.jpg";
bgimg12 = "/_images/products/VideoTraxxHD/1/features_bgimg_12.jpg";
bgimg13 = "/_images/products/VideoTraxxHD/1/features_bgimg_13.jpg";
bgimg14 = "/_images/products/VideoTraxxHD/1/features_bgimg_14.jpg";
bgimg15 = "/_images/products/VideoTraxxHD/1/features_bgimg_15.jpg";
bgimg16 = "/_images/products/VideoTraxxHD/1/features_bgimg_16.jpg";
bgimg17 = "/_images/products/VideoTraxxHD/1/features_bgimg_17.jpg";
bgimg18 = "/_images/products/VideoTraxxHD/1/features_bgimg_18.jpg";
bgimg19 = "/_images/products/VideoTraxxHD/1/features_bgimg_19.jpg";
bgimg20 = "/_images/products/VideoTraxxHD/1/features_bgimg_20.jpg";
bgimg21 = "/_images/products/VideoTraxxHD/1/features_bgimg_21.jpg";
bgimg22 = "/_images/products/VideoTraxxHD/1/features_bgimg_22.jpg";
bgimg23 = "/_images/products/VideoTraxxHD/1/features_bgimg_23.jpg";
bgimg24 = "/_images/products/VideoTraxxHD/1/features_bgimg_24.jpg";

function swapvtxhd() {
	if (timerHD){ clearTimeout(timerHD); }
		if (bgid=='whats_insidebg1') {
			//$(bgid).fade(0);
			$(bgid).set('tween', { duration: 1050 }); $(bgid).tween('opacity', 1, 0);
			bgid = 'whats_insidebg2'; 
		} else { 
			//$(bgid).fade(0);
			$(bgid).set('tween', { duration: 1050 }); $(bgid).tween('opacity', 1, 0);
			bgid = 'whats_insidebg1';
		}
		$(bgid).setStyles({'background':'url('+ eval("bgimg"+addImgPos)+') no-repeat bottom right'});
		//$(bgid).fade(1);
		$(bgid).set('tween', { duration: 750 }); $(bgid).tween('opacity', 0, 1);
		addImgPos++;
		if (addImgPos >= 25) { addImgPos = 1; }
		timerHD = setTimeout("swapvtxhd()",6000);
}

function bord(id){		
	if (bflag!=false){ $(myitem).setStyles({ background: 'none', border:'none', padding:'10px 0 5px 0', color:'#3399ff'}); }
	$(id).setStyles({ background: 'transparent url(/_images/_interface/utility/20x20_50pct_transparent_cyan_tile.png) repeat top left', border:'1px solid #135', padding:'9px 0 4px 0', color:'#fff'});
	
	myitem = id;
	bflag = true;
}
function writeImage(imgName,imgID){ document.getElementById(imgID).innerHTML='<img src="'+imgName+'" height="180" width="320" alt="" class="vtximg"/>'; }


function playVtxHD(j) {
	today = new Date();
	sec = today.getSeconds();
	imgName = $(j).getProperty('vtx');
	imgType = $(j).getProperty('type');
	movName = imgName.replace(".jpg", ".mov");
	
	if (j.match(/t1/g)){ 
		folderName="Realtime_Previews"; movName=movName.replace("thumbs",folderName);
		document.getElementById(j).src="/_images/products/VideoTraxxHD/1/gallery_realtime_on_icon.gif";
		if (imgType==5){document.getElementById(j.replace("t1","t2")).src="/_images/products/VideoTraxxHD/1/gallery_slow_off_icon.gif";}
		imgID = j.replace("t1","");
	}
	if (j.match(/t2/g)){ 
		folderName="VerySlow_Previews"; movName=movName.replace("thumbs",folderName);
		document.getElementById(j).src="/_images/products/VideoTraxxHD/1/gallery_slow_on_icon.gif";
		if (imgType==5){document.getElementById(j.replace("t2","t1")).src="/_images/products/VideoTraxxHD/1/gallery_realtime_off_icon.gif";}
		imgID = j.replace("t2","");
	}
	
	if (flag != false){writeImage(param1,param2);}
	param1 = imgName;
	param2 = imgID;
	flag = true;
		
	document.getElementById(imgID).innerHTML="";
	document.getElementById(imgID).innerHTML= '<div style="border:1px solid #3399FF"><object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"'+ 
	'codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+imgWidth+'" height="'+(eval(imgHeight)+16)+'" id="movie1">'+ 
	
	'<param name="src" value="'+ movName +'?t='+ sec +'">'+ 
	'<param name="autoplay" value="true">'+
	'<param name="controller" value="true">'+
	'<param name="scale" value="aspect">'+
	'<param name="kioskmode" value="true">'+
	'<param name="enablejavascript" value="true">'+
	'<param name="loop" value="false">'+
	'<param name="bgcolor" value="#000000">'+
	'<embed width="'+ imgWidth +'" height="'+(eval(imgHeight)+16)+'" enablejavascript="true" name="movie1"'+ 
	' src="'+ movName +'?t='+ sec +'" kioskmode="true" scale="aspect" controller="true" loop="false" bgcolor="#000000"  pluginspage="http://www.apple.com/quicktime/download/">'+ 
	'</embed></object></div>';
}

function vtxhdPreview(catName,selectedHeader) {
	$('vtx-gallery').innerHTML = "";
	cat_detailG=cat_detailH=cat_preview=catPlay1="";
	for (i=0; i<vtxhdArray.length; i++){
		if (vtxhdArray[i][2]==catName){
			vtxCatGalleryImg.push(vtxhdArray[i][0]);
			vtxCatGalleryId.push(vtxhdArray[i][1]);
		}
	}
	$('vtx-gallery-header').innerHTML = "<h3 style='background:url(/_images/products/VideoTraxxHD/1/vtxhd_category_" +parseInt(selectedHeader) + ".png) no-repeat top left; height:20px; width:245px; margin-top:3px;)' class='iepngfix'></h3>";
	cat_detailH ='<ul id="content-list">'
			   + '<li style="height:auto; margin:0 0 0 15px; width:550px;">Click on button to view Animation.<br />'
			   + ' Animations have been reduced in size and overall quality for demonstration purposes.</li>';

	for (j=0; j<vtxCatGalleryImg.length; j++){		   
		cat_Img = '<li class="small-text"><div id='+ j +'><img src="http://cloudfront.public.digitaljuice.com/media/videotraxx_hd/thumbs/'+ vtxCatGalleryImg[j] + '.jpg" height="180"'
				   + ' width="320" alt="'+ vtxCatGalleryImg[j] + '" class="vtximg"/></div>' + vtxCatGalleryImg[j] ;
				   
			if (vtxCatGalleryId[j]==1) {
				catPlay1 = '<img id="' + j +'t1" src="/_images/products/VideoTraxxHD/1/gallery_realtime_off_icon.gif" height="15" width="20" class="vtx-button"'
				   + ' vtx="http://cloudfront.public.digitaljuice.com/media/videotraxx_hd/thumbs/'+ vtxCatGalleryImg[j] + '.jpg" name="' +j+'" type="'+vtxCatGalleryId[j]+'" onclick=playVtxHD("'+j+'t1") title="Realtime Previews" />';
			}
			if (vtxCatGalleryId[j]==4) {
				catPlay1 = '<img id="'+ j +'t2"'
				   + ' src="/_images/products/VideoTraxxHD/1/gallery_slow_off_icon.gif" height="15" width="20" class="vtx-button"'
				   + ' vtx="http://cloudfront.public.digitaljuice.com/media/videotraxx_hd/thumbs/'+ vtxCatGalleryImg[j] + '.jpg" name="'+j +'" type="'+vtxCatGalleryId[j]+'" onclick=playVtxHD("'+j+'t2") title="Very Slow Previews" /></li>';
			}
			if (vtxCatGalleryId[j]==5) {
				catPlay1 = '<img id="' + j +'t1" src="/_images/products/VideoTraxxHD/1/gallery_realtime_off_icon.gif" height="15" width="20" class="vtx-button"'
				   + ' vtx="http://cloudfront.public.digitaljuice.com/media/videotraxx_hd/thumbs/'+ vtxCatGalleryImg[j] + '.jpg" name="' +j+'" type="'+vtxCatGalleryId[j]+'" onclick=playVtxHD("'+j+'t1") title="Realtime Previews" />'
				   + '<img id="'+ j +'t2"'
				   + ' src="/_images/products/VideoTraxxHD/1/gallery_slow_off_icon.gif" height="15" width="20" class="vtx-button"'
				   + ' vtx="http://cloudfront.public.digitaljuice.com/media/videotraxx_hd/thumbs/'+ vtxCatGalleryImg[j] + '.jpg" name="'+j +'" type="'+vtxCatGalleryId[j]+'" onclick=playVtxHD("'+j+'t2") title="Very Slow Previews" /></li>';
			}
			
		cat_preview = cat_Img + catPlay1;
		cat_detailG = cat_detailG + cat_preview;
	}
			   
	$('vtx-gallery').innerHTML = cat_detailH + cat_detailG + '</ul>';
	while(vtxCatGalleryImg.length>0){ vtxCatGalleryImg.pop(); vtxCatGalleryId.pop(); }
}
			   
window.addEvent('domready', function() {
	var vtxCatLink = $$('.presets li img');
		vtxCatLink.each(function(element) { 
		element.addEvent('click', function(el){ 
			vtxhdPreview(element.getProperty('name'),element.getProperty('catid'));
			flag = false;
		});
	});
	vtxhdPreview("Around the House",1);

	$('whats_insidebg1').setStyles({'background':'url('+bgimg1+') no-repeat bottom right'});
	bgid = 'whats_insidebg1';
	timerHD = setTimeout("swapvtxhd()",6000);


});
