﻿function click_deal(id)
{
	var newWindow = window.open('/deal/goto/id/'+id, '_blank');
	newWindow.focus();
	return false;
}

var xmlHttp;
var deal_id;
function like_deal(id)
{
	deal_id = id;
	xmlHttp=GetXmlHttpObject();
	var url = '/deal/like/type/1/id/'+id;
	xmlHttp.onreadystatechange=like_deal_success;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function notlike_deal(id)
{
	deal_id = id;
	xmlHttp=GetXmlHttpObject();
	var url = '/deal/like/type/-1/id/'+id;
	xmlHttp.onreadystatechange=notlike_deal_success;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function like_deal_success() 
{ 
	var cnt = xmlHttp.responseText;
	if (xmlHttp.readyState==4)
		alert("共有"+xmlHttp.responseText+"人顶过, 折扣帮感谢您的参与!");
	var e = document.getElementById("like_"+deal_id);
	e.title=cnt+"人顶过";
	e.width=17+parseInt(cnt);
}
function notlike_deal_success() 
{ 
	var cnt = xmlHttp.responseText;
	if (xmlHttp.readyState==4)
		alert("共有"+xmlHttp.responseText+"人踩过, 折扣帮感谢您的参与!");
	var e = document.getElementById("notlike_"+deal_id);
	e.title=cnt+"人踩过";
	e.width=17+parseInt(cnt);
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
	// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}