// JavaScript Document
// Copies passed text to the clipboard
	function copyToClipboard(text) {
		var range = document.body.createTextRange();
		range.findText(text);
		range.select();
		document.execCommand("Copy");
		document.execCommand("Unselect");
	}
	
popUpWin = "nowin";
function popWin(name, file, width, height, status, resizable, scrollable) {
	var h=height;
	var w=width;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',status='+status+',resizable='+resizable+',scrollbars='+scrollable;
	popUpWin = window.open( file , name, winprops );
	popUpWin.focus();
}

function closePopUp() {
	if( popUpWin != "nowin" ) {
		if( !popUpWin.closed ) {
			popUpWin.close();
		}
	}
}
function checkState(THIS, stateField) {
	//alert(THIS.value + '\n' + document.getElementById(stateField).value);
	if (THIS.value != 'US' && THIS.value != 'CA') {
		document.getElementById(stateField).value = '  ';
		//document.getElementById(stateField).disabled = 'disabled';
	}
	else {
		//alert(THIS.value);
		document.getElementById(stateField).value = '';
		//document.getElementById(stateField).disabled = '';
	}
}



function doAddressCopy() {
	var fieldList = "firstname,lastname,company,address1,address2,city,state,zipcode,country,phone";
	var i = 0;
	fieldList = fieldList.split(",");
	for (; i < fieldList.length; i++) {
		document.forms[0]["ship_" + fieldList[i]].value = document.forms[0]["bill_" + fieldList[i]].value;
	}
	
	return true;	
}

function toggleMoreBody(linkDiv, contentDiv) {
		if (document.getElementById(linkDiv).style.display == "block") {
			document.getElementById(linkDiv).style.display = "none";
			document.getElementById(contentDiv).style.display = "block";
		} else {
			document.getElementById(linkDiv).style.display = "block";
			document.getElementById(contentDiv).style.display = "none";
		}
	}
function swapNameVal(whatToSwap){
	if(whatToSwap == "color"){
		$('selectedColor').name = 'option_'+$F('colorSelector').split(',')[0];
		$('selectedColor').value = $F('colorSelector').split(',')[1];
	}
	else{
		$('selectedSize').name = 'option_'+$F('sizeSelector').split(',')[0];
		$('selectedSize').value = $F('sizeSelector').split(',')[1];
	}
}