
$(function(){
	
    $("a.link_reveal","div.type-voucher-code").click(function(){
        $(".click-done",$(this).parents(".type-voucher-code")).show();
        $(".code",$(this).parents(".type-voucher-code")).addClass('click-clicked');
        $(".show",$(this).parents(".type-voucher-code")).hide();
        $(".hide",$(this).parents(".type-voucher-code")).show();
        popupWindow($(this).attr("href"),false); // Open New Window and Don't Blur it
        return false;
		
    });
	
    $("a.link_reveal","td.discount").click(function(){
        $(".click-done",$(this).parents(".discount")).show();
        $(".code",$(this).parents(".discount")).show();
        $(".code",$(this).parents(".discount")).addClass('click-clicked');
		
        $(".show",$(this).parents(".discount")).hide();
        $(".hide",$(this).parents(".discount")).show();
        $($(this)).unbind('click');
		
        popupWindow($(this).find(".show a:first").attr("href"),false); // Open New Window and Don't Blur it
        return false;
		
    });
	
    $(".hover_reveal").mouseover(function(){
        $(".hide",$(this)).show();
        $(".show",$(this)).hide();
    }); 
    $(".hover_reveal").mouseout(function(){
        $(".hide",$(this)).hide();
        $(".show",$(this)).show();
    });	

    $(".hover_reveal").mouseup(function(){
	
        $($(this)).unbind('mouseover');
        $($(this)).unbind('mouseout');
        $($(this)).unbind('mouseup');
        $(".click-done",$(this)).show();
        $(".code",$(this)).addClass('click-clicked');

        popupWindow($(this).find(".show a:first").attr("href"),false); // Open New Window and Don't Blur it
        return false;
		
    });
	
    $(".click-show").click(function(e){
        e.preventDefault();
        $(".click-done",$(this)).show();
        $(".show",$(this)).hide();
        $(".hide",$(this)).show();
        $($(this)).unbind('click');
		
        $(".code",$(this)).addClass('click-clicked');
        popupWindow($(this).find(".show a:first").attr("href"),false); // Open New Window and Don't Blur it
        return false;
		
    });
	
	
    $(".click-show-2").click(function(){
        $(".click-done",$(this).parent().parent()).show();
        $(".show",$(this).parent().parent()).hide();
        $(".hide",$(this).parent().parent()).show();
        $($(this)).unbind('click');
        $(".code",$(this).parents($(".coupon"))).addClass('click-clicked');

        popupWindow($(this).find("a:first").attr("href"),false); // Open New Window and Don't Blur it
        return false;
		
    });	
    // Added by Chetan
    $(".pic-non-vc a, .searchy-pic-non-vc a, .title-non-vc a, .show-non-vc a, .fleft a, .restaurant-voucher-pic a, .restaurant-title a, .travel-voucher-pic a, .travel-title a").click(function(){	
        popupWindow($(this).attr("href"),false); // Open New Window and Don't Blur it
        return false;
		
    });
 	
  //   $(".box-description a").click(function(){
  //      popupWindow($(this).attr("href"),false); // Open New Window and Don't Blur it
  //      return false;
//		
  //  });
 

    $(".full_reveal").click(function(){
        $(".click-done",$(this)).show();
        $(".code",$(this)).addClass('click-clicked');
        $($(this)).unbind('click');

		
        popupWindow($(this).find(".code a:first").attr("href"),false); // Open New Window and Don't Blur it
        return false;
		
    });
	
    $(".no_reveal").click(function(){
        $(".deal",$(this)).addClass('click-clicked');
        popupWindow($(this).find(".deal a:first").attr("href"),false); // Open New Window and Don't Blur it
        return false;
		
    });
	
	
	
    $(".exp_reveal").mouseup(function(){
        $(".deal",$(this)).addClass('click-clicked');
        $($(this)).unbind('mouseup');
        popupWindow($(this).find(".deal a:first").attr("href"),false); // Open New Window and Don't Blur it
        return false;
		
    });
    $(".exp_reveal").click(function(){
        return false;
    });

    $(".reveal_all").click(function(){
		
        $(".show").hide();
        $(".hide").show();
        $($(this)).unbind('click');
        $(".code").addClass('click-clicked');
        $(this).addClass('click-clicked');
		
        popupWindow($(this).attr("href"),true); // Open New Window and Don't Blur it
        $(this).html('<a href="#discounts">Scroll Down To View Discounts</a>'); 
        window.location = window.location + "#discounts";
        return false;
    });
});

function jumpTo(list) {
	
    if (list.options[list.selectedIndex].value != "home") {
        location = list.options[list.selectedIndex].value
    }
	
}
function showItems(numItems){
    var all = $('.offer');
    var categories = $('#tickets a[id^="ticket"]');
    var yep = {
        ticket_all: all,
        ticket_vouchers: all.filter('.vcr'),
        ticket_deals: all.filter('.dis'),
        ticket_printables: all.filter('.prt')
    };

    var not = { 
        ticket_all: $([]),
        ticket_vouchers: all.not('.vcr'),
        ticket_deals: all.not('.dis'),
        ticket_printables: all.not('.prt')
    };
	
    //first initialization for mixed items
    var itemToShow = numItems;
    all.hide();
    yep['ticket_all'].show();
    for( var i = yep['ticket_all'].length-1; i>itemToShow-1; i-- ) $(yep['ticket_all'][i]).hide();
	
	
    categories.click(function () {
        var sel = $(this).attr('id');
        not[sel].hide();
        yep[sel].show();
		
        categories.removeClass('selected');
        $(this).addClass('selected');
		
        $('div.picklist').show();
        $('div.picklist').each(function (i) {
            var vis = $(this).find('.offer:visible');
			
            $('.browsebydate').find('li').eq(i).find('span').html('(' + (vis.length-1) + ')');
			
            if (vis.length > 0)
            {
                $(this).show();
                vis.removeClass('offerlast').eq(vis.length-1).addClass('offerlast');
            }
            else
            {
                $(this).hide();
            }
        });
		
        for( var i = yep[sel].length-1; i>itemToShow-1; i-- ) $(yep[sel][i]).hide();
        return false;
    });
}
//toggle hide show a div
function toggleHideShow(v,anim){
    if( typeof(anim) == 'undefined') anim = 'fast';
    $(v).slideToggle(anim);
}


//Old Popup Code 
//
function popupWindow(href,blur){
    var new_win = window.open(href,'_blank','toolbar=1,height=300, width=600,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,top=0,left=0');
    if(blur!==undefined && blur) {
        //new_win.blur();
    }
}



