
    var flashvars = {};
    var params = {menu: "false", wmode: "transparent", allowScriptAccess: "sameDomain", allowFullScreen: "false"};
    var attributes = {id: "FlipClock", name: "FlipClock"};
    swfobject.embedSWF("swf/FlipClock.swf", "myclock", "497", "151", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
    var totalCount = 0;
    var totalCountTimers = 0;
    var arrAlarmTime = new Array(3);
    var arrAlarmTimeoutID = new Array(3);

    function setAlarm() {
        if (totalCountTimers < 3) {
            var alarmHours = document.getElementById("cmdHours").value;
            var alarmMinutes = document.getElementById("cmdMinute").value;
            LoadTimeAlarm();
            var alarmMeredien = document.getElementById("cmbMeredien").value;
            showAlarmHours = (alarmHours.length == 1) ? "0" + alarmHours : alarmHours;
            showAlarmMinutes = (alarmMinutes.length == 1) ? "0" + alarmMinutes : alarmMinutes;
            arrAlarmTime[totalCount] = showAlarmHours + ":" + showAlarmMinutes + " " + alarmMeredien;
            if (alarmMeredien == "PM") {
                if (alarmHours == 12) {
                    alarmHours = 0;
                }
                alarmHours = parseInt(alarmHours) + parseInt(12);
            } else if (alarmMeredien == "AM") {
                if (alarmHours == 12) {
                    alarmHours = 0;
                }
            }
            var d = new Date;
            var currentHours = d.getHours();
            var currentMinutes = d.getMinutes();
            var currentSeconds = d.getSeconds();
            var remaininghrs = 23 - currentHours;
            var remainingmins = 60 - currentMinutes;
            var remainingsecs = 60 - currentSeconds;
            var totalAlarmSecondsTemp = (parseInt(alarmHours) * 3600) + parseInt(alarmMinutes) * 60;
            var remainingtotalsecs = (parseInt(remaininghrs) * 3600) + parseInt(remainingmins) * 60 + remainingsecs;
            var totalCurrentSecondsTemp = (parseInt(currentHours) * 3600) + parseInt(currentMinutes) * 60 + parseInt(currentSeconds);
            var totalSeconds = totalAlarmSecondsTemp - totalCurrentSecondsTemp;
            if (totalSeconds < 0) {
                totalAlarmSecondsTemp = totalAlarmSecondsTemp + remainingtotalsecs;
                totalSeconds = totalAlarmSecondsTemp;
                _L("totalAlarmSecondsTemp " + totalAlarmSecondsTemp);
                _L("totalSeconds " + totalSeconds);
            }
            if (totalSeconds >= 0) {
                _L("fire back after secs" + totalSeconds);
                totalDiffMiliseconds = parseInt(totalSeconds) * parseInt(1000);
                arrAlarmTimeoutID[totalCount] = setTimeout("showFlash('" + totalCount + "')", parseInt(totalDiffMiliseconds));
                var showAlarmTime = "";
                for (i = 0; i < arrAlarmTime.length; i++) {
                    if (arrAlarmTime[i]) {
                        showAlarmTime += "<div id='li_" + arrAlarmTimeoutID[i] + "'><span class='alarm_time'>" + arrAlarmTime[i] + "</span><span class='link'>[ <a style='color:#ffffff' href='javascript:void(0);' onclick='clearTimer(" + i + ");'>x</a> ]</span> <span class='alarm_description'>( alarm set )</span></div>";
                    }
                }
                totalCount++;
                totalCountTimers++;
                document.getElementById("divCurrentAlarms").innerHTML = showAlarmTime;
                document.getElementById("divAlarmNo").innerHTML = totalCountTimers;
            }
        } else {
            alert("You can't set more than 3 Alarms");
        }
    }


function setAlarmTweet() { 

	document.getElementById("divtwitter").style.visibility = "visible";
            document.getElementById("txtemail").focus();

    }

function closeTwitterbox(){
		document.getElementById("divtwitter").style.visibility = "hidden";
         //   document.getElementById("txtemail").focus();
	
}

function closePreview(){
		document.getElementById("divpreview").style.visibility = "hidden";
         //   document.getElementById("txtemail").focus();
	
}


function CloseTwitterAfterOAuth(){
		document.getElementById("divtwitter2").style.visibility = "hidden";
            document.getElementById("txtemail").focus();
	
}



    function clearTimer(clearID) {
        clearTimeout(arrAlarmTimeoutID[clearID]);
        document.getElementById("li_" + arrAlarmTimeoutID[clearID]).innerHTML = "";
        totalCountTimers--;
        document.getElementById("divAlarmNo").innerHTML = totalCountTimers;
        arrAlarmTime[clearID] = "";
    }


    function _L(logstr) {
		return 0;
        try {
			console.log(logstr)
        } catch (err) {
        }
    }


    var mymovie;
    var isWindows = navigator.appName.indexOf("Microsoft") != -1;

    function onFlashLoad() {
    }




    function InitializePage() {
        var dDefault = new Date;
        var currentHoursDefault = dDefault.getHours();
        var currentMinutesDefault = dDefault.getMinutes();
        if (currentHoursDefault > 12) {
            currentHoursDefault = parseInt(currentHoursDefault) - 12;
            document.getElementById("cmbMeredien").value = "PM";
        } else if (currentHoursDefault == 12) {
            document.getElementById("cmbMeredien").value = "PM";
        } else {
            document.getElementById("cmbMeredien").value = "AM";
        }
        document.getElementById("cmdHours").value = currentHoursDefault;
        document.getElementById("cmdMinute").value = currentMinutesDefault;
        setTimeout("preloadswfs()", 1000);
        setVal("isLoud", 0);
    }


    function setParent(el, newParent) {
        newParent.appendChild(el);
    }


    function getSWF(movieName) {
        return document.getElementById(movieName);
    }


    function StartplayingfromScript(trframeno) {
        mymovie = getSWF("infotimer");
        mymovie.StartplayingfromScript(trframeno);
    }


    function setLoudAlarm(myvalr) {
        mymovie = getSWF("infotimer");
        mymovie.setLoudAlarm(myvalr);
    }


    function obj(_id) {
        return document.getElementById(_id);
    }


    function $V(_id) {
        return document.getElementById(_id).value;
    }


    function setVal(_id, _val) {
        document.getElementById(_id).value = _val;
    }


    function setHtml(_id, _txte) {
        document.getElementById(_id).innerHTML = _txte;
    }


    function ChangesoundType() {
        selobj = document.getElementById("cmbalarmtype");
        if ($V("isLoud") == "1") {
            setVal("isLoud", 0);
            setHtml("divovalbtn", "<span>Loud :) </span>");
            currTabElem = obj("divovalbtn");
            currTabElem.setAttribute("class", "ovalbuttonloud");
            currTabElem.setAttribute("className", "ovalbuttonloud");
        } else {
            setVal("isLoud", 1);
            setHtml("divovalbtn", "<span> ~ Soft ~ </span>");
            currTabElem = obj("divovalbtn");
            currTabElem.setAttribute("class", "ovalbuttonsoft");
            currTabElem.setAttribute("className", "ovalbuttonsoft");
        }
        setLoudAlarm($V("isLoud"));
    }


    function updatezipcode() {
//        selobj = document.getElementById("cmbalarmtype");
        if (document.getElementById("txtzip").value == "") {
           // selobj.selectedIndex = 0;
            document.getElementById("divzipcode").style.visibility = "hidden";
            return;
        }
     
	 //_myval = "WEATHER_" + document.getElementById("txtzip").value;
        createCookie("myLocId", $V('txtzip'));
  
  createCookie("ChangeLocinfo", "true");
  

        document.getElementById("divzipcode").style.visibility = "hidden";
	//	setVal("alarmtype", "2") 
//		changeflashzipcode($V('txtzip'));
		
		 window.location.reload( false );

		
		

//        ChangemyAlarmtype("2");
    }


    function onUpdateFlightcode() {
       
        if (document.getElementById("txtflightno").value == "") {
       
            document.getElementById("divflight").style.visibility = "hidden";
            return;
        }
       
        createCookie("myflightcode", $V('txtflightno'));
       
	   document.getElementById("divflight").style.visibility = "hidden";
	   
	   setVal("alarmtype", "3") 
	    ChangemyAlarmtype("3");
		changeflashflightcode($V('txtflightno'));
		
        
    }

	function showUpdateZipcode(){
		
//		    document.getElementById("txtzip").value = _zipcode;
            document.getElementById("divzipcode").style.visibility = "visible";
            document.getElementById("txtzip").focus();
	}
	function closeFlightInfo(){
		  document.getElementById("divflight").style.visibility = "hidden";
		
	}
		function showUpdateFlightcode(){
		
//		    document.getElementById("txtzip").value = _zipcode;
            document.getElementById("divflight").style.visibility = "visible";

				document.getElementById("txtflightno").value=document.getElementById("flightcode").value
            document.getElementById("txtflightno").focus();
			
	}

    function ChangemyAlarmtype(_curindex) {

       /* _L(document.getElementById("cmbalarmtype").value);
        _curindex = document.getElementById("cmbalarmtype").selectedIndex;
        bufferval = document.getElementById("cmbalarmtype").value;
        alrmtype = bufferval;
        _changeweatherindex = 2;
        _changeflightindex = 3;
        if (bufferval == "NewWeatherLocation") {
            document.getElementById("divzipcode").style.visibility = "visible";
            document.getElementById("txtzip").focus();
            return;
        } else if (bufferval == "ChangeWeatherLocation") {
            selobj = document.getElementById("cmbalarmtype");
            opt = selobj.options[_changeweatherindex];
            _bufferval = opt.value;
            selobj.selectedIndex = _changeweatherindex;
            _zipcode = _bufferval.replace("WEATHER_", "");
            document.getElementById("txtzip").value = _zipcode;
            document.getElementById("divzipcode").style.visibility = "visible";
            document.getElementById("txtzip").focus();
            return;
        }
        if (bufferval == "NewFlight") {
            document.getElementById("divflight").style.visibility = "visible";
            document.getElementById("txtflightno").focus();
            return;
        } else if (bufferval == "ChangeFlight") {
            selobj = document.getElementById("cmbalarmtype");
            opt = selobj.options[_changeflightindex];
            _bufferval = opt.value;
            selobj.selectedIndex = _changeflightindex;
            _flightcode = _bufferval.replace("FLIGHT_", "");
            document.getElementById("txtflightno").value = _flightcode;
            document.getElementById("divflight").style.visibility = "visible";
            document.getElementById("txtflightno").focus();
            return;
        }*/
        if (_curindex == 2) {
            _zipcode = document.getElementById("txtzip").value;
//            _L("_zipcode " + _zipcode);
            changeflashzipcode(_zipcode);
        }
  /*      if (_curindex == 3) {
            _flightcode = document.getElementById("txtflightno").value;
          //  _L("_flightcode " + _flightcode);
            changeflashflightcode(_flightcode);
        }*/
        _L("alarm type " + _curindex);
        mymovie = getSWF("infotimer");
        mymovie.changeAlarmtype(_curindex);
    }


    function previewplay(_playID) {
       
        if (_playID >= 0 &&  _playID  <= 6) {
            loadandplay(_playID);
            maximizeplayer();
        } else {
            alert("Please select a Valid option");
        }
    }


    function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(";");
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == " ") {
                c = c.substring(1, c.length);
            }
            if (c.indexOf(nameEQ) == 0) {
                return c.substring(nameEQ.length, c.length);
            }
        }
        return "";
    }


    function createCookie(name, value, days) {
        if (days) {
            var date = new Date;
            date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
            var expires = "; expires=" + date.toGMTString();
        } else {
            var expires = "";
        }
        document.cookie = name + "=" + value + expires + "; path=/";
    }


    function changeflashzipcode(zipval) {
		setVal("zipcode", zipval) ;
        mymovie = getSWF("infotimer");
        mymovie.changeflashzipcode(zipval);
    }


    function changeflashflightcode(_fcode) {
				setVal("flightcode", _fcode) ;
        mymovie = getSWF("infotimer");
        mymovie.changeflashflightcode(_fcode);
    }


    function loadandplay(alrmvalue) {
        mymovie = getSWF("infotimer");
        if (mymovie == null) {
            alert("null");
        }
        mymovie.loadandplay(alrmvalue);
    }


    function LoadweatherAlarm() {
        mymovie = getSWF("infotimer");
        mymovie.initializeweatherinfo();
    }


    function LoadTimeAlarm() {
        mymovie = getSWF("infotimer");
        mymovie.resetpreviewflag();
        hrval = change24hr(parseInt(document.getElementById("cmdHours").value), document.getElementById("cmbMeredien").value);
        mymovie.loadTimeSounds(hrval, document.getElementById("cmdMinute").value);
    }


    function change24hr(alarmHours, alarmMeredien) {
        if (alarmMeredien == "PM") {
            if (alarmHours == 12) {
                alarmHours = 0;
            }
            alarmHours = parseInt(alarmHours) + parseInt(12);
        } else if (alarmMeredien == "AM") {
            if (alarmHours == 12) {
                alarmHours = 0;
            }
        }
        return alarmHours;
    }


    function callExternalInterface() {
        getSWF("infotimer").goHome();
    }


    function maximizeplayer() {
        mymovie = getSWF("infotimer");
        mymovie.width = "487";
        mymovie.height = "540";
    }


    function hideplayer() {
        mymovie = getSWF("infotimer");
        mymovie.width = "1";
        mymovie.height = "1";
    }


    function playsounds() {
        mymovie = getSWF("infotimer");
        mymovie.playsounds();
    }


    function callbackplay() {
        maximizeplayer();
        playsounds();
    }

function showInviteInfo(){
		document.getElementById("divsignup").style.visibility = "visible";
            document.getElementById("txtemail").focus();
	
}
function closeInviteInfo(){
		document.getElementById("divsignup").style.visibility = "hidden";
         //   document.getElementById("txtemail").focus();
	
}

function closeLocationInfo(){
		document.getElementById("divzipcode").style.visibility = "hidden";
         //   document.getElementById("txtemail").focus();
	
}

    function showFlash(srno) {
        var curdate = new Date;
        var mday = curdate.getDate();
        var mmonth = curdate.getMonth();
        var swfstr = "MusicandSounds/swfdaydate/9/" + mday + ".swf";
        document.getElementById("divFlash").style.display = "inline";
        document.getElementById("divFlash").style.visibility = "visible";
        callbackplay();
        document.getElementById("li_" + arrAlarmTimeoutID[srno]).innerHTML = "";
        totalCountTimers--;
        document.getElementById("divAlarmNo").innerHTML = totalCountTimers;
        arrAlarmTime[srno] = "";
    }
function setUserAutomateAlarm(userhrs,userminutes,meridien){
	 mymovie = getSWF("infotimer");
        if (mymovie == null) {
    
			setTimeout("setUserAutomateAlarm(" + userhrs +"," + userminutes + ",'"+ meridien + "')", 3000);
			return;
        }
	 document.getElementById("cmbMeredien").value = meridien;
      
        document.getElementById("cmdHours").value = userhrs;
        document.getElementById("cmdMinute").value = userminutes;
		
		setAlarm();
}
function hideFlash()
		{
		hideplayer();
					  
//		  document.getElementById('divFlash').style.display='inline'; 
	//	  		  document.getElementById('divFlash').style.visibility='hidden'; 
		  
		}
