﻿function ChangeTimeList(objID)
{
	myObj="divTimeList"+objID;
	var arrDiv=getE("tdTimeList").getElementsByTagName("div");
	var arrInput=getE("tdTimeList").getElementsByTagName("input");
	for(var i=0; i<arrInput.length;i++){
   		arrInput[i].checked = false;
	}
	for(var i=0; i<arrDiv.length;i++){
		if (myObj==arrDiv[i].id){
			arrDiv[i].style.display="block";
		}else{
			arrDiv[i].style.display="none";
		}
	}
}

function DelOrderItem(ID) {
    if (confirm("确定删除吗？")) {
        $.get("/ajax/order.aspx", { action: "DelOrderDetail", ItemID: ID }, function(data) {
            if (data != "") {
                //objTag.innerHTML = data;
                location.reload();
            }
        });
    }
}

function CheckCustomer(oID, sValue) {
    oTag = getE(oID);
    if (sValue == "") { return; }
    $.get("/ajax/master.aspx", { action: "CheckCustomer", Keyword: sValue }, function(data) {
        if (data == "") {
            alert("该Code不存在，请填写正确的Company Code！");
            oTag.focus();
        }
    });
}

function checkCartNum(obj) {
    var sValue = obj.value;
    if (sValue == "") {isValue == 1;}
    if (!IsNum(sValue)) {
        alert("只能输入整数！");
        obj.value = 1;
    }
}

function GetUserAddress(addID){
    var idParent = "";
	$.getJSON("/ajax/shopping.aspx", { action: "GetUserAddress", ID: addID }, function(json){
		//alert("JSON Data: " + json.users[3].name);
		$("#"+idParent+"txtName").attr("value", json.Name);
		$("#"+idParent+"txtTel").attr("value",json.Tel);
		$("#"+idParent+"txtMobile").attr("value",json.Mobile);
		$("#"+idParent+"txtPostcode").attr("value",json.Postcode);
		$("#"+idParent+"txtAddress").attr("value",json.Address);
	});
}

function delTbRowConfirm(tbID,rowIndex) {
	if (confirm("Are you sure delete this row!")) {
		var objTable = document.getElementById(tbID);
		objTable.deleteRow(parseInt(rowIndex));
	}
}
function delTbRow(tbID,rowIndex,minRow) {
	var objTable = document.getElementById(tbID);
    var rowNum = objTable.rows.length;
    if (rowNum <= parseInt(minRow)) { return false; }
	objTable.deleteRow(parseInt(rowIndex));
}

// JavaScript Document
function playSwf(sFile,sWidth,sHeight){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ sWidth +'" height="'+ sHeight +'"> ');
	document.write(' <param name="movie" value="'+ sFile +'"> ');
	document.write(' <param name="quality" value="high"> ');
	document.write(' <param name="wmode" value="transparent"> ');
	document.write(' <embed src="'+ sFile +'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ sWidth +'" height="'+ sHeight +'"></embed> ');
	document.write('</object> ');
}

function changePic(objID, sFileName, sTitle){
	var obj = document.getElementById(objID);
	obj.src = "upload/product/"+ sFileName +"";
	obj.alt = sTitle;
}

function ChangeValue(objID1,objID2)
{
	if (getE(objID1).checked){
		getE(objID2).value="Y";
	}else{
		getE(objID2).value="N";
	}
}

function OpenVideoWin(sURL) {
    //	width=600,height=400,top=0,left=20,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no
	var VideoWin=window.open(sURL,"VideoWin","width=750,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
	VideoWin.focus();
}

function OpenPicWin(sURL) {
    //	width=600,height=400,top=0,left=20,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no
	var PicWin=window.open(sURL,"PicWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
	PicWin.focus();
}

function OpenAudioWin(sURL) {
    //	width=600,height=400,top=0,left=20,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no
	var AudioWin=window.open(sURL,"AudioWin","width=750,height=600,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes");
	AudioWin.focus();
}

