if (self.parent.frames.length != 0)
	self.parent.location.replace(document.location.href);

function em(box, server, zone) {
	var at = String.fromCharCode(64);
	document.write('<a href="'+'mai'+'lto'+':'+box+at+server+'.'+zone+'">'+box+at+server+'.'+zone+'<'+'/a>');
}

function initFormLabels() {
	$('input').each(function(){
		if ($(this).attr('type')=='text' || $(this).attr('type')=='password') {
			if ($(this).attr('value')=='' || $(this).attr('value')==$(this).attr('title')){
				$(this).attr('value', $(this).attr('title'));
			} else {
				$(this).addClass('active');
			}
			$(this).blur(function(){
				if ($(this).attr('value')==''){
					$(this).attr('value', $(this).attr('title'));
					$(this).removeClass('active');
				}
			});
			$(this).focus(function(){
				if ($(this).attr('value')==$(this).attr('title')){
					$(this).attr('value', '');
				}
				$(this).addClass('active');
			});
		} else {
			$(this).addClass('active');
		}
	});
}

function initHomeBrands() {
	$('#brands .container').each(function(){
		$(this).find(".hover").css({display:"block", opacity:"0"}).
			find(".nav").css({bottom:"-100px"});
		if (!$.browser.msie)
			$(this).find(".hover .bg").css({opacity:"0.75"});
		$(this).hover(function(){
			$(this).find(".hover").stop().animate({opacity:"1.0"}, 200).
				find(".nav").stop().animate({bottom:"0px"}, 200);
		},function(){
			$(this).find(".hover").stop().animate({opacity:"0.0"}, 200).
				find(".nav").stop().animate({bottom:"-100px"}, 200);
		});
	});
}

function initMenu() {
	$('#header .menu a').each(function(){
		$(this).click(function(){
			$('#header .menu li').each(function(){
				$(this).removeClass('active');
			});
			$(this).parent().addClass('active');
		});
	});
}

function initGeoSelector() {
	if (!$.browser.opera) {
		$('#geo select').each(function(){
			var title = $(this).attr('title');
			if ($('option:selected', this).val() != '')
				title = $('option:selected',this).text();
			$(this)
				.css({'z-index':10,'opacity':0,'-khtml-appearance':'none'})
				.after('<span class="select">' + title + '</span>')
				.change(function(){
					val = $('option:selected',this).text();
					$(this).next().text(val);
				})
		});
	}
}

$(function(){
	$('#brands').pngFix({blankgif:'/i/x.gif'});
	initMenu();
	initGeoSelector();
	initFormLabels();
	initHomeBrands();
});
