setup='';
prevSelector='';
var skuinfo=new Array();

skuinfo[11] = '9.95,Universal Fits All (Keyboard Only)';
skuinfo[111] = '14.95,11in MacBook Air (2010)';
skuinfo[112] = '14.95,11in MacBook Air (2011)';
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 (With Trackpad Button)';
skuinfo[134] = '14.95,13in MacBook Air (2 USB Ports)';
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 29x22cm';
skuinfo[505] = '16.95,16-17.5in Wide Screen 36x23cm';

		
var preload=new Array();
preload[1] = 'beauty111*beauty111.jpg,';
preload[50] = ',';
preload[11] = 'beauty1111*beauty1111.jpg,beauty1121*beauty1121.jpg,';
preload[12] = 'beauty1211*beauty1211.jpg,';
preload[13] = 'beauty1311*beauty1311.jpg,beauty1321*beauty1321.jpg,beauty1331*beauty1331.jpg,beauty1341*beauty1341.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') {
	
		jQuery("#toptab1,#toptab11,#toptab12,#toptab13,#toptab14,#toptab15,#toptab17,#toptab50,#toptab99").css({'background-color' : 'transparent', 'font-size' : '14px', 'color' : ''});
		jQuery("#tab1,#tab11,#tab12,#tab13,#tab14,#tab15,#tab17,#tab50,#tab99").css("display","none");
		
		toptabid = "#toptab" + id;
		tabid = "#tab" + id;
		jQuery(toptabid).css("background","#e5e5e5");
		jQuery(toptabid).css("fontSize","16px");
		jQuery(toptabid).css("color","#000000");
		jQuery(tabid).css("display","block");
		
		images = preload[id];
		preloadSingleImages("/Images/Products/ScreenSavrzNotebook/new/",images);
		if (id != 99) {
			jQuery("#beauty").css("display","block");
			jQuery("#beautycustom").css("display","none");
			if (id == 17) { builder(173); }
			else if (id == 11) { builder(112); }
			else { builder(id + '1'); }
		}
		else {
			jQuery("#beauty").css("display","none");
			jQuery("#beautycustom").css("display","block");
			
			custombuilder(1,jQuery('#customWidth').val(),jQuery('#customHeight').val());
		}

	}
}
function updatecustom(w,h) {
	if (!w) { w=0; }
	if (!h) { h=0; }
	if (jQuery('#customUnits').val() == "inches") {
		if (w) { 
			if (w > 18) { jQuery('#customWidth').val(18); custombuilder("",18,""); }
			else if (w < 4) { jQuery('#customWidth').val(4); custombuilder("",4,""); }
			else { custombuilder("",w,""); }
		}
		if (h) { 
			if (h > 13) { jQuery('#customHeight').val(13); custombuilder("","",13); }
			else if (h < 2) { jQuery('#customHeight').val(2); custombuilder("","",2); }
			else { custombuilder("","",h); }
		}
		
	}
	else {
		if (w) { 
			if (w > 45) { jQuery('#customWidth').val(45); custombuilder("",45,""); }
			else if (w < 10) { jQuery('#customWidth').val(10); custombuilder("",10,""); }
			else { custombuilder("",w,""); }
		}
		if (h) { 
			if (h > 33) { jQuery('#customHeight').val(33); custombuilder("","",33); }
			else if (h < 5) { jQuery('#customHeight').val(5); custombuilder("","",5); }
			else { custombuilder("","",h); }
		}
	}
	if (!w && !h) {
		if (jQuery('#customUnits').val() == "inches") {
			w = jQuery('#customWidth').val()/2.54;
			h = jQuery('#customHeight').val()/2.54;
			jQuery('#formUnits').val('i');
		}
		else {
			w = jQuery('#customWidth').val()*2.54;
			h = jQuery('#customHeight').val()*2.54;
			jQuery('#formUnits').val('c');
		}
		jQuery('#customWidth').val(w);
		jQuery('#customHeight').val(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 = jQuery('#customWidth').val();
	readh = jQuery('#customHeight').val();
	if ((readw.indexOf(".25") != -1 || readw.indexOf(".75") != -1) && jQuery('#customUnits').val() == "inches") { jQuery('#customWidth').val() = parseInt((jQuery('#customWidth').val()*100))/100; }
	else { jQuery('#customWidth').val(roundNumber(jQuery('#customWidth').val(),1)); }
	if ((readh.indexOf(".25") != -1 || readh.indexOf(".75") != -1) && jQuery('#customUnits').val() == "inches") { jQuery('#customHeight').val() = parseInt((jQuery('#customHeight').val()*100))/100; }
	else { jQuery('#customHeight').val(roundNumber(jQuery('#customHeight').val(),1)); }
	if (jQuery('#customWidth').val() == "") { jQuery('#customWidth').val(0); }
	if (jQuery('#customHeight').val() == "") { jQuery('#customHeight').val(0); }

	if (jQuery('#customUnits').val() == "inches") {
		if (w) { pixelw = w*25; jQuery("#beautycustom").css("width",pixelw); }
		if (h) { pixelh = h*25; jQuery("#beautycustom").css("height",pixelh); }
	}
	else {
		if (w) { pixelw = (w/2.54)*25; jQuery("#beautycustom").css("width",pixelw); }
		if (h) { pixelh = (h/2.54)*25; jQuery("#beautycustom").css("height",pixelh); }
	}
	if (c) {
		savedcolor = c;
		newbeauty = "beauty99" + c;
		resetcolors();
		jQuery("#color"+c).css("background-color","#666666");
		jQuery("#beautycustom").css("background-image","url(" + eval("document."+newbeauty+".src") + ")");
		jQuery("#beautycustom").css("background-position", "bottom center");
	}
	generatesku(99,savedcolor);
	
}
function builder(id) {
	if (setup == 'complete') {

		if (prevSelector) {
			selectorid="#selector" + prevSelector;
			jQuery(selectorid).css("background-position","top center");
			jQuery(selectorid).css("color","#333333");
		}
		prevSelector=id;
		selectorid="#selector" + id;
		jQuery(selectorid).css("background-position","bottom center");
		jQuery(selectorid).css("color","#000000");
		
		jQuery("#color1, #color2, #color3, #color4, #color5, #color6, #color7").css("display","block");
		
		images = allcolorpreload(id);
		preloadSingleImages("/Images/Products/ScreenSavrzNotebook/new/",images);
		
		resetcolors();
		
		if (id == "11") {
			newbeauty = "beauty" + id + "2";
			jQuery("#beauty").attr("src",eval('document.'+newbeauty+'.src'));
			
			jQuery("#color1").css("display","none");
			jQuery("#color3").css("display","none");
			generatesku(id,2);
			jQuery("#color2").css("background-color","#666666");
		}
		else if (id == "133") {
			newbeauty = "beauty" + id + "2";
			jQuery("#beauty").attr("src",eval('document.'+newbeauty+'.src'));
			
			jQuery("#color1").css("display","none");
			generatesku(id,2);
			jQuery("#color2").css("background-color","#666666");
		}
		else if (id == "111") {
			newbeauty = "beauty" + id + "2";
			jQuery("#beauty").attr("src",eval('document.'+newbeauty+'.src'));
			
			jQuery("#color1").css("display","none");
			jQuery("#color6").css("display","none");
			generatesku(id,2);
			jQuery("#color2").css("background-color","#666666");
		}
		else {
			
			newbeauty = "beauty" + id + "1";
			jQuery("#beauty").attr("src",eval('document.'+newbeauty+'.src'));
			
			jQuery("#color1").css("background-color","#666666");
			generatesku(id,1);
		}
		
		if (id == "141" || id == "142" || id == "503" || id == "504") {
			jQuery("#color3").css("display","none");
			jQuery("#color4").css("display","none");
			jQuery("#color5").css("display","none");
			jQuery("#color6").css("display","none");
		}
		if (id == "112") {
			jQuery("#color2").css("display","none");
			jQuery("#color4").css("display","none");
			jQuery("#color5").css("display","none");
			jQuery("#color7").css("display","none");
		}
		
		
		
			

		


	}
}
function color(id) {
	if (setup == 'complete') {
		resetcolors();
		colorid = "#color" + id;
		jQuery(colorid).css("background-color","#666666");
		
		if (jQuery("#beautycustom").css("display") == "block") {
			newbeauty = "beauty99" + id;
			jQuery("#beautycustom").css("background-image",'url(' + eval('document.'+newbeauty+'.src') + ')');
			jQuery("#beautycustom").css("background-position","bottom center");
			savedcolor = id;
			generatesku(99,id);
			
		}
		else {
			newbeauty = "beauty" + prevSelector + "" + id;
			jQuery("#beauty").attr("src",eval('document.'+newbeauty+'.src'));
			generatesku(prevSelector,id);
		}
	}
}
function selector(display,id) {
	if (setup == 'complete') {
		if (display == 1) {
			jQuery("#" + id).css("background-position","bottom center");
		}
		else {
			selectorid="selector" + prevSelector;
			if (selectorid != id) {
				jQuery("#" + id).css("background-position","top center");
			}
		}
	}
}
function resetcolors() {
	jQuery("#color1,#color2,#color3,#color4,#color5,#color6,#color7").css("background-color","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 == 111) {
		if(thiscolor == 1){ sku = '13263';}
		else if(thiscolor == 6){ sku = '13268';}
		else if(thiscolor == 3){ sku = '13265';}
		else if(thiscolor == 2){ sku = '13264';}
		else if(thiscolor == 4){ sku = '13266';}
		else if(thiscolor == 5){ sku = '13267';}
		else if(thiscolor == 7){ sku = '13269';}
	}else if(thissize == 112) {
		if(thiscolor == 1){ sku = '16023';}
		else if(thiscolor == 6){ sku = '16024';}
		else if(thiscolor == 3){ sku = '16025';}
	}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 == 134 || 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 = 'Fuchsia'; 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(",");
		if (sku == 13247) {
			jQuery("#prodspecs").html(parts[1] + ", " + colorname + " - $" + parts[0] + " <span style='color:#FF0000;'>(DISCONTINUED)</span>");
		}
		else {
			jQuery("#prodspecs").html(parts[1] + ", " + colorname + " - $" + parts[0]);
		}
		sssku = sku;
	}
	else {
		if (jQuery('#customUnits').val() == "inches") { units = "in"; }
		else { units = "cm"; }
		jQuery("#prodspecs").html("Custom Size: " + jQuery('#customWidth').val() + units + " by " + jQuery('#customHeight').val() + 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' || thissize == '134') { sku = '13426'; }
	if (thissize == '131') { sku = '13438'; }
	if (thissize == '151') { sku = '13432'; }
	if (thissize == '173') { sku = '13444'; }
	if (thissize == '111' || thissize == '112') { sku = '13462'; }
  }
   if ( thiscolor == 2 )
  {
  	if (thissize == '132') { sku = '13410'; }
  	if (thissize == '152') { sku = '13411'; }
  	if (thissize == '171' || thissize == '172') { sku = '13412'; }
  	if (thissize == '133' || thissize == '134') { sku = '13427'; }
	if (thissize == '131') { sku = '13439'; }
	if (thissize == '151') { sku = '13433'; }
	if (thissize == '173') { sku = '13445'; }
	if (thissize == '111' || thissize == '112') { sku = '13463'; }
  }
  if ( thiscolor == 3 )
  {
  	if (thissize == '132') { sku = '13413'; }
	if (thissize == '152') { sku = '13414'; }
  	if (thissize == '171' || thissize == '172') { sku = '13415'; }
  	if (thissize == '133' || thissize == '134') { sku = '13428'; }
	if (thissize == '131') { sku = '13440'; }
	if (thissize == '151') { sku = '13434'; }
	if (thissize == '173') { sku = '13446'; }
	if (thissize == '111' || thissize == '112') { sku = '13464'; }
  }
   if ( thiscolor == 4 )
  {
  	if (thissize == '132') { sku = '13416'; }
  	if (thissize == '152') { sku = '13417'; }
  	if (thissize == '171' || thissize == '172') { sku = '13418'; }
  	if (thissize == '133' || thissize == '134') { sku = '13429'; }
	if (thissize == '131') { sku = '13441'; }
	if (thissize == '151') { sku = '13435'; }
	if (thissize == '173') { sku = '13447'; }
	if (thissize == '111' || thissize == '112') { sku = '13465'; }
  }
  if ( thiscolor == 5 )
  {
  	if (thissize == '132') { sku = '13423'; }
	if (thissize == '152') { sku = '13424'; }
  	if (thissize == '171' || thissize == '172') { sku = '13425'; }
  	if (thissize == '133' || thissize == '134') { sku = '13430'; }
	if (thissize == '131') { sku = '13442'; }
	if (thissize == '151') { sku = '13436'; }
	if (thissize == '173') { sku = '13448'; }
	if (thissize == '111' || thissize == '112') { sku = '13466'; }
  }
  if ( thiscolor == 6 )
  {
  	if (thissize == '132') { sku = '13420'; }
	if (thissize == '152') { sku = '13421'; }
  	if (thissize == '171' || thissize == '172') { sku = '13422'; }
  	if (thissize == '133' || thissize == '134') { sku = '13431'; }
	if (thissize == '131') { sku = '13443'; }
	if (thissize == '151') { sku = '13437'; }
	if (thissize == '173') { sku = '13449'; }
	if (thissize == '111' || thissize == '112') { sku = '13467'; }
  }
  	if (sku) {
  		skuprice = '$24.95';
  		if (thissize == '171' || thissize == '172' || thissize == '173') { skuprice = '$29.95'; }
	  	jQuery("#sleevzprice").html(skuprice);
	  	jQuery("#addsleevz").css("display","block");
	  	jQuery("#add_sleevz").val(sku);
	  	jQuery("#sleevzphoto").attr("src",'/Images/Products/SleevzNotebook/btyProduct' + (thiscolor+1) + '.jpg');
  	}
  	else {
  		jQuery("#addsleevz").css("display","none");
  	}
}

function addtocart () {
	if (jQuery("#beauty").css("display")=="none") {
		jQuery("#ProdList").attr("name","");
		jQuery("#ProdId").attr("name","ProdId");
		jQuery("#ProdId").val(sssku);
		jQuery("#formWidth").val(jQuery('#customWidth').val());
		jQuery("#formHeight").val(jQuery('#customHeight').val());
	}
	else {
		jQuery("#ProdList").attr("name", "ProdList");
		jQuery("#ProdId").attr("name", "");
		if (jQuery("#add_sleevz").attr('checked')) {
			jQuery("#ProdList").val(sssku + ":1," + jQuery("#add_sleevz").val() + ":1,");
		}
		else {
			jQuery("#ProdList").val(sssku + ":1,");
		}
		return true;
	}
}
function showsleevz() {
	if (jQuery("#sleevzphoto").css("display") == 'none') {
		jQuery("#sleevzphoto").css("display","block");
	}
	else {
		jQuery("#sleevzphoto").css("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);
	}	

}

jQuery(document).ready(function () {
	buildersetup();
});
