$(function() {
	/**
	 * top menu
	 */
	/***********************************************
	* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
	* This notice MUST stay intact for legal use
	* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
	***********************************************/
	ddsmoothmenu.arrowimages = {down : [], right:['rightarrowclass', 'images/layout/topMenuRightArrow.gif']};
	ddsmoothmenu.init({
		mainmenuid: "mainTabNav", //menu DIV id
		orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'ddsmoothmenu', //class added to menu's outer DIV
		//customtheme: ["#1c5a80", "#18374a"],
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	});
	
	/**
	 * left column collapse modules
	 */
	$('#loginBox-Title.smallRedTabLeft, #myAccountBox-Title.smallRedTabLeft').append('<span class="ml5 control control-up"/>');
	$('#loginBox-Title.smallRedCornersLeft, #myAccountBox-Title.smallRedCornersLeft').append('<span class="ml5 control control-down"/>');
	
	$('#loginBox-Title, #loginBox-Title span.title, #myAccountBox-Title, #myAccountBox-Title span.title').click(
			function(event) {
				
				var eventEl = $(event.target), container;
				container = eventEl.closest('.w100p');
				
				if (container.children('div').first().hasClass('smallRedTabLeft')) {
					container.children('.inside-efefef').hide('blind',1000,function(){
						container.children('.greyBottomLeft, .greyBottomRight').hide(50);
						container.children('.smallRedTabLeft').addClass('smallRedCornersLeft').removeClass('smallRedTabLeft')
									.find('span.control').addClass('control-down').removeClass('control-up');
						container.children('.smallRedTabRight').addClass('smallRedCornersRight').removeClass('smallRedTabRight');
					});
				} else {
					container.children('.greyBottomLeft, .greyBottomRight').show(50,function(){
						container.children('.inside-efefef').show('blind',1000);
						container.children('.smallRedCornersLeft').addClass('smallRedTabLeft').removeClass('smallRedCornersLeft')
									.find('span.control').addClass('control-up').removeClass('control-down');
						container.children('.smallRedCornersRight').addClass('smallRedTabRight').removeClass('smallRedCornersRight');
					});
				}
			}
		);
	
	if ($('#docSearchMode').val() != 'cofa') {
		$('#docSearchLot').hide();
	}
	$('#docSearchMode').change(function(event){
		if($(this).val() == 'cofa') {
			$('#docSearchLot').show('blind',{direction: 'vertical'},500);
		} else {
			$('#docSearchLot').hide('blind',{direction: 'vertical'},500);
		}
	});
	/**
	 * right column
	 */
	jQuery('#qlNewsletter').click(function() {
		window.open('newsletter.php', '', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=610,height=700');
	});
	jQuery('#qlCatalog').click(function() {
		window.open('newsletter.php?cat=1','','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=610,height=700');
	});
	
	$('.gradual').each(function() {
		var el = $(this);
		if (el.height() > 300) {
			el.addClass('full');
		}
	});
});

function popupWindow (url) {
	window.open(url, 'popupWindow', 'width=650,height=550');
	return false;
}
