url="";
//url="http://192.168.5.22/360";
Oxml=[]; var OxmlM; var strURL; var eSel; //neded to load data from database to dropdown
var Oxml_cnt=0;
//for offline
ref=window.location.href;   ref=ref.replace("http://","");  ref=ref.replace("www.","");
ref=ref.substr(0,8);
if(ref=="sanfranc")//iscovisitor".substr(0,8))
{//sanfrancisco
    document.write("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAlSEy2pse0klnIUnDJRuq-BQi8d9Xnoxbl9_HB1MimsG9YYaMBhQmE-chK6SfX9aT4lcX-8ymkVRZNQ' type='text/javascript'></script>");
}
else if(ref=="192.168.")
{//domain offline
    document.write(" <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAADJI26cAqt3VWCbKHh-nn7hTJ2sc-PdMCSBzsgJivtCS7mLGCPRTZjKqH3bgVHcO0hsEjMs4qf8uVJQ' type='text/javascript' charset='utf-8'></script>");
}
else
{//sftravel
    document.write("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAlSEy2pse0klnIUnDJRuq-BTvQLPnaBNMX0lRkGwebni0ZwtGOhT4kiXEcbLVxZd1IL9yEagmlcOzjQ' type='text/javascript'></script>");
}


//for online
//document.write("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAlSEy2pse0klnIUnDJRuq-BTvQLPnaBNMX0lRkGwebni0ZwtGOhT4kiXEcbLVxZd1IL9yEagmlcOzjQ' type='text/javascript'></script>");

/////////////////////////////////////////////////
///////////////// gmap functions starts /////////////// 
/*************************************************
* Created with GoogleMapAPI 2.0
* Author: Monte Ohrt <monte AT ohrt DOT com>
* Copyright 2005-2006 New Digital Group
* http://www.phpinsider.com/php/code/GoogleMapAPI/
*************************************************/
var points = [];
var markers = [];
var counter = 0;
var to_htmls = [];
var from_htmls = [];
var gmap = null;
var ary=[];
function onLoad(ary) 
{
if (GBrowserIsCompatible()) 
    {
        var mapObj = document.getElementById(ary["name"]);
        if (mapObj != "undefined" && mapObj != null)
        {
            gmap = new GMap2(document.getElementById(ary["name"]));
            gmap.setCenter(new GLatLng(ary["lat"], ary["lon"]), 15, G_NORMAL_MAP);
            gmap.addControl(new GLargeMapControl());
            gmap.addControl(new GMapTypeControl());
            var point = new GLatLng(ary["lat"],ary["lon"]);
            var marker = createMarker(point,ary["addr"],"<div id=\"gmapmarker\" style=\"white-space: nowrap;\">"+ary['addr']+"</div>", 0);
            gmap.addOverlay(marker);
        }
    }
    else
    {
        alert("Sorry, the Google Maps API is not compatible with this browser.");
    }
}
function createMarker(point, title, html, n)
{
    if(n >= 0) { n = -1; }
    var marker = new GMarker(point);
    to_htmls[counter] = html + '<p /><form class="gmapDir" id="gmapDirTo" style="white-space: nowrap;" action="http://maps.google.com/maps" method="get" target="_blank">' +
                        '<span class="gmapDirHead" id="gmapDirHeadTo">Directions: <strong>To here</strong> - <a href="javascript:fromhere(' + counter + ')">From here</a></span>' +
                        '<p class="gmapDirItem" id="gmapDirItemTo"><label for="gmapDirSaddr" class="gmapDirLabel" id="gmapDirLabelTo">Start address: (include addr, city st/region)<br /></label>' +
                        '<input type="text" size="40" maxlength="40" name="saddr" class="gmapTextBox" id="gmapDirSaddr" value="" onfocus="this.style.backgroundColor = \'#e0e0e0\';" onblur="this.style.backgroundColor = \'#ffffff\';" />' +
                        '<span class="gmapDirBtns" id="gmapDirBtnsTo"><input value="Get Directions" type="submit" class="gmapDirButton" id="gmapDirButtonTo" /></span></p>' +
                        '<input type="hidden" name="daddr" value="' +
                        point.y + ',' + point.x + "(" + title.replace(new RegExp(/"/g),'&quot;') + ")" + '" /></form>';
                         from_htmls[counter] = html + '<p /><form class="gmapDir" id="gmapDirFrom" style="white-space: nowrap;" action="http://maps.google.com/maps" method="get" target="_blank">' +
                        '<span class="gmapDirHead" id="gmapDirHeadFrom">Directions: <a href="javascript:tohere(' + counter + ')">To here</a> - <strong>From here</strong></span>' +
                        '<p class="gmapDirItem" id="gmapDirItemFrom"><label for="gmapDirSaddr" class="gmapDirLabel" id="gmapDirLabelFrom">End address: (include addr, city st/region)<br /></label>' +
                        '<input type="text" size="40" maxlength="40" name="saddr" class="gmapTextBox" id="gmapDirSaddr" value="" onfocus="this.style.backgroundColor = \'#e0e0e0\';" onblur="this.style.backgroundColor = \'#ffffff\';" />' +
                        '<span class="gmapDirBtns" id="gmapDirBtnsFrom"><input value="Get Directions" type="submit" class="gmapDirButton" id="gmapDirButtonFrom" /></span></p' +
                        '<input type="hidden" name="daddr" value="' +
                        point.y + ',' + point.x + "(" + title.replace(new RegExp(/"/g),'&quot;') + ")" + '" /></form>';
                        html = html + '<p /><div id="gmapDirHead" class="gmapDir" style="white-space: nowrap;">Directions: <a href="javascript:tohere(' + counter + ')">To here</a> - <a href="javascript:fromhere(' + counter + ')">From here</a></div>';
    GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); });
    points[counter] = point;
    markers[counter] = marker;
    counter++;
    return marker;
}
function showInfoWindow(idx,html)
{
    gmap.centerAtLatLng(points[idx]);
    markers[idx].openInfoWindowHtml(html);
}
function tohere(idx)
{
    markers[idx].openInfoWindowHtml(to_htmls[idx]);
}
function fromhere(idx)
{
    markers[idx].openInfoWindowHtml(from_htmls[idx]);
}
function generate_map(nm,lat,lon,addr)
{
    nm="map_"+nm;
    if (GBrowserIsCompatible())
    {
        ary["name"]=nm;
        ary["lon"]=lon,
        ary["lat"]=lat;       
        ary["addr"]=addr;
        loadInnerHtml("gmap",'<div id="'+nm+'" style="width: 550px; height: 360px"></div>');
        //document.write('<div id="'+nm+'" style="width: 550px; height: 360px"></div>');
    }
    else
    {
        document.write('<b>Javascript must be enabled in order to use Google Maps.</b>');
    }
    onLoad(ary);
}
///// gmap functions ends /////////////////
/////////////////////////////////////
function char_count(t)
{
    val=t.value;
    if(parseInt(val.length)>=750)
    {
        return false;
    }
    limit=749;
    rem=parseInt(limit)-parseInt(val.length)
    loadInnerHtml("js_char_count",rem);
}
/////////////////////////////////////
function del_mem_photo()
{
    if(confirm("Are you sure you want to delete selected Photo?"))
    {
        this.document.frm.mem_photo_name.value="";
        this.document.frm.up_id.value="-1";
        loadInnerHtml("js_mem_photo","<a href=\"JavaScript:mem_photo_upload()\">Click here to Upload File</a>");
    }
}
//////////////////////////////
function terms_conditions()
{
    window.open("/review.php?act=terms_show","Popup_Window","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=400");
}
//////////////////////////////
function mem_photo_upload()
{
    window.open("/review.php?act=mem_photo_show","Popup_Window","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=200");
}
///////////////////////////////////
function sign_chk()
{
    if(this.document.frm.mem_username.value=="" || this.document.frm.mem_password.value==""|| this.document.frm.mem_name.value==""|| this.document.frm.mem_email.value=="")
    {
        alert("Please enter all * marked fields to continue");
        return false
    }
    if(this.document.frm.mem_password.value!=this.document.frm.mem_password1.value)
    {
        alert("Password do not matched");
        return false;
    }
    if(this.document.frm.terms.checked==false)
    {
        alert("Please agree with our Terms & Conditions to continue");
        return false;
    }
    if(this.document.frm.captcha.value=="")
    {
        alert("Please enter Confirmation Code to continue");
        return false;
    }
    js_xml_form_submit(this.document.frm.action,js_form_submit(this.document.frm));
    return false;
}
///////////////////////////////////
function login_chk()
{
    if(this.document.l_frm.mem_username.value=="" || this.document.l_frm.mem_password.value=="")
    {
        alert("Please enter Username & Password to login");
        return false
    }
    js_xml_form_submit(this.document.l_frm.action,js_form_submit(this.document.l_frm));
    
    return false;
}
///////////////////////////////////
function rev_save()
{
    if(this.document.frm.rev_text.value=="")
    {
        alert("Please enter your review in less than 1000 chars. to continue");
        return false
    }
    js_xml_form_submit(this.document.frm.action,js_form_submit(this.document.frm));
    return false;
}
///////////////////////////////////
function isArray(a) {
    return isObject(a) && a.constructor == Array;
}
////////////////////////////////////////////////
function handler(php_file,act)
{
    strURL = url+php_file+"?"+act;
    //alert(strURL);
    //window.history.location(window.history.length+1)=strURL;
    //alert(window.history[0]);
    //window.copyhistory=strURL;
    load_db_innerHTML_data();
}
///////////////////////////////////////////////
function js_form_submit(ctrl)
{
    var sep="";
    var str="";
    var val="";
    for(i=0; i<ctrl.elements.length; i++)
    {
        val="";
        if(ctrl.elements[i].type=="radio" || ctrl.elements[i].type=="checkbox")
        {
            if(ctrl.elements[i].checked==true)
            {
                val=ctrl.elements[i].value;
            }
        }
        else if(ctrl.elements[i].type=="select-multiple" && ctrl.elements[i].name!="cs_unassigned")
        {
            aa=ctrl.elements[i].length;
            for(aaa=0;aaa<aa;aaa++)
            {
                //if(ctrl.elements[i].options[i].selected==true)
                {
                    val_=ctrl.elements[i].options[aaa].value;
                    val_=val_.replace("&","%26");
                    str=str+sep+ctrl.elements[i].name+"[]="+val_
                    sep="&";
                }
            }
        }
        else
        {
            val=ctrl.elements[i].value;
            val=val.replace(/\n/g,"<br>");
        }
        if(val!="")
        {
            str=str+sep+ctrl.elements[i].name+"="+val.replace("&","%26");
            sep="&";
        }
    }
    return str;
}
////////////////////////////////////////////////
function js_xml_form_submit(php_file,dat)
{
    strURL = url+php_file+"?"+dat;
    //alert(strURL);
    load_db_innerHTML_data();
}
/////////////////////////////////////
function loadInnerHtml(tag,val)
{
    //alert(tag+"=>"+val);
    if(tag=="gmap_js")
    {
        eval(val);
        return;
    }
    aa1=document.getElementsByTagName('*');
    aa1[tag].innerHTML=val;
}
///functions to load values in dropdown without refreshing page
function load_db_innerHTML_data()
{
    
    //js_ls();
    strURL=strURL.replace("#","-");
    if(Oxml[Oxml_cnt] && Oxml[Oxml_cnt].readyState!=4)
    {
        Oxml_cnt++;
    }
    try
    {
        Oxml[Oxml_cnt] = new XMLHttpRequest();
    }
    catch (error)
    {
        try
        {
            Oxml[Oxml_cnt] = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (error)
        {
            Oxml[Oxml_cnt]= null;
            return false;
        }
    }
    Oxml[Oxml_cnt].onreadystatechange = On_XmlRet_innerHTML;
    //alert(strURL);
    Oxml[Oxml_cnt].open("GET", strURL);
    Oxml[Oxml_cnt].send(null);   
}
///////////////////////////////
function On_XmlRet_innerHTML()
{
    var rootnode;
    var intNodecnt;
    var intNodeLen;
    var ONodeAttr;
    var strTemp1,strTemp2;
    var obj;
    for(var xl=0;xl<=Oxml_cnt;xl++)
    {
        if(Oxml[xl] && Oxml[xl].readyState==4 )
        {
            intNodecnt = Oxml[xl].responseXML.getElementsByTagName("tag");
            intNodeLen = intNodecnt.length;
            for(var i = 0;i<intNodeLen;i++)
            {
                rootnode = Oxml[xl].responseXML.getElementsByTagName("tag")[i];
                strTemp1=rootnode.childNodes[0].nodeValue
                strTemp2=rootnode.attributes[0].value;
                loadInnerHtml(strTemp2,strTemp1);
            }
            Oxml[xl]=null
        }
    }
    //js_lh();
}
///////////////////////////////////
function getkey(e)
{
if (window.event)
return window.event.keyCode;
else if (e)
return e.which;
else
return null;
}
/////////////////////////////////////
function limitchar(e)
{
var goods="0123456789";
var key, keychar;
key = getkey(e);
if (key == null) return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
goods = goods.toLowerCase();
if (goods.indexOf(keychar) != -1)
return true;
if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
return true;
return false;
}
///////////////////////////////////////////////
function js_ls()
{
    document.getElementById('DivLoading').style.display = ''; //show
}
///////////////////////////////////////////////
function js_lh()
{
   
    document.getElementById('DivLoading').style.display = 'none'; //hide
    
}
//just a patch work remove if using other than sftravel - 12-june-06

