﻿
//var map = new CM.Map('cm-example', cloudmade);
var map = null;
$(document).ready(function() 
{
    map = initMap(map);
    initTabs();
    initInnerTabs();
    //my addresses drop down menu
    if (!isMobile) {
        $('ul.menu_body').css("top", $('.menu_head').position().top+20);
        $('ul.menu_body').css("right", "100px");    
    }
    else {
        $('ul.menu_body').css("left","10px");
        $('ul.menu_body').css("width","65%");
    }

    $('.menu_head').click(function () {
        loadMyAddresses(0);
    });
    //$('body').click(function() {document.getElementById('myAddressesMenuBody').style.display = "none"; });
});



//global vars
var initMapError=false;
var inAnimation = false;
var okToZoomByTab = false;
var lastSearchedAddress = '';



//submit a comment
function submitComment(myForm)
{
    //alert("myForm=" + $(myForm).serialize());
    $.post("/ajax/addComments.asp", $(myForm).serialize(), function(data) {
        if (data == "done") {
            document.getElementById("commentSubmitButton").value = "תודה";
            document.getElementById("commentSubmitButton").disabled = true;        
            alert("תודה, תגובתך תפורסם בעתיד הקרוב. בהתאם לשיקולי המערכת...");
        }
        else if (data == "error") {
            alert("תקלה");
        }
        else if (data == "empty") {
            alert("עליך למלא דירוג או לכתוב הערה");
        }
        else if (data == "notLoggedIn") {
            alert("אינך מחובר/ת למערכת");
            document.location.href = document.location.href;
        }
        else {        
            alert(data);
        }
    });
}

/*
 ### jQuery Star Rating Plugin v3.13 - 2009-03-26 ###
 * Home: http://www.fyneworks.com/jquery/star-rating/
 * Code: http://code.google.com/p/jquery-star-rating-plugin/
 *
	* Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 ###
*/
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';5(29.1j)(7($){5($.1L.1J)1I{1t.1H("1K",J,H)}1M(e){};$.n.3=7(i){5(4.Q==0)k 4;5(A I[0]==\'1h\'){5(4.Q>1){8 j=I;k 4.W(7(){$.n.3.y($(4),j)})};$.n.3[I[0]].y(4,$.1T(I).1U(1)||[]);k 4};8 i=$.12({},$.n.3.1s,i||{});$.n.3.K++;4.2a(\'.9-3-1f\').o(\'9-3-1f\').W(7(){8 a,l=$(4);8 b=(4.23||\'21-3\').1v(/\\[|\\]/g,\'Z\').1v(/^\\Z+|\\Z+$/g,\'\');8 c=$(4.1X||1t.1W);8 d=c.6(\'3\');5(!d||d.18!=$.n.3.K)d={z:0,18:$.n.3.K};8 e=d[b];5(e)a=e.6(\'3\');5(e&&a)a.z++;x{a=$.12({},i||{},($.1b?l.1b():($.1S?l.6():s))||{},{z:0,F:[],v:[]});a.w=d.z++;e=$(\'<1R V="9-3-1Q"/>\');l.1P(e);e.o(\'3-15-T-17\');5(l.S(\'R\'))a.m=H;e.1c(a.E=$(\'<P V="3-E"><a 14="\'+a.E+\'">\'+a.1d+\'</a></P>\').1g(7(){$(4).3(\'O\');$(4).o(\'9-3-N\')}).1i(7(){$(4).3(\'u\');$(4).G(\'9-3-N\')}).1l(7(){$(4).3(\'r\')}).6(\'3\',a))};8 f=$(\'<P V="9-3 q-\'+a.w+\'"><a 14="\'+(4.14||4.1p)+\'">\'+4.1p+\'</a></P>\');e.1c(f);5(4.11)f.S(\'11\',4.11);5(4.1r)f.o(4.1r);5(a.1F)a.t=2;5(A a.t==\'1u\'&&a.t>0){8 g=($.n.10?f.10():0)||a.1w;8 h=(a.z%a.t),Y=1y.1z(g/a.t);f.10(Y).1A(\'a\').1B({\'1C-1D\':\'-\'+(h*Y)+\'1E\'})};5(a.m)f.o(\'9-3-1o\');x f.o(\'9-3-1G\').1g(7(){$(4).3(\'1n\');$(4).3(\'D\')}).1i(7(){$(4).3(\'u\');$(4).3(\'C\')}).1l(7(){$(4).3(\'r\')});5(4.L)a.p=f;l.1q();l.1N(7(){$(4).3(\'r\')});f.6(\'3.l\',l.6(\'3.9\',f));a.F[a.F.Q]=f[0];a.v[a.v.Q]=l[0];a.q=d[b]=e;a.1O=c;l.6(\'3\',a);e.6(\'3\',a);f.6(\'3\',a);c.6(\'3\',d)});$(\'.3-15-T-17\').3(\'u\').G(\'3-15-T-17\');k 4};$.12($.n.3,{K:0,D:7(){8 a=4.6(\'3\');5(!a)k 4;5(!a.D)k 4;8 b=$(4).6(\'3.l\')||$(4.U==\'13\'?4:s);5(a.D)a.D.y(b[0],[b.M(),$(\'a\',b.6(\'3.9\'))[0]])},C:7(){8 a=4.6(\'3\');5(!a)k 4;5(!a.C)k 4;8 b=$(4).6(\'3.l\')||$(4.U==\'13\'?4:s);5(a.C)a.C.y(b[0],[b.M(),$(\'a\',b.6(\'3.9\'))[0]])},1n:7(){8 a=4.6(\'3\');5(!a)k 4;5(a.m)k;4.3(\'O\');4.1a().19().X(\'.q-\'+a.w).o(\'9-3-N\')},O:7(){8 a=4.6(\'3\');5(!a)k 4;5(a.m)k;a.q.1V().X(\'.q-\'+a.w).G(\'9-3-1k\').G(\'9-3-N\')},u:7(){8 a=4.6(\'3\');5(!a)k 4;4.3(\'O\');5(a.p){a.p.6(\'3.l\').S(\'L\',\'L\');a.p.1a().19().X(\'.q-\'+a.w).o(\'9-3-1k\')}x $(a.v).1m(\'L\');a.E[a.m||a.1Y?\'1q\':\'1Z\']();4.20()[a.m?\'o\':\'G\'](\'9-3-1o\')},r:7(a,b){8 c=4.6(\'3\');5(!c)k 4;5(c.m)k;c.p=s;5(A a!=\'B\'){5(A a==\'1u\')k $(c.F[a]).3(\'r\',B,b);5(A a==\'1h\')$.W(c.F,7(){5($(4).6(\'3.l\').M()==a)$(4).3(\'r\',B,b)})}x c.p=4[0].U==\'13\'?4.6(\'3.9\'):(4.22(\'.q-\'+c.w)?4:s);4.6(\'3\',c);4.3(\'u\');8 d=$(c.p?c.p.6(\'3.l\'):s);5((b||b==B)&&c.1e)c.1e.y(d[0],[d.M(),$(\'a\',c.p)[0]])},m:7(a,b){8 c=4.6(\'3\');5(!c)k 4;c.m=a||a==B?H:J;5(b)$(c.v).S("R","R");x $(c.v).1m("R");4.6(\'3\',c);4.3(\'u\')},1x:7(){4.3(\'m\',H,H)},24:7(){4.3(\'m\',J,J)}});$.n.3.1s={E:\'25 26\',1d:\'\',t:0,1w:16};$(7(){$(\'l[27=28].9\').3()})})(1j);',62,135,'|||rating|this|if|data|function|var|star|||||||||||return|input|readOnly|fn|addClass|current|rater|select|null|split|draw|inputs|serial|else|apply|count|typeof|undefined|blur|focus|cancel|stars|removeClass|true|arguments|false|calls|checked|val|hover|drain|div|length|disabled|attr|be|tagName|class|each|filter|spw|_|width|id|extend|INPUT|title|to||drawn|call|andSelf|prevAll|metadata|append|cancelValue|callback|applied|mouseover|string|mouseout|jQuery|on|click|removeAttr|fill|readonly|value|hide|className|options|document|number|replace|starWidth|disable|Math|floor|find|css|margin|left|px|half|live|execCommand|try|msie|BackgroundImageCache|browser|catch|change|context|before|control|span|meta|makeArray|slice|children|body|form|required|show|siblings|unnamed|is|name|enable|Cancel|Rating|type|radio|window|not'.split('|'),0,{}))

/////////////////////////////////////////////////////////////////////////////////////

function checkMaxOnTextArea(obj, max) {
    if (obj.value.length >= max) {
        obj.value =  obj.value.substr(0, max-2);
        alert("מקסימום " + max + " תוים");
    }
}

//LOGIN - LOGOUT

function easyLogout()
{
/*
    $.get('/ajax/easyLogin.asp?logout=true', function(data) {
            document.location.href = "/" + currentQS;
    });
    */
    document.location.href = easySite + currentQS + ((currentQS.indexOf('?')>0)?'&':'?') + 'newEasyLogin=loggedOut';
}

function FBLogout(){
    //FB.getLoginStatus(handleFBSessionResponse);
    //FB.logout(function (response) {
        // do something with response
        //logout();
    document.location.href = easySite + currentQS + ((currentQS.indexOf('?') > 0) ? '&' : '?') + 'newFacebookLogin=loggedOut';
    //});
    //location.href = document.URL;//'/user_sessions/new';
}
function googleLogout() {
    document.location.href = easySite + currentQS + ((currentQS.indexOf('?') > 0) ? '&' : '?') + 'newGoogleLogin=loggedOut';
}

// handle a session response from any of the auth related calls
function handleFBSessionResponse(response) {
    /*
    //Check the facebook login status
    alert("handleFBSessionResponse(), "
    + "\nresponse.status="+response.status
    +" \nresponse.session="+response.session
    +" \nresponse.perms="+response.perms);
    */
    //if we do have a non-null response.session, call FB.logout(),
    //the JS method will log the user out
    //of Facebook and remove any authorization cookies
    FB.logout(handleFBSessionResponse);
}


function showFB() {
    document.getElementById("fbloader").style.display="none";
    document.getElementById("facebookLogin").style.display="inline";
}

function showGFC() {
    document.getElementById("gfcloader").style.display="none";
    document.getElementById("gfc").style.display="inline";
}



function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}

//submit query
var submitted=false;
function doSubmit(searchItem)
{   
    searchItem = searchItem.replace(/\//g," ");  
    if (submitted==false) {
        submitted=true;
        if (searchItem == "")
            document.location.href = "/";
        else        
            document.location.href = "/"+trim(searchItem.replace(/&/g,"_"))+"?action=search";
    }            
}


var distanceScalar; // bizlist slider


 // ON READY
$(document).ready(function() {
    // bizlist slider
    if (document.getElementById('listSlider'))
        $("#listSlider").slider({ max: 100,
                                  min: 0,
                                  value: distanceScalar,
                                  change: function(event, ui) {
                                    if (mapid == 0) {
                                        $('html, body').animate({scrollTop:0}, 'fast', function(){
                                            loadMyAddresses(1); 
                                        });                                           
                                    }
                                    else {
                                        submitDistanceScalar(ui.value);
                                    }
                                  }

                               });   
     
 
    window.onunload = function(){
                    submitted=false;
             } 
    
});
  



  
// submit new distanceScalar
function submitDistanceScalar(val)
{
    // submit new distanceScalar
    var href = document.URL ;
    if (href.indexOf("distanceScalar=") > 0) {
    
        var pos = href.indexOf("&",href.indexOf("distanceScalar="))
        if (pos == -1)
            href = href.substring(0,href.indexOf("distanceScalar=")-1)
        else
            href =  href.substring(0, href.indexOf("distanceScalar=") - 1) + href.substring(pos, href.length);
        //alert(href);

    }
    if (href.indexOf("?") == -1) {
        document.location.href = href + "?distanceScalar=" + val;
    }else {
    document.location.href = href + "&distanceScalar=" + val;        
    }
}



function deleteAddress(mapid)
{
	var txt = 'האם למחוק את הכתובת?';
	
	$.prompt(txt,{
	    opacity: 0.2,
	    zIndex:10001,
		buttons:{מחק:true, ביטול:false},
		callback: function(v,m,f){
			
			if(v){

				$.post("/ajax/deleteUserAddress.asp", {mapid:mapid});
				$('#'+mapid).hide('slow', function(){ $(this).remove(); });
			}
			else{}
			
		}	
	});//callback
    
}


/*
$(document).ready(function() {
    $("#ajaxErrMsg").ajaxError(function(e, xhr, settings, exception){
       $(this).append('error in: ' + settings.url + '<br/>'+'error: ' + exception);
     });

    $.ajaxSetup({
        type: "POST",
        cache: false    
    });
  });  
*/  

function getAddressSuggest(txt, prevMapID, ismobile)
{
    txt = trim(txt);
    lastSearchedAddress = txt;
    if (txt == "")
        return;
    
    document.getElementById('ajaxLoader').style.visibility='visible';
        
    if (ismobile == true)
        ismobile = 1;
    else
        ismobile = 0;
            
    txt = txt.replace(/ /g,"-");
    txt = heb2hex(txt);
    //var referer = document.getElementById("referer").value;
    
    var referer = currentQS;

    
    //alert("/ajax/addressSuggest.asp?newLocation="+txt+"&prevMapID="+prevMapID+'&uid='+uid);
    $.ajax({
	    url: "/ajax/addressSuggest.asp?newLocation="+txt+"&prevMapID="+prevMapID,
	    dataType: "xml",
	    success: function(xml) {
	        document.getElementById('ajaxLoader').style.visibility='hidden';
	        //alert($(xml).text());
	        var cunt = $(xml).find('cunt').text();
	        var resultType = $(xml).find('resultType').text();
	        if (cunt==0)
	        {
	            var out='<div class="h4">הכתובת לא נמצאה</div>';
	            out += '<li>' + getAddressInputField() + '</li>'; 
	            $('#myAddresses').html(out);    
	        } 
            else if (cunt==1 && resultType != 3)
            {
                var mapid=$(xml).find('addr').attr("id");
                var pointRadius=$(xml).find('addr').attr("pointRadius");
                var type1=$(xml).find('addr').attr("type");
                if (type1 < 3 && pointRadius > 1500) {
                    getAddressExamps(mapid)
                }
                else {
                    document.location.href='/changeLocation.asp?ismobile='+ismobile+'&newLocation='+mapid+'&referer='+referer;
                }
            }
            else
            {
                $('#myAddresses').html("");
                writeAddresses(xml);
            }
            document.getElementById("myLocation").focus(); 
            document.getElementById("myLocation").select();    
	    }
    });
}

function getAddressExamps(mapid)
{
    //alert("be more specific");
    var out='<div style="font-size:24px;color:red">';
    out += 'הכניסו כתובת מלאה';
    out+='</div>';
    $('#addressSuggestResults').html(out);
    document.getElementById('ajaxLoader').style.visibility='visible';
    $.get('/ajax/getMoreExamps.asp?mapid='+mapid, function(data) {
          document.getElementById('ajaxLoader').style.visibility='hidden';
          writeAddresses(data);
        });
}

//write addresses list in changeAddress
function writeAddresses (data)
{
    var $xmlDoc = jQuery(data);
    var resultType = $xmlDoc.find("root").attr("type");
    //title
    var out = '<div class="h4">';
    if (resultType == "Examps") {
        out += '<span style="color:#42a0fa;">' + $xmlDoc.find("city").text() + ' מקום די גדול<br/>';
        out += '' + 'נא הכניסו כתובת מלאה ב' + $xmlDoc.find("city").text() + '... לדוגמא:<br/></span>';
        var lat = $xmlDoc.find("city").attr("lat");
        var lng = $xmlDoc.find("city").attr("lng");
        //alert(lat + "," + lng);
        /*
        map.setCenter(new google.maps.LatLng(lat, lng), 10);
        map.setZoom(13);
        markerHome.setPosition(new google.maps.LatLng(lat, lng));
        */
    }
    else if (resultType == "MyAddresses") {
        out += 'כתובות אחרונות';
    }
    else if (resultType == "AddressSuggest") {   
        out += 'נמצאה יותר מאפשרות אחת לחיפוש';
    }
    else if (resultType == "EstimatedLocation") {   
        out += 'כתובת משוערת';
    }    
    out += '</div>';
    
    //body    
    //out += '<div id="addressResults" class="addressResults"><ul>'
    $xmlDoc.find("addr").each(function() {        
        var mapid = $(this).attr("id");
        var type1 = $(this).attr("type");
        var pointRadius = $(this).attr("pointRadius");
        out += '<li id="' + mapid + '">';
        if (resultType == "MyAddresses") {
            out += '<a style="margin-left:10px;" onclick="deleteAddress(' + mapid + ');">X</a>';
        }
        var addressLink = $(this).find("name").text();
        if (resultType == "Examps")
            var addressDisplay = addressLink.substring(0, addressLink.indexOf(','));
        else
            var addressDisplay = addressLink;
        
        addressLink = addressLink.replace(/\'/g, '&#39;');
        addressLink = addressLink.replace(/\"/g, '&quot;');
        
        if (type1 < 3 && pointRadius > 1500) {
            out += '<a title="לחץ כאן להצעות בכתובת זו" onclick="getAddressExamps('+mapid+')">' + addressDisplay + '</a>'
        }
        else {
            out += '<a title="לחץ כאן להחליף לכתובת זו" onclick="document.location.href=\'/changeLocation.asp?newLocation=' + mapid + '&referer=' + escape(currentQS) + '\';">' + addressDisplay + '</a>'
        }
        out += '</li>'; 
    });
    out += '<li>' + getAddressInputField() + '</li>';
    //out += '</ul></div>';
    //if (resultType == "AddressSuggest" || resultType == "Examps") {
    //    $('#exampsArea').html("");
    //}
    
    $('#myAddresses').html(out);
    document.getElementById("myLocation").focus();
}


//hide the address menu when pressing ESC
$(document).keyup(function(e) {
    if (e.keyCode == 27) { // esc
        $('ul.menu_body').slideUp(200); 
    }   
});


function loadMyAddresses(toShow)
{
    if (document.getElementById("myAddressesMenuBody").innerHTML == "") {
        var out = '<div id="addressInputCloseButton" class="h5 hover" onclick="$(\'ul.menu_body\').slideToggle(200);">X</div><div style="clear:both;"></div>';
        $.get('/ajax/getMyAddresses.asp', function(data) {
            var $xmlDoc = jQuery(data);
            out += '<div id="myAddresses">';
            if (mapid == 0) {
                out += '<li>' + getAddressInputField() + '</li>';
            }
            $xmlDoc.find("addr").each(function() {
                var myMapID = $(this).attr("id");
                out += '<li id="' + myMapID + '"><div>';
                if (mapid != 0) {
                    out += '<div style="float:right;cursor:pointer;" title="מחק מההסטוריה" class="hover" onclick="deleteAddress('+myMapID+');">x</div>';
                }
                var addressLink = $(this).find("name").text();
                var addressDisplay = addressLink;
                addressLink = addressLink.replace(/\'/g, '&#39;');
                addressLink = addressLink.replace(/\"/g, '&quot;');
                out += '<div><a title="לחץ כאן להחליף לכתובת זו" onclick="document.location.href=\'/changeLocation.asp?ismobile='+isMobile+'&newLocation='+myMapID+'&referer='+escape(currentQS)+'\';">' + addressDisplay + '</a></div>'        
                out += '</div></li>';             
            
            });
            if (mapid != 0) {
                out += '<li>' + getAddressInputField() + '</li>';
            }
            if (hasGPS) {
                out += '<li  onclick="runGeoLocationJS();">';
                out += '    <div style="clear:both;float:right;"cursor:pointer;background-color:#AAAAAA;">';
                out += '        <img src="'+ imagesBase + 'images/category/120white/2708b.png" style="height:20px;width:20px;"/>';
                out += '    </div>';
                out += '    <div class="h4" style="float:right;">שנה למיקום נוכחי</div>';
                out += '</li>';
            }
            out += '</div>';
            //out += '<li><a href="/changeAddress" class="h2" style="color:#dc6241">כתובת חדשה...</a></li>';
            //out += '<li><a href="' + document.URL + ((document.URL.indexOf("?")>0)?'&':'?') + 'changeAddress=1" class="h2" style="color:#dc6241">כתובת חדשה...</a></li>';
            document.getElementById("myAddressesMenuBody").innerHTML = out;
            $('#myAddressesMenuBody').css("width", $('#myAddressesMenuBody').width()+50);
            //$("ul.menu_body li:even").addClass("alt");
            if (toShow)
                $('ul.menu_body').slideDown(200);
            else
                $('ul.menu_body').slideToggle(200);  
            document.getElementById("myLocation").focus();  
        }); 
    }
    else {
        if (toShow)
            $('ul.menu_body').slideDown(200);
        else
            $('ul.menu_body').slideToggle(200);
        document.getElementById("myLocation").focus();
    }
    
}
var defaultAddressText = '';//'הכניסו כתובת חדשה...';
function getAddressInputField() {
    
    if (lastSearchedAddress == '')
        lastSearchedAddress = defaultAddressText;
    else
        lastSearchedAddress = lastSearchedAddress.replace(/\"/g, "&quot;");
        
    var styleColor;
    if (lastSearchedAddress == defaultAddressText)
        styleColor = "#aaaaaa;";
    else
        styleColor = "black;" ;   
      
    var str = '<div id="addressInputDiv">';
    str +=      '<input style="color:'+styleColor+'" type="text" id="myLocation" value="' + lastSearchedAddress + '" onclick="if (this.value==defaultAddressText) {this.value=\'\'; this.style.color=\'black\';}" onkeydown="if (this.value==defaultAddressText){ this.value=\'\';this.style.color=\'black\'}" onkeyup="if (event.keyCode==13) {getAddressSuggest(this.value, mapid, isMobile);return false;}"/>';
    str +=    '</div>';
    str +=    '<div id="ajaxLoader"><img src="/images/ajax-loader.gif" /></div>';
    str +=    '<div id="addressInputButtonDiv"><input id="changeAddressButton" type="button" value="החלף כתובת" onclick="getAddressSuggest(document.getElementById(\'myLocation\').value, mapid, isMobile);return false;" /></div>';
    return str;
}



function heb2hex(str)
{
  var key1 = str;
  key1 = key1.replace(/א/g, "E0");
  key1 = key1.replace(/ב/g, "E1");
  key1 = key1.replace(/ג/g, "E2");
  key1 = key1.replace(/ד/g, "E3");
  key1 = key1.replace(/ה/g, "E4");
  key1 = key1.replace(/ו/g, "E5");
  key1 = key1.replace(/ז/g, "E6");
  key1 = key1.replace(/ח/g, "E7");
  key1 = key1.replace(/ט/g, "E8");
  key1 = key1.replace(/י/g, "E9");
  key1 = key1.replace(/ך/g, "EA");
  key1 = key1.replace(/כ/g, "EB");
  key1 = key1.replace(/ל/g, "EC");
  key1 = key1.replace(/ם/g, "ED");
  key1 = key1.replace(/מ/g, "EE");
  key1 = key1.replace(/ן/g, "EF");
  key1 = key1.replace(/נ/g, "F0");
  key1 = key1.replace(/ס/g, "F1");
  key1 = key1.replace(/ע/g, "F2");
  key1 = key1.replace(/ף/g, "F3");
  key1 = key1.replace(/פ/g, "F4");
  key1 = key1.replace(/ץ/g, "F5");
  key1 = key1.replace(/צ/g, "F6");
  key1 = key1.replace(/ק/g, "F7");
  key1 = key1.replace(/ר/g, "F8");
  key1 = key1.replace(/ש/g, "F9");
  key1 = key1.replace(/ת/g, "FA");
  return key1;
}


function sendSiteFeedback(referer)
{
    $.ajax( {
        type : "POST",
        url : "/ajax/siteFeedback.asp",
        data : $("#siteFeedbackForm").serialize(),
        success : function(msg) {
            alert(msg);
            //if (msg == "thank u")
                //$.fancybox.close();
            document.location.href = referer;
          }
    });
}


var isNextEvents = false;
function showMoreEvents(map)
{
    if (isNextEvents == false) {
        $("#eventsDiv1").fadeOut('slow', function() {
        $("#map").fadeOut(150, function() {
        isNextEvents = true;
        for (i = 1; i <= 5; i++) {
            eval("marker" + i).setMap(null);
            eval("marker" + (i + 5)).setMap(map);
        }
        $("#map").fadeIn(150, function() {
                $("#eventsDiv2").fadeIn(150);

                });
            });
        });
         
    }
    else {
        $("#eventsDiv2").fadeOut('slow', function() {
        $("#map").fadeOut(150, function() {
        isNextEvents = false;
        for (i=1; i<=5; i++) {
            eval("marker"+(i+5)).setMap(null);
            eval("marker"+i).setMap(map);
        }          
        $("#map").fadeIn(150, function() {
        $("#eventsDiv1").fadeIn(150);

    });
});
});
    }    
}


//switch tabs in bizpage and sync map icons
function switchTab(myID, tabPos, theTabs, doMarkers, map)
{
    var myObj = document.getElementById(myID);
    var prevObj = document.getElementById(theTabs[0]);
    var prevTabPos = theTabs[1];
    
    if (tabPos==0)
        myObj.className='FirstTab';
    else
        myObj.className='SecondTabSel';
    if (theTabs[0]==0) 
        prevObj.className='FirstTabUnSel';
    else 
        prevObj.className='SecondTab';
        
    $('#'+theTabs[0]+'Div').slideUp(300,function () {
        theTabs[0]=myID;
        theTabs[1]=tabPos;
        $('#'+theTabs[0]+'Div').slideDown(300);
    });
       
    if (doMarkers) {       
        for (i=arrMapTabs[prevTabPos][0]; i < arrMapTabs[prevTabPos][1]; i++)
            eval("marker"+i).setMap(null);
        for (i=arrMapTabs[tabPos][0]; i < arrMapTabs[tabPos][1]; i++)
            eval("marker"+i).setMap(map);
   }     
   
   return theTabs     
}

function zoomMyMap(tabPos)
{
    var latlngbounds = new GLatLngBounds( );
    for (var i=arrMapTabs[tabPos][0]; i<arrMapTabs[tabPos][1]; i++) {
        latlngbounds.extend(eval("markerLocation"+i)); 
    }
    if (map.getBoundsZoomLevel(latlngbounds)>5 && map.getBoundsZoomLevel(latlngbounds)<17) {
        map.setCenter(new google.maps.LatLng(currentLat, currentLng), map.getBoundsZoomLevel( latlngbounds ));
        
    }else
        map.setCenter(new google.maps.LatLng(currentLat, currentLng), 13); 
                  
}



function initTabs(){

	//When page loads...
	$(".tab_content").hide(); //Hide all content
	
	$("ul.tabs.a li:first").addClass("active").show(); //Activate first tab
	$(".tab_content.a:first").show(); //Show first tab content

	$("ul.tabs.b li:first").addClass("active").show(); //Activate first tab
	$(".tab_content.b:first").show(); //Show first tab content
	
	$("ul.tabs.c li:first").addClass("active").show(); //Activate first tab
	$(".tab_content.c:first").show(); //Show first tab content
	
	$("ul.tabs.d li:first").addClass("active").show(); //Activate first tab
	$(".tab_content.d:first").show(); //Show first tab content	
	
	$("ul.tabs.e li:first").addClass("active").show(); //Activate first tab
	$(".tab_content.e:first").show(); //Show first tab content				
	
	//On Click Event
	$("ul.tabs li").click(function() {
	    if (inAnimation == true) 
	        return;
	
	    inAnimation = true;
        var tabsArr = ($(this).attr("class")).substring(0,1);
        var lastTabObj = $("ul.tabs."+tabsArr+" li.active");
        lastTab = $(lastTabObj).find("a").attr("href");
		$("ul.tabs."+tabsArr+" li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab

        
		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		if (lastTab != activeTab)
		    $(".tab_container."+tabsArr).height($(activeTab).height()+20); //set the height of the active tab to the outer div
		$(".tab_content."+tabsArr).hide(0); //Hide all tab content

		$(activeTab).fadeIn(300, function(){inAnimation=false;}); //Fade in the active ID content
		
		
        if ($(this).hasClass("showInMap")) {
            var tabPos = $(activeTab).attr('id').substring(4,5)-1;       

            for (var i=arrMapTabs[0][0]; i < arrMapTabs[arrMapTabs.length-1][1]; i++) {
                if (eval("marker"+i)) {                            
                    eval("marker"+i).setVisible(false);
                }
            }

            for (var i=arrMapTabs[tabPos][0]; i < arrMapTabs[tabPos][1]; i++) {
                //alert(i);
                eval("marker"+i).setVisible(true);
            }
            if (okToZoomByTab) {
             //   zoomMyMap(tabPos);
            }else {
                okToZoomByTab = true; 
            }    
                
        } 		
		return false;
	});

}





// inner tabs
function initInnerTabs()
{
	//When page loads...
	$(".inner_tab_content").hide(); //Hide all content
	
	$("div.inner_tabs.a div:first").addClass("active").show(); //Activate first tab
	$(".inner_tab_content.a:first").show(); //Show first tab content
	
	$("div.inner_tabs.b div:first").addClass("active").show(); //Activate first tab
	$(".inner_tab_content.b:first").show(); //Show first tab content			
	
	//On Click Event
	$("div.inner_tabs div").click(function() {

	    if (inAnimation == true) 
	        return;
	 
	    inAnimation = true;
        var tabsArr = ($(this).attr("class")).substring(0,1);
		$("div.inner_tabs."+tabsArr+" div").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".inner_tab_content."+tabsArr).hide(0); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(300, function(){inAnimation=false;}); //Fade in the active ID content
		
		return false;
	});

}



function loadSocialContent()
{
    $('#socialDiv').load('/ajax/socialContent.asp');
}
/*
function deleteSocialContent()
{
    $('#socialInfo').load('/ajax/socialDisconnect.asp');
    document.getElementById('socialInfo').innerHTML = '';
    document.getElementById('socialLogoutLink').style.display = 'none';
    document.getElementById('socialLoginLink').style.display = 'inline';
}
*/


