//
// Function: load()
// Called by HTML body element's onload event when the web application is ready to start
//
function load()
{
    dashcode.setupParts();
}

// This object implements the dataSource methods for the list.
var listDataSource = {
	
	// Sample data for the content of the list. 
	// Your application may also fetch this data remotely via XMLHttpRequest.
	_rowData: ["For The End User" , "For The Administrator" , "Create Citrix Demo Account" , "How To Setup Demo Account", "Citrix iPhone Community", "Sign up for News"],
	
	// The List calls this method to find out how many rows should be in the list.
	numberOfRows: function() {
		return this._rowData.length;
	},
	
	// The List calls this method once for every row.
	prepareRow: function(rowElement, rowIndex, templateElements) {
		// templateElements contains references to all elements that have an id in the template row.
		// Ex: set the value of an element with id="label".
		if (templateElements.label) {
			templateElements.label.innerText = this._rowData[rowIndex];
		}

		// Assign a click event handler for the row.
		rowElement.onclick = function(event) 
        {
            var browser = document.getElementById('browser').object;
            
            // Sets navigation forward on the stackLayout object to Requirements Page
            
            //end user   
            if (rowIndex == 0)  
            {
                //location = "http://teddfox1@idisk.me.com/teddfox1/Web/Sites/iApps/pdf/iphone-receiver-user.pdf";
                location = "m.iphone.citrix.com/gp/iphone/pdf/iphone-receiver-user.pdf";
            }
            
            //administrator
            else if (rowIndex == 1)
             {
                //location = "http://teddfox1@idisk.me.com/teddfox1/Web/Sites/iApps/pdf/iphone-receiver-admin.pdf";
                location = "m.iphone.citrix.com/go/iphone/pdf/iphone-receiver-admin.pdf";
            }
            else if (rowIndex == 2)
            {
                open("http://iphonereg.citrixcloud.net");
            }
             
            else if (rowIndex == 3)
           
            //First Time Run Vid
            {
                //location = "http://web.citrix.com/go/iphone/Videos/CitrixReceiverFirstTimeSetup-iPhone.m4v";
                location = "http://web.me.com/gusp/iApps/CitrixReceiver/Videos/CitrixReceiverFirstTimeSetup-iPhone.m4v";
            }
             
            // Opens Citrix iPhone Community site.
            else if (rowIndex == 4)
            {
                open("http://community.citrix.com/iphone");
            }
            
            // Sets navigation forward on the stackLayout object to Sign up for Receiver updates
            else if (rowIndex == 5)
            {
                browser.goForward(document.getElementById('receiverNews'), "Citrix Receiver");
            }
           

		};
	}
};

function sendSignupEmail(event)
{
    if ((document.getElementById('firstname').value != "") &&
        (document.getElementById('lastname').value != "") &&
        (document.getElementById('email').value != ""))
    {
        var encodedEmailAddress = encodeURI("iphone@citrix.com");
        var encodedSubject = encodeURI("Sign me up for Citrix Receiver Updates");
        var encodedBody0 = encodeURI("Name      :   " + document.getElementById('firstname').value 
        + document.getElementById('returnCh').innerHTML);
        var encodedBody1 = encodeURI("Last Name :   " + document.getElementById('lastname').value 
        + document.getElementById('returnCh').innerHTML);
        var encodedBody2 = encodeURI("Email     :   " + document.getElementById('email').value 
        + document.getElementById('returnCh').innerHTML);
        var encodedBody3 = encodeURI(document.getElementById('singUpEmailText').innerHTML);
        window.location = "mailto:" + encodedEmailAddress + "?subject=" + encodedSubject + "&body=" 
        + encodedBody0 + encodedBody1 + encodedBody2 + encodedBody3;
    }
    else
    {
        alert("All fields are required!");
    }
};

function emailReqsPage(event)
{
    var encodedEmailAddress = encodeURI("");
    var encodedSubject = encodeURI("Citrix Receiver Requirements");
    var encodedBody = encodeURI(document.getElementById('receiverRequirementsText').innerHTML);
    window.location = "mailto:" + encodedEmailAddress + "?subject=" + encodedSubject + "&body=" + encodedBody;
};

function emailTipsPage(event)
{
    var encodedEmailAddress = encodeURI("");
    var encodedSubject = encodeURI("Citrix Receiver Tips and Tricks");
    var encodedBody = encodeURI(document.getElementById('receiverTipsandTricksText').innerHTML);
    window.location = "mailto:" + encodedEmailAddress + "?subject=" + encodedSubject + "&body=" + encodedBody;
};
