﻿

    var styleToSelect;
    //var _server = "http://62.232.41.224/weather2/w2website";
    //var _server = 'http://localhost:1590/W2Website';
    var _server = 'http://www.myweather2.com';

    function onOk() {
        $get('Paragraph1').className = styleToSelect;
    }
    
    // Add click handlers for buttons to show and hide modal popup on pageLoad
    function pageLoad() {
        
        if($get('ctl00_MiddleContentHolder_TabMenu1_LoginView1_lnkSaveForecast'))                
            $addHandler($get("ctl00_MiddleContentHolder_TabMenu1_LoginView1_lnkSaveForecast"), 'click', showModalSaveForecastPopupViaClient);  
            
        if($get('ctl00_MiddleContentHolder_TabMenu1_butNoRemoveForecast'))
              $addHandler($get("ctl00_MiddleContentHolder_TabMenu1_butNoRemoveForecast"), 'click', hideModalRemoveForecastPopupViaClient);  
//              
//        if ($get("CancelButtonPaypalConfirm"))
//            $addHandler($get("CancelButtonPaypalConfirm"), 'click', hideModalPaypalConfirmPopupViaClient);
//            
//        if ($get("lnkEditDetails"))
//            $addHandler($get("lnkEditDetails"), 'click', hideModalPaypalConfirmPopupViaClient); 
    }
    
    function hideModalRemoveForecastPopupViaClient() {                    
        var modalPopupBehavior = $find('programmaticModalRemoveForecastPopupBehavior');
        modalPopupBehavior.hide();
    }
    
     function hideModalPaypalConfirmPopupViaClient(ev) {
        ev.preventDefault();
        var modalPopupBehavior = $find('programmaticModalPaypalConfirmPopupBehavior');
        modalPopupBehavior.hide();
    }  
        
    
    function showModalPopupViaClientOnRequest(b)
    {
        var modalPopupBehavior = $find(b);
        modalPopupBehavior.show();
    }       
    
    function showModalSaveForecastPopupViaClient(ev) {
        ev.preventDefault();        
                                   
        var modalPopupBehavior = $find('programmaticModalSaveForecastPopupBehavior');
        modalPopupBehavior.show();
        
        
    }
       
                
     function showModalVMapPopupViaClient(ev) {
        ev.preventDefault();        
                                   
        var modalPopupBehavior = $find('programmaticModalVMapBehavior');
        modalPopupBehavior.show();
        
        
    }                                
          
                
    function SetControlToViewRemoveForecast(v)
    {            
            var uf=document.getElementById("ctl00_MiddleContentHolder_TabMenu1_uf_id");
            
            uf.value=v;
             
            var modalPopupBehavior = $find('programmaticModalRemoveForecastPopupBehavior');
            modalPopupBehavior.show();
    }
    
    
    function onUpdatingForecastData(gridView){
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDivForecastData'); 
        // make it visible
        updateProgressDiv.style.display = '';

        //  get the gridview element        
        //var gridView = $get('<%= this.UpdatePanelForecastData.ClientID %>');
        
        // get the bounds of both the gridview and the progress div
        var gridViewBounds = Sys.UI.DomElement.getBounds(gridView);
        var updateProgressDivBounds = Sys.UI.DomElement.getBounds(updateProgressDiv);
       
        //    do the math to figure out where to position the element (the center of the gridview)
        var x = gridViewBounds.x + Math.round(gridViewBounds.width / 2) - Math.round(updateProgressDivBounds.width / 2);
        var y = gridViewBounds.y + Math.round(gridViewBounds.height / 15);
        
        //    set the progress element to this position
        Sys.UI.DomElement.setLocation (updateProgressDiv, x, y);        
    }

    function onUpdatedForecastData() {
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDivForecastData'); 
        // make it invisible
        if (updateProgressDiv!=null)
            updateProgressDiv.style.display = 'none';
        
       
    }               
    
    
    function CallPrint(url)
    {        
         
         var win_height=500;
         
         var win_width =620;
           
         window.open(_server + '/print-forecast.aspx?snap=' + url,'','top=10,left=10,width=' + win_width + ',height=' + win_height + ',toolbar=0,scrollbars=1,status=0');
         
         //WinPrint.document.write("<link href=\"http://localhost:3196/ajaxW2Website/css/w2main.css\" rel=\"stylesheet\" type=\"text/css\" />");
         /*WinPrint.document.write("<link href=\"http://62.232.41.224/weather2/w2website/css/w2main.css\" rel=\"stylesheet\" type=\"text/css\" />");
         WinPrint.document.write(prtContent.innerHTML);
         WinPrint.document.close();
         WinPrint.focus();
         WinPrint.print();
         WinPrint
         WinPrint.close();
         prtContent.innerHTML=strOldOne;*/
    }       
    
    
    function OpenChildWindow(activityid,fields)
    {
        //open a new dialog window
        var sFeatures="dialogHeight: 250px;";
        sFeatures += "dialogWidth: 455px;";
        sFeatures += "center: yes;";
        sFeatures += "edge: sunken;";
        sFeatures += "scroll: no;";
        sFeatures += "status: yes;";
        sFeatures += "resizeable: no;";
        var url = _server + '/activity/more-weather-fields.aspx?activityID=' + activityid + '&Field_ids=' + fields;
        
        returnValueFromChild = window.showModalDialog(url, 'MoreWeatherFields', sFeatures);            
        if (returnValueFromChild!=null) {
            if (returnValueFromChild.toString() != 'N/A')
            {
                window.document.getElementById('ctl00_MiddleContentHolder_selected_field_ids').value = returnValueFromChild.toString();
            
                window.document.getElementById('ctl00_MiddleContentHolder_btnHiddenForUpdate').click();                
            }
        }
    }
    
    
    function OpenUnitChangeWindow()
    {
        //open a new dialog window
        var sFeatures="dialogHeight: 540px;";
        sFeatures += "dialogWidth: 410px;";
        sFeatures += "center: yes;";
        sFeatures += "edge: sunken;";
        sFeatures += "scroll: no;";
        sFeatures += "status: yes;";
        sFeatures += "resizeable: no;";
        var url = _server + '/activity/change-unit.aspx';
        
        var returnValueFromChild = window.open(url, 'UnitChangeWindow', sFeatures);            
        if (returnValueFromChild!=null) {
            if (returnValueFromChild.toString() != 'N/A')
            {
                window.document.getElementById('ctl00_MiddleContentHolder_unit_change').value = returnValueFromChild.toString();
            
                window.document.getElementById('ctl00_MiddleContentHolder_btnHiddenForUnitChange').click();                
            }
        }
    }
    
    
    function OpenDialogWindow(opt_value,activity_id,width,height,id)
    {
        //open a new dialog window
        var sFeatures="dialogHeight: " + height + "px;";
        sFeatures += "dialogWidth: " + width + "px;";
        sFeatures += "center: yes;";
        sFeatures += "edge: sunken;";
        sFeatures += "scroll: no;";
        sFeatures += "status: yes;";
        sFeatures += "resizeable: no;";        
        
        url = _server + '/activity/' + url;
        
        var returnValueFromChild = window.showModalDialog(url, id, sFeatures);                    
    }
    
    function OpenScrollableDialogWindow(url,width,height,id)
    {
        //open a new dialog window
        var sFeatures="dialogHeight: " + height + "px;";
        sFeatures += "dialogWidth: " + (width * 1.5) + "px;";
        sFeatures += "center: yes;";
        sFeatures += "edge: sunken;";
        sFeatures += "scroll: yes;";
        sFeatures += "status: yes;";
        sFeatures += "resizeable: no;";        
        
        //url = _server + '/activity/' + url;
        
        var returnValueFromChild = window.showModalDialog(url, id, sFeatures);                    
    }
    
    

	
// this function calls a popupWindow where
// win is the page address i.e. '../page.htm'

function popupWindow(win){
	
	var winWidth = 400; // sets a default width for browsers who do not understand screen.width below
    var winheight = 400; // ditto for height

if (screen){ // weeds out older browsers who do not understand screen.width/screen.height
   winWidth = screen.width;
   winHeight = screen.height;
}

	newWindow = window.open(win,'newWin','toolbar=no,location=no,scrollbars=no,resizable=yes,width='+winWidth+',height='+winHeight+',left=0,top=0');
	newWindow.focus();
}

</script>
