﻿// JScript 文件
 function bcategory()
 {
     var url="http://blog.mcuol.com/addfavorite.aspx?type=0";
    var str=createXMLHttpRequest(url);
    var strobj=str.getElementsByTagName("Category");
    var category=document.getElementById ("ddlFriendLink");
    category.options.length=0;
    for(i=0;i<strobj.length;i++)
    {
        category.options.add(new Option(strobj[i].getElementsByTagName('FavoriteName')[0].firstChild.data,strobj[i].getElementsByTagName('FavoriteCategoryID')[0].firstChild.data));
    }
    category.selectedIndex=category.options.length-1;
    setCategory();
 }
function addFavorite()
{
    var ft=document.getElementById ("sort_txt");
    if(ft.value=='')
    {
        alert("收藏夹分类不能为空！");
        return;
    }
    var url="http://blog.mcuol.com/addfavorite.aspx?v="+escape(ft.value);
    var str=createTextHttpRequest(url);
    if(str=='0')
    {
        alert("您已经添加了此收藏夹！");
        return;
    }
    else
    {
        bcategory();
		$('add_sort_txt').style.display = 'none';
		$('add_sort_desc').style.display = 'none';
		$('add_sort_switch').className = "sort_open"; 
    }
    
}
function checkName()
{
    if(document.getElementById ("tbFriendLink").value=='')
    {
        alert("名称不能为空！");
        return false;
    }
    else
    {
        return true;
    }
}
function setCategory()
{
    document.getElementById ("hfCategory").value=document.getElementById ("ddlFriendLink").value;
}
function checkUser(title,url)
{
    var now = new Date(); 
    var num=now.getYear()+now.getMonth()+now.getDay()+now.getHours()+now.getMinutes()+now.getTime();
    var ul="http://blog.mcuol.com/checklogin.aspx?type=0&x="+num;
    var str=createTextHttpRequest(ul);
    if(str==null||str=='')
    {
        alert('您还没有登录，请先登录后再使用网络收藏夹');
        OpenLogin();
    }
    else
    {
        openWindow('http://blog.mcuol.com/Favorites.aspx?title='+escape(title)+'&url='+escape(url),'400','200','加入收藏', true);
    }
}
