



var selectedService = "none";



var currentLevel = -1;



var contacts = [

    { title: "Contact our offices", value: "offices", level: "officesLevel" },

    { title: "Submit a question", value: "question", level: "questionLevel" },

    { title: "Send us an email", value: "email", level: "emailLevel" }

];



var alcoholItems = [

    { title: "Donors Details", value: "donors", level: "donorsLevel" },

    { title: "Invoice and Result", value: "invoice", level: "invoiceLevel" },

	

    { title: "Alcohol Questions", value: "alcohol questions", level: "alcoholQuestionsLevel" },

    { title: "Test(s) required", value: "test required", level: "testRequiredLevel" },

	

    { title: "Expert Witness Statement", value: "witness", level: "witnessLevel" },

    { title: "Nurse Sample Collection", value: "nurse", level: "nurseLevel" },

    { title: "Your details", value: "details", level: "detailsLevel" }

];



var drugItems = [

    { title: "Donors Details", value: "donors", level: "donorsLevel" },

    { title: "Invoice and Result", value: "invoice", level: "invoiceLevel" },

	

    { title: "Drug to be tested for", value: "drug tested", level: "drugTestedLevel" },

    { title: "Duration of drug testing", value: "duration", level: "durationLevel" },

    { title: "Type of test required", value: "type", level: "typeLevel" },

	

    { title: "Expert Witness Statement", value: "witness", level: "witnessLevel" },

    { title: "Nurse Sample Collection", value: "nurse", level: "nurseLevel" },

    { title: "Your details", value: "details", level: "detailsLevel" }

];



var offices = [

    {

		key: "uk",

		title: "UK (Headquarters)",

		add1: "15 Old Bailey",

		add2: "London",

		add3: "EC4M 7EF",

		add4: "",

		tel: "tel: +44 (0)845 388 0124",

		fax: "fax: +44 (0)845 280 2475",

		call: "+44-845-388-0124",

		map: "15 Old Bailey, London, United Kingdom",

		img: "Images/uk.jpg"

	},
	
	{

		key: "uk lab",

		title: "UK (Laboratory)",

		add1: "Hexagon Tower",

		add2: "Old Market Street",

		add3: "Blackley",

		add4: "Manchester M9 8ES",

		tel: "",

		fax: "",

		call: "",

		map: "Hexagon Tower, Old Market Street, Manchester M9 8ES, UK",

		img: "Images/uk.jpg"

	},

    {

		key: "germany",

		title: "Germany",

		add1: "Sedanstrasse 14",

		add2: "Ulm",

		add3: "89077",

		add4: "",

		tel: "tel: +49 (0)731 159 27320",

		fax: "fax: +49 (0)731 230 9059",

		call: "+49-731-159-27302",

		map: "Sedanstrasse 14, Ulm, Germany",

		img: "Images/ger.jpg"

	},

    {

		key: "south africa",

		title: "South Africa",

		add1: "32 Roeland Square",

		add2: "Roeland Street",

		add3: "Cape Town 8001",

		add4: "",

		tel: "tel: +27 (0)21 673 6783",

		fax: "fax: +27 (0)21 556 2516",

		call: "+27-21-673-6783",

		map: "32 Roeland Square, Roeland Street, Cape Town, South Africa",

		img: "Images/rsa.jpg"

	}


];



var alcoholController = {

    

    numberOfRows: function() {

        return alcoholItems.length;

    },

    

    prepareRow: function(rowElement, rowIndex, templateElements) {

        templateElements.label1.innerText = alcoholItems[rowIndex].title;



        var self = this;

        var handler = function() {

            var alcoholItem = alcoholItems[rowIndex];

            var browser = document.getElementById('browser').object;

            browser.goForward(document.getElementById(alcoholItem.level), alcoholItem.title);

			currentLevel = rowIndex;

        };

        rowElement.onclick = handler;

    }

};



var drugController = {

    

    numberOfRows: function() {

        return drugItems.length;

    },

    

    prepareRow: function(rowElement, rowIndex, templateElements) {

        templateElements.label2.innerText = drugItems[rowIndex].title;



        var self = this;

        var handler = function() {

            var drugItem = drugItems[rowIndex];

            var browser = document.getElementById('browser').object;

            browser.goForward(document.getElementById(drugItem.level), drugItem.title);

			currentLevel = rowIndex;

        };

        rowElement.onclick = handler;

    }

};



var contactController = {

    

    numberOfRows: function() {

        return contacts.length;

    },

    

    prepareRow: function(rowElement, rowIndex, templateElements) {

        templateElements.label.innerText = contacts[rowIndex].title;



        var self = this;

        var handler = function() {

            var contact = contacts[rowIndex];

            var browser = document.getElementById('browser').object;

            switch(contact.value){

                case "offices":

                browser.goForward(document.getElementById('officeLevel'), contact.title);

                break;

                case "question":

                browser.goForward(document.getElementById('questionFormLevel'), contact.title);

				document.getElementById('whichForm').value = "Question";

                break;

                case "email":

                window.location = "mailto:" + "info@trimegalabs.com" + "?subject=" + "IPHONE INFO REQUEST";

                break;

            }

        };

        rowElement.onclick = handler;

    }

};



var officeController = {

    

    numberOfRows: function() {

        return offices.length;

    },

    

    prepareRow: function(rowElement, rowIndex, templateElements) {

        templateElements.label3.innerText = offices[rowIndex].title;



        var self = this;

        var handler = function() {

            var office = offices[rowIndex];

            officeContactController.setOffice(office);

            var browser = document.getElementById('browser').object;

            browser.goForward(document.getElementById('contactLevel'), office.title);

        };

        rowElement.onclick = handler;

    }

};



var officeContactController = {

    

    setOffice: function(office) {

        this._office = office;

        this._representedObject = office.name;

        

        document.getElementById('detailTitle').innerHTML = this._office.title;

        document.getElementById('detailLocation').innerHTML = this._office.add1;

        document.getElementById('detailLocation1').innerHTML = this._office.add2;

        document.getElementById('detailLocation2').innerHTML = this._office.add3;
		
        document.getElementById('detailLocation3').innerHTML = this._office.add4;

        document.getElementById('detailDescription').innerHTML = this._office.tel;

        document.getElementById('detailDescription1').innerHTML = this._office.fax;

		if(this._office.call==""){
			document.getElementById('callButton').style.display="none";
		}else{
			document.getElementById('callButton').style.display="block";
			document.getElementById('callButton').object.setPhoneNumber(this._office.call);
		}

        document.getElementById('mapButton1').object.setAddress(this._office.map);

        document.getElementById('img20').src = this._office.img;

    }

    

};



function load()

{

    dashcode.setupParts();

}



function goToAlcohol(event)

{

    var browser = document.getElementById('browser').object;

    browser.goForward(document.getElementById('alcoholLevel'), "Alcohol");

	selectedService = "Alcohol";

	document.getElementById('whichForm').value = "Quotation";

}



function goToDrugs(event)

{

    var browser = document.getElementById('browser').object;

    browser.goForward(document.getElementById('drugsLevel'), "Drugs");

	selectedService = "Drugs";

	document.getElementById('whichForm').value = "Quotation";

}









function goToNextLevel(event)

{

	currentLevel++;

	var nextLevel = currentLevel;

	

	switch(selectedService){

    	case "Alcohol":

			var nextItem = alcoholItems[nextLevel];

        break;

    	case "Drugs":

			var nextItem = drugItems[nextLevel];

        break;

    }

	

    var browser = document.getElementById('browser').object;

    browser.goForward(document.getElementById(nextItem.level), nextItem.title);

}



function submitQuestion(event)

{

	if( validateQuestionForm() ) {

		document.forms["quotation"].submit();

	}

}



function submitQuotation(event)

{

	if( validateQuotationForm() ) {

		document.forms["quotation"].submit();

	}

}



function clearFieldValue(field, initialState)

{

	if(field.value == initialState){

		field.value = "";

	}

}



function clearFieldHTML(field, initialState)

{

	if(field.value == initialState){

		field.innerHTML = "";

	}

}



function refillFieldValue(field, initialState)

{

	if(field.value == ""){

		field.value = initialState;

	}

}



function refillFieldHTML(field, initialState)

{

	if(field.value == ""){

		field.innerHTML = initialState;

	}

}



function validateQuotationForm() {



	if (document.quotation.donor_name.value=="")

	{

		if(currentLevel!=0){

			var browser = document.getElementById('browser').object;

			browser.goForward(document.getElementById('donorsLevel'), 'Donors Details');

			currentLevel = 0;

		}

		document.quotation.donor_name.focus();

		alert("Please enter Donor's Name");

		return false;

	}

	else if (document.quotation.salutation.value=="")

	{

		if(currentLevel!=0){

			var browser = document.getElementById('browser').object;

			browser.goForward(document.getElementById('donorsLevel'), 'Donors Details');

			currentLevel = 0;

		}

		document.quotation.salutation.focus();

		alert("Please select your Salutation");

		return false;

	}

	else if (document.quotation.date_of_birth.value=="")

	{

		if(currentLevel!=0){

			var browser = document.getElementById('browser').object;

			browser.goForward(document.getElementById('donorsLevel'), 'Donors Details');

			currentLevel = 0;

		}

		document.quotation.date_of_birth.focus();

		alert("Please enter Donor's Date of Birth.");

		return false;

	}

	

	

	

	else if (document.quotation.name_sent.value=="")

	{

		if(currentLevel!=1){

			var browser = document.getElementById('browser').object;

			browser.goForward(document.getElementById('invoiceLevel'), 'Invoice and Result');

			currentLevel = 1;

		}

		document.quotation.name_sent.focus();

		alert("Please enter Results and Invoice to be sent to Name");

		return false;

	}

	else if (document.quotation.post_code.value=="")

	{

		if(currentLevel!=1){

			var browser = document.getElementById('browser').object;

			browser.goForward(document.getElementById('invoiceLevel'), 'Invoice and Result');

			currentLevel = 1;

		}

		document.quotation.post_code.focus();

		alert("Please enter Results and Invoice to be sent to Post Code");

		return false;

	}

	else if (document.quotation.organisation.value=="")

	{

		if(currentLevel!=1){

			var browser = document.getElementById('browser').object;

			browser.goForward(document.getElementById('invoiceLevel'), 'Invoice and Result');

			currentLevel = 1;

		}

		document.quotation.organisation.focus();

		alert("Please enter Results and Invoice to be sent to organisation");

		return false;

	}

	else if (document.quotation.tel_no.value=="")

	{

		if(currentLevel!=1){

			var browser = document.getElementById('browser').object;

			browser.goForward(document.getElementById('invoiceLevel'), 'Invoice and Result');

			currentLevel = 1;

		}

		document.quotation.tel_no.focus();

		alert("Please enter Results and Invoice to be sent to Tel No");

		return false;

	}

	else if (document.quotation.address.value=="")

	{

		if(currentLevel!=1){

			var browser = document.getElementById('browser').object;

			browser.goForward(document.getElementById('invoiceLevel'), 'Invoice and Result');

			currentLevel = 1;

		}

		document.quotation.address.focus();

		alert("Please enter Results and Invoice to be sent to Address");

		return false;

	}

	else if (document.quotation.fax_no.value=="")

	{

		if(currentLevel!=1){

			var browser = document.getElementById('browser').object;

			browser.goForward(document.getElementById('invoiceLevel'), 'Invoice and Result');

			currentLevel = 1;

		}

		document.quotation.fax_no.focus();

		alert("Please enter Results and Invoice to be sent to Fax No");

		return false;

	}

	

	else if (document.quotation.reference.value=="")

	{

		if(currentLevel!=1){

			var browser = document.getElementById('browser').object;

			browser.goForward(document.getElementById('invoiceLevel'), 'Invoice and Result');

			currentLevel = 1;

		}

		document.quotation.reference.focus();

		alert("Please enter your Reference");

		return false;

	}

	

	else if (document.quotation.emailaddress.value=="")

	{

		if(currentLevel!=1){

			var browser = document.getElementById('browser').object;

			browser.goForward(document.getElementById('invoiceLevel'), 'Invoice and Result');

			currentLevel = 1;

		}

		document.quotation.emailaddress.focus();

		alert("Please enter your Email Address");

		return false;

	}



	return true;

	

}



function validateQuestionForm() {



	if ((document.quotation.company.value=="")||(document.quotation.company.value=="Company / Firm / Authority Name"))

	{

		document.quotation.company.focus();

		alert("Please enter your Company Name");

		return false;

	}

	else if ((document.quotation.fname.value=="")||(document.quotation.fname.value=="First Name"))

	{

		document.quotation.fname.focus();

		alert("Please enter your First Name");

		return false;

	}

	else if ((document.quotation.lname.value=="")||(document.quotation.lname.value=="Last Name"))

	{

		document.quotation.lname.focus();

		alert("Please enter your Last Name");

		return false;

	}

	else if ((document.quotation.email.value=="")||(document.quotation.email.value=="Email"))

	{

		document.quotation.email.focus();

		alert("Please enter your Email");

		return false;

	}



	return true;

	

}


