/*
 Copyright Innovision IT 2009
*/

if (typeof(scripts) == 'undefined') var scripts = new Object();
importScript('./library/javascript/ajax.js');
importScript('./library/filament/eventRouter.js');
importScript('./library/scriptaculous/lib/prototype.js');
importScript('./library/scriptaculous/src/effects.js');

function importScript(jsFile) {
	if (scripts[jsFile] != null) return;
	var scriptElt = document.createElement('script');
	scriptElt.type = 'text/javascript';
	scriptElt.src = jsFile;
	document.getElementsByTagName('head')[0].appendChild(scriptElt);
	scripts[jsFile] = jsFile; // or whatever value your prefer
}

window.onload = function(){
	init();
}

function init(){
	var home = document.getElementById('home');
	var homeRouter = new jsEvent.EventRouter(home, 'onclick');
	homeRouter.addListener(homeMouseObserver);

	var contact = document.getElementById('contact');
	var contactRouter = new jsEvent.EventRouter(contact, 'onclick');
	contactRouter.addListener(contactMouseObserver);

	var newsletters = document.getElementById('newsletters');
	var newslettersRouter = new jsEvent.EventRouter(newsletters, 'onclick');
	newslettersRouter.addListener(newslettersMouseObserver);

	var companyProfile = document.getElementById('companyProfile');
	var companyProfileRouter = new jsEvent.EventRouter(companyProfile, 'onclick');
	companyProfileRouter.addListener(companyProfileMouseObserver);

	var financialServicesGuide = document.getElementById('financialServicesGuide');
	var financialServicesGuideRouter = new jsEvent.EventRouter(financialServicesGuide, 'onclick');
	financialServicesGuideRouter.addListener(financialServicesGuideMouseObserver);

	var services = document.getElementById('services');
	var servicesRouter = new jsEvent.EventRouter(services, 'onclick');
	servicesRouter.addListener(servicesMouseObserver);

	var strategicPartners = document.getElementById('strategicPartners');
	var strategicPartnersRouter = new jsEvent.EventRouter(strategicPartners, 'onclick');
	strategicPartnersRouter.addListener(strategicPartnersMouseObserver);

	var hayesKnight = document.getElementById('hayesKnight');
	var hayesKnightRouter = new jsEvent.EventRouter(hayesKnight, 'onclick');
	hayesKnightRouter.addListener(hayesKnightMouseObserver);

	var wealthsure = document.getElementById('wealthsure');
	var wealthsureRouter = new jsEvent.EventRouter(wealthsure, 'onclick');
	wealthsureRouter.addListener(wealthsureMouseObserver);

	var mda = document.getElementById('mda');
	var mdaRouter = new jsEvent.EventRouter(mda, 'onclick');
	mdaRouter.addListener(mdaMouseObserver);
}

function homeMouseObserver(event){
	getDataForId("./view/home.php", "content");
}

function contactMouseObserver(event){
	getDataForId("./view/contact.php", "content");
}

function newslettersMouseObserver(event){
	getDataForId("./view/newsletters.php", "content");
}

function companyProfileMouseObserver(event){
	getDataForId("./view/companyProfile.php", "content");
}

function financialServicesGuideMouseObserver(event){
	getDataForId("./view/financialServicesGuide.php", "content");
}

function servicesMouseObserver(event){
	getDataForId("./view/services.php", "content");
}

function lifestylePlanningMouseObserver(event){
	getDataForId("./view/lifestylePlanning.php", "content");
}

function managedFundsMouseObserver(event){
	getDataForId("./view/managedFunds.php", "content");
}

function retirementPlanningMouseObserver(event){
	getDataForId("./view/retirementPlanning.php", "content");
}

function superannuationMouseObserver(event){
	getDataForId("./view/superannuation.php", "content");
}

function wealthAccumulationMouseObserver(event){
	getDataForId("./view/wealthAccumulation.php", "content");
}

function wealthProtectionMouseObserver(event){
	getDataForId("./view/wealthProtection.php", "content");
}

function strategicPartnersMouseObserver(event){
	getDataForId("./view/strategicPartners.php", "content");
}

function hayesKnightMouseObserver(event){
	getDataForId("./view/hayesKnight.php", "content");
}

function familyLawSettlementsMouseObserver(event){
	getDataForId("./view/familyLawSettlements.php", "content");
}

function wealthsureMouseObserver(event){
	getDataForId("./view/wealthsure.php", "content");
}

function mdaMouseObserver(event){
	getDataForId("./view/mda.php", "content");
}

function getPicture(pictureName){
	getDataForId("./view/picture.php?name=" + pictureName, "divPicture");
}

function fade(element, call){
	var obj = document.getElementById(element);
	Effect.Fade(obj);
	window.setTimeout(call, 1000);
}

function appear(element, call){
	var obj = document.getElementById(element);
	Effect.Appear(obj);
}

function grow(element){
	var obj = document.getElementById(element);
	Effect.Grow(obj);
}

function uploadPhoto(obj) {
   var poststr = "&name=" + encodeURI( document.getElementById("name").value ) +
                 "&email=" + encodeURI( document.getElementById("email").value) +
                 "&photo=" + encodeURI( document.getElementById("photo").value) +
                 "&comment=" + encodeURI( document.getElementById("comment").value +
                 "&submit=''");
   makePOSTRequest('./view/upload.php', poststr);
}
