function checkUrlValid()
{
    var str = document.getElementById("httpurl").value;
    if ($('name') != null) {
        if (document.getElementById("name").value == "")
        {
            alert("个人网站名称不能为空！");
            return false;
        }
    }
    var urlpatern0 = /^https?:\/\/.+$/i;
    if (!urlpatern0.test(str))
    {
        alert(str + "url地址必须以'http:\/\/'或'https:\/\/'开头!");
        return false;
    }
    return true;
}
function linkValate() {
    if ($('link').value == "") {
        alert("链接地址不能为空！请重新填写！")
        return false;
    } else
        return true;
}

function checkHead()
{
    var s = uploadForm.file.value;
    if (uploadForm.file.value == "")
    {
        alert(" 请输入图片地址! ");
        uploadForm.file.focus();
        return false;
    }
    s = s.substring(s.lastIndexOf(".") + 1).toLowerCase();
    if (s != "gif" && s != "jpg" && s != "jpeg" && s != "bmp")
    {
        alert(" 请选择正确的图片格式! ")
        return false;
    }
    var img = new Image();
    var FileMaxSize = 100 ; // 限制上传的文件大小，单位(k)

    img.src = s;
    if (img.fileSize > FileMaxSize * 1024) {
        alert(" 请上传小于100K的图片 ");
        uploadForm.file.focus();
        return false;
    }
}

function checkResume()
{
    var s = uploadResumeForm.resumeFile.value;
    if (uploadResumeForm.resumeFile.value == "")
    {
        alert(" 请选择准备上传的简历! ");
        uploadResumeForm.resumeFile.focus();
        return false;
    }
    s = s.substring(s.lastIndexOf(".") + 1).toLowerCase();
    if (s != "doc" && s != "pdf" && s != "txt")
    {
        alert(" 请上传正确的简历格式! ")
        return false;
    }
}

var flag = false;
function DrawImage(ImgD, maxwidth, maxheight) {
    var image = new Image();
    image.src = ImgD.src;
    if (image.width > 0 && image.height > 0) {
        flag = true;
        if (image.width / image.height >= maxwidth / maxheight) {
            if (image.width > maxwidth) {
                ImgD.width = maxwidth;
                ImgD.height = (image.height * maxwidth) / image.width;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
        else {
            if (image.height > maxheight) {
                ImgD.height = maxheight;
                ImgD.width = (image.width * maxheight) / image.height;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
    }
}
function sure() {
    var r = confirm("确认删除！")
    if (r == false)
    {
        return false;
    }
}

function textCheck() {
    var textValues = document.getElementsByName("tagName");
    var string = "";
    for (var i = 0; i < textValues.length; i++) {
        if (textValues[i].value != null && textValues[i].value != undefined)
            string += textValues[i].value + ",";
    }
    textValues[0].value = string;
}

function websiteButtonView() {
    document.getElementById('websiteButtonView').style.display = "none"
}


function inviteSendToFriendEmail() {
    var emailArray = document.getElementsByName("email");
    var friendNameArray = document.getElementsByName("friendName");
    if (friendNameArray[0].value == "" && emailArray[0].value == "") {
        alert("姓名不能为空!")
        friendNameArray[0].onfocus = setStyle(friendNameArray[0].id);
        alert("e-mail不能为空!")
        emailArray[0].onfocus = setStyle(emailArray[0].id);
        return false;
    }
    for (var i = 0; i < 3; i++) {
        if (friendNameArray[i].value == "" && emailArray[i].value == "") {
            return;
        } else {
            if (friendNameArray[i].value != null && friendNameArray[i].value != "" && friendNameArray[i].value != undefined) {
                friendNameArray[i].style.background = "";
                if (emailArray[i].value == null || emailArray[i].value == "" || emailArray[i].value == undefined) {
                    alert("e-mail不能为空!")
                    emailArray[i].onfocus = setStyle(emailArray[i].id);
                    return false;
                }
            }
            if (emailArray[i].value != null && emailArray[i].value != undefined && emailArray[i].value != "") {
                emailArray[i].style.background = "";
                if (friendNameArray[i].value == null || friendNameArray[i].value == "" || friendNameArray[i].value == undefined) {
                    alert("姓名不能为空!")
                    friendNameArray[i].onfocus = setStyle(friendNameArray[i].id);
                    return false;
                }
                if (!isValidEmail(emailArray[i].value)) {
                    alert("您输入的e-mail地址格式有误!");
                    return false;
                }
            }
        }
    }
}
function setStyle(id)
{
    document.getElementById(id).style.background = "yellow"
}

function resumeDirectionSubmit(){
    if($(directionName).value == null){
        alert("请填写悬赏名称！");
    }else if($(instructionStatement).value == null){
        alert("请填写悬赏描述！");
    }else if($(rewardMoney).value == null){
        alert("请填写悬赏金额！")
    }else{
        this.form.submit();
    }
}

function carrerPlanSubmit(){
    if($(directionName).value == null){
        alert("请填写悬赏名称！");
    }else if($(instructionStatement).value == null){
        alert("请填写悬赏描述！");
    }else if($(rewardMoney).value == null){
        alert("请填写悬赏金额！")
    }else{
        return;
    }
}
