﻿
var WindowObjectReference;


function GetSurveyResponse(id,url,width,height) {

    var radio = document.getElementsByName(id);

    for (var ii = 0; ii < radio.length; ii++) {

        if (radio[ii].checked) {

            if (radio[ii].value == "YES") {

                windowPosition = generatePosition(); 
                windowFeatures = 'width=' + width + ',height=' + height + windowPosition;
                                         
                //Check to see if the surveywin popup window is already open
                if(WindowObjectReference == null || WindowObjectReference.closed)
                {
                    var WindowObjectReference = window.open(url, 'surveyWin', windowFeatures);
                    var chromeBroswer = navigator.userAgent.indexOf('Chrome/');


                    if ((chromeBroswer > 0) && window.parent && window.parent.focus ) {

                        window.parent.blur();
                        window.parent.focus();
                       

                    } else if (window.parent && window.parent.focus) {

                        window.parent.focus();
                        
                    } else {
                          
                        //Do nothing    
                    }
                      

                } else {

                       // Do nothing if surveywin is already open
                       
                } 
                
            }
            
         //End Outer if        
        }
     //End for Loop  
    }

}

function generatePosition() {

    var innerWidth = 0;
    var parentPositionX = 0;
    var parentPositionY = 0;
    //var h = 0;

    //IE
    if (!window.innerWidth) {
        //strict mode
        if (!(document.documentElement.clientWidth == 0)) {
        
              innerWidth = ((document.documentElement.clientWidth - 980) / 2) + 197; 
              parentPositionY = window.screenTop ;
              parentPositionX = window.screenLeft + innerWidth ;
            
            
        }
        //quirks mode
        else {
        
             innerWidth = ((document.documentElement.clientWidth - 980) / 2) + 197;
             parentPositionY = window.screenTop ;
             parentPositionX = window.screenLeft + innerWidth ;
            
        }
    }
    //w3c
    else {
         
            innerWidth = ((window.innerWidth - 980) / 2) + 196;
            parentPositionY = window.screenY + 130;
            parentPositionX = window.screenX + innerWidth;
        
    }



    position = ',location=yes,resizable=yes,scrollbars=yes,' + ',top=' + parentPositionY + ',left=' + parentPositionX;
    return position;
   


}




