﻿		//Global XMLHTTP Request object
var XmlHttp;
var intP;
var intS=0;
var intT=0;
var boolName=1;
var arrAns=new Array(5);
var arrControlId=new Array(5);
var arrQId=new Array(5);
var QId;
var Answer;
//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp()
{
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
}
function HandleQuestionResponse()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{		
		    //window.alert("i am here");	
			var divValue = document.getElementById('Questionaire1_dvQuestionnare');
			//var str = XmlHttp.responseText;
			if(divValue != null && divValue != "")
			{
			    divValue.innerHTML =  XmlHttp.responseText;
			}
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}


//function CountryListOnChange(q_page) 
//{
function GetQuestion(q_page) 
{
	//var countryList = document.getElementById("ctl00_Footer1_cmbCounty");
	//Getting the selected country from country combo box.
	//var selectedCountry = countryList.options[countryList.selectedIndex].value;
	//window.alert('Hi') 
	// URL to get states for a given country
    var vrAnswers = document.getElementById('hidAnswer').value;
    var vrQuestion = document.getElementById('hidQId').value;
    var vrUserAnswer = document.getElementById('hidUserAnswer').value;
//	 var requestUrl = "/ActivClub/GetQuestionnair.aspx" + "?q_page=" + q_page + "&q_answers=" + vrAnswers + "&q_question=" + vrQuestion + "&q_UserAnswer=" + vrUserAnswer;
	 
	  var requestUrl = "/GetQuestionnair.aspx" + "?q_page=" + q_page + "&q_answers=" + vrAnswers + "&q_question=" + vrQuestion + "&q_UserAnswer=" + vrUserAnswer;
	 //var requestUrl = "/GetQuestionnair.aspx" + "?q_page=" + q_page + "&q_answers=" + vrAnswers + "&q_question=" + vrQuestion + "&q_UserAnswer=" + vrUserAnswer;
	//var requestUrl = "/GetQuestionnair.aspx" + "?q_page=" + q_page;
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleQuestionResponse;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}
	//getValue(q_page);
	//return XmlHttp;
}



function getValue(page_No)
{
    //comments document.forms[0][5].outerHTML,document.forms[0][5].value,document.forms[0][5].name
    if(page_No==2)
    {         
    
        Answer = document.getElementById('hidAnswer');
        QId = document.getElementById('hidQId');           
        for(intP=0; intP < 15; intP++)
        {     
         
            if(document.forms[0][intP].name=="uniquId1")
            {
                
               Answer.value += "/" + document.forms[0][intP].value;
               
                 alert(Answer.value); 
                intS++;
            }
            if(document.forms[0][intP].name=="comments")
            {
               
                Answer.value += "/" + document.forms[0][intP].value;
               
                 alert(Answer.value); 
                intS++;
            }
            if(document.forms[0][intP].name=="ddlOption")
            {
                
               if(document.forms[0][intP][intT].selected==true )
               {
                   Answer.value += "/" + document.forms[0][intP].value;
                    //selectedIndex
                     alert(Answer.value); 
                    intS++;
                    intT = 0;
                }
                intT++;
            }
            if(document.forms[0][intP].name=="btnRadio")
            {     
//                if(boolName == 1)
//                {           
//                    Answer.value += "/" + document.getElementById("answer").value;
//                    boolName = 0;
//                }
               if(document.forms[0][intP].name.selected==false)
               {
               
                   Answer.value += "/" + document.forms[0][intP].value;
                    //selectedIndex
                     alert(Answer.value); 
                    intS++;
                }
            }
            if(document.forms[0][intP].name=="chkBox")
            {
                if(document.forms[0][intP].name.checked==true)
                {
                    Answer.value += "/" + document.forms[0][intP].value;
                    //checked
                    alert(Answer.value); 
                    intS++;
                }
            }
            
        }
        return arrAns;
    }
   
}
function ClearAndSetStateListItems(countryNode)
{
    var stateList = document.getElementById("ctl00_Footer1_cmbTown");
	//Clears the state combo box contents.
	for (var count = stateList.options.length-1; count >-1; count--)
	{
		stateList.options[count] = null;
	}

	var stateNodes = countryNode.split("-");
	//window.alert(stateNodes) 
	var textValue; 
	var optionItem;
	//Add new states list to the state combo box.
	for (var count = 0; count < stateNodes.length; count++)
	{
   		textValue = (stateNodes[count]);
		optionItem = new Option( textValue, textValue,  false, false);
		//window.alert(textValue); 
		//stateList.appendChild(textValue); 
		stateList.options[stateList.length] = optionItem;
	}
	
	
}
//function check(browser)
//{
//    document.getElementById("answer").value=browser;
//}


