/*
function IB_error_msg(Error) {
	str = '';
	if(Error.messages.length) {	
		str += '<div id="failure"><p>Your changes could not be saved.</p><h3>The following problems occurred:</h3><ul>';
		$.each(Error.messages, function(i, o) {
			str += '<p>'+o+'</p>';
		});
		str += '</ul>';

		if(Error.optional.length) {
			str += '<h3>Additional Error Messages</h3><ul>';
			$.each(Error.optional, function(i, o){
				str += '<li>'+o+'</li>'
			});
			str += '</ul>';
		}
		str += '</div>';
	}
	if(str) { $("#BelowErrorNotify").before(str); }
}
*/
function IB_notify_msg(Notify) {
	// remove all notifications
	$("#Notify").remove(); 
	str = '<div id="Notify">';
	if(Notify.messages.length) {	
		$.each(Notify.messages, function(i, o) {
			str += '<p>'+o+'</p>';
		});
	}
    str += '</div>';
	$("#CBResultsHolder h2").before(str);
	IB_notify_msg_show();
}
function IB_notify_msg_show() {
	$("#Notify").slideDown(500, function() {
		$("#Notify").fadeOut(5000);
	});
}
/**
 * Applies drop shadows (only visible ones)
 * @param e - element(s) to apply shadows to (jQuery Selector)
 * @param f - optional function: redraw, remove
 */
function IB_ds(e, f, d) {
	if(f == "redraw") {
		IB_ds(e, "remove"); 
		$(e).each(function (i) {
			if(!$(this).parents().is(":hidden")) {
				//if(d == "up") {
				//	$(this).dropShadow({left: 3, top: -5, opacity: 0.5, blur: 1});
				//}
				//else {
					$(this).dropShadow({left: 3, top: 0, opacity: 0.5, blur: 1});
				//}
			}
		});
		/* seems to be broken in IE
		$(e).each(function (i) {
			if(!$(this).parents().is(":hidden")) {
				$(this).redrawShadow();
			}
		});
		*/
	}
	else if(f == "remove") {
		//$(e).each(function (i) {
		//	if(!$(this).parents().is(":hidden")) {
		//		$(this).removeShadow();
		//	}
		//});
		$(".dropShadow").remove();	
	}
	else {
		$(e).each(function (i) {
			if(!$(this).parents().is(":hidden")) {
				//if(d == "up") {
				//	$(this).dropShadow({left: 3, top: -5, opacity: 0.5, blur: 1});
				//}
				//else {
					$(this).dropShadow({left: 3, top: 0, opacity: 0.5, blur: 1});
				//}
			}
		});
		// redraw for ie bug
		if ( $.browser.msie ) { IB_ds(e, "redraw"); }
	}
}

function EX_add_to_clipboard(u, t, d) {
	data = {"p": "json", "c": "add_to_clipboard_cms", "t": t, "u": u, "d": d};
	$.ajax({
		url: "/OcchealthSearch/",
		dataType: "json",
		data: data,
		type: "POST",
		success: function(json){
			$("a.ex-cb-add").addClass("clipboard-added");
			$("a.ex-cb-add").removeClass("clipboard");  
		}
	});	
}