
/* Clears input value on blur */
$(document).ready(function() {
	$('.default-value').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if(this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});
	/* Add firstChild and lastChild fix for IE6 */
	$('.contentBottom > p:first, ul.menu ul li:first-child')
	.addClass('firstChild');
	$('ul.menu ul li:last-child')
	.addClass('lastChild');
	$('.parties .contentBottom:last-child')
	.addClass('lastChild');
	/* Dynmically applies 'selected' to the correct parent top nav tab for each page */
	$(function(){
		var path = location.pathname.substring(1);
		if (path)
		    $('#menu a[href^="/' + location.pathname.split("/")[1] + '"]').attr('class', 'selected');
	});
	/* Opens all links within the coupon control in a new window */
	$(".coupon a").attr("target","_blank")
});

/* Drop Down Menu */
var menu=function(){
	var t=15,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();

/* Rotating Banner */
$(function(){
	$('#bannerHome img:gt(0)').hide();
	setInterval(function(){$('#bannerHome :first-child').fadeOut().next('img').fadeIn().end().appendTo('#bannerHome');}, 5000);
});

/* sIFR */
var swfFont = { src: '/swf/sifr.swf', ratios: [6,1.41,9,1.35,15,1.29,21,1.25,22,1.22,27,1.24,29,1.21,34,1.22,41,1.21,45,1.2,46,1.21,59,1.2,68,1.19,69,1.2,96,1.19,97,1.18,102,1.19,103,1.18,112,1.19,114,1.18,116,1.19,120,1.18,121,1.19,1.18] };
sIFR.activate(swfFont)
sIFR.replace(swfFont, {
	selector: '#contentTop h1,#contentTop h2,.contentBottom h2,.sf_searchBox label',
	css: [ '.sIFR-root { color:#e40a7c; leading: -5; }' ],
	wmode: 'transparent'
});
sIFR.replace(swfFont, {
	selector: '#contentTop h3',
	css: [ '.sIFR-root { color:#e40a7c; leading: -5; text-align:center; }' ],
	wmode: 'transparent'
});
/* Product Selector */
function HideContent(d) {
	document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
	document.getElementById(d).style.display = "block";
}
function HideAll() {
	HideContent('product1');
	HideContent('product2');
	HideContent('product3');
	HideContent('product4');
	HideContent('product5');
	HideContent('product6');
	HideContent('product7');
	HideContent('product8');
	HideContent('product9');
	HideContent('product10');
}
