
function checkSizeQtySubmit() {
	var check = CheckSizeQty();
	if( check ) {
		document.addToCart.target='cartAddition';
		if(typeof hideExpressShop == 'function') hideExpressShop();
	}
	return check;
}

function checkSizeQtyWishlist() {
	var check = CheckSizeQty();
	if( check ) {
		document.addToCart.target='_top';
	}
	return check;
}

function getSizeArg()
{
  var args = new Object();
  var query = location.search.substring(1);	// get the query string
  var pairs = query.split("&");				//  break at the ampersand
  for (var i=0; i<pairs.length; i++)
  {
	var pos = pairs[i].indexOf('=');		// look for name=value
	if(pos==-1) continue;					// if not found, bounce
	var argname = pairs[i].substring(0,pos);// extraction of name
	var value = pairs[i].substring(pos+1);	// extraction of value
	args[argname] = unescape(value);		// store as property, without silly characters
	if(argname=="size")
	{
		var sizeArg = args["size"];
		break;
	}
  }
  if (sizeArg) return sizeArg;
  else return false;
}
function getSearchedSize()
{
	var urlSizeArg = getSizeArg();
	if (urlSizeArg!="")
	{
		for (var p=0; p < document.addToCart.size.options.length; p++)
		{
			if (urlSizeArg == document.addToCart.size.options[p].text)
			{
 				var index = p;
				document.addToCart.size.selectedIndex=index;
			}
		}
	}
}

function CheckSizeQty() {

  if (enableCheckOut == true) {
	var product_Size = $('#size').attr('value');
	var product_Quantity = document.addToCart.quantity.selectedIndex;
	var msg="";
	if (product_Size == "" || product_Size == " " || product_Size == null) {
	  msg = "Please select a size.\n";
	  alert(msg);
	  return false;
	}
	else {
	  return true;
	}
  }
  else {
  	if(product != null){ if(product.config.page == 'pdp'){ $('#inventoryMessage').html('<span class="noSelection">'+product.config.msgs.noSelection+'</span>'); } }
	return false;
  }// end enableCheckOut
}
function GetSizeBeforeSubmit()
{
	var product_Size = $('#size').attr('value');
	if (product_Size != "" && product_Size != " " && product_Size != null)
	{
	  document.PrintPage.sizeName.value=product_Size;
	}
}
function showErrorMsg(msg) {
  var msgNN = msg.replace(/<br>/gi,"\n");
  alert(msgNN);
}

// operation:	runs through drop-down, finds matching class_style_color - selects and passes value to SwapLaydown
function SwapfromSwatch(incoming_string2,incoming_listprice,incoming_baseprice)
{
  var temp;
  done = 0;
  document.addToCart.OMColorString.value=incoming_string2;
  document.addToCart.color.value=incoming_string2;
  
  SwapPrice(incoming_listprice,incoming_baseprice);
}


// used to dynamically swap the link on the Email a Friend button
function SwapEmailFriendLink(incoming_string2)
{
  if(typeof document.EmailFriend != 'undefined') document.EmailFriend.id.value = incoming_string2;
}
// used to dynamically swap the link on the Email a Friend button
function SwapPrintLink(incoming_string2)
{
  if(typeof document.PrintPage != 'undefined') document.PrintPage.colorId.value = incoming_string2;
}
// operation:	takes the passed incoming_price and resets the price if changed
function SwapPrice(list_price,base_price)
{
	var new_text = "";
	var price_insert = "";
	var list_amount = 0;
	var base_amount = 0;
	list_amount = parseFloat(list_price).toFixed(2);
	base_amount = parseFloat(base_price).toFixed(2);
	if(Number(list_amount) > Number(base_amount)) {
		new_text = '<span class="newprice">now <em>$'+base_amount+'</em></span> <span class="maxprice">was $'+list_amount+'</span>';
	}
	else {
		new_text = '<span class="maxprice">$'+base_amount+'</span>';
	}
	$('.product_price').html(new_text);
}

function submitForm(form, button) {
	if(document.addToCart.size.value != null){
	    form.sizeSkuId.value = document.addToCart.size.value;
	}                                                
	if(document.addToCart.color.value != null){
	    form.colorProductId.value = document.addToCart.color.value;
	}  
	if(document.addToCart.OMColorString.value !=null){
	        form.color.value = (document.addToCart.OMColorString.value).substring(10,13);
	}
	if(document.addToCart.size.value !=null){
	        form.size.value = document.addToCart.size.value;
	}
	
	function CheckSizeQty_spl(x) {
	  if (enableCheckOut == true) {
	    var product_Size = document.addToCart.size.value;
	    var product_Quantity = document.addToCart.quantity.selectedIndex;
	    var msg="";
	    if (document.addToCart.size.value == "") {
	      msg = "Please select a size.\n";
	      alert(msg);
	      //document.addToCart.size.focus(); turned off because it throws an error if the email to friend window is open location of focus is lost
	      return false;
	    }
	    else {
	    hideEmailToFriend();
	    showPhoneToFriend();
	    return true;
	    }
	  }
	  else {
	    return false;
	    
	  }// end enableCheckOut
	}
	return CheckSizeQty_spl(0);
}

function submitMobile() {
	if(document.addToCart.size.value != null){
	    document.forms['PhoneFriend'].sizeSkuId.value = document.addToCart.size.value;
	}                                                
	if(document.addToCart.color.value != null){
	    document.forms['PhoneFriend'].colorProductId.value = document.addToCart.color.value;
	}  
	if(document.addToCart.OMColorString.value !=null){
	        document.forms['PhoneFriend'].color.value = (document.addToCart.OMColorString.value).substring(10,13);
	}
	if(document.addToCart.size.value !=null){
	        document.forms['PhoneFriend'].size.value = document.addToCart.size.value;
	}
	
	function CheckSizeQty_spl(x) {
	  //if (enableCheckOut == true) {
	    var product_Size = document.addToCart.size.value;
	    var product_Quantity = document.addToCart.quantity.selectedIndex;
	    var msg="";
	    if (document.addToCart.size.value == "") {
	      msg = "Please select a size.\n";
	      alert(msg);
	      //document.addToCart.size.focus(); turned off because it throws an error if the email to friend window is open location of focus is lost
	      return false;
	    }
	    else {
		hideEmailToFriend();
	    showPhoneToFriend();
		document.forms['PhoneFriend'].submit();
	    }
	  /*}
	  else {
	    return false;
	    
	  }*/// end enableCheckOut
	}
	return CheckSizeQty_spl(0);
}

/*
function showMask() {
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			$("body","html").css({height: "100%", width: "100%"});
			$("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
				$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay2'></div><div id='TB_window'></div>");
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				$("body").append("<div id='TB_overlay2'></div><div id='TB_window'></div>");
			}
		}
}
*/

function submitEmail() {                                             
	if(document.addToCart.color.value != null){
	    document.forms['EmailFriend'].id.value = document.addToCart.color.value;
	}
	hidePhoneToFriend();
	showEmailToFriend();
	document.forms['EmailFriend'].submit();
	return true;
}

function submitPrint() {
	if(document.addToCart.size.value != null){
	    document.forms['PrintPage'].sizeName.value = document.addToCart.size.value;
	}                                                
	if(document.addToCart.color.value != null){
	    document.forms['PrintPage'].colorId.value = document.addToCart.color.value;
		hideEmailToFriend();
	    hidePhoneToFriend();
	    document.forms['PrintPage'].submit();
		return false;
	}else{
		alert("Please select a color");
		return false;
	}
	
	/*function CheckSizeQty_spl(x) {
	  if (enableCheckOut == true) {
	    var product_Size = document.addToCart.size.value;
	    var product_Quantity = document.addToCart.quantity.selectedIndex;
	    var msg="";
	    if (document.addToCart.size.value == "") {
	      msg = "Please select a size.\n";
	      alert(msg);
	      //document.addToCart.size.focus(); turned off because it throws an error if the email to friend window is open location of focus is lost
	      return false;
	    }
	    else {
	    hideEmailToFriend();
	    hidePhoneToFriend();
	    document.forms['PrintPage'].submit();
	    }
	  }
	  else {
	    return false;
	    
	  }// end enableCheckOut
	}
	return CheckSizeQty_spl(0);*/
}

function hidePhoneEmailForms(){
	$("#prodform1").hide("");$("#prodform2").hide("");$("#prodform3").hide("");
}

function showPhoneEmailForms(){
	$("#prodform1").show("");$("#prodform2").show("");$("#prodform3").show("");
}
	
function showEmailToFriend(){
	$(document).ready(function() {
	hidePhoneEmailForms();
	hidePhoneToFriend();
		document.getElementById("friendBackground").className="showPhoneFriend";
		document.getElementById("sentFriend").className="showPhoneFriend";
	});
}

function hideEmailToFriend(){
	$(document).ready(function() {
		document.getElementById("sentFriend").className="hidePhoneFriend";
		document.getElementById("friendBackground").className="hidePhoneFriend";
	});
	showPhoneEmailForms();
}

function showPhoneToFriend(){
	$(document).ready(function() {
		hidePhoneEmailForms();
		hideEmailToFriend();
		document.getElementById("phoneBackground").className="showPhoneFriend";
		document.getElementById("sentPhone").className="showPhoneFriend";
	});
}

function showPhoneSuccess(){
	$(document).ready(function() {
		hidePhoneEmailForms();
		hideEmailToFriend();
		hidePhoneToFriend();
		document.getElementById("phoneSuccess").className="showPhoneFriend";
		$("#phoneSuccess").show("fast");
		document.getElementById("pSuccessContent").className="showPhoneFriend";
		});
}

function hidePhoneSuccess(){
	$(document).ready(function() {
		document.getElementById("phoneSuccess").className="hidePhoneFriend";
		$("#pSuccessContent").hide("fast");
	   });
}

function showEmailSuccess(){
	$(document).ready(function() {
		hidePhoneEmailForms();
		hideEmailToFriend();
		hidePhoneToFriend();
		document.getElementById("emailSuccess").className="showPhoneFriend";
		document.getElementById("eSuccessContent").className="showPhoneFriend";
		});
}

function hideEmailSuccess(){
	$(document).ready(function() {
		document.getElementById("emailSuccess").className="hidePhoneFriend";
		document.getElementById("eSuccessContent").className="hidePhoneFriend";
	   });
}

function hidePhoneToFriend(){
	$(document).ready(function() {
		document.getElementById("sentPhone").className="hidePhoneFriend";
		document.getElementById("phoneBackground").className="hidePhoneFriend";
	});
	showPhoneEmailForms();
}

function showPelago(){
	document.getElementById("pelago").className="showPhoneFriend";
	document.getElementById("pelagoAhref").className="showPhoneFriend";
}

function hidePelago(){
	document.getElementById("pelago").className="hidePhoneFriend";
	document.getElementById("pelagoAhref").className="hidePhoneFriend";
}

function historySet(){
 	history.back(1);
	/*this is called by the trigger on the dropdown cart to reset the back button history*/
}
//equity tooltip function
function equity_tips(bullitt, e_tt) {
	var tipLink = $(bullitt);
	var tooltip = $(e_tt);
	var qvModalObj = $('#qvModal');
	
	if(tipLink.length > 0)
	{
		if (qvModalObj.length > 0)
		{
			qvSwapTabs('description');
		}
		var tipLinkLeft = tipLink.position().left;
		var cssObj = {
			'left' : tipLinkLeft + tipLink.width() - 22 + 'px'
		};
		
		if (qvModalObj.length > 0)
		{
			qvSwapTabs('overview');
		}
		// update positioning before setting handler
		tooltip.css(cssObj);
		
		tipLink.bind('mouseover',function() {
			tooltip.show();
			ie6SelectFix('hide');
		}).bind('mouseout',function() {
			tooltip.hide();
			ie6SelectFix('show');
		});
	}
}
/*
function setFreeShipReturnMsg() {
	var height = $("#product_description").height();
}
*/
