var ie4=document.all
var dom=document.getElementById

var currentItemID = 0;
var IFrameObj;
function bookmarkItem() {
	if(document.frmLogin.loggedIn == undefined) {
		alert("对不起，请先登入后方可将此项目加入您的收藏夹\n\n若您还没成为我们的会员，请今天就加入我们的社群，免费的哦！");
		return false;
	}
  if (!document.createElement) {return true};
  var IFrameDoc;
  var URL = 'http://offerstation.sinchew-i.com/bookmark.php?bm='+currentItemID;
    if (!IFrameObj && document.createElement) {
     try {
        var tempIFrame=document.createElement('iframe');
        tempIFrame.setAttribute('id','RSIFrame');
        tempIFrame.style.border='0px';
        tempIFrame.style.width='0px';
        tempIFrame.style.height='0px';
        tempIFrame.style.borderStyle='none';
        tempIFrame.style.position='absolute';
        tempIFrame.style.left='0px';
        tempIFrame.style.top='0px';
        IFrameObj = document.body.appendChild(tempIFrame);
        
        if (document.frames) {
          IFrameObj = document.frames['RSIFrame'];
        }
      } catch(exception) {
        iframeHTML='\<iframe id="RSIFrame" style="';
        iframeHTML+='border:0px;';
        iframeHTML+='width:0px;';
        iframeHTML+='height:0px;';
        iframeHTML+='position:absolute;';
        iframeHTML+='border-style:none;';
        iframeHTML+='left:0px;';
        iframeHTML+='top:0px;';
        iframeHTML+='"><\/iframe>';
        document.body.innerHTML+=iframeHTML;
        IFrameObj = new Object();
        IFrameObj.document = new Object();
        IFrameObj.document.location = new Object();
        IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
        IFrameObj.document.location.replace = function(location) {
          this.iframe.src = location;
        }
      }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    setTimeout('bookmarkItem()',10);
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  
  //alert(URL);
  IFrameDoc.location.replace(URL);
  alert("您选择的项目已经储存到您的收藏夹。\n要查看或删除收藏项目，\n点击以上『我的收藏夹』标签即可", "OfferStation.com");
  return false;
}

function viewDetails() {
  var URL = 'http://offerstation.sinchew-i.com'+currentItemID;
  parent.document.location = URL;
}

function removeBookmark() {
  if (!document.createElement) {return true};
	if(!confirm("您是否确定要删除收藏项目？删除后无法还原"))
	{
		return false;
	}
  var IFrameDoc;
  var URL = 'http://offerstation.sinchew-i.com/removebookmark.php?bm='+currentItemID;
    if (!IFrameObj && document.createElement) {
     try {
        var tempIFrame=document.createElement('iframe');
        tempIFrame.setAttribute('id','RSIFrame');
        tempIFrame.style.border='0px';
        tempIFrame.style.width='0px';
        tempIFrame.style.height='0px';
        tempIFrame.style.borderStyle='none';
        tempIFrame.style.position='absolute';
        tempIFrame.style.left='0px';
        tempIFrame.style.top='0px';
        IFrameObj = document.body.appendChild(tempIFrame);
        
        if (document.frames) {
          IFrameObj = document.frames['RSIFrame'];
        }
      } catch(exception) {
        iframeHTML='\<iframe id="RSIFrame" style="';
        iframeHTML+='border:0px;';
        iframeHTML+='width:0px;';
        iframeHTML+='height:0px;';
        iframeHTML+='position:absolute;';
        iframeHTML+='border-style:none;';
        iframeHTML+='left:0px;';
        iframeHTML+='top:0px;';
        iframeHTML+='"><\/iframe>';
        document.body.innerHTML+=iframeHTML;
        IFrameObj = new Object();
        IFrameObj.document = new Object();
        IFrameObj.document.location = new Object();
        IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
        IFrameObj.document.location.replace = function(location) {
          this.iframe.src = location;
        }
      }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    setTimeout('bookmarkItem()',10);
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  
  IFrameDoc.location.replace(URL);
  alert("您的收藏项目已被删除。点击\"OK\"更新收藏夹", "asd");
  return false;
}
