// remap jQuery to $
(function($){})(window.jQuery);

function submitchk(e,cID,vID,DateFilter) {
	//alert('iam here');
	var BDate="";
	var EDate="";
	if (DateFilter.length != 0) {
      var mySplitResult = DateFilter.split("|", 2);
      BDate = mySplitResult[0];
      EDate = mySplitResult[1];
	 } 
	 
	var cIndex=document.getElementById(cID).selectedIndex;
	var vIndex=document.getElementById(vID).selectedIndex;
	var c=document.getElementById(cID).options[cIndex].text;
	var v=document.getElementById(vID).options[vIndex].text;
	
	
			if (document.getElementById(e).value != "" && document.getElementById(e).value!= "TYPE EVENT") {
				if(c !="ALL")
				{
					  if(v!="ALL")
						 window.location.href=LandingURL+"ResultsEventVenueCity.php?venname="+v+"&kwds="+trim(document.getElementById(e).value.replace(' (Event)','').replace(' (City)','').replace(' (Venue)',''))+"&state="+c+ "&tn=&begindate=" + BDate + "&enddate=" + EDate;
					  else //if v="ALL"
						window.location.href=LandingURL+"ResultsGeneralAtCity.php?city=" +c+"&kwds="+trim(document.getElementById(e).value.replace(' (Event)','').replace(' (City)','').replace(' (Venue)',''))+ "&tn=&begindate=" + BDate + "&enddate=" + EDate;
				}
				else //C="ALL"
				{
					window.location.href=LandingURL+"searchresult.php?kwds=" +trim(document.getElementById(e).value.replace(' (Event)','').replace(' (City)','').replace(' (Venue)','')) +"&category=a&tn=&begindate=" + BDate + "&enddate=" + EDate;
				}
				return true;
			}
			else {
							document.getElementById(e).focus();
							return false;
			}
}

function trim(str)
{
    if(!str || typeof str != 'string')
        return null;

    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}
/*DOCUMENT-READY*/
$(document).ready(function($){
													 
if($('tr.tn_results_alternate_row:first td').length==1){$('tr.tn_results_alternate_row:first').hide();}

$('.tn_results_event_venue_group_text a[name]').each(function() {
aname=this.name;
$(this).attr('id',aname.replace("+"," "));
$(this).css({'float':'none','margin-right':'right'});
$(this).html('&gt;');
});
													 

//START- Fix for Button Length Issue
var buybtn=$("a.btnbuy");
if(buybtn.length != 0){
	var limit = 58;
	var str = buybtn.html();
	var from = str.lastIndexOf("Tickets");
	var tix = str.substring(0,from);
	var strtemp = tix.substr(0,limit);
	var cstr = str.length;

	if (cstr > limit) {
	str = strtemp+'...Tickets &gt;';
	buybtn.html(str);
	}
}
//END- Fix for Button Length Issue

$('body').append("<a href='http://www.ticketluck.com/fbd/feedback.php' class='feedback'></a>");
$(".feedback").colorbox({iframe:true, width:"500", height:"550"});

$("#guarantee a").colorbox({iframe:true, width:"760", height:"450"});

$("#tabContainer:empty").remove();
$(".detailblock").next(".gotop").remove();
$(".detailblock:empty").remove();
$("table[bordercolor] table").addClass("NewE");


$(".allcategories div:nth-child(3n)").css("margin-right","0");

/*TEMP*/
$("strong:contains('aaanow')").addClass("aaanow");

var categorylinks=$(".categorylinks").text().length;
if(categorylinks<3){
$(".categorylinks").next(".gotop").remove();
$(".categorylinks").remove();
}

$(".lnkblock:empty").next(".gotop").remove();
$(".lnkblock:empty").remove();

var cmsP=$(".cmsblock p").length;
if(cmsP==0){
$(".cmsblock").next(".gotop").remove();
$(".cmsblock").remove();
}
/*TEMP*/
/*
$("table.tn_results tbody tr").live("hover", function() {
	$(this).toggleClass("highlight");
});
*/
$('table.tn_results tbody tr').mouseover(function() {
         $(this).addClass('highlight');
      }).mouseout(function() {
         $(this).removeClass('highlight');
      });
/*READ-ALL BUTTON
var pHeight=$(".cntblock").height();
var minHeight="250";
if(pHeight>minHeight){
$(".cntblock").css({'height':'250px'});
$(".cntblock").append("<a class='readall'><span><strong>&or;</strong> Read All</span></a>");
$(".cntblock").addClass("hAuto");

$(".readall").toggle(function(){
$(this).children("span").html("<strong>&and;</strong>Read Less");
$(this).parent().css({'height':'auto'});
}, function(){
$(this).children("span").html("<strong>&or;</strong> Read All");
$(this).parent().css({'height':'250px'});
	});
}else{
}*/

/*GOTO BACK TO TOP*/
$(".btop").after("<a class=\"gotop\" title=\"Back to Top\"><span><em>Back to Top</em>&and;</span></a>");
$(".gotop").click(function(){
		$('html, body').animate({scrollTop:0},500);
});


//START-	Share Floating Widget
if($('#sharethis').length){
var share_block = $('#sharethis');
var top = share_block.offset().top - parseFloat($('#sharethis').css('marginTop').replace(/auto/, 0));
$(window).scroll(function (event) {
var y = $(this).scrollTop();
if (y >= top) {
share_block.addClass('fix');
} else {
share_block.removeClass('fix');
}});
}
//END-	Share Floating Widget

//$('#testimonials').innerfade({animationtype:'fade',speed:1000,timeout:8000,type:'random',containerheight:'160px'});

/*HOME PAGE - FADE-SHOW*/
$('#fadeShow li:gt(0)').hide();
setInterval(function(){$('#fadeShow li:first-child').fadeOut(2000).next('li').fadeIn(2000).end().appendTo('#fadeShow');}, 5000);
/*TESTIMONIALS - SLIDES*/
$('#testimonials div:gt(0)').hide();
setInterval(function(){$('#testimonials div:first-child').fadeOut(1000).next('div').fadeIn(1000).end().appendTo('#testimonials');}, 8000);

$("#gridtix").removeClass("show");
      $("#tabs li:first-child a").attr('class', 'selected').trigger('click');
      $("#tabs li.more").click(function () {
        $(".more_tabs").slideDown('fast').show();
        $(".more_tabs").parent().hover(function () {}, function () {
          $(".more_tabs").slideUp('slow');
        });
      });

$(".tabs li.more").click(function() {
				$(".more_tabs").slideDown('fast').show();
				$(".more_tabs").parent().hover(function() {
				}, function() {
								$(".more_tabs").slideUp('slow');
							});
});


$("table.tablesorter tbody tr").live("hover", function() {
			$(this).toggleClass("highlight");
});

$.tablesorter.defaults.sortList = [[1,0]];

$("#bcrumbs table td:last-child").addClass("current");

});

/* optional triggers

$(window).load(function() {
});

$(window).resize(function() {
});

*/
