var editevent= false;
var eventLoadingHTML="<div style='width:100%; text-align:center; padding:10px 0 10px 0'><img src='images/loading2.gif'/></div>";
var hash= "";

function addRatingAccess(){
    $('div.ratingHolder').each( function(){
        id= $(this).children("div.rating").attr("id");
        curvalue= $(this).children("div.rating").attr("param");
        $(this).children("div.rating").rating({maxvalue:5, id:id, curvalue:curvalue, inactive:false});                 
    });

}
function addMouseActions(){
    $('div.ratingHolder').each( function(){
        id= $(this).children("div.rating:not(.hasrating)").attr("id");
        curvalue= $(this).children("div.rating:not(.hasrating)").attr("param");
        bool= (admin)? false:true;
        $(this).children("div.rating:not(.hasrating)").rating({maxvalue:5, curvalue:curvalue, id:id,inactive:false});    
        $(this).children("div.rating:not(.hasrating)").addClass("hasrating");
    });
    $("div.tr:not(.active, .nohref, .editmode)").addClass("href");
    $("div.tr:not(.active, .nohref, .editmode)").click(function(event){
		if( !editevent){
        event.preventDefault(); 
       
		href= $(this).find("a.event").attr("href");
		target= $(this).find("a.event").attr("target");
		if( target) 
			window.open(href);
		else 
			document.location.href= href;       
		}
    });
    $("div.tr:not(.active, .nohref, .editmode)").mouseover(function(event){
        if(!editevent) $(this).addClass("selected");
    }).mouseout(function(event){
        if(!editevent) $(this).removeClass("selected");
    });
    
}
function removeDuplicates(){
$(".today:gt(0)").remove();
$(".tomorrow:gt(0)").remove();
$(".thisweek:gt(0)").remove();
$(".nextweek:gt(0)").remove();
$(".comingup:gt(0)").remove();
}

function fb_submitFeed( template_data, action_links){
	
	FB.Connect.streamPublish('',template_data,action_links);
	return false;
	//FB.Connect.showFeedDialog(142297758986, template_data);
}


function lookupmore( str, sx, event){
$("#more_btn>div").html($("#more_btn>div").html()+'<img src="images/loading.gif" width="10" style="padding-left:10px"/>');

$.post("/search.php", {searchstring:""+str+"",limit:sx, event:event},
        function(data){
            if( data.length>0){
                $("#more_btn").after( data).remove();
                removeDuplicates();
                addMouseActions();
                
            }
        });
}

function lookup(){
    str= $("#inputSearch").val();
    if( str!= "Search for sports...")
    if( str!= "Find sportbars...")
    if( str.length== 0){
        $("#results").html('');
    }else{
		document.location.href='/index.php?search='+str;
    }
}


function changeCountry(){
    country= $("#country").val();
    $.post("change_location.php", {country:country},
        function( data){
            $("#location_headline").html( data);
            renderCities( );
        });    
}
function renderCities(){
    country= $("#country").val();
    $.post("generate_cities.php", {country:country},
        function( data){
            $("#city-holder").html( data);
            changeCity();
            $("#city").change( function(){ changeCity();});
        });    

}
function changeCity(){
    city= $("#city").val();
    
    $.post("change_location.php", {city:city},
        function( data){
            $("#location_headline").html( data);
            
        });    
}




