ContentPages = function(){}; 
ContentPages.MenuLeft = null; 
ContentPages.DataBridgeObj = null; 

// for Internet Explorer (using conditional comments)
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
  if (this.readyState == "complete") {
    init(); // call the onload handler
  }
};
/*@end @*/

window.onload = init;

function init()
{
	ContentPages.SetupBrochurePage(); 
}

	
ContentPages.Calculate = function ()
{
    var Daily_Total = 0;
    var Monthly_Total = 0;
    var Yearly_Total = 0;
    var Average_Vend = $("averagevend").value;
    var Total_Machines = $("totalmachines").value;

    if(!$("averagevend").value){
	    alert("You must enter the Average Vend");
	    return false;
    }
    else if(!$("totalmachines").value){
	    alert("You must enter the total number of machines");
	    return false;
    }
    else{
	    $("Average_Vend").innerHTML = "<span class=normal><b>Average Vends Per Machine: </b><font color=red><strong>&nbsp;&nbsp;"+Average_Vend+"</strong></font></span>";
	    $("Total_Machines").innerHTML = "<span class=normal><b>Number of Machines: </b><font color=red><strong>&nbsp;&nbsp;"+Total_Machines+"</strong></font></span>";

	    Daily_Total = Average_Vend*0.25*Total_Machines;
	    Monthly_Total = Average_Vend*0.25*Total_Machines*30;
	    Yearly_Total = Average_Vend*0.25*Total_Machines*365;

	    $("Daily_Total").innerHTML = "<span class=normal><b>Daily Total: </b><font color=red><strong>&nbsp;&nbsp;$"+Daily_Total+"</strong></font></span>";
	    $("Monthly_Total").innerHTML = "<span class=normal><b>Monthly Total:</b> </strong><font color=red><strong>&nbsp;&nbsp;$"+Monthly_Total+"</strong></font></span>";
	    $("Yearly_Total").innerHTML = "<span class=normal><b>Yearly Total:</b> <font color=red><strong>&nbsp;&nbsp;$"+Yearly_Total+"</strong></font></span>";
    }

}


ContentPages.SetupBrochurePage = function()
{
	ContentPages.FirstNameControl = new UIControls.TextControl("AUTO_First_Name", $("FirstName")); 
	ContentPages.FirstNameControl.Label = "First Name:";
	ContentPages.FirstNameControl.Required = true; 
	ContentPages.FirstNameControl.ValidationErrorWriteOut = false; 
	ContentPages.FirstNameControl._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.FirstNameControl.Render(); 

	ContentPages.LastNameControl = new UIControls.TextControl("AUTO_Last_Name", $("LastName")); 
	ContentPages.LastNameControl.Label = "Last Name:";
	ContentPages.LastNameControl.Required = true; 
	ContentPages.LastNameControl.ValidationErrorWriteOut = false; 
	ContentPages.LastNameControl._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.LastNameControl.Render(); 

	ContentPages.CompanyControl = new UIControls.TextControl("AUTO_Company", $("Company")); 
	ContentPages.CompanyControl.Label = "Company:";
	ContentPages.CompanyControl.Required = true; 
	ContentPages.CompanyControl.ValidationErrorWriteOut = false; 
	ContentPages.CompanyControl._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.CompanyControl.Render(); 

	ContentPages.EmailControl = new UIControls.EmailControl("AUTO_Email", $("Email")); 
	ContentPages.EmailControl.Label = "Email:";
	ContentPages.EmailControl.Required = true; 
	ContentPages.EmailControl.ValidationErrorWriteOut = false; 
	ContentPages.EmailControl._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.EmailControl.Render(); 

	ContentPages.Address1Control = new UIControls.TextControl("AUTO_Address1", $("Address1")); 
	ContentPages.Address1Control.Label = "Address 1:";
	ContentPages.Address1Control.Required = true; 
	ContentPages.Address1Control.ValidationErrorWriteOut = false; 
	ContentPages.Address1Control._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.Address1Control.Render(); 

	ContentPages.Address2Control = new UIControls.TextControl("AUTO_Address2", $("Address2")); 
	ContentPages.Address2Control.Label = "Address 2:";
	ContentPages.Address2Control.Required = false; 
	ContentPages.Address2Control.ValidationErrorWriteOut = false; 
	ContentPages.Address2Control._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.Address2Control.Render(); 

	ContentPages.CityControl = new UIControls.TextControl("AUTO_City", $("City")); 
	ContentPages.CityControl.Label = "City:";
	ContentPages.CityControl.Required = true; 
	ContentPages.CityControl.ValidationErrorWriteOut = false; 
	ContentPages.CityControl._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.CityControl.Render(); 

	ContentPages.StateControl = new UIControls.StateControl("AUTO_State", $("State")); 
	ContentPages.StateControl.Label = "State:";
	ContentPages.StateControl.Required = true; 
	ContentPages.StateControl.ValidationErrorWriteOut = false; 
	ContentPages.StateControl._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.StateControl.Render(); 

	ContentPages.ZipControl = new UIControls.TextControl("AUTO_Zip", $("Zip")); 
	ContentPages.ZipControl.Label = "Zip:";
	ContentPages.ZipControl.Required = true; 
	ContentPages.ZipControl.ValidationErrorWriteOut = false; 
	ContentPages.ZipControl._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.ZipControl.Render(); 

	ContentPages.PhoneControl = new UIControls.TextControl("AUTO_Phone", $("Phone")); 
	ContentPages.PhoneControl.Label = "Phone:";
	ContentPages.PhoneControl.Required = true; 
	ContentPages.PhoneControl.ValidationErrorWriteOut = false; 
	ContentPages.PhoneControl._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.PhoneControl.Render(); 

	ContentPages.FaxControl = new UIControls.TextControl("AUTO_Fax", $("Fax")); 
	ContentPages.FaxControl.Label = "Fax:";
	ContentPages.FaxControl.Required = false; 
	ContentPages.FaxControl.ValidationErrorWriteOut = false; 
	ContentPages.FaxControl._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.FaxControl.Render(); 

	ContentPages.DateToStartBusiness = new UIControls.TextControl("AUTO_DateToStartBusiness", $("DateToStartBusiness")); 
	ContentPages.DateToStartBusiness.Label = "Date To Start Business:";
	ContentPages.DateToStartBusiness.Required = false; 
	ContentPages.DateToStartBusiness.ValidationErrorWriteOut = false; 
	ContentPages.DateToStartBusiness._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.DateToStartBusiness.Render(); 

	ContentPages.CapitolToInvestControl = new UIControls.ComboBox("AUTO_CapitolToInvest", $("CapitolToInvest")); 
	ContentPages.CapitolToInvestControl.Label = "Capitol To Invest";
	ContentPages.CapitolToInvestControl.Required = false; 
	ContentPages.CapitolToInvestControl.ValidationErrorWriteOut = false; 
	ContentPages.CapitolToInvestControl._onEnterF = ContentPages.SendBrochureForm; 	
	ContentPages.CapitolToInvestControl.AddOption("$0 - $5,000","0-5000"); 
	ContentPages.CapitolToInvestControl.AddOption("$5,000 - $10,000","5k-10k");
	ContentPages.CapitolToInvestControl.AddOption("$10,000 - $20,000","10k-20k"); 
	ContentPages.CapitolToInvestControl.AddOption("$20,000 or more","20k-Up");
	ContentPages.CapitolToInvestControl.Render(); 

	ContentPages.InternetControl = new UIControls.ComboBox("AUTO_Internet", $("Internet")); 
	ContentPages.InternetControl.Label = "Internet";
	ContentPages.InternetControl.Required = false; 
	ContentPages.InternetControl.ValidationErrorWriteOut = false; 
	ContentPages.InternetControl._onEnterF = ContentPages.SendBrochureForm; 	
	ContentPages.InternetControl.AddOption("Other");
	ContentPages.InternetControl.AddOption("AltaVista");
	ContentPages.InternetControl.AddOption("Excite/AOL NetFind");
	ContentPages.InternetControl.AddOption("100 Franchises");
	ContentPages.InternetControl.AddOption("Food Franchises");
	ContentPages.InternetControl.AddOption("Franchise Connection");
	ContentPages.InternetControl.AddOption("Franchise Gator");
	ContentPages.InternetControl.AddOption("Franchise Opportunities");
	ContentPages.InternetControl.AddOption("Franchise Works");
	ContentPages.InternetControl.AddOption("Franchise Solutions");
	ContentPages.InternetControl.AddOption("franchisedirect.com");
	ContentPages.InternetControl.AddOption("franchiseforsale.com");
	ContentPages.InternetControl.AddOption("franchiseonline.com");
	ContentPages.InternetControl.AddOption("gumballmachines.com");
	ContentPages.InternetControl.AddOption("HotBot");
	ContentPages.InternetControl.AddOption("InfoSeek");
	ContentPages.InternetControl.AddOption("LinkStar");
	ContentPages.InternetControl.AddOption("Lycos");
	ContentPages.InternetControl.AddOption("Magellan");
	ContentPages.InternetControl.AddOption("NorthernLight");
	ContentPages.InternetControl.AddOption("smallbusinessfranchise.com");
	ContentPages.InternetControl.AddOption("smallbusinessopportunity.com");
	ContentPages.InternetControl.AddOption("smartpages.com");
	ContentPages.InternetControl.AddOption("USA Today");
	ContentPages.InternetControl.AddOption("Vending Yellow Pages");
	ContentPages.InternetControl.AddOption("WebCrawler");
	ContentPages.InternetControl.AddOption("Yahoo");
	ContentPages.InternetControl.AddOption("yourownfranchise.com");
	ContentPages.InternetControl.Render(); 

	ContentPages.MagazineControl = new UIControls.ComboBox("AUTO_Magazine", $("Magazine")); 
	ContentPages.MagazineControl.Label = "Magazine";
	ContentPages.MagazineControl.Required = false; 
	ContentPages.MagazineControl.ValidationErrorWriteOut = false; 
	ContentPages.MagazineControl._onEnterF = ContentPages.SendBrochureForm; 	
	ContentPages.MagazineControl.AddOption("Other");
	ContentPages.MagazineControl.AddOption("Business Opportunity Handbook");
	ContentPages.MagazineControl.AddOption("Entrepreneur");
	ContentPages.MagazineControl.AddOption("Home Business Connection");
	ContentPages.MagazineControl.AddOption("Home Business Magazine");
	ContentPages.MagazineControl.AddOption("Small Business Opportunity");
	ContentPages.MagazineControl.Render(); 

	ContentPages.OtherControl = new UIControls.TextControl("AUTO_Other", $("Other")); 
	ContentPages.OtherControl.Label = "Other:";
	ContentPages.OtherControl.Required = false; 
	ContentPages.OtherControl.ValidationErrorWriteOut = false; 
	ContentPages.OtherControl._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.OtherControl.Render(); 

	ContentPages.CommentControl = new UIControls.TextArea("AUTO_Comments", $("Comments")); 
	ContentPages.CommentControl.Label = "Enter your comments here:";
	ContentPages.CommentControl.Required = false; 
	ContentPages.CommentControl.ValidationErrorWriteOut = false; 
	ContentPages.CommentControl._onEnterF = ContentPages.SendBrochureForm; 
	ContentPages.CommentControl.Render(); 
	
	ContentPages.BrochureRequestForm = new HtmlForm.Control("BrochureRequestForm");
	ContentPages.BrochureRequestForm.AddObject(ContentPages.FirstNameControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.LastNameControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.CompanyControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.EmailControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.Address1Control);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.Address2Control);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.CityControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.StateControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.ZipControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.PhoneControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.FaxControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.DateToStartBusiness);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.CapitolToInvestControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.InternetControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.MagazineControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.OtherControl);
	ContentPages.BrochureRequestForm.AddObject(ContentPages.CommentControl);	
};

ContentPages.CreateEmailContent = function(pageToEdit)
{	
	var thisLayout = Layouts.Get(pageToEdit); 	
	var serverData = new ServerData.SenderObject("createEmail", null, "./ServerData/ContentEditor.ashx", "PageContent=" + Globals.UrlEncode(thisLayout.GetHTMLPageFormattedContent()) + "&PageName=" + pageToEdit);             
	
	Globals.ShowSpinner("status", "Saving Content..."); 
	serverData.SendData(function(results)
	{  
		GoToPage(Page.ContentPage, pageToEdit); 
	});	
};


ContentPages.ContactForm = function(){}; 
ContentPages.ContactForm.FirstName = null; 
ContentPages.ContactForm.LastName = null; 
ContentPages.ContactForm.Email = null; 
ContentPages.ContactForm.Phone = null; 
ContentPages.ContactForm.Fax = null; 
ContentPages.ContactForm.Comments = null; 
ContentPages.ContactForm.Form = null; 

ContentPages.CreateContactUsPage = function()
{	
	var introText = '' + 
	'<div id="ContactUsFormDiv">' + 
		'<div id="FirstName"></div>' + 
		'<div id="LastName"></div>' + 
		'<div id="Email"></div>' + 
		'<div id="Phone"></div>' + 
		'<div id="Fax"></div>' + 
		'<div id="Comments"></div>' + 
		'<hr /><button onclick="ContentPages.ContactForm.Submit();">Send Email</button>' + 
	'</div>';

	$("ContactUsDiv").innerHTML = introText; 
	
	ContentPages.ContactForm.FirstName = new UIControls.TextControl("AUTO_First_Name", $("FirstName")); 
	ContentPages.ContactForm.FirstName.Label = "First Name:";
	ContentPages.ContactForm.FirstName.Required = true; 
	ContentPages.ContactForm.FirstName.ValidationErrorWriteOut = false; 
	ContentPages.ContactForm.FirstName._onEnterF = ContentPages.ContactForm.Submit; 
	ContentPages.ContactForm.FirstName.Render(); 
	
	ContentPages.ContactForm.LastName = new UIControls.TextControl("AUTO_Last_Name", $("LastName")); 
	ContentPages.ContactForm.LastName.Label = "Last Name:";
	ContentPages.ContactForm.LastName.Required = true; 
	ContentPages.ContactForm.LastName.ValidationErrorWriteOut = false; 
	ContentPages.ContactForm.LastName._onEnterF = ContentPages.ContactForm.Submit; 
	ContentPages.ContactForm.LastName.Render(); 

	ContentPages.ContactForm.Email = new UIControls.EmailControl("AUTO_Email", $("Email")); 
	ContentPages.ContactForm.Email.Label = "Email:";
	ContentPages.ContactForm.Email.Required = true; 
	ContentPages.ContactForm.Email.ValidationErrorWriteOut = false; 
	ContentPages.ContactForm.Email._onEnterF = ContentPages.ContactForm.Submit; 
	ContentPages.ContactForm.Email.Render(); 

	ContentPages.ContactForm.Phone = new UIControls.TextControl("AUTO_Phone", $("Phone")); 
	ContentPages.ContactForm.Phone.Label = "Phone:";
	ContentPages.ContactForm.Phone.Required = true; 
	ContentPages.ContactForm.Phone.ValidationErrorWriteOut = false; 
	ContentPages.ContactForm.Phone._onEnterF = ContentPages.ContactForm.Submit; 
	ContentPages.ContactForm.Phone.Render(); 

	ContentPages.ContactForm.Fax = new UIControls.TextControl("AUTO_Fax", $("Fax")); 
	ContentPages.ContactForm.Fax.Label = "Fax:";
	ContentPages.ContactForm.Fax.Required = false; 
	ContentPages.ContactForm.Fax.ValidationErrorWriteOut = false; 
	ContentPages.ContactForm.Fax._onEnterF = ContentPages.ContactForm.Submit; 
	ContentPages.ContactForm.Fax.Render(); 

	ContentPages.ContactForm.Comments = new UIControls.TextArea("AUTO_Comments", $("Comments")); 
	ContentPages.ContactForm.Comments.Label = "Comments:";
	ContentPages.ContactForm.Comments.Required = false; 
	ContentPages.ContactForm.Comments.ValidationErrorWriteOut = false; 
	ContentPages.ContactForm.Comments._onEnterF = ContentPages.ContactForm.Submit; 
	ContentPages.ContactForm.Comments.Render(); 


	ContentPages.ContactForm.Form = new HtmlForm.Control("ContactUsFormDiv");
	ContentPages.ContactForm.Form.AddObject(ContentPages.ContactForm.FirstName);
	ContentPages.ContactForm.Form.AddObject(ContentPages.ContactForm.LastName);
	ContentPages.ContactForm.Form.AddObject(ContentPages.ContactForm.Email);
	ContentPages.ContactForm.Form.AddObject(ContentPages.ContactForm.Phone);
	ContentPages.ContactForm.Form.AddObject(ContentPages.ContactForm.Fax);
	ContentPages.ContactForm.Form.AddObject(ContentPages.ContactForm.Comments);
}; 

ContentPages.ContactForm.Submit = function(language)
{
	if(language == null)
	{
		language = ""; 
	}
	
	if(ContentPages.ContactForm.Form.Validate() == "" 
		&& ContentPages.ContactForm.FirstName.GetValue() != "" 
		&& ContentPages.ContactForm.LastName.GetValue() != ""
		&& ContentPages.ContactForm.Phone.GetValue() != "")
	{
		var serverData = new ServerData.SenderObject("contact_form", null, "http://216.167.205.196/UTurn-Vending/ServerData/SendEmailFromForm.ashx", ContentPages.ContactForm.Form.GetURIFormat() + "&" + Globals.URLParamsString + "&lang=" + language);             
		Globals.ShowSpinner("status", "Sending Email..."); 		
		serverData.SendData(function()
		{
			//alert("sent!"); 
			//GoToPage(Page.ContentPage, "ContactUsReturn"); 
		});	
		
		setTimeout( "window.location.href = 'http://www.uturnvending.com/Message-Delivered.aspx'", 0 );		
	}
	else
	{
        alert("Some required fields are missing or incorrect."); 
	}
};

ContentPages.SendBrochureForm2 = function(language)
{
	if(language == null)
	{
		language = ""; 
	}

 	var retVal = ContentPages.BrochureRequestForm.Validate();
	if(retVal == "")
	{
	
		var serverData = new ServerData.SenderObject("request_brochure_form", null, "http://www.uturnvending.com/services/ServerData/SendEmailFromForm.ashx", ContentPages.BrochureRequestForm.GetURIFormat() + "&CurrentPage=&lang=" + language);             	
		serverData.SendData(function()
		{
			//window.location = "http://216.167.205.196/UTurnCMS/Message-Delivered.aspx";
		});	
		window.setTimeout('window.location.href = "http://www.uturnvending.com/Message-Delivered.aspx";', 1);
		window.location.href = "http://www.uturnvending.com/Message-Delivered.aspx";
	}
	else
	{
        alert(retVal); 	
	}
}

ContentPages.SendBrochureForm = function()
{
	alert("in3");
	return; 
	
    var retVal = ""; //ContentPages.BrochureRequestForm.Validate();
	if(retVal == "")
	{
	
		//var serverData = new ServerData.SenderObject("request_brochure_form", null, "http://216.167.205.196/UTurn-Vending/ServerData/SendEmailFromForm.ashx", ContentPages.BrochureRequestForm.GetURIFormat() + "&CurrentPage=");             	
		//window.location = "http://216.167.205.196/UTurnCMS/Message-Delivered.aspx";
		alert("in2"); 
	}
	else
	{
        alert(retVal); 	
	}
}
