﻿function delGift(id, name)
{
  if (confirm("你确定删除礼品"+name+"吗？"))
  {
    gel("hfDeleteGiftID").value = id;
    var myForm = document.forms['form1'];
    if (!myForm)
    {
      myForm = document.form1;
    }
    myForm.submit();
  }
}
function gel(id)
{
  return document.getElementById(id);
}

function buy(id)
{
}

function changeCheckState(checked)
{
	//var frm=form.document.forms[0]
	var frm = document.forms["form1"];
	for (i=0; i<frm.length; i++) 
	{
		if (frm.elements[i].id.indexOf('chkItemChecked') != -1)
		{
			frm.elements[i].checked = checked;
		}
	}
}

//用于发送礼物的js。receiveUserID是接受礼物的用户ID。sendGoodsID是我的礼物盒的ID
function sendGiftWindow(isbackDiv,receiveUserID,sendGoodsID)
{
  if(gel('floatDiv')==null)
  {
    var floatDiv = document.createElement('div');
    floatDiv.id = "floatDiv";
    floatDiv.style.position = "absolute";
    floatDiv.style.width = 800 + "px";
    floatDiv.style.height = 400 + "px";
    floatDiv.style.left =(document.documentElement.clientWidth/2 + document.documentElement.scrollLeft - 400)+"px";
    floatDiv.style.top =(document.documentElement.clientHeight/2 + document.documentElement.scrollTop-150 )+"px";
    floatDiv.style.zIndex = 1001;
    var sendGiftText=null;
    var scrollTop=document.documentElement.scrollTop;
   
    if((receiveUserID!=null)&&(sendGoodsID!=null))
    {
       sendGiftText = "<iframe id=\"iframe1\" frameborder=\"0\" scrolling=\"no\" src=\"../Gift/GiftSend.aspx?userID="+receiveUserID+"&goodsID="+sendGoodsID+"&scrollTop="+scrollTop+"\" width=\"100%\" height=\"400\"></iframe>";
     }
    else if(receiveUserID!=null)
    {
          sendGiftText = "<iframe id=\"iframe1\" frameborder=\"0\" scrolling=\"no\" src=\"../Gift/GiftSend.aspx?userID="+receiveUserID+"&scrollTop="+scrollTop+"\" width=\"100%\" height=\"400\"></iframe>";
    }
    else if(sendGoodsID!=null)
    {
          sendGiftText = "<iframe id=\"iframe1\" frameborder=\"0\" scrolling=\"no\" src=\"../Gift/GiftSend.aspx?goodsID="+sendGoodsID+"&scrollTop="+scrollTop+"\" width=\"100%\" height=\"400\"></iframe>";
    }
    else
       sendGiftText = "<iframe id=\"iframe1\" frameborder=\"0\" scrolling=\"no\" src=\"../Gift/GiftSend.aspx?+scrollTop="+scrollTop+"\" width=\"100%\" height=\"400\"></iframe>";  
    floatDiv.innerHTML = sendGiftText;
    document.body.appendChild(floatDiv);
  }
  else
  {
    gel('floatDiv').style.display = "block";
  }
  if(gel('backDiv')==null && isbackDiv ==true)
  {
    var backDiv = document.createElement('div');
    backDiv.id = "backDiv";
    backDiv.style.backgroundColor = "Black";
    backDiv.style.filter = "alpha(opacity=70)";
    backDiv.style.MozOpacity = "0.70";
    backDiv.style.position = "absolute";
    backDiv.style.left = "0px";
    backDiv.style.top = "0px";
    backDiv.style.width = Math.max(document.body.scrollWidth, document.documentElement.clientWidth) +"px";
    backDiv.style.height = Math.max(document.body.scrollHeight, document.documentElement.clientHeight)+"px";
    document.body.appendChild(backDiv);
    gel('backDiv').style.zIndex = 1000;
  }
  else if(isbackDiv ==true)
  {
    gel('backDiv').style.display = "block";
  }
}
function moveDiv(event, elem)
{
  gel('floatDiv').style.filter = "alpha(opacity=50)";
  var oObj = gel(elem);
  oObj.onmousemove = mousemove;
  oObj.onmouseup = mouseup;
  oObj.setCapture ? oObj.setCapture() : function()
 {

 };
oEvent = window.event ? window.event : event;
var dragData =
{
  x : oEvent.clientX, y : oEvent.clientY
};
var backData =
{
  x : parseInt(oObj.style.top), y : parseInt(oObj.style.left)
};
function mousemove()
{
  var oEvent = window.event ? window.event : event;
  var iLeft = oEvent.clientX - dragData["x"] + parseInt(oObj.style.left);
  var iTop = oEvent.clientY - dragData["y"] + parseInt(oObj.style.top);
  oObj.style.left = iLeft;
  oObj.style.top = iTop;
  dragData =
  {
    x: oEvent.clientX, y: oEvent.clientY
  };
}
function mouseup()
{
  var oEvent = window.event ? window.event : event;
  oObj.onmousemove = null;
  oObj.onmouseup = null;
  gel('floatDiv').style.filter = "";
  if(oEvent.clientX < 1 || oEvent.clientY < 1)
  {
    oObj.style.left = backData.y;
    oObj.style.top = backData.x;
  }
oObj.releaseCapture ? oObj.releaseCapture() : function()
{
};
}
}
function CloseFloatDiv()
{   
  if(gel('floatDiv'))
  {
    gel('floatDiv').style.display = "none";
  } 
  if(gel('backDiv'))
  {
    gel('backDiv').style.display = "none";
  }
   window.location.reload();

}
function CloseFloatDivWithoutFresh()
{
  if(gel('floatDiv'))
  {
    gel('floatDiv').style.display = "none";
  } 
  if(gel('backDiv'))
  {
    gel('backDiv').style.display = "none";
  }
}
 function closeWinAndOpenWin()
    {
        if(gel('floatDiv'))
        {
           gel('floatDiv').style.display = "none";
        } 
        if(gel('backDiv'))
        {
            gel('backDiv').style.display = "none";
        }
        window.open("GiftShop.aspx");
    }

function gift_findObj(n, d)
{
  var p,i,x;
  if(!d) d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length)
  {
    d=parent.frames[n.substring(p+1)].document;
    n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n];
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=gift_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n);
  return x;
}
function gift_showHideLayers()
{
  var i,p,v,obj,args=gift_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=gift_findObj(args[i]))!=null)
  {
    v=args[i+2];
    if (obj.style)
    {
      obj=obj.style;
      v=(v=='show')?'visible':(v=='hide')?'hidden':v;
    }
    obj.visibility=v;
  }
}

