var IE = document.all?true:false;

$(function(){
	$('img[class^="btn_o"]').each(function(){
		var theImgType = $(this).attr('src').toString().match(/\.[a-z][a-z][a-z][a-z]?$/);
		var theExt = $(this).attr('class').toString().match(/btn_[a-zA-Z0-9]*/gi).toString().replace('btn', '');
		$(this).mouseover(function(){
			$(this).attr('src', $(this).attr('src').toString().replace(''+theImgType,''+theExt+theImgType));
	    }).mouseout(function(){
			$(this).attr('src', $(this).attr('src').toString().replace(''+theExt+theImgType,''+theImgType));
	    });
	});
	$("object:not(.activated), embed:not(.activated)").each(function() {
		this.outerHTML = this.outerHTML;
	});
	if (typeof(configureLeftMenu)=="function") {
		configureLeftMenu();
	}
	if (typeof($.preloadImages)=="function") {
		$.preloadImages();
	}
	if (typeof(generateMenu2)=="function") {
		generateMenu2();
	}
	$('a.btn_go').bind('click',function(){
		search();
	});
	textFields.searchbox.reset();
	
	$('.btn_search').bind('click', function(){
		search();
	});
	
	$('#searchbox, #newsletter_sign_up_email').bind('keypress', function(e){
		var id = $(this).attr('id');
		var keynum, keychar, numcheck, result;
		if(window.event){	keynum = e.keyCode;	}else if(e.which){	keynum = e.which;	}
		switch(keynum){
			case 13:
				switch(id){
					case "searchbox":	search();	break;
					case "newsletter_sign_up_email":	document.forms[0].submit();	break;
				}
				break;
			case 27:	$(this).trigger('blur'); break;
		}
	}).bind('focus', function(){
		this.value = '';
		this.style.color = '#000';
	}).bind('blur', function(){
		if($(this).val()==""){
			var id = $(this).attr('id');
			eval('textFields.'+id+'.reset();');
			this.blur();
		}
	});
});


$(document).mouseup(function(){
});
$(window).resize(function(){
	configureLeftMenu();
});
/*
var block=[1,2,3];
if(location.href.search('home/index')!=-1){
	var timerBlock=new Array();
	$(function(){
		textFields.newsletter_sign_up_email.reset();
		
		var parentHeight = $('.index_block1').height();
		var titleHeight = $('.block_title:eq(0)').height();
		var counter = 0;
		$('.block_content').each(function(){
			$(this).wrapInner('<div class="moving_layer"></div>')
			$('.moving_layer', this).each(function(){
				$(this).css({
					position: 'relative',
					top: '0px'
				}).attr('asheight', $(this).height());
			});
			timerBlock[counter] = setTimeout('loop('+counter+')', 500);
			counter++
		});
	});
}
function loop(index){
	$('.index_block'+block[index]+' .block_content .moving_layer').each(function(){
		var newTop = $(this).css('top').replace('px','')*1-5;
		$(this).css({top: newTop+'px'});
		if(($(this).css('top').replace('px','')*1 + 115)<=0){
			$(this).css({top:'115px'});
		}
	});
	timerBlock[index] = setTimeout('loop('+index+')', 200);
}

*/
function debug(msg){
	if($('div[id="debug"]').length == 0){
		$('body').append('<div id="debug" style="position:absolute; left: 10px; top: 200px; background: #999999; color: #333333;"></div>');
	}$('div[id="debug"]').html(msg);
}