﻿//////////////////////////////////////////////////////////////
//                                                          //
//   Original code written by Reboot Concetps, Inc. for:    //
//   Dealoco, LLC.                                          //
//                                                          //
//   Contact us for support, upgrades, or assistance.       //
//   support@rebootconcepts.com                             //
//                                                          //
//   Any modifications to the code below not written by     //
//   Reboot Concepts, Inc. will invalidate any and all      //
//   warranty previously agreed upon.  While Reboot         //
//   Concepts, Inc. is not responsible for repairing such   //
//   a modification, we would be happy to do so at our      //
//   hourly rate.                                           //
//                                                          //
//////////////////////////////////////////////////////////////

$(document).ready(function()
    {
	$(".print_filters_buttons").bind("click", function() 
	    {
		var next_cat = $(this).attr('id');
		if(current_cat == next_cat) {
		    changeImages('button_'+current_cat,'/images/button_'+current_cat+'.gif'); 
		    current_cat = 'nocat';
		}
		else {
		    changeImages('button_'+current_cat,'/images/button_'+current_cat+'.gif'); 
		    current_cat = $(this).attr('id');
		}

		$("#deals_wrap").load( print_filters_links[current_cat], function() 
		    {
			bind_deal_buttons();
		    }
		);
	    });

	$(".print_filters_buttons").hover( 
	    function() {
		var button = $(this).attr('id');
		changeImages('button_'+button,'/images/button_'+button+'_over.gif'); 
	    },
	    function() {
		var button = $(this).attr('id');
		var active = (button == current_cat)?'_over':'';
		changeImages('button_'+button,'/images/button_'+button+active+'.gif'); 
	    });
	
	bind_deal_buttons();
    });

function bind_deal_buttons() {
    $(".ap-button").bind("click", function() 
	{
	    var id = $(this).attr('id').substr(10);
	    $('#ap-div-'+id).slideToggle('normal');
	});

    $(".ap-link").bind("click", function() 
	{
	    var id = $(this).attr('id').substr(8);
	    $('#ap-div-'+id).slideToggle('normal');
	});

    $(".review-button").bind("click", function() 
	{
	    var id = $(this).attr('id').substr(14);
	    $('#review-div-'+id).slideToggle('normal');
	});

    $(".dc-link").bind("click", function() 
	{
	    var id = $(this).attr('id').substr(8);
	    $('#dc-'+id).slideToggle('normal');
	});

    $(".friend-button").bind("click", function() 
	{
	    var id = $(this).attr('id').substr(14);
	    $('#friend-div-'+id).slideToggle('normal');
	});

    $(".friend-send-button").bind("click", function() 
	{
	    var id = $(this).attr('id').substr(19);
	    var email1 = $('#friend-email-input-'+id+'_1').val();
	    var email2 = $('#friend-email-input-'+id+'_2').val();
	    var email3 = $('#friend-email-input-'+id+'_3').val();
	    $.post("/friend_email.php", {
		    email1: email1,
		    email2: email2,
		    email3: email3,
		    deal_id: id
		});
		document.getElementById('friend-email-input-'+id+'_1').value = '';
		document.getElementById('friend-email-input-'+id+'_2').value = '';
		document.getElementById('friend-email-input-'+id+'_3').value = '';
	    $('#friend-div-'+id).slideUp('normal');
	    $('#friend-email-sent-div-'+id).slideDown('normal');
		$.fn.pause(2000);
	    $('#friend-email-sent-div-'+id).fadeOut(2000);
	});

}
