setup='';
prevSelector='';
var skuinfo=new Array();

skuinfo[11] = '9.95,Universal Fits All (Keyboard Only)';
skuinfo[121] = '14.95,12in iBook/PowerBook';
skuinfo[131] = '14.95,13in UniBody MacBook and MacBook Pro';
skuinfo[132] = '14.95,13in Plastic MacBook';
skuinfo[133] = '14.95,13in MacBook Air';
skuinfo[141] = '14.95,14in iBook';
skuinfo[142] = '14.95,12-14in PowerBook G3';
skuinfo[151] = '16.95,15in UniBody MacBook Pro';
skuinfo[152] = '14.95,15in MacBook Pro';
skuinfo[153] = '14.95,15in PowerBook';
skuinfo[171] = '16.95,17in MacBook Pro';
skuinfo[172] = '16.95,17in PowerBook';
skuinfo[173] = '16.95,17in UniBody MacBook Pro';

skuinfo[501] = '16.95,12-13.8in Standard Screen 26x20cm';
skuinfo[502] = '14.95,12-13.8in Wide Screen 31x21cm';
skuinfo[503] = '14.95,14-15.5in Wide Screen 32x21cm';
skuinfo[504] = '16.95,14-17in Standard Screen 29x32cm';
skuinfo[505] = '16.95,16-17.5in Wide Screen 36x23cm';

		
var preload=new Array();
preload[1] = 'beauty111*beauty111.jpg,';
preload[50] = ',';
preload[12] = 'beauty1211*beauty1211.jpg,';
preload[13] = 'beauty1311*beauty1311.jpg,beauty1321*beauty1321.jpg,beauty1331*beauty1331.jpg,';
preload[14] = 'beauty1411*beauty1411.jpg,beauty1421*beauty1421.jpg,';
preload[15] = 'beauty1511*beauty1511.jpg,beauty1521*beauty1521.jpg,beauty1531*beauty1531.jpg,';
preload[17] = 'beauty1711*beauty1711.jpg,beauty1721*beauty1721.jpg,beauty1731*beauty1731.jpg,';
preload[50] = 'beauty5011*beauty5011.jpg,beauty5021*beauty5021.jpg,beauty5031*beauty5031.jpg,beauty5041*beauty5041.jpg,beauty5051*beauty5051.jpg,';
preload[99] = 'beauty991*beauty991.jpg,beauty992*beauty992.jpg,beauty993*beauty993.jpg,beauty994*beauty994.jpg,beauty995*beauty995.jpg,beauty996*beauty996.jpg,beauty997*beauty997.jpg,';
imagedir = "/Images/Products/ScreenSavrzNotebook/new/";

function allcolorpreload(id) {

	btystring = "beauty" + id + "2*beauty" + id + "2.jpg,";
	btystring += "beauty" + id + "3*beauty" + id + "3.jpg,";
	btystring += "beauty" + id + "4*beauty" + id + "4.jpg,";
	btystring += "beauty" + id + "5*beauty" + id + "5.jpg,";
	btystring += "beauty" + id + "6*beauty" + id + "6.jpg,";
	btystring += "beauty" + id + "7*beauty" + id + "7.jpg,";

	return btystring;
}

function tab(id) {
	if (setup == 'complete') {
		$("toptab1").style.background="transparent"; $("toptab1").style.fontSize="14px"; $("toptab1").style.color=""; $("tab1").style.display="none";
		$("toptab12").style.background="transparent"; $("toptab12").style.fontSize="14px"; $("toptab12").style.color=""; $("tab12").style.display="none";
		$("toptab13").style.background="transparent"; $("toptab13").style.fontSize="14px"; $("toptab13").style.color=""; $("tab13").style.display="none";
		$("toptab14").style.background="transparent"; $("toptab14").style.fontSize="14px"; $("toptab14").style.color=""; $("tab14").style.display="none";
		$("toptab15").style.background="transparent"; $("toptab15").style.fontSize="14px"; $("toptab15").style.color=""; $("tab15").style.display="none";
		$("toptab17").style.background="transparent"; $("toptab17").style.fontSize="14px"; $("toptab17").style.color=""; $("tab17").style.display="none";
		$("toptab50").style.background="transparent"; $("toptab50").style.fontSize="14px"; $("toptab50").style.color=""; $("tab50").style.display="none";
		$("toptab99").style.background="transparent"; $("toptab99").style.fontSize="14px"; $("toptab99").style.color=""; $("tab99").style.display="none";
		toptabid = "toptab" + id;
		tabid = "tab" + id;
		$(toptabid).style.background="#e5e5e5";
		$(toptabid).style.fontSize="16px";
		$(toptabid).style.color="#000000";
		$(tabid).style.display="block";
		
		images = preload[id];
		preloadSingleImages("/Images/Products/ScreenSavrzNotebook/new/",images);
		if (id != 99) {
			$("beauty").style.display="block";
			$("beautycustom").style.display="none";
			if (id != 17) { builder(id + '1'); }
			else { builder(173); }
		}
		else {
			$("beauty").style.display="none";
			$("beautycustom").style.display="block";
			custombuilder(1,$('customWidth').value,$('customHeight').value);
		}

	}
}
function updatecustom(w,h) {
	if ($('customUnits').value == "inches") {
		if (w) { 
			if (w > 18) { $('customWidth').value = '18'; custombuilder("",18,""); }
			else if (w < 4) { $('customWidth').value = '4'; custombuilder("",4,""); }
			else { custombuilder("",w,""); }
		}
		if (h) { 
			if (h > 13) { $('customHeight').value = '13'; custombuilder("","",13); }
			else if (h < 2) { $('customHeight').value = '2'; custombuilder("","",2); }
			else { custombuilder("","",h); }
		}
		
	}
	else {
		if (w) { 
			if (w > 45) { $('customWidth').value = '45'; custombuilder("",45,""); }
			else if (w < 10) { $('customWidth').value = '10'; custombuilder("",10,""); }
			else { custombuilder("",w,""); }
		}
		if (h) { 
			if (h > 33) { $('customHeight').value = '33'; custombuilder("","",33); }
			else if (h < 5) { $('customHeight').value = '5'; custombuilder("","",5); }
			else { custombuilder("","",h); }
		}
	}
	if (!w && !h) {
		if ($('customUnits').value == "inches") {
			w = $('customWidth').value/2.54;
			h = $('customHeight').value/2.54;
			$('formUnits').value = 'i';
		}
		else {
			w = $('customWidth').value*2.54;
			h = $('customHeight').value*2.54;
			$('formUnits').value = 'c';
		}
		$('customWidth').value = w;
		$('customHeight').value = h;
		updatecustom(w,h);
	}
	
}
function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}
function custombuilder(c,w,h) {
	readw = $('customWidth').value;
	readh = $('customHeight').value;
	if ((readw.indexOf(".25") != -1 || readw.indexOf(".75") != -1) && $('customUnits').value == "inches") { $('customWidth').value = parseInt(($('customWidth').value*100))/100; }
	else { $('customWidth').value = roundNumber($('customWidth').value,1); }
	if ((readh.indexOf(".25") != -1 || readh.indexOf(".75") != -1) && $('customUnits').value == "inches") { $('customHeight').value = parseInt(($('customHeight').value*100))/100; }
	else { $('customHeight').value = roundNumber($('customHeight').value,1); }
	if (isNaN($('customWidth').value)) { $('customWidth').value = 0; }
	if (isNaN($('customHeight').value)) { $('customHeight').value = 0; }

	if ($('customUnits').value == "inches") {
		if (w) { pixelw = w*25; $("beautycustom").style.width=pixelw + 'px'; }
		if (h) { pixelh = h*25; $("beautycustom").style.height=pixelh + 'px'; }
	}
	else {
		if (w) { pixelw = (w/2.54)*25; $("beautycustom").style.width=pixelw + 'px'; }
		if (h) { pixelh = (h/2.54)*25; $("beautycustom").style.height=pixelh + 'px'; }
	}
	if (c) {
		savedcolor = c;
		newbeauty = "beauty99" + c;
		resetcolors();
		$("color"+c).style.background="#666666";
		$("beautycustom").style.background = 'url(' + eval('document.'+newbeauty+'.src') + ')';
		$("beautycustom").style.backgroundPosition = 'bottom center';
	}
	generatesku(99,savedcolor);
	
}
function builder(id) {
	if (setup == 'complete') {
		if (id )
		if (prevSelector) {
			selectorid="selector" + prevSelector;
			$(selectorid).style.backgroundPosition="top center";
			$(selectorid).style.color="#333333";
		}
		prevSelector=id;
		selectorid="selector" + id;
		$(selectorid).style.backgroundPosition="bottom center";
		$(selectorid).style.color="#000000";
		newbeauty = "beauty" + id + "1";
		$("beauty").src = eval('document.'+newbeauty+'.src');
		images = allcolorpreload(id);
		preloadSingleImages("/Images/Products/ScreenSavrzNotebook/new/",images);
		resetcolors();
		$("color1").style.background="#666666";
		generatesku(id,1);
	}
}
function color(id) {
	if (setup == 'complete') {
		resetcolors();
		colorid = "color" + id;
		$(colorid).style.background="#666666";
		
		if ($("beautycustom").style.display=="block") {
			newbeauty = "beauty99" + id;
			$("beautycustom").style.background = 'url(' + eval('document.'+newbeauty+'.src') + ')';
			$("beautycustom").style.backgroundPosition = 'bottom center';
			savedcolor = id;
			generatesku(99,id);
			
		}
		else {
			newbeauty = "beauty" + prevSelector + "" + id;
			$("beauty").src = eval('document.'+newbeauty+'.src');
			generatesku(prevSelector,id);
		}
	}
}
function selector(display,id) {
	if (setup == 'complete') {
		if (display == 1) {
			$(id).style.backgroundPosition="bottom center";
		}
		else {
			selectorid="selector" + prevSelector;
			if ($(selectorid) != $(id)) {
				$(id).style.backgroundPosition="top center";
			}
		}
	}
}
function resetcolors() {
	$("color1").style.background="transparent";
	$("color2").style.background="transparent";
	$("color3").style.background="transparent";
	$("color4").style.background="transparent";
	$("color5").style.background="transparent";
	$("color6").style.background="transparent";
	$("color7").style.background="transparent";
}

function generatesku(thissize,thiscolor) {
	sku='';
	if(thissize == 11){
		if(thiscolor == 1){ sku = '13291';}
		else if(thiscolor == 6){ sku = '13296';}
		else if(thiscolor == 3){ sku = '13293';}
		else if(thiscolor == 2){ sku = '13292';}
		else if(thiscolor == 4){ sku = '13294';}
		else if(thiscolor == 5){ sku = '13295';}
		else if(thiscolor == 7){ sku = '13297';}
	}else if(thissize == 121 || thissize == 501){
		if(thiscolor == 1){ sku = '13202';}
		else if(thiscolor == 6){ sku = '13277';}
		else if(thiscolor == 3){ sku = '13221';}
		else if(thiscolor == 2){ sku = '13217';}
		else if(thiscolor == 4){ sku = '13218';}
		else if(thiscolor == 5){ sku = '13219';}
		else if(thiscolor == 7){ sku = '13241';}
	}else if(thissize == 131 || thissize == 132 || thissize == 502){
		if(thiscolor == 1){ sku = '13209';}
		else if(thiscolor == 6){ sku = '13280';}
		else if(thiscolor == 3){ sku = '13229';}
		else if(thiscolor == 2){ sku = '13230';}
		else if(thiscolor == 4){ sku = '13231';}
		else if(thiscolor == 5){ sku = '13232';}
		else if(thiscolor == 7){ sku = '13244';}
	}else if(thissize == 133){
		if(thiscolor == 1){ sku = '13281';}
		else if(thiscolor == 6){ sku = '13286';}
		else if(thiscolor == 3){ sku = '13283';}
		else if(thiscolor == 2){ sku = '13282';}
		else if(thiscolor == 4){ sku = '13284';}
		else if(thiscolor == 5){ sku = '13285';}
		else if(thiscolor == 7){ sku = '13287';}
	}else if(thissize == 152 || thissize == 153 || thissize == 503){
		if(thiscolor == 1){ sku = '13201';}
		else if(thiscolor == 6){ sku = '13276';}
		else if(thiscolor == 3){ sku = '13220';}
		else if(thiscolor == 2){ sku = '13250';}
		else if(thiscolor == 4){ sku = '13251';}
		else if(thiscolor == 5){ sku = '13252';}
		else if(thiscolor == 7){ sku = '13240';}
	}else if(thissize == 141 || thissize == 142 || thissize == 504){
		if(thiscolor == 1){ sku = '13203';}
		else if(thiscolor == 6){ sku = '13278';}
		else if(thiscolor == 3){ sku = '13222';}
		else if(thiscolor == 2){ sku = '13245';}
		else if(thiscolor == 4){ sku = '13246';}
		else if(thiscolor == 5){ sku = '13247';}
		else if(thiscolor == 7){ sku = '13242';}
	}else if(thissize == 171 || thissize == 172 || thissize == 505){
		if(thiscolor == 1){ sku = '13253';}
		else if(thiscolor == 6){ sku = '13258';}
		else if(thiscolor == 3){ sku = '13255';}
		else if(thiscolor == 2){ sku = '13254';}
		else if(thiscolor == 4){ sku = '13256';}
		else if(thiscolor == 5){ sku = '13257';}
		else if(thiscolor == 7){ sku = '13259';}
	}else if(thissize == 173){
		if(thiscolor == 1){ sku = '13253';}
		else if(thiscolor == 6){ sku = '13258';}
		else if(thiscolor == 3){ sku = '13255';}
		else if(thiscolor == 2){ sku = '13254';}
		else if(thiscolor == 4){ sku = '13256';}
		else if(thiscolor == 5){ sku = '13257';}
		else if(thiscolor == 7){ sku = '13259';}
	}else if(thissize == 151){
		if(thiscolor == 1){ sku = '13233';}
		else if(thiscolor == 6){ sku = '13238';}
		else if(thiscolor == 3){ sku = '13235';}
		else if(thiscolor == 2){ sku = '13234';}
		else if(thiscolor == 4){ sku = '13236';}
		else if(thiscolor == 5){ sku = '13237';}
		else if(thiscolor == 7){ sku = '13239';}
	}else if(thissize == 99){
		if(thiscolor == 1){ sku = '13233';}
		else if(thiscolor == 6){ sku = '13238';}
		else if(thiscolor == 3){ sku = '13235';}
		else if(thiscolor == 2){ sku = '13234';}
		else if(thiscolor == 4){ sku = '13236';}
		else if(thiscolor == 5){ sku = '13237';}
		else if(thiscolor == 7){ sku = '13239';}
	}
	
	
	colorname="";
	if(thiscolor == 1){ colorname = 'Gray'; customsku = "12105"}
	else if(thiscolor == 2){ colorname = 'Fuschia'; customsku = "12106"}
	else if(thiscolor == 3){ colorname = 'Indigo'; customsku = "12107"}
	else if(thiscolor == 4){ colorname = 'Green'; customsku = "12108"}
	else if(thiscolor == 5){ colorname = 'Grape'; customsku = "12109"}
	else if(thiscolor == 6){ colorname = 'Black'; customsku = "12110"}
	else if(thiscolor == 7){ colorname = 'Shagwire'; customsku = "12111"}
	var parts = new Array();
	if (thissize != 99){
		temp = skuinfo[thissize];
		parts = temp.split(",");
		$("prodspecs").innerHTML = parts[1] + ", " + colorname + " - $" + parts[0];
		sssku = sku;
	}
	else {
		if ($('customUnits').value == "inches") { units = "in"; }
		else { units = "cm"; }
		$("prodspecs").innerHTML = "Custom Size: " + $('customWidth').value + units + " by " + $('customHeight').value + units + ", " + colorname + " - $" + 17.95
		sssku = customsku;
	}
	generatesleevzsku(thissize,thiscolor);
}




function generatesleevzsku(thissize,thiscolor) {
	sku='';
	  if ( thiscolor == 1 )
  {
  	if (thissize == '132') { sku = '13409'; }
  	if (thissize == '152') { sku = '13408'; }
	if (thissize == '171' || thissize == '172') { sku = '13406'; }
	if (thissize == '153') { sku = '13407'; }
	if (thissize == '133') { sku = '13426'; }
	if (thissize == '131') { sku = '13438'; }
	if (thissize == '151') { sku = '13432'; }
	if (thissize == '173') { sku = '13444'; }
  }
   if ( thiscolor == 2 )
  {
  	if (thissize == '132') { sku = '13410'; }
  	if (thissize == '152') { sku = '13411'; }
  	if (thissize == '171' || thissize == '172') { sku = '13412'; }
  	if (thissize == '133') { sku = '13427'; }
	if (thissize == '131') { sku = '13439'; }
	if (thissize == '151') { sku = '13433'; }
	if (thissize == '173') { sku = '13445'; }
  }
  if ( thiscolor == 3 )
  {
  	if (thissize == '132') { sku = '13413'; }
	if (thissize == '152') { sku = '13414'; }
  	if (thissize == '171' || thissize == '172') { sku = '13415'; }
  	if (thissize == '133') { sku = '13428'; }
	if (thissize == '131') { sku = '13440'; }
	if (thissize == '151') { sku = '13434'; }
	if (thissize == '173') { sku = '13446'; }
  }
   if ( thiscolor == 4 )
  {
  	if (thissize == '132') { sku = '13416'; }
  	if (thissize == '152') { sku = '13417'; }
  	if (thissize == '171' || thissize == '172') { sku = '13418'; }
  	if (thissize == '133') { sku = '13429'; }
	if (thissize == '131') { sku = '13441'; }
	if (thissize == '151') { sku = '13435'; }
	if (thissize == '173') { sku = '13447'; }
  }
  if ( thiscolor == 5 )
  {
  	if (thissize == '132') { sku = '13423'; }
	if (thissize == '152') { sku = '13424'; }
  	if (thissize == '171' || thissize == '172') { sku = '13425'; }
  	if (thissize == '133') { sku = '13430'; }
	if (thissize == '131') { sku = '13442'; }
	if (thissize == '151') { sku = '13436'; }
	if (thissize == '173') { sku = '13448'; }
  }
  if ( thiscolor == 6 )
  {
  	if (thissize == '132') { sku = '13420'; }
	if (thissize == '152') { sku = '13421'; }
  	if (thissize == '171' || thissize == '172') { sku = '13422'; }
  	if (thissize == '133') { sku = '13431'; }
	if (thissize == '131') { sku = '13443'; }
	if (thissize == '151') { sku = '13437'; }
	if (thissize == '173') { sku = '13449'; }
  }
  	if (sku) {
  		skuprice = '$24.95';
  		if (thissize == '171' || thissize == '172' || thissize == '173') { skuprice = '$29.95'; }
	  	$("sleevzprice").innerHTML = skuprice;
	  	$("addsleevz").style.display = 'block';
	  	$("add_sleevz").value = sku;
	  	$("sleevzphoto").src = '/Images/Products/SleevzNotebook/btyProduct' + (thiscolor+1) + '.jpg';
  	}
  	else {
  		$("addsleevz").style.display = 'none';
  	}
}

function addtocart () {
	if ($("beauty").style.display=="none") {
		$("ProdList").name = "";
		$("ProdId").name = "ProdId";
		$("ProdId").value = sssku;
		$("formWidth").value = $('customWidth').value;
		$("formHeight").value = $('customHeight').value;
	}
	else {
		$("ProdList").name = "ProdList";
		$("ProdId").name = "";
		if ($("add_sleevz").checked == true) {
			$("ProdList").value = sssku + ":1," + $("add_sleevz").value + ":1,";
		}
		else {
			$("ProdList").value = sssku + ":1,";
		}
		return true;
	}
}
function showsleevz() {
	if ($("sleevzphoto").style.display == 'none') {
		$("sleevzphoto").style.display = 'block';
	}
	else {
		$("sleevzphoto").style.display = 'none';
	}
}

function buildersetup() {
	setup = 'complete';
	prevSelector='';
	var OSName="Unknown OS";	
	if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
	if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
	if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
	if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";

	if( OSName == "Windows" ) {
		tab(50);
		builder(501);
		color(1);
	}
	else {
		tab(15);
		color(6);
	}	

}

Element.observe(document, 'dom:loaded', function(){
	buildersetup();
});