$import("net.sf.iafw.js.html.IElement");

function showCouponDetail(id, url)
{
	document.getElementById('codehide'+id).style.display='none';
	document.getElementById('codeshow'+id).style.display='block';
	//tb_show('', '#TB_inline?height=220&amp;width=680&amp;inlineId=codeshow' + id, false);
	var new_win = window.open(url,'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
	new_win.blur();
}
function closeCouponDetail(id)
{
	document.getElementById('codeshow'+id).style.display='none';
	document.getElementById('codehide'+id).style.display='block';
}
function showCoupon(id)
{
	document.getElementById('codehide'+id).style.display='none';
	document.getElementById('codeshow'+id).style.display='block';
}

function showAllCoupons(url){
	$import("net.sf.iafw.js.html.IElement");
	var flag=IElement.getElement("flag").value;
	for(var i=2;i<=flag;i++)
	{
		IElement.getElement("codehide"+i).style.display="none";
		IElement.getElement("codeshow"+i).style.display="block";
	}
	var new_win = window.open(url,'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
	new_win.blur();
}

function SpamAdd(id,flag)
{
	$import("net.sf.iafw.js.http.IRequest");
	$import("net.sf.iafw.js.html.IElement");
	var httpRequest = new IRequest("/ajax/fetchClickAdd.asp?id=" + id +"&spam=1"+"&flag="+flag, true, IRequest.GET, hideCoupons);
	httpRequest.response();
}
function SpamAddShort(id,flag)
{
	$import("net.sf.iafw.js.http.IRequest");
	$import("net.sf.iafw.js.html.IElement");
	var httpRequest = new IRequest("/ajax/fetchClickAdd.asp?id=" + id +"&spam=1"+"&flag="+flag, true, IRequest.GET, hideCouponsShort);
	httpRequest.response();
}
function BerryAdd(id,flag)
{
	$import("net.sf.iafw.js.http.IRequest");
	var httpRequest = new IRequest("/ajax/fetchClickAdd.asp?id=" + id+"&spam=2"+"&flag="+flag, true, IRequest.GET, hideCouponsno);
	httpRequest.response();
}
function hideCoupons(http)
{
	
	$import("net.sf.iafw.js.html.IElement");
	var objstr = http.responseText;
	var index = objstr.lastIndexOf(",");
	if(index > 0) {
		objstr = objstr.substr(0, objstr.lastIndexOf(",")) + "]";
	}
	var obj = eval(objstr);
	if(obj.length > 0) {
		IElement.getElement("codehide"+obj[0].flag).style.display="block";
		IElement.getElement("codeshow"+obj[0].flag).style.display="none";
		var voteNum = IElement.getElement("voteNum"+obj[0].flag);
		voteNum.innerHTML="";
		IElement.appendText("voteNum"+obj[0].flag,"<ul><li><a href=\"#\" title=\""+obj[0].spamnum+" people have voted that this voucher codes/promotion worked\"><span>"+obj[0].spamnum+"</span></a></li></ul>");
	}
	alert("Thank you!Hope you enjoy our service!");
}
function hideCouponsno(http)
{
	
	$import("net.sf.iafw.js.html.IElement");
	var objstr = http.responseText;
	var index = objstr.lastIndexOf(",");
	if(index > 0) {
		objstr = objstr.substr(0, objstr.lastIndexOf(",")) + "]";
	}
	var obj = eval(objstr);
	if(obj.length > 0) {
		IElement.getElement("codehide"+obj[0].flag).style.display="block";
		IElement.getElement("codeshow"+obj[0].flag).style.display="none";
		var voteNum = IElement.getElement("voteNum"+obj[0].flag);
		voteNum.innerHTML="";
		IElement.appendText("voteNum"+obj[0].flag,"<ul><li><a href=\"#\" title=\""+obj[0].spamnum+" people have voted that this voucher codes/promotion worked\"><span>"+obj[0].spamnum+"</span></a></li></ul>");
	}
	alert("Thank you for your feedback. We will solve this problem as soon as possible!");
}
function hideCouponsShort(http)
{
	$import("net.sf.iafw.js.html.IElement");
	var objstr = http.responseText;
	var index = objstr.lastIndexOf(",");
	if(index > 0) {
		objstr = objstr.substr(0, objstr.lastIndexOf(",")) + "]";
	}
	var obj = eval(objstr);
	if(obj.length > 0) {
		//IElement.getElement("codehide"+obj[0].flag).style.display="block";
		// IElement.getElement("codeshow"+obj[0].flag).style.display="none";
		var voteNum = IElement.getElement("voteNum"+obj[0].flag);
		voteNum.innerHTML="";
		IElement.appendText("voteNum"+obj[0].flag,"<ul><li><a href=\"#\" title=\""+obj[0].spamnum+" people have voted that this voucher codes/promotion worked\"><span>"+obj[0].spamnum+"</span></a></li></ul>");
	}
	alert("Thank you!Hope you enjoy our service!");
}



//p.asp spam add / berry add
function SpamAdd1(id,flag)
{
	$import("net.sf.iafw.js.http.IRequest");
	$import("net.sf.iafw.js.html.IElement");
	var httpRequest = new IRequest("/ajax/fetchClickAdd.asp?id=" + id +"&spam=1"+"&flag="+flag, true, IRequest.GET, hideCoupons1);
	httpRequest.response();
}
function BerryAdd1(id,flag)
{
	$import("net.sf.iafw.js.http.IRequest");
	var httpRequest = new IRequest("/ajax/fetchClickAdd.asp?id=" + id+"&spam=2"+"&flag="+flag, true, IRequest.GET, hideCoupons1);
	httpRequest.response();
}
function hideCoupons1(http)
{
	$import("net.sf.iafw.js.html.IElement");
	var objstr = http.responseText;
	var index = objstr.lastIndexOf(",");
	if(index > 0) {
		objstr = objstr.substr(0, objstr.lastIndexOf(",")) + "]";
	}
	var obj = eval(objstr);
	//alert(objstr);
/*	if(obj.length > 0) {
		IElement.getElement("codehide"+obj[0].flag).style.display="block";
		IElement.getElement("codeshow"+obj[0].flag).style.display="none";
		var voteNum = IElement.getElement("voteNum"+obj[0].flag);
		voteNum.innerHTML="";
		//IElement.appendText("voteNum"+obj[0].flag,"<ul><li><a href=\"#\" title=\""+obj[0].spamnum+" people have voted that this voucher codes/promotion worked\"><span>"+obj[0].spamnum+"</span></a></li></ul>");
	}*/
	alert("Thank you!Hope you enjoy our service!");
}
