

function showInfo()
{
    current_informer = $("prompt_container");
    current_informer.style.display="block";
    current_informer.style.zIndex=100;
    
    if(!veil_on)
    {
        sizeVeil();
        veil();
    }
    centerElementOnScreen(current_informer);
        
}

function closeInfo()
{
    current_informer = $("prompt_container");    
    current_informer.style.display="none";
    current_informer.style.innerHTML="";
    removeVeil();    
}

function continueInfo()
{
    current_informer = $("prompt_container");    
    current_informer.style.display="none";
    current_informer.style.innerHTML="";
}


// aws_informer
function alert_message(messageID, message, button1_label, button1_onclick, button2_label, button2_onclick,title )
{
	try{
		this.messageID = messageID;
		this.message = message;
		this.button1_label = button1_label;
		this.button1_onclick = button1_onclick;
		this.button2_label = button2_label;
		this.button2_onclick = button2_onclick;	
		this.title = title;

	}catch(e){alert("error in function alert_message(business_messages.js). Error:"+e)}
}

function close_alert()
{
	document.getElementById('alert_veil').style.display="none";
	document.getElementById('alert_box_outer').style.display="none";
}

function hide_alert()
{
	$("alert_outer_container").remove();
	main_function = null;	
}

function showAlert(messageID)
{
	//autre est utilise por transer de parametres
	try{
		document.getElementById('alert_veil').style.display="block";
		document.getElementById('alert_box_outer').style.display="block";
		var alert_container = $("alert_box_outer");
		var alert_message = $("alert_content");
		var alert_title = $("alert_box_title");
		var alert_button1 = $("alert_button1");
		var alert_button2 = $("alert_button2");
	
		for(i=0;i<alert_messages.length;i++)
		{
			if(alert_messages[i].messageID==messageID)
			{
				alert_message.innerHTML=alert_messages[i].message;
				alert_title.innerHTML=alert_messages[i].title;
				alert_button1.value=alert_messages[i].button1_label;
				alert_button1.onclick = alert_messages[i].button1_onclick;
				if (alert_messages[i].button2_label != null) {
					$("alert_button2_container").style.display="block";
					alert_button2.value = alert_messages[i].button2_label;
					alert_button2.onclick = alert_messages[i].button2_onclick;
				}
			}
		}
		
		centerElementOnScreen(alert_container);
	}catch(e){alert("error in function show_alert(aws_informer.js). Error:"+e)}
}


function sizeAlertVeil()
{
	try{
		document.getElementById('alert_veil');
		if(document.getElementById('alert_veil')==null)
			setTimeout("sizeAlertVeil()",0);
		else{			
			var body_height =document.getElementsByTagName('body')[0].clientHeight;
			var body_width =document.getElementsByTagName('body')[0].clientWidth;	
			document.getElementById('alert_veil').style.height = body_height+225+"px";
			document.getElementById('alert_veil').style.width = body_width+"px";	
		}
	}catch(e){alert("sizeAlertVeil (in informer.js) has thrown an error:"+e)}
}

function quick_message(message,title,alertImg)
{
	
	try {
		
		if (!pre_loading_completed())
			quick_message.delay(3,message,title,alertImg);
		else
		{
			var theMessageInfo = new alert_messages("quick");
			createAlert();
			$("alert_body").innerHTML = message;
			$("alert_body").style.textAlign = "center";
			if ($("alert_body").getHeight() < 100) 
				$("alert_body").style.height = "100px";
			
			if (alertImg != null) 
				$("alert_img").src = pathToAlertImages + alertImg;
			else 
				$("alert_img").src = pathToAlertImages + "alert.jpg";
			$("alert_button_container").innerHTML = "";
			
			create_alert_button({
				id: "alert1",
				theCaption: theMessageInfo.button1_label,
				onclick_actions: theMessageInfo.button1_onclick
			});
			
			$("alert_title").innerHTML = title;
			position_alert($("alert_outer_container"));
		}
	}catch(e){alert("error in function show_alert(main.js). Error:"+e)}
}


function position_alert()
{
	try{
		
		if($("alert_outer_container") == null)
			position_alert.delay(global_delay);
		else
		{
			var alert_outer_container = $("alert_outer_container");
		
			if (alert_outer_container != null && alert_outer_container.style.display=="block") {
				center_element_in_viewport(alert_outer_container);
			}
		}
	}catch(e){}
}

function create_alert_button(options)
{
	try{
		var id = options.id;//possible ids are alert1(for button1) and alert2(for button2)
		var theCaption = options.theCaption;
		var onclick_actions = options.onclick_actions;	

		new Buttons.create({id:id,
						   theCaption:theCaption,
						   enabled:true,
						   onclick_actions:onclick_actions,
						   positionning:{cssFloat:'right'},
						   child_of:"alert_button_container",
						   class_Prefix:"alert",
						   type:"button"});
	}catch(e){alert("error in function create_alert_button(button_ojects.js). Error:"+e)}
}



