	  
	  function coupon_codes_open(theURL)
	  {
			window.open(theURL,'mywindow');  
			window.focus();
			//self.opener.location.href="/"+mname+"-coupons";
	  }
	  


	
		
	function coupon_codes_copy_index(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,'mywindow');
								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 = '';
	
		} 
		
		
		function coupon_codes_copy(theURL,mersiteid)
		{
			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());
				
				/*txt = text3;*/
				
                clip.setText(txt);
				
				
                clip.addEventListener('complete', function(client, text) {
				/*alert(text);*/

							if(text)
							{
								   if (lastMerClicked != mersiteid)
								   {
									var newwindow = window.open(theURL,"mywindow");
									lastMerClicked = mersiteid;
	
									
								   }
								   
								   
								   	thetext1 = 'Coupon Code is Copied';
									tipobj.innerHTML=thetext1;

							}
						
				});
				
				clip.addEventListener('mouseOver', function(client, text) {

					   if (lastMerClicked != mersiteid)
					   {
					   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 = '';
	
		}   
		



		

		
