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 showCardCodeHelp()
{
	var URL = "https://www.strapgraphics.com/cardCodeTip.html";
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=475,height=450,left = 50,top = 50');");
}

$(document).ready(function(){
    $(document).pngFix();
	
	$('#sg-home-flash').flash({   
		swf: 'flash/sg_home_flash.swf',
		width: 760,
		height: 615,
		params: {
			wmode: "transparent"
		}
	});
	
	$('#custom-flash').flash({   
		swf: 'flash/custom-flash.swf',
		width: 390,
		height: 270,
		params: {
			wmode: "transparent"
		}
	});
});

function showCustomizer()
{
	$('#designer-loader').flash({   
		swf: 'flash/designerLoader.swf',
		width: 800,
		height: 500,
		params: {
			wmode: "transparent"
		}
	});
	
	$.fn.colorbox({ inline:true, opacity:0.7, width:842, height:570, href:'#designer-loader', open:true});
}


function autoPopShipInfo()
{
	var ship_same_as_bill = document.getElementById( "ship_same_as_bill" );
	
	if( ship_same_as_bill.checked == true )
	{
		// get billing elements
		var bill_first_name = document.getElementById( "bill_first_name" );
		var bill_last_name = document.getElementById( "bill_last_name" );
		var bill_company_name = document.getElementById( "bill_company_name" );
		var bill_address_1 = document.getElementById( "bill_address_1" );
		var bill_address_2 = document.getElementById( "bill_address_2" );
		var bill_city = document.getElementById( "bill_city" );
		var bill_state = document.getElementById( "bill_state" );
		var bill_zip = document.getElementById( "bill_zip" );
		var bill_country_id = document.getElementById( "bill_country_id" );
		var bill_phone = document.getElementById( "bill_phone" );
		var bill_email = document.getElementById( "bill_email" );
		
		// get shipping elements
		var ship_first_name = document.getElementById( "ship_first_name" );
		var ship_last_name = document.getElementById( "ship_last_name" );
		var ship_company_name = document.getElementById( "ship_company_name" );
		var ship_address_1 = document.getElementById( "ship_address_1" );
		var ship_address_2 = document.getElementById( "ship_address_2" );
		var ship_city = document.getElementById( "ship_city" );
		var ship_state = document.getElementById( "ship_state" );
		var ship_zip = document.getElementById( "ship_zip" );
		var ship_country_id = document.getElementById( "ship_country_id" );
		var ship_phone = document.getElementById( "ship_phone" );
		var ship_email = document.getElementById( "ship_email" );
		
		// set ship values
		ship_first_name.value = bill_first_name.value;
		ship_last_name.value = bill_last_name.value;
		ship_company_name.value = bill_company_name.value;
		ship_address_1.value = bill_address_1.value;
		ship_address_2.value = bill_address_2.value;
		ship_city.value = bill_city.value;
		ship_state.value = bill_state.value;
		ship_zip.value = bill_zip.value;
		ship_country_id.value = bill_country_id.value;
		ship_phone.value = bill_phone.value;
		ship_email.value = bill_email.value;
	}
}

function disablePlaceOrder()
{
	$('#top_place_order').innerHTML = "Processing your order. Please wait.";
	$('#lower_place_order').innerHTML = "Processing your order. Please wait.";
}