function WwsDialogue()
{
	this._init();
};

WwsDialogue.prototype._dialog;
WwsDialogue.prototype._notify;
WwsDialogue.prototype._manager;
WwsDialogue.prototype._contactForm;

WwsDialogue.prototype._init = function()
{
	
	this._dialog = new YAHOO.widget.Dialog("overlay", {
													  fixedcenter: true,
													  visible:false,
													  zIndex: 10,
													  width:"650px",
													  height: "740px",
													  modal: true,
													  iframe: true,
													  effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25}
													  } );
	
	// Validate the entries in the form to require that both first and last name are entered
	this._dialog.validate = function() {
		var data = this.getData();
		var inputs = ["First_Name", "Last_Name", "Email", "Phone_Number"];
		var valid = true;
		for (i=0; i < inputs.length; i++)
		{
			if(YAHOO.util.Dom.hasClass(inputs[i], "warn"))
			{
				YAHOO.util.Dom.removeClass(inputs[i], "warn");
			}
		}
		for (i=0; i < inputs.length; i++)
		{
			if (data[inputs[i]] == "") 
			{
				if(!YAHOO.util.Dom.hasClass(inputs[i], "warn"))
				{
					YAHOO.util.Dom.addClass(inputs[i], "warn");
				}
				valid = false;
			}
		}
		return valid;

	};
	var submitButton = new YAHOO.widget.Button("pushbutton1"); 
	submitButton.set('onclick', {fn: this.handleSubmit, obj: null, scope: this});
	var cancelButton = new YAHOO.widget.Button("pushbutton2");
	cancelButton.set('onclick', {fn: this.handleCancel, obj: null, scope: this});
	
	var _this = this;
	this._notify = new YAHOO.widget.SimpleDialog("notify", 
			 { width: "400px",
			   fixedcenter: true,
			   visible: false,
			   draggable: false,
			   close: true,
			   modal: true,
			   icon: YAHOO.widget.SimpleDialog.ICON_INFO,
			   constraintoviewport: true,
			   buttons: [ { text:"OK", handler:_this.handleOK, isDefault:true },
						   ]
			 } );
		
	this._notify.setHeader("Your Form Has Been Submitted");
	this._notify.setBody("Thank you for submitting.  A representative will contact you as soon as possible.");
	
	this.initContactForm();
	this._manager = new YAHOO.widget.OverlayManager();
	this._manager.register([this._notify,this._dialog, this._contactForm]);
	
}

WwsDialogue.prototype.onSelectedMenuItemChange = function (event) {

	var oMenuItem = event.newValue;

	this.set("label", ("<em class=\"yui-button-label\">" + 
				oMenuItem.cfg.getProperty("text") + "</em>"));

};

WwsDialogue.prototype.showPanel = function(type)
{
	switch(type)
		{ 
			case "quote": this._dialog.setHeader("Get Quote"); this.hideDiv("info-form"); this.showDiv("quote-form"); break;
			case "info": this._dialog.setHeader("Contact Us"); this.hideDiv("quote-form"); this.showDiv("info-form"); break;
			default: break;
		}	
		this._dialog.render(document.body);
		this._dialog.show();
}

WwsDialogue.prototype.handleSubmit = function() 
{
	var valid = this._dialog.validate();
	if(valid)
	{
		var formType = this._dialog.form.id;
		var data = this._dialog.getData();
		var jsonString = YAHOO.lang.JSON.stringify(data);
		YAHOO.util.Connect.asyncRequest('POST', 'app/php/FormSender.php', this.phpCallBack, "request="+formType+"&data="+jsonString);
		this._dialog.cancel();	
		this._notify.render("notify-container");
		this._notify.show();
	}
	else
	{
		this.showDiv("errors");	
	}
}
WwsDialogue.prototype.handleOK = function() 
{
	this.hide();
}

WwsDialogue.prototype.handleCancel = function() 
{
	this._dialog.hide();
	this._dialog.cancel();
}
WwsDialogue.prototype.hideDiv = function(className) 
{
	if(!YAHOO.util.Dom.hasClass(className, "hidden"))
	{
		YAHOO.util.Dom.addClass(className, "hidden");
	}
}

WwsDialogue.prototype.showDiv = function(className) 
{
	if(YAHOO.util.Dom.hasClass(className, "hidden"))
	{
		YAHOO.util.Dom.removeClass(className, "hidden");
	}
}
WwsDialogue.prototype.phpCallBack = function(a, b, c) 
{
	var placeholder;
}
WwsDialogue.prototype.showContactForm = function()
{
	this._contactForm.focus();
}
WwsDialogue.prototype.initContactForm = function()
{
	this._contactForm = new YAHOO.widget.Dialog("ContactDialogue", {
													  modal: false,
													  visible: true,
													  underlay: "none",
													  close: false,
													  width: 600,
													  zIndex: 200
													  } );
	
	var submitButton = new YAHOO.widget.Button("submitbutton1"); 
	submitButton.set('onclick', {fn: this.contactSubmit, obj: null, scope: this});
	this._contactForm.render();
}
WwsDialogue.prototype.contactCancel = function() 
{
	this._contactForm.cancel();
}
WwsDialogue.prototype.contactSubmit = function() 
{
	var formType = this._contactForm.form.id;
	var data = this._contactForm.getData();
	var jsonString = YAHOO.lang.JSON.stringify(data);
	YAHOO.util.Connect.asyncRequest('POST', 'app/php/FormSender.php', this.phpCallBack, "request="+formType+"&data="+jsonString);
	this._contactForm.cancel();	
	this.showDiv("FormSubmit");
}