/*
 * IMPORTANT:
 * 
 * This file has been moved to codebase/script/ in order to be php-parsed.
 * This file will be deprecated. DO NOT USE IT!
 * 
 */

/** new school */
var new_win = null;
$(function(){
	
	$("a.link_reveal","div.type-voucher-code").click(function(){
		
		//$.copy($("a",$(".hide,",$(this).parents(".type-voucher-code"))).html());
		$(".code_confirm",$(this).parents(".type-voucher-code")).show();
		$(".code",$(this).parents(".type-voucher-code")).addClass('code_clicked');
		
		$(".show",$(this).parents(".type-voucher-code")).hide();
		$(".hide",$(this).parents(".type-voucher-code")).show();
		//$(".popout",$(this).parents(".type-voucher-code")).hide();
		//$(".popout_clicked",$(this).parents(".type-voucher-code")).show();
		
		new_win = window.open($(this).attr("href"),'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
		if (new_win) {new_win.blur();}
		return false;
		
	});
	
	$("a.link_reveal","td.discount").click(function(){
		
		//$.copy($("a",$(".hide,",$(this).parents(".discount"))).html());
		$(".code_confirm",$(this).parents(".discount")).show();
		$(".code",$(this).parents(".discount")).show();
		$(".code",$(this).parents(".discount")).addClass('code_clicked');
		
		$(".show",$(this).parents(".discount")).hide();
		$(".hide",$(this).parents(".discount")).show();
		//$(".popout",$(this).parents(".discount")).hide();
		//$(".popout_clicked",$(this).parents(".discount")).show();
		$($(this)).unbind('click');
		
		new_win = window.open($("a",$(".hide,",$(this).parents(".discount"))).attr("href"),'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
		if (new_win) {new_win.blur();}
		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');
	
		//$.copy($("a",$(".hide,",$(this))).html());
		$(".code_confirm",$(this)).show();
		$(".code",$(this)).addClass('code_clicked');
		
		//$(".popout",$(this)).hide();
		//$(".popout_clicked",$(this)).show();
		
		new_win = window.open($("a",$(".hide,",$(this))).attr("href"),'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
		if (new_win) {new_win.blur();}
		return false;
		
	});
	
	$(".click_reveal").click(function(){
		//$.copy($("a",$(".hide,",$(this))).html());
		$(".code_confirm",$(this)).show();
		$(".show",$(this)).hide();
		$(".hide",$(this)).show();
		$($(this)).unbind('click');
		
		$(".code",$(this)).addClass('code_clicked');
		
		//$(".popout",$(this)).hide();
		//$(".popout_clicked",$(this)).show();
		
		new_win = window.open($("a",$(".hide,",$(this))).attr("href"),'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
		if (new_win) {new_win.blur();}
		return false;
		
	});
	
	$(".full_reveal").click(function(){
		//$.copy($("a",$(".code,",$(this))).html());
		$(".code_confirm",$(this)).show();
		$(".code",$(this)).addClass('code_clicked');
		$($(this)).unbind('click');
		
		//$(".popout",$(this)).hide();
		//$(".popout_clicked",$(this)).show();
		
		new_win = window.open($("a",$(".code,",$(this))).attr("href"),'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
		if (new_win) {new_win.blur();}
		return false;
		
	});
	
	$(".no_reveal").click(function(){
		$(".deal",$(this)).addClass('code_clicked');
		
		//$(".popout",$(this)).hide();
		//$(".popout_clicked",$(this)).show();
		
		new_win = window.open($("a",$(".deal,",$(this))).attr("href"),'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
		//new_win.blur();
		return false;
		
	});
	
	
	
	$(".exp_reveal").mouseup(function(){
		$(".deal",$(this)).addClass('code_clicked');
		$($(this)).unbind('mouseup');
		//$(".popout",$(this)).hide();
		//$(".popout_clicked",$(this)).show();
		
		new_win = window.open($("a",$(".deal,",$(this))).attr("href"),'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
		if (new_win) {new_win.blur();}
		return false;
		
	});
	$(".exp_reveal").click(function(){
		return false;
	});
	/*
	$(".exp_reveal").click(function(){
		$(".deal",$(this)).addClass('code_clicked');
		
		//$(".popout",$(this)).hide();
		//$(".popout_clicked",$(this)).show();
		
		new_win = window.open($("a",$(".deal,",$(this))).attr("href"),'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
		new_win.blur();
		return false;
		
	});
	*/
	$(".reveal_all").click(function(){
		
		$(".show").hide();
		$(".hide").show();
		$($(this)).unbind('click');
		$(".code").addClass('code_clicked');
		$(this).addClass('code_clicked');
		
		new_win = window.open($("a",$(this)).attr("href"),'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
		if (new_win) {new_win.blur();}
		$(this).html('<a href="#discounts">Scroll Down To View Discounts</a>'); 
		window.location = window.location + "#discounts";
		return false;
	});
	
	$(".limited_reveal").click(function(){
		var $thisdiv = $(this);
		var $id = $(this).attr('id');
		//$("a.limrev", $thisdiv).html('hello');
		$.post("../../uniquecode.php", { id: $id },
			function(data){
				$("a.limrev", $thisdiv).html(''+data+'');
				//alert(data);
				//$("a",$(".code,",$(this))).html(data);
		});
		
		$(".code",$(this)).addClass('code_clicked');
		$(".code_confirm",$(this)).show();
		$(".show",$(this)).hide();
		$(".hide",$(this)).show();
		$($(this)).unbind('click');
		new_win = window.open($("a",$(".code,",$(this))).attr("href"),'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
		//new_win.blur();
		return false;
	});
	
	/*$("div.scrollable").scrollable({ 
             
        // items are auto-scrolled in 2 secnod interval 
        interval: 2000, 
         
        // when last item is encountered go back to first item 
        loop: true,  
         
        // make animation a little slower than the default 
        speed: 600, 
         
        // when seek starts make items little transparent 
        onBeforeSeek: function() { 
            this.getItems().fadeTo(300, 0.2);         
        }, 
         
        // when seek ends resume items to full transparency 
        onSeek: function() { 
            this.getItems().fadeTo(300, 1); 
        } 
    }); */
	
});

