﻿// JScript 文件

function AddToWatch(ProductID,obj,ProductType)
    {
        //alert("aaa");
        var xmlHttp;
	    if (window.ActiveXObject) { 
	    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    } 
		else if (window.XMLHttpRequest) {
			    xmlHttp = new XMLHttpRequest();
		    }
		    else
		    {
		        alert("no");
		    }
	    
	    var now= new Date();
	    if(ProductType == "1")
	    {
	        url="/AjaxPage/Ajax_AddToWatch.aspx?ProductID=" + ProductID + "&ProductType=1&key=" + now.getMilliseconds();
	    }
	    else if(ProductType == "3")
	    {
            url="/AjaxPage/Ajax_AddToWatch.aspx?ProductID=" + ProductID + "&ProductType=3"+ "&key=" + now.getMilliseconds();
        }else{
            url="/AjaxPage/Ajax_AddToWatch.aspx?ProductID=" + ProductID +  "&key=" + now.getMilliseconds();
        }
        xmlHttp.onreadystatechange = function(){
        
        if(xmlHttp.readyState == 4) {
			    if(xmlHttp.status == 200) {
				    var AllHtml =xmlHttp.responseText;
				    if(AllHtml == "url")
				    {
				        window.location.href = "/CustomerManager/Login.aspx?url=" +  window.location.href;
				    }
				    else
				    {
				        //alert(AllHtml);
				        if(AllHtml == "OK")
				        {				            
				            obj.innerHTML = "<font  class=\"Text2\">You are watching this item!</font>";

				        }
				    }
				    xmlHttp = null;
			    }
		    }
        
        }
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
        return false;
    }
