jQuery.noConflict();

var openHeight = "115px";
var closedHeight = "73px";

var boxOpen = false;
var dropDisplay="";

jQuery(document).ready(function(){
								
	selectVal = jQuery("#selectList option:selected").val();
	
	if (selectVal=="emailROI") {
		jQuery('#loginformExpand').attr({ action: 'http://emailer.emailroi.com/dbadmin/non_icemaker_enter.pl' });
	} else if (selectVal=="ecomROI") {
		jQuery('#loginformExpand').attr({ action: 'https://secure.eroi.com/servlet/com.gcm.servlet.security.SecureLogin'});
	} else if (selectVal=="eventROI") {
		jQuery('#loginformExpand').attr({ action: 'https://secure.eroi.com/servlet/com.gcm.servlet.security.SecureLogin'});
	} else if (selectVal=="blogROI") {
		jQuery('#loginformExpand').attr({ action: 'http://blog.eroidelivers.com/bins/mt/mt.cgi'});
	} else {
		jQuery('#loginformExpand').attr({ action: 'http://emailer.emailroi.com/dbadmin/non_icemaker_enter.pl'});
	}		
						 		

 

    jQuery("#search a").click(function(){
		if (boxOpen == false){
			show(jQuery("#searchBox"));
			expand();
			dropDisplay = "search";
		} else if (dropDisplay == "login") {
			close(true);
		} else {
			close(false);
		}
	});
	
	jQuery("#login a").click(function(){
		if (boxOpen == false){
			show(jQuery("#clientLog"));
			expand();
			dropDisplay = "login";
		} else if (dropDisplay == "search") { 
			close(true);
		} else {
			close(false);
		}
	});	
		
});

function show(toShow) {
	if (toShow.attr("id") == "searchBox" ) {
		jQuery("#searchBox").css("display","block");
		jQuery("#clientLog").css("display","none");
		dropDisplay = "search";
	} else {
		jQuery("#clientLog").css("display","block");
		jQuery("#searchBox").css("display","none");
		dropDisplay = "login";
	}
}



function expand() {
	jQuery(".headerExpand").animate( { height: "115px" }, 500, "easeInOutQuad", function() {
		boxOpen = true;	
	});
}

function close(reopen) {
	jQuery(".headerExpand").animate( {height: "73px" }, 500, "easeInOutQuad", function() {
		boxOpen = false;
		if (reopen) {
			if(dropDisplay=="search") {
				show(jQuery("#clientLog"));
				expand();
			} else { 
				show(jQuery("#searchBox"));
				expand();
			}
		}
	});
}