// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function chooseShirt(id) {
	shirtlink = $(id).value;
	window.location='http://www.reruntees.com/shirts/'+shirtlink+'/'+id;	
}

function updateColorBox(value) {
		if(value=='White')	$('colorBox').className = 'largeBox whiteBox';
		else if(value == 'Ash') $('colorBox').className = 'largeBox ashBox';
		else if(value == 'Light Steel') $('colorBox').className = 'largeBox lightSteelBox';
		else if(value == 'Black') $('colorBox').className = 'largeBox blackBox';
		else if(value == 'Deep Forest') $('colorBox').className = 'largeBox forestBox';
		else if(value == 'Kelly Green') $('colorBox').className = 'largeBox kellyBox';
		else if(value == 'Lime Green') $('colorBox').className = 'largeBox limeBox';
		else if(value == 'Navy Blue') $('colorBox').className = 'largeBox navyBox';
		else if(value == 'Deep Royal') $('colorBox').className = 'largeBox deepRoyalBox';
		else if(value == 'Carolina Blue') $('colorBox').className = 'largeBox carolinaBox';
		else if(value == 'Light Blue') $('colorBox').className = 'largeBox lightBlueBox';
		else if(value == 'Deep Red') $('colorBox').className = 'largeBox deepRedBox';
		else if(value == 'Cardinal') $('colorBox').className = 'largeBox cardinalBox';
		else if(value == 'Orange') $('colorBox').className = 'largeBox orangeBox';
		else if(value == 'Texas Orange') $('colorBox').className = 'largeBox texasOrangeBox';
		else if(value == 'Gold') $('colorBox').className = 'largeBox goldBox';
		else if(value == 'Natural') $('colorBox').className = 'largeBox naturalBox';
		else if(value == 'Yellow') $('colorBox').className = 'largeBox yellowBox';
		else if(value == 'Pink') $('colorBox').className = 'largeBox pinkBox';
		else if(value == 'Purple') $('colorBox').className = 'largeBox purpleBox';
		else if(value == 'Baby Blue') $('colorBox').className = 'largeBox lightBlueBox';
		else if(value == 'Heather') $('colorBox').className = 'largeBox lightSteelBox';
		else if(value == 'Brown') $('colorBox').className = 'largeBox brownBox';
		else if(value == 'Olive') $('colorBox').className = 'largeBox oliveBox';
		else if(value == 'Red') $('colorBox').className = 'largeBox deepRedBox';
		else if(value == 'Charcoal') $('colorBox').className = 'largeBox charcoalBox';
		else if(value == 'Moss') $('colorBox').className = 'largeBox mossBox';
}

function updateColorChoice(value, color, condition) {
	if(condition) {
		$('colorChoice').value = value;
	} else {
		$('colorChoice').value = color;
	}
}


function updateSizeChoice(value, color, condition) {
	if(condition) {
		$('sizeChoice').value = value;
	} else {
		$('sizeChoice').value = color;
	}
}


function removeCartItem(id) {
	if(id) {
		$('cartItem').value = id;
		$('cartAction').value = 'REMOVE';
		$('cartBtn').click();
	}
}

function showColors(value) {

	if($('smColor')) 
		$('smColor').style.display='none';
	if($('medColor')) 
		$('medColor').style.display='none';
	if($('lrgColor')) 
		$('lrgColor').style.display='none';
	if($('xlColor')) 
		$('xlColor').style.display='none';
	if($('xxlColor')) 
		$('xxlColor').style.display='none';
	if($('xxxlColor')) 
		$('xxxlColor').style.display='none';
	
	if(value=='S') {
		$('smColor').style.display='';
		$('color').value = $('smColor').options[$('smColor').selectedIndex].value;
	}
	else if(value=='M') {
		$('medColor').style.display='';
		$('color').value = $('medColor').options[$('medColor').selectedIndex].value;
	}
	else if(value=='L') {
		$('lrgColor').style.display='';
		$('color').value = $('lrgColor').options[$('lrgColor').selectedIndex].value;
	}
	else if(value=='XL') {
		$('xlColor').style.display='';
		$('color').value = $('xlColor').options[$('xlColor').selectedIndex].value;
	}
	else if(value=='XXL') {
		$('xxlColor').style.display='';
		$('color').value = $('xxlColor').options[$('xxlColor').selectedIndex].value;
	}
	else if(value=='XXXL') {
		$('xxxlColor').style.display='';
		$('color').value = $('xxxlColor').options[$('xxxlColor').selectedIndex].value;
	}

}
	
function iePNGFix(path, scale) {
	if ( /MSIE (5\.5|6\.)/.test(navigator.userAgent) &&
           navigator.platform == "Win32" ) {
	  var elements = document.getElementsByTagName('img');
	  if ( elements != null ) {
	    for ( var i = 0; i < elements.length; i++ ) {
	      if ( ! elements[i].src ) continue;
	      if ( /\.png$/.test(elements[i].src.toLowerCase()) ) {
	          // set filter
						if(scale) {
	        		elements[i].style.filter =
	              "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
	                              elements[i].src + "',sizingMethod='scale')";
						
						} else {
							elements[i].style.filter =
	              "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
	                              elements[i].src + "',sizingMethod='image')";
						}
	        elements[i].src = path+'/img/blank.gif';
	      }  
	    }  
	  }  
	} 
}
