
		
		function coupon_codes_copy()
		{

			$(function() {

            $("#myTable td:last-child").each(function() {
                var clip = new ZeroClipboard.Client();
                var lastTd = $(this);
                var parentRow = lastTd.parent("tr");

                clip.glue(lastTd[0]);

                var txt = $.trim($("td:first-child", parentRow).text()) + "\r\n" + $.trim($("td:nth-child(2)", parentRow).text()) + "\r\n" +
                $.trim($("td:nth-child(3)", parentRow).text()) + "\r\n" + $.trim($("td:nth-child(4)", parentRow).text());
				
				/*txt = text3;*/
				
                clip.setText(txt);
				
				
                clip.addEventListener('complete', function(client, text) {
				/*alert(text);*/

							if(text)
							{
		
								   	thetext1 = 'Coupon Code is Copied';
									tipobj.innerHTML=thetext1;

							}
						
				});
				
				clip.addEventListener('mouseOver', function(client, text) {

						thetext1 = 'Click to copy the coupon code';
						tipobj.innerHTML=thetext1;

						
				});
				
            });
        });
		text3 = '';
	
		}   


//functions for deals page
	  
	 function coupon_codes_open_deal(cou) 
	  {
		  var dest = "/dealgrab.php?deal="+cou+"&amp;afsrc=1";
		   window.open(dest,'newwindow');
		   window.focus();
		  
	  }
		
		function coupon_codes_copy_deal(theURL,mersiteid1)
		{  
			var lastMerClicked;
			$(function() {

            $("#myTable td:last-child").each(function() {
                var clip = new ZeroClipboard.Client();
                var lastTd = $(this);
                var parentRow = lastTd.parent("tr");

                clip.glue(lastTd[0]);

                var txt = $.trim($("td:first-child", parentRow).text()) + "\r\n" + $.trim($("td:nth-child(2)", parentRow).text()) + "\r\n" +
                $.trim($("td:nth-child(3)", parentRow).text()) + "\r\n" + $.trim($("td:nth-child(4)", parentRow).text());
				
                clip.setText(txt);
				
                clip.addEventListener('complete', function(client, text) {
				
							if(text)
							{
								
								window.location.href = window.open(theURL,'name');
								location.href = ''; 
								
							}
							
									thetext1 = 'Coupon Code is Copied';
									tipobj.innerHTML=thetext1;

						
				});
				
						clip.addEventListener('mouseOver', function(client, text) {

					   if (lastMerClicked != mersiteid1)
					   {
					   thetext1 = 'Click to copy this coupon code and open the site';
						tipobj.innerHTML=thetext1;
						
					   }
					   else
					   {
						   
						thetext1 = 'Click to copy the coupon code';
						tipobj.innerHTML=thetext1;

					   }
								   
						
				});
				
				
				
            });
        });
		text3 = '';
	
		} 

		

