function showpresence(presence) {  

	  var msnid = presence.id;
	  var msnstatus = presence.status;
	  var msnstatusText = presence.statusText;
	  var iconurl = presence.icon.url;
	    	  
	  if (msnstatus == "Offline") {
	  		$('div[id="msnonline_' + msnid + '"]').hide();
	  		$('div[id="msnoffline_' + msnid + '"]').show();
        $('div[id="msnoffline_' + msnid + '"] font[id="msntext"]').html(msnstatusText);
        $('div[id="msnoffline_' + msnid + '"] img[id="msnicon"]').attr("src",iconurl);
   } else {
   	  $('div[id="msnonline_' + msnid + '"]').show();
        $('div[id="msnoffline_' + msnid + '"]').hide();
        if (msnstatus == "Online") {
        } else {
	        $('div[id="msnonline_' + msnid + '"] font[id="msntext"]').html(msnstatusText);
	      }
        $('div[id="msnonline_' + msnid + '"] img[id="msnicon"]').attr("src",iconurl);
   }
}


function enableLiveChat(siteID){
     return enableLiveChat(siteID,null);
}
         
function enableLiveChat(siteID,anameID){
   	var locationHref = window.location.href;
   	var indexOfWell = locationHref.indexOf("#");
   	var langID = document.enableLiveChatFrm.langID.value;
   	
   		
   	if (indexOfWell > -1) {
   		locationHref = locationHref.substr(0,indexOfWell);
   	}
    document.enableLiveChatFrm.src1.value=locationHref;
      
    if (anameID!=null && anameID!='') {
     	document.enableLiveChatFrm.src1.value+=("#IM" + anameID);
    }
    
    document.enableLiveChatFrm.src2.value= "/diyep/dir/main/talk_window?langID=" + langID + "&amp;siteID=" + siteID;
    document.enableLiveChatFrm.submit();
    return false;
}
			
	
function showListAdminBlock() {
				
				
				var timeOutAdminID=0;
				
				var listAdmin = $("#listAdmin");
				var listAdminBlock = $("#listAdminBlock");
				var listAdminFrame = $("#listAdminFrame");
				var listAdminArrowLeft = $("#listAdminArrowLeft");
				
				var iframeBaseURL=listAdminFrame.attr('title');
				
				//show
				$(".ui-icon-tool").mouseover(function() {  
					
						var contentType = $(this).attr("contentType");
						var contentID = $(this).attr("contentID");
						var siteID = $(this).attr("siteID");
						var iframeURL = iframeBaseURL;
						
						if (contentType=="product") {
							iframeURL +="&siteID="+siteID+"&productID="+contentID;
						} else if (contentType=="message") {
							iframeURL +="&siteID="+siteID+"&messageID="+contentID;
						} else if (contentType=="company") {
							iframeURL +="&siteID="+siteID;
						}
						
						clearTimeout(timeOutAdminID);
						timeOutAdminID=0;
							
						listAdmin.show();
						
						listAdminFrame.attr('src',iframeURL);
						//alert($(this).offset().left + " " + $(this).offset().top + " " + $(this).width());
						
						listAdmin.css('left', $(this).offset().left);
						listAdmin.css('top',$(this).offset().top + ($(this).height()/2));
				});
				
				
				$("#listAdminBlock, #listAdminArrowLeft").mouseover(function() {
					clearTimeout(timeOutAdminID);
				});
				
				
				$("#listAdminBlock, #listAdminArrowLeft, .ui-icon-tool").mouseout(function() {
					clearTimeout(timeOutAdminID);
			 		timeOutAdminID=setTimeout(function() {
			 			listAdmin.hide();
						listAdminFrame.attr('src',"");
			 		}, 250);
				});
				
}


function loadPageTo(url) {
		window.location=url;
}		
	
function addAlertKeyword(){
		document.addAlertKeywordFrm.keyword.value=document.searchForm.qs.value;
		document.addAlertKeywordFrm.submit();
}

$(document).ready(function() {
	$("#bookmark-container a").each(function() {
		
		var title = $(document).attr("title");
		
		var rawURL = window.location.href;
		rawURL = rawURL.replace("#", "");
	
		/*
		if (rawURL.indexOf("SRCCODE=") > 0) {
			rawURL = rawURL.replace("SRCCODE=", "SRCCODE=WEBDIGG&OLDSRC=");
		} else if (rawURL.indexOf("?") > 0) {
			rawURL = rawURL + "&SRCCODE=WEBDIGG";
		} else {
			rawURL = rawURL + "?SRCCODE=WEBDIGG";
		}
		*/
		
		var currentURL = encodeURIComponent(rawURL);
		var title = encodeURIComponent(title);
		
		var newURL;
		
		switch ($(this).attr("site")) {
			case "reddit":
				newURL = "http://reddit.com/submit?"
				+ "url=" + currentURL
				+ "&title=" + title;
			break;
			case "facebook":
				newURL = "http://www.facebook.com/sharer.php?src=sp" 
				+ "&u=" + currentURL
				+ "&t=" + title;
			break;
			case "twitter":
				newURL = "http://twitter.com/home?" 
				+ "&status=" + currentURL
				+ "+-+" + title;
			break;
			case "google":
				newURL = "http://www.google.com/bookmarks/mark?op=edit&output=popup"
				+ "&bkmk=" + currentURL
				+ "&title=" + title;
			break;
			case "delicious":
				newURL = "http://www.delicious.com/post?"
				+ "url=" + currentURL
				+ "&title=" + title;
			break;
			
			case "qq":
				newURL = "http://shuqian.qq.com/post?from=3&jumpback=2&noui=1"
				+ "&title=" + title
				+ "&uri=" + currentURL;
			break;	
			/*case "baidu":
				newURL = "http://cang.baidu.com/do/add?"
				+ "it=" + title
				+ "&iu=" + currentURL;
			break;*/
			case "live":
				newURL = "http://skydrive.live.com/sharefavorite.aspx/.sharedfavorites/?"
				+ "&title=" + title
				+ "&url=" + currentURL;
			break;
			case "yahoo":
				newURL = "http://myweb.cn.yahoo.com/popadd.html?"
				+ "url=" + currentURL
				+ "&title=" + title;
			break;
		}
		$(this).attr("href",newURL);
	});
	
});

function chromeBookmark(){var a=window,b=document,c=encodeURIComponent,d=a.open("http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk="+c(b.location)+"&title="+c(b.title),"bkmk_popup","left="+((a.screenX||a.screenLeft)+10)+",top="+((a.screenY||a.screenTop)+10)+",height=420px,width=550px,resizable=1,alwaysRaised=1");a.setTimeout(function(){d.focus()},300)};

function bookmarksite() {
	
	var title = $(document).attr("title");
	var url = window.location.href;
	if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute("href",url);
		elem.setAttribute("title",title);
		elem.setAttribute("rel","sidebar");
		elem.click();
	}else if(window.chrome){
		alert('Press ctrl+D to bookmark (Command+D for macs) after you click Ok');
	} else if (window.sidebar) { // firefox
		window.sidebar.addPanel(title, url, "");
	} else if(document.all) {// ie
		window.external.AddFavorite(url, title);
	}
}


