﻿// JScript 文件

function AddToWatch(ProductID,obj,ProductType,ev)
    {
        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="/AjaxFolds/Ajax_AddToWatch.aspx?ProductID=" + ProductID + "&ProductType=1&key=" + now.getMilliseconds();
	    }
	    else
	    {
            url="/AjaxFolds/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;
						 alert("Please Login First !");
						 if(document.getElementById("UserControl_Customer_Login_ID$input_Customer_Name"))
						 {
							 document.getElementById("UserControl_Customer_Login_ID$input_Customer_Name").focus();
						 }
				    }
				    else
				    {
				        //alert(AllHtml);
				        if(AllHtml == "OK")
				        {
				            obj.innerHTML = "You are watching this item ";
				        }
				    }
				    xmlHttp = null;
			    }
		    }
        
        }
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
        return false;
    }

