if(typeof(YAHOO) != "undefined"){
	YAHOO.util.Event.addListener(window, "load", cominit);
}
var contactpanel;

function cominit(){
	contactpanel = SimplePanel('contactform','Contact MovieHopping.org');
}

function contact(){
	contactpanel.showme();
}

function sendEmail(){
	ShowLoadingPanel();
	//alert(byid("contactform_form"));
	YAHOO.util.Connect.setForm("contactform_form");
	YAHOO.util.Connect.asyncRequest('POST', 'contact.php', {success:function(o){sendEmailSuccess(o);},failure:function(o){sendEmailFailure(o);}});
}
function sendEmailSuccess(o){
	if(o.responseText.indexOf("Error") > -1){
		sendEmailFailure(o);
	}
	else{
		PanelMessage("<br><br><div style='padding:10px;'>Your message has been send. Thank you for your feedback!</div>");
		contactpanel.hide();
	}
}
function sendEmailFailure(o){
	PanelError(o.responseText);
}

function byid(id){
	return document.getElementById(id);
}

function SimplePanel(id, header){
	var mypanel;
		
	//YAHOO.util.Event.addListener(window, "load", function(){
		mypanel = new YAHOO.widget.Panel(id);
		mypanel.setBody('<form action="none" method="post" name="'+id+'_form" id="'+id+'_form">'+document.getElementById(id).innerHTML+'</form>');
		document.getElementById(id).innerHTML="";
		mypanel.render(document.body);
		mypanel.setHeader(header);
		mypanel.cfg.setProperty("visible", false);
		mypanel.cfg.setProperty("modal", true);
		mypanel.cfg.setProperty("underlay", "shadow");
		mypanel.cfg.setProperty("draggable", false);
		mypanel.cfg.setProperty("constraintoviewport", true);
		mypanel.cfg.setProperty("fixedcenter",true);
		mypanel.showme = function(){
			this.render(document.body);
			this.cfg.setProperty("visible", true);		
		}
	//});
	return mypanel;
	
}
