// Email Clock -  usage: <span class="emailCloak">sales(at)website.com</span>
function emailCloak() {
	if (document.getElementById) {
		var alltags = document.all? document.all : document.getElementsByTagName("*");
		for (i=0; i < alltags.length; i++) {
		if (alltags[i].className == "emailCloak") {
		var oldText = alltags[i].firstChild;
		var emailAddress = alltags[i].firstChild.nodeValue;
		var user = emailAddress.substring(0, emailAddress.indexOf("("));
		var website = emailAddress.substring(emailAddress.indexOf(")")+1, emailAddress.length);
		var newText = user+"@"+website;
		var a = document.createElement("a");
		a.href = "mailto:"+newText;
		var address = document.createTextNode(newText);
		a.appendChild(address);
		alltags[i].replaceChild(a,oldText);
		}
	}
  }
}
window.onload = emailCloak;

$(document).ready(function(){
	
	// Start Fancy Box
	$("a#fancybox").fancybox({
		'zoomSpeedIn' : 500,
		'zoomSpeedOut' : 500
	});
	// End Fancybox
	
	// Start Cart Slider
	$("div#cart_slider").slideDown("slow");
	$("#no_thank_you").click(function(){
		$("div#cart_slider").slideUp("slow");
    });

	// End Cart Slider	
	
	// Start Tabs
	//$("#tabs").tabs();
	// End Tabs	
	
	// beautify the legends
	$('fieldset legend').wrap('<div class="legend"></div>');
	$('input.required').prev('label').append('<span class="helper-required">&nbsp;*</span>');

	// POPUPS
	// to use this just give any link a class of popupwindow and then choose from one of the profiles below, put the profile in the rel attribute
	// example: <a href="/cart/cvv_code.cfm" class="popupwindow" rel="windowCenter6x6">More Info</a>
	// or you can create your own (put these in the rel attribute): height:550,width:750,toolbar:1,scrollbars:1,status:1,resizable:0,left:50,top:100 
	jQuery.fn.popupwindow=function(p){var profiles=p||{};return this.each(function(index){var settings,parameters,mysettings,b,a;mysettings=(jQuery(this).attr("rel")||"").split(",");settings={height:600,width:600,toolbar:0,scrollbars:0,status:0,resizable:1,left:0,top:0,center:0,createnew:1,location:0,menubar:0};if(mysettings.length==1&&mysettings[0].split(":").length==1){a=mysettings[0];if(typeof profiles[a]!="undefined"){settings=jQuery.extend(settings,profiles[a]);}}else{for(var i=0;i<mysettings.length;i++){b=mysettings[i].split(":");if(typeof settings[b[0]]!="undefined"&&b.length==2){settings[b[0]]=b[1];}}}if(settings.center==1){settings.top=(screen.height-(settings.height+110))/2;settings.left=(screen.width-settings.width)/2;}parameters="location="+settings.location+",menubar="+settings.menubar+",height="+settings.height+",width="+settings.width+",toolbar="+settings.toolbar+",scrollbars="+settings.scrollbars+",status="+settings.status+",resizable="+settings.resizable+",left="+settings.left+",screenX="+settings.left+",top="+settings.top+",screenY="+settings.top;jQuery(this).bind("click",function(){var name=settings.createnew?"PopUpWindow"+index:"PopUpWindow";window.open(this.href,name,parameters).focus();return false;});});};
	var profiles = {window800:{height:800,width:800,status:1},windowCenter6x6:{height:600,width:600,center:1,scrollbars:1,resizable:1}};
	$(function(){$(".popupwindow").popupwindow(profiles);});
	
});
