﻿var XmlHttp;
var xmlDoc;
var mydd;
var wind;
var startDate=false;
var endDate=false;
var selStartDate=null;
var selEndDate=null;

function CreateXmlHttp()
{
	
    //Creating object of XMLHTTP in IE
    try
    {
        XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(ex)
        {
            XmlHttp = null;
        }
    }
    //Creating object of XMLHTTP in Mozilla and Safari
    if(!XmlHttp && typeof XMLHttpRequest != "undefined")
    {
        XmlHttp = new XMLHttpRequest();
    }
    
}

function getData(dd,letter,langid){
	//var targ = document.getElementById(dd);	
	//targ.disabled=true;
	var targ = document.getElementById(dd);	
    while (targ.firstChild){
        targ.removeChild(targ.firstChild);
    }
	targ.style.textAlign='center';
	//targ.style.verticalAlign='middle';
	//targ.style.height='400px';
	targ.innerHTML='<img src="/images/ajax-loader.gif" align=center>'
	
	CreateXmlHttp();
	mydd=dd;
	//wind=win;
    if(XmlHttp)
    {    
        XmlHttp.onreadystatechange = HandleResponse;
        XmlHttp.open("GET", "/glwssari_xml.asp?langid="+langid+"&letter="+escape(letter),  true);
        XmlHttp.send(null);           
    }
}

function findWhiteSpace(node, nodeNo) {
	for (i=0; i < node.childNodes.length; i++) {
		if (node.childNodes[i].nodeType == 3 && is_ws(node.childNodes[i])) {
			nodesToDelete[nodesToDelete.length] = node.childNodes[i]
		}
		if (node.childNodes[i].hasChildNodes()) {
			findWhiteSpace(node.childNodes[i], i);
		}
	}
	node = node.parentNode;
	i = nodeNo;
}

function stripWhiteSpace(node) {
	nodesToDelete = Array();
	findWhiteSpace(node, 0);
	for(i=nodesToDelete.length-1;i>=0;i--) {
		nodeRef = nodesToDelete[i];
		nodeRef.parentNode.removeChild(nodeRef)
	}
}

function proccessXML() {
	if (xmlRequestObj.readyState == 4 && (xmlRequestObj.status == 200 || xmlRequestObj.status == 304)) {
		if(stripWS) {
			stripWhiteSpace(xmlRequestObj.responseXML);
		}
		resultXML = xmlRequestObj.responseXML;
		functionToCall()
	}
}


function HandleResponse()
{	
	//alert(XmlHttp.readyState);
    if(XmlHttp.readyState == 4)
    {
    	
        if(XmlHttp.status == 200)
        {        
			stripWhiteSpace(XmlHttp.responseXML)	
			//alert(XmlHttp.responseXML.documentElement.getElementsByTagName('record').length);
            xmlDoc=XmlHttp.responseXML.documentElement;
			//alert(xmlDoc.getElementsByTagName('record')[0].childNodes[1].firstChild.nodeValue);
            populate1(mydd);           
        }
        else
        {
            alert("There was a problem retrieving data from the server." );
        }
    }else{
    	//HandleResponse();
    }
}

function is_ws(nod) {
	return !(/[^\t\n\r ]/.test(nod.data));
}

function populate1(dd){
    
	var targ = document.getElementById(dd);	
    while (targ.firstChild){
        targ.removeChild(targ.firstChild);
    }	
	targ.style.textAlign='';
	//targ.options.length=0;	
	
	var records=xmlDoc.getElementsByTagName('glwssari');		
	//alert(records);
	for (var i=0;i < xmlDoc.getElementsByTagName('glwssari').length;i++){
	 //   if (i%4==0){
	  //      clearDiv = document.createElement("div");
	 //       clearDiv.className="clearer";
	  //      targ.appendChild(clearDiv);
	  //      curPos=1;
	//    } 
		
		eDIV = document.createElement("div");
	    eDIV.className="all_glwssary_OLD";
	    //eDIV.setAttribute('theDate',records[i].childNodes[3].firstChild.nodeValue);
		txtto='';
    	txtto+='<table cellspacing="0" cellpadding="0"  border="0" style="padding-left:20px;" summary="">';
		txtto+='<tbody>';
     //   txtto+='<tr>';
    //    txtto+='<td valign="top"><div class="pos_num">aaaa&nbsp;</div></td></tr>';
    //    txtto+='<tr><td>';
	//	txtto+='<table border="0" cellpadding="0" cellspacing="0" >';
        txtto+='<tr>';
       	txtto+='<td>';
		if(records[i].childNodes[1].firstChild!=undefined){
			txtto+='<a href="javascript:void(window.open(\'/includes/textMore.asp?text='+escape(records[i].childNodes[1].firstChild.nodeValue)+'\',\'internet\',\'resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=400,height=200\'))">'+records[i].childNodes[1].firstChild.nodeValue+'</a>';
		}
	//	txtto+='<a href="javascript:void(window.open(\'../includes/textMore.asp?text='+records[i].childNodes[1].firstChild.nodeValue+'\',\'internet\',\'resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=400,height=200\'))">'+records[i].childNodes[2].firstChild.nodeValue+'</a>';
//	txtto+=''+records[i].childNodes[3].firstChild.nodeValue+'';
	
		//txtto+='<img src="'+records[i].childNodes[2].firstChild.nodeValue+'" />';
	

		txtto+='</td>';
      	txtto+='</tr>';
       	txtto+='<tr>';
      	txtto+='<td><img src="/userfiles/Image/template/seperator_glwssari.gif" /></td>';
       	txtto+='</tr>';				
	//	txtto+='<tr>';
	//	txtto+='<td><div class="pos_text">E - booking:</div></td>';
	//	txtto+='<td><div class="pos_text2">';
	//	if(records[i].childNodes[7].firstChild!=undefined){
	//		txtto+='<a href="'+records[i].childNodes[7].firstChild.nodeValue+'" >';
	//	}
	//	txtto+='<img src="../AIRLINES_LISTING/images/'+records[i].childNodes[3].firstChild.nodeValue+'.gif" />';
	//	if(records[i].childNodes[7].firstChild!=undefined){
	//		txtto+='</a>';
	//	}
	//	txtto+='</div></td>                    </tr>';							
	//	txtto+='					<tr>';
	//	txtto+='                        <td><div class="pos_text">E - check in:</div></td>';
	//	txtto+='                        <td><div class="pos_text2">';
	//	if(records[i].childNodes[8].firstChild!=undefined){
	//		txtto+='<a href="'+records[i].childNodes[8].firstChild.nodeValue+'" >';
	//	}
	//	txtto+='<img src="../AIRLINES_LISTING/images/'+records[i].childNodes[4].firstChild.nodeValue+'.gif" />';
	//	if(records[i].childNodes[8].firstChild!=undefined){
	//		txtto+='</a>';
	//	}
	//	txtto+=' </div></td>                   </tr>';							
	//	txtto+='                </table>';		
	//	txtto+='            </td>';
	//	txtto+='            <td valign="top"><td>';
	//	txtto+='        </tr>   ';
		txtto+='</tbody>';
		txtto+='    </table>';
		eDIV.innerHTML=txtto;
	    targ.appendChild(eDIV);    	    
		
	}		
	
}	
function pickStartDay(){
	    startDate=true;
	    endDate = false;
	    //alert(startDate);
	}
	
	function pickEndDay(){
	    endDate=true;
	    startDate = false;
	}
	
	function setDate(){
	    if (startDate){
	        document.getElementById('startDateInput').value=this.getAttribute('theDate');
	        selStartDate=this.getAttribute('theDate');
	    }
	    if (endDate){
	        document.getElementById('endDateInput').value=this.getAttribute('theDate');
	        selEndDate=this.getAttribute('theDate');
	    }
	}


