var tmpCallback1;
var tmpBox


function function_exists(function_name) {
     if (typeof function_name == 'string'){  
	 
         return (typeof window[function_name] == 'function');  
     } else{  
         return (function_name instanceof Function);  
    }  
}

function showDialogbox(id, dialogText, button1, callback1, button2, callback2) {

  buttons2url = {"yes": "http://static.sector15.com/images/DE/text/merchant_yes.gif", "no": "http://static.sector15.com/images/DE/text/merchant_no.gif", "ok": "http://static.sector15.com/images/DE/text/ok.gif", "abort": "images/text/abort.gif"};
  
  box = $("#"+id);
  
  boxText = $("#"+id+"Text");
  buttons = $("#"+id+"Buttons");
  box.show();
  boxText.html(dialogText);
	buttonHtml = "";
	if(button1){	
  	buttonHtml += '<img id="'+id+'Button1" src="'+buttons2url[button1]+'" alt="'+button1+'">';
  }
	if(button2){
  	buttonHtml += ' <img id="'+id+'Button2" src="'+buttons2url[button2]+'" alt="'+button2+'">';
	}
	$("#"+id+"Buttons").html(buttonHtml);

	if(button1){
	 	$("#"+id+"Button1").click(function() {
			box.hide();
			//alert(callback1);
			//alert("1 "+function_exists(callback1));


				try {
					callback1();
				}
				catch(err) {}
			

		});
	}
	if(button2){
 		$("#"+id+"Button2").click(function() {
			box.hide();
			
		
				try {
					callback2();
				}
				catch(err) {}
			

			
		});
	}
}


function submitDialogbox(dialogText, formId) {
	if(typeof formId == "undefined")
		; //c1 = function() { document.form.submit() };
	else
		c1 = function() { document.getElementById(formId).submit() };
	
	showDialogbox("dialogbox", dialogText, "ok", c1, "abort", null);
}

