// JavaScript Document
var photoManager = {
   	contactInfo : function(hide) {
		//YAHOO.util.Dom.setStyle('contactCard', 'display', 'block'); 
		
		var contactCard = document.getElementById('contactCard');
		var feature = document.getElementById('feature');
		if (hide==true) {
			contactCard.style.display='block';
			feature.style.display='none';
		} else {
			contactCard.style.display='none';
			feature.style.display='block';
		}
	},
	
	 init : function() {
		alert("Welcome To Photo Manager");
        $("contactInfo").onclick = function() {
            photoManager.contactInfo()
        };
		/*
		if(navigator.appName.indexOf("Microsoft") != -1) {
    		this.flash = window.flashThermostat;
 		 }else {
    		this.flash = window.document.flashThermostat;
  		}
		
		if(this.initiated==true){
			setTimeout("thermostatManager.refresh();",500);
			return;	
		}		

        minInitTemp = 0;//$("minInitTemp").value;
        actualInitTemp = 0;//$("actualInitTemp").value;
        maxInitTemp = 0;//$("maxInitTemp").value;

        //set up sliders and spinners
        tempSliderControls = new tempSliderControls('', 'tempSliderControls');
        tempSliderControls.init(minInitTemp,maxInitTemp);

		events.subscribe('tempSliderControls', function() {
			//alert("event tempSliderControls fired. "+tempSliderControls.minField.value+" "+tempSliderControls.maxField.value);
			if(typeof(thermostatManager.flash.setFlashHeatPoint)!="function") return;
    		thermostatManager.flash.setFlashHeatPoint(tempSliderControls.minField.value);
    		thermostatManager.flash.setFlashCoolPoint(tempSliderControls.maxField.value);
   			//alert("flash is "+ thermostatManager.flash.getFlashHeatPoint+" "+thermostatManager.flash.getFlashCoolPoint);
		});

        //bottom submit / cancel buttons
        $("refreshButton").onclick = function() {
            thermostatManager.refresh()
        };
        $("returnButton").onclick = function() {
            thermostatManager.returnToProgram()
        };
        $("setAwayButton").onclick = function() {
            thermostatManager.setOccMode(1)
        };
        $("setSleepButton").onclick = function() {
            thermostatManager.setOccMode(2)
        };
        $("setHomeButton").onclick = function() {
            thermostatManager.setOccMode(0)
        };
        
		//heat cool mode radios behavior
        $("rb_hc").onclick = function() {
            thermostatManager.changeHeatCool('on', 'on')
        };
        $("rb_ho").onclick = function() {
            thermostatManager.changeHeatCool('on', 'off')
        };
        $("rb_co").onclick = function() {
            thermostatManager.changeHeatCool('off', 'on')
        };
        $("rb_fo").onclick = function() {
            thermostatManager.changeHeatCool('off', 'off')
        };
        $("rb_off").onclick = function() {
            thermostatManager.changeHeatCool('off', 'off')
        };
        //alert("done init");
		setTimeout("thermostatManager.refresh();",500);
		this.initiated=true;
		*/
    }

	/*
    doCall : function(url) {
		if(typeof(thermostatManager.flash.showFlashLoading)=='function')
			thermostatManager.flash.showFlashLoading(true);
        //YAHOO.util.Dom.setStyle('thermostatLoading', 'display', 'block');
        //fadeIn.animate();
        var callbacks = {

            success : function(response) {
                thermostatManager.updateThermostat(0, response);
                //YAHOO.util.Dom.setStyle('thermostatLoading', 'display', 'none');
                //fadeOut.animate();        
            },

            failure : function(response) {

                alert(response.status + "\n" +
                      response.statusText + "\n" +
                      response.getAllResponseHeaders);
            }

        }

        // Make the AJAX connection via YUI
        var connection = YAHOO.util.Connect.asyncRequest("GET", url, callbacks);
        return false;
    },

    updateThermostat : function(id, arg) {
        // Make the AJAX connection via YUI
        //alert("updateThermostat");
        var values = eval('(' + arg.responseText + ')');

        //HvacModeTxt = "Custom Mode";
        switch (values.hvacMode) {
            case 0:
                $("rb_hc").checked = true;
                //$("hvacModeDisplay").value = "Auto";
				//HvacModeTxt="Auto";
                thermostatManager.changeHeatCool('on', 'on');
                break;
            case 1:
                $("rb_ho").checked = true;
                //$("hvacModeDisplay").value = "Heat On";
				//HvacModeTxt="Heat On";
                thermostatManager.changeHeatCool('on', 'off');
                break;
            case 2:
                $("rb_co").checked = true;
                //$("hvacModeDisplay").value = "AC On";
				//HvacModeTxt="AC On";
                thermostatManager.changeHeatCool('off', 'on');
                break;
            case 3:
                $("rb_fo").checked = true;
                //$("hvacModeDisplay").value = "Fan Only";
				//HvacModeTxt="Fan Only";
                thermostatManager.changeHeatCool('off', 'off');
                break;
            case 4:
                $("rb_off").checked = true;
                //$("hvacModeDisplay").value = "Off";
				//HvacModeTxt="Off";
                thermostatManager.changeHeatCool('off', 'off');
                break;
        }

        switch (values.occMode) {
            case 0:
                //$("occModeDisplay").value = "Home";
                OccModeTxt="Home";
                //$("rb_home").checked = true;
                break;
            case 1:
            case 3:
                //$("occModeDisplay").value = "Away";
                OccModeTxt="Away";
                //$("rb_away").checked = true;
                break;
            case 2:
                //$("occModeDisplay").value = "Sleep";
                OccModeTxt="Sleep";
                //$("rb_asleep").checked = true;
                break;
            // todo - default is program mode?
        }

        //alert('heat stage: '+values.heatStage+' cool stage: '+values.coolStage+' fan on: '+values.fanOn);
        HvacModeTxt = " --- ";
        if (values.heatStage>0) {
            HvacModeTxt = "Heat Stage "+values.heatStage;
        } else if (values.coolStage>0) {
            HvacModeTxt = "Cool Stage "+values.coolStage;
        } else if (values.fanOn) {
            HvacModeTxt = "Fan On";
        }
		//alert("HvacModeTxt='"+HvacModeTxt+"'");
        if(typeof(this.flash.setFlashHeatPoint)=='function'){
			//alert("flash defined");
        	thermostatManager.flash.setFlashHeatPoint(values.heatPointDisplay);
			thermostatManager.flash.setFlashCoolPoint(values.coolPointDisplay);
			thermostatManager.flash.setFlashActualPoint(values.currentTempDisplay);
			thermostatManager.flash.showFlashLoading(false);
			thermostatManager.flash.setFlashHvacMode(HvacModeTxt);
			thermostatManager.flash.setFlashOccMode(OccModeTxt);
		}
        thermostatManager.setMinMax(values.heatPointDisplay, values.coolPointDisplay);
		tempSliderControls.setMinMax(values.heatPointDisplay, values.coolPointDisplay);
//		$("tstatApplet").refresh();

		//alert("ready to quit");

        return false;
    },
	*/
}

// Initialize thermostatManager when thermostat popup has completed loading via
// AJAX to avoid referencing non existent HTML elements
//events.subscribe("init", function() {
//    photoManager.init();
//});
//  triggered by the tempSliderControls.js upon changes to the slider
/*events.subscribe("json", function(id, arg) {
    thermostatManager.updateThermostat(id, arg);
});*/


