﻿function valid_image(flag) {
    if (emptyField(document.getElementById("_ctl0_ContentPlaceHolder1_txttitle"))) {
        alert('Please enter title');
        return false;
    }
    if (flag == "Edit") {
    }
    else {
        if (emptyField(document.getElementById("_ctl0_ContentPlaceHolder1_File4"))) {
            alert('Please select image path');
            return false;
        }
        else {
            if (!chkExtension(document.getElementById("_ctl0_ContentPlaceHolder1_File4"))) {
                alert('Please select only jpg/gif file');
                document.getElementById("_ctl0_ContentPlaceHolder1_File4").select();
                document.getElementById("_ctl0_ContentPlaceHolder1_File4").focus();
                return false;
            }
        }
    }
    if (emptyField(document.getElementById("_ctl0_ContentPlaceHolder1_txtDate"))) {
        alert('Please select date');
        return false;
    }
}

function checkdate() {

    //        if ((document.getElementById("_ctl0_ContentPlaceHolder1_txtFromDate").value == "") && (document.getElementById("_ctl0_ContentPlaceHolder1_txtToDate").value != "")) {
    //            alert('Select From Date');
    //            return false;
    //        }
    //        else {
    var str1 = document.getElementById("_ctl0_ContentPlaceHolder1_txtFromDate").value;
    var str2 = document.getElementById("_ctl0_ContentPlaceHolder1_txtToDate").value;
    var dt1 = parseInt(str1.substring(0, 2), 10);
    var mon1 = parseInt(str1.substring(3, 5), 10);
    var yr1 = parseInt(str1.substring(6, 10), 10);
    var dt2 = parseInt(str2.substring(0, 2), 10);
    var mon2 = parseInt(str2.substring(3, 5), 10);
    var yr2 = parseInt(str2.substring(6, 10), 10);
    var date1 = new Date(yr1, mon1, dt1);
    var date2 = new Date(yr2, mon2, dt2);
    if (date2 < date1) {
        alert("To Date Cannot Be Less Than From Date");
        return false;
    }
    //}
}

function SendToFriend(no,id) {
    //alert(document.location.href);
    
    if (no == 0) {
        link = document.location.href;
    }
    else {
    link=id
    }

    var win = window.open("SentToFriendoftheweek.aspx?link=" + link, null, "location=0,scrolling=0,resize=0,directories=0,status=0,menubar=0,toolbar=0,width=600,height=450", true);
    //var win = window.open("SentToFriend.aspx?link=" + link, null, "location=0,scrolling=0,resize=0,directories=0,status=0,menubar=0,toolbar=0,width=600,height=450", true);
    win.focus();
    return false;
}
function resizeMe() {
    self.resizeTo(document.getElementById("Table12").clientWidth + 45, document.getElementById("Table12").clientHeight + 120);
}


function SendToFriend1(busname,fromname) {
    //alert(document.location.href);

//    if (no == 0) {
//        //var win = window.open("../SentToFriend.aspx?link=" + link, null, "location=0,scrolling=0,resize=0,directories=0,status=0,menubar=0,toolbar=0,width=600,height=450", true);
//    }
//    else {
//        link = id
//    }
//    
    link = document.location.href;
    link = link.replace("http://", "");
    var win = window.open("../importer/index.php?flag=shr" + "&fromname=" + fromname + "&busname=" + busname + "&link=" + link, null, "location=0,scrollbars=yes,resize=0,directories=0,status=0,menubar=0,toolbar=0,width=700,height=660", true);
    //var win = window.open("SentToFriend.aspx?link=" + link, null, "location=0,scrolling=0,resize=0,directories=0,status=0,menubar=0,toolbar=0,width=600,height=450", true);
    win.focus();
    return false;
}


function SendToFriend2(busname, fromname, link) {
    //alert(document.location.href);

    //    if (no == 0) {
    //        //var win = window.open("../SentToFriend.aspx?link=" + link, null, "location=0,scrolling=0,resize=0,directories=0,status=0,menubar=0,toolbar=0,width=600,height=450", true);
    //    }
    //    else {
    //        link = id
    //    }
    //    
    link = document.location.href;
    link = link.replace("http://", "");
    var win = window.open("../importer/index.php?flag=shr" + "&fromname=" + fromname + "&busname=" + busname + "&link=" + link, null, "location=0,scrollbars=yes,resize=0,directories=0,status=0,menubar=0,toolbar=0,width=700,height=660", true);
    //var win = window.open("SentToFriend.aspx?link=" + link, null, "location=0,scrolling=0,resize=0,directories=0,status=0,menubar=0,toolbar=0,width=600,height=450", true);
    win.focus();
    return false;
}
