var restaurantDetails = new Array();
var browsername;
var msg = '2' ;
var req = false;
var xmlfilepath = "/mx/xml/data.xml";
 //var emailcgifile = "/cgi-bin/emergemail.cgi";
 //var printscsspath = "/common/css/esprint.css";
var copyrightcontent = "";
var numvalue;
var rgnval = "en";



function trim (str) {	
	return str.replace(/^\s+|\s+$/g,""); }
function restaurantlist()
{
	this.restaurantcomdin=arguments[0];
	this.restaurantdireccion=arguments[1];
	this.restauranttelefono=arguments[2];
	this.restaurantzona=arguments[3];
	this.restaurantreferencia=arguments[4];
	this.restaurantespecialadad=arguments[5];
	this.horario=arguments[6];
	this.rango=arguments[7];
	this.nombre = arguments[8];
	this.imgsmallsize = arguments[9];
	this.imgbigsize = arguments[10];
	this.reservationurl = arguments[11];	
	this.linkurl = arguments[12];
	this.description = arguments[13]
}

function initProcess()
{

	req = createAjaxObj();
	if (req)
	{
		req.onreadystatechange = getContents;
		req.open('GET',xmlfilepath, true);
		req.send(null);
	}
}

function createAjaxObj()
{
	if (window.XMLHttpRequest)
	{
		browsername = 'ns';
		req = new XMLHttpRequest();
		if (req.overrideMimeType) {
			req.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject) {	
		browsername = 'ie';		
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				
				return false;
			}
		}
	}
	else
	{
		
		return false;
	}
	return req;
}





function getContents() {

	if (req.readyState == 4) {
		

         if (req.status == 200) {
			var xml = req.responseXML;
			xmldata = xml.getElementsByTagName('root')[0];
			setrestaurantDetails(xmldata);
			loadZoneandloc();
		 }
	}
}
function setrestaurantDetails(xmlNode){

		for(var i=0;i<xmlNode.childNodes.length;i++){
		nname = xmlNode.childNodes[i].nodeName;
		if (nname == 'data'){
			var c_description="";
			c_comida="";
			c_direccion="";
			i_telefono="";
			c_zona="";
			c_referencia="";
			c_especialidad="";
			c_horario="";
			c_rangodeprecious="";
			c_nombre = "";
			c_imgsmallsize = "";
			c_imgbigsize = "";
			c_reservationurl = "";
			c_linkurl="";
			c_description;
			dataNode = xmlNode.childNodes[i];
			if (xmlNode.childNodes[i].childNodes.length>0)
			{
				for (var j =0;j<dataNode.childNodes.length;j++)
				{
					fieldNode = dataNode.childNodes[j];
					switch (fieldNode.nodeName)
					{	
						case 'comida': { 
							c_comida = trim(fieldNode.firstChild.nodeValue);
							break; }
						case 'direccion': {
							c_direccion = trim(fieldNode.firstChild.nodeValue);
							
							break; }
						case 'telefono': {
							i_telefono = trim(fieldNode.firstChild.nodeValue);
							
							break; }			
						case 'zona': {
							c_zona = trim(fieldNode.firstChild.nodeValue);
						
							break; }
						case 'referencia': {
							c_referencia = trim(fieldNode.firstChild.nodeValue);
							
							break; }
						case 'especialidad': {
							c_especialidad = trim(fieldNode.firstChild.nodeValue);
							
							break; }
						case 'horario': {
							c_horario = trim(fieldNode.firstChild.nodeValue);
							
							break; }
						case 'rangodeprecious': {
							c_rangodeprecious = trim(fieldNode.firstChild.nodeValue);
							break; }
						case 'description': {
							c_description = trim(fieldNode.firstChild.nodeValue);
							//alert(c_description);
							break; }
						case 'nombre': {
							c_nombre = trim(fieldNode.firstChild.nodeValue);
							break; }
						case 'imgsmallsize': {
							c_imgsmallsize = trim(fieldNode.firstChild.nodeValue);
							break; }
						case 'imgbigsize': {
							c_imgbigsize = trim(fieldNode.firstChild.nodeValue);
							break; }
						case 'reservationurl': {
							c_reservationurl = trim(fieldNode.firstChild.nodeValue);
							break; }
						case 'linkurl': {
							c_linkurl = trim(fieldNode.firstChild.nodeValue);
														break; }
					}
				}
				restaurantDetails[restaurantDetails.length++] = new restaurantlist(c_comida,c_direccion,i_telefono,c_zona,c_referencia,c_especialidad,c_horario,c_rangodeprecious,c_nombre,c_imgsmallsize,c_imgbigsize,c_reservationurl,c_linkurl,c_description,'0');
			}			
		}
	}
}

