var copyArray=new Array();

function couponRate(val,id,mode) {
	if(val=='')
		couponRateHide(id);
	else
	{
		$('vote_box_'+id).style.display='block';
		$('vote_box_'+id).innerHTML='Loading...';	
		var d = new Date();
		var milliSeconds=d.getTime();
		url='/transport/coupon-rate?coupon_id='+id+'&rating='+val+'&mode='+mode+'&unix_time='+milliSeconds;
		new Ajax.Request(url, {
			method:'get',
			onSuccess: function(transport) {
				var response = transport.responseText || "no response text";
				$('vote_box_'+id).innerHTML=response;
			}, onFailure: function() {
				$('vote_box_'+id).innerHTML="no information available";
			}
		});
	}
}

function couponRateHide(id) {
	$('vote_box_'+id).style.display='none';
}

function codePrep(obj,id)
{
	/** The following is used to create a popup when a user highlights a coupon code */
	/* Unused for now
	var w = 700
	var h = 400;
	var popW = 700;
	var popH = 400;
	var url='/direct/'+id;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	var windowParams='toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width='+popW+',height='+popH;
	windowParams+=',top='+topPos+',left='+leftPos+',status=1';
	window.open(url,'popup',windowParams).blur();
	*/

	/** The following is used to analyze the number of times a code was highlighted */
	var temp='';
	var idFound=false;
	for(var i=0;i<copyArray.length && !idFound;i++)
	{
		if(copyArray[i]==obj.id)
			idFound=true;
	}
	if(!idFound)
	{
		clickTrackImage= new Image(1,1);
		clickTrackImage.src = '/direct/'+id+'?couponCopy=1';
		copyArray.push(obj.id);
	}
	obj.focus();
	obj.select();
}


