/*
 * SimpleModal Basic Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2009 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: jQueryId: basic.js 185 2009-02-09 21:51:12Z emartin24 jQuery
 *
 */

jQuery(document).ready(function () {
	
	jQuery('.viewDetail').click(function (e) {
		e.preventDefault();
		jQuery('#viewDetailModal').modal();
	});
	

	
	
});


/*jQuery(document).ready(function () {
	jQuery("div.subnav").corner("br bl 20px");
	jQuery("#nav1 > div.subnav").corner("tr round 20px").css('padding-top', '25px');
	jQuery("#nav2 > div.subnav").corner("tr round 20px").css('padding-top', '25px');
	jQuery("#nav3 > div.subnav").corner("tr round 20px").css('padding-top', '25px');
	
});*/




/* END SimpleModal Basic Modal Dialog */

jQuery(document).ready( function () {
	jQuery(".modifyorder").click( function () {
		jQuery("#modifyorderPop").show();
		return false;
	});
});

jQuery(document).ready( function () {
	jQuery(".addaddress").click( function () {
		jQuery("#addaddressPop").show();
		return false;
	});
});

jQuery(document).ready( function () {
	jQuery(".whatis").click( function () {
		jQuery("#whatisPop").show();
		return false;
	});
});

// shipPolicy links direct to shipping policy page
//jQuery(document).ready( function () {
//	jQuery(".shipPolicy").click( function () {
//		jQuery("#shipPolicyPop").show();
//		return false;
//	});
//});



jQuery(document).ready( function () {
	jQuery("#topSearches").click( function () {
		jQuery("#topSearchPop").show();
		return false;
	});
});

jQuery(document).ready( function () {
	jQuery(".chart").click( function () {
		jQuery("#sizeChartPop").show();
		return false;
	});
});

jQuery(document).ready( function () {
	jQuery(".blind").click( function () {
		jQuery("#blindPop").show();
		return false;
	});
});


jQuery(document).ready( function () {					 	
	jQuery(".forgot").click( function () {
		jQuery("#forgotPop").show();
		return false;
	});
});
jQuery(document).ready( function () {					 	
	jQuery(".balance").click( function () {
		jQuery("#balancePop").show();
		return false;
	});
});

/*
jQuery(document).ready( function () {
	jQuery("#cart").click( function () {
		jQuery("#cartPop").show();
		return false;
	});
});
*/

jQuery(document).ready( function () {
	jQuery("#shareFriend").click( function () {
		jQuery("#sharePop").show();
		return false;
	});
});



jQuery(document).ready( function () {
	jQuery(".close").click( function () {
		jQuery(this).parent().hide();
	});
});


jQuery(document).ready( function () {
	jQuery(".checkoutbtn").mouseover( function () {
		jQuery(this).attr("src","images/checkout_off.gif");
	});
	jQuery(".checkoutbtn").mouseout( function () {
		jQuery(this).attr("src","images/checkout.gif");
	});
});

/*jQuery(document).ready(function(){
  jQuery("#topSearches").bind("click", function(e) {
	  e.stopPropagation(); // Stops the following click function from being executed
	  jQuery("#topSearchPop").show();
	  e.stopPropagation(); // Stops the following click function from being executed
	  jQuery(document).one("click", function(f) {
		  jQuery("#topSearchPop").hide();
	  });
  });
});*/




jQuery(document).ready(function () {
	jQuery("#nav").children("li").hover(
		function () {
			jQuery(this).addClass("current");
		},
		function () {
			jQuery(this).removeClass("current");
		}
	);
	
	jQuery(".subnav").children("li").hover(
		function () {
			jQuery(this).addClass("current");
		},
		function () {
			jQuery(this).removeClass("current");
		}
	);
});

jQuery(document).ready(function () {
	
	jQuery("#nav").children("li").hover(
		function () {
			jQuery(this).addClass("hover");
		},
		function () {
			jQuery(this).removeClass("hover");
		}
	);
});

function Comma(number) {
	number = '' + number;
	if (number.length > 6) {
		var output = number.substring(0, number.length-6);
		output = output + ',';
		output = output + number.substring(number.length-6)
		return (output);
	}
	else 
		return number;
}

function handleGPrice(r) {
	if(r) {
		jQuery.cookie("gd", r, {path: '/'});
	}
	gd = jQuery.cookie("gd");
	if(gd && jQuery('.dprice').length == 0) {
		jQuery('.nprice').each(function() {
			jQuery(this).css('text-decoration', 'line-through');
			var nprice = jQuery(this).text().replace(" ", "").replace(",", "").replace("$","");
			var dprice = (nprice * ((100- gd) / 100)).toFixed(2);
			jQuery(this).after("<span class=\"dprice\">$" + Comma(dprice) + "</span>")
		});
		
		jQuery('#volume_qty').each(function() {
			var nprice = jQuery('.nprice').text().replace(" ", "").replace(",", "").replace("$","");
			var volume_price = ((nprice * ((100- gd) / 100)) * jQuery(this).text()).toFixed(2);
			jQuery('#volume_price').text("$" + Comma(volume_price));
			
		});
	}
}

function deleteGPrice() {
	jQuery.cookie("gd", null, {path: '/'} );
}

jQuery(document).ready(function () {
	handleGPrice();
});

