	function SelectAllCheckboxes(spanChk){
	
	// Added as ASPX uses SPAN for checkbox 
	var xState=spanChk.checked;
	var theBox=spanChk;


		elm=theBox.form.elements;
		for(i=0;i<elm.length;i++)
		if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
			{
			//elm[i].click();
			if(elm[i].checked!=xState)
			elm[i].click();
			//elm[i].checked=xState;
			}
}

function head_check_disable(spanChk) {

    spanChk.checked = false;
}

function HighlightRow(chkB) {


    var xState = chkB.checked;

    if (xState) {
        chkB.parentElement.parentElement.style.backgroundColor = '#F2F2F2';  // grdEmployees.SelectedItemStyle.BackColor
        chkB.parentElement.parentElement.style.color = 'black'; // grdEmployees.SelectedItemStyle.ForeColor
    } else {
        chkB.parentElement.parentElement.style.backgroundColor = 'white'; //grdEmployees.ItemStyle.BackColor
        chkB.parentElement.parentElement.style.color = 'black'; //grdEmployees.ItemStyle.ForeColor
    }
}

function ParentHighlightRow(chkB) {


    var xState = chkB.checked;

    if (xState) {
        chkB.parentElement.parentElement.parentElement.style.backgroundColor = '#F2F2F2';  // grdEmployees.SelectedItemStyle.BackColor
        chkB.parentElement.parentElement.parentElement.style.color = 'black'; // grdEmployees.SelectedItemStyle.ForeColor
    } else {
        chkB.parentElement.parentElement.parentElement.style.backgroundColor = 'white'; //grdEmployees.ItemStyle.BackColor
        chkB.parentElement.parentElement.parentElement.style.color = 'black'; //grdEmployees.ItemStyle.ForeColor
    }
}

function ParentHighlightRow_vCard(chkB) {

    var theBox = chkB;
    var elm = theBox.form.elements;
    for (i = 0; i < elm.length; i++) {

        if (elm[i].type == "checkbox" && elm[i].name != theBox.name) {

            elm[i].checked = false;
            elm[i].parentElement.parentElement.parentElement.style.backgroundColor = 'white'; //grdEmployees.ItemStyle.BackColor
            elm[i].parentElement.parentElement.parentElement.style.color = 'black'; //grdEmployees.ItemStyle.ForeColor
        }
    }

    ParentHighlightRow(chkB);
}


// FONT SIZE Change
var ContentCurrentFontSize = 16;
var ContentCurrentLineHeight = 16;

function setCookie( name, value, expiredays ) {
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	todayDate.setHours(0,0,0);
	document.cookie = name + "=" + escape( value ) + "; path=/" + ";";
}

function Get_Cookie(check_name) {
    // first we'll split this cookie up into name/value pairs
    // note: document.cookie only returns name=value, not the other components
    var a_all_cookies = document.cookie.split(';');
    var a_temp_cookie = '';
    var cookie_name = '';
    var cookie_value = '';
    var b_cookie_found = false; // set boolean t/f default f

    for (i = 0; i < a_all_cookies.length; i++) {
        // now we'll split apart each name=value pair
        a_temp_cookie = a_all_cookies[i].split('=');


        // and trim left/right whitespace while we're at it
        cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

        // if the extracted name matches passed check_name
        if (cookie_name == check_name) {
            b_cookie_found = true;
            // we need to handle case where cookie has no value but exists (no = sign, that is):
            if (a_temp_cookie.length > 1) {
                cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
            }
            // note that in cases where cookie is initialized but no value, null is returned
            return cookie_value;
            break;
        }
        a_temp_cookie = null;
        cookie_name = '';
    }
    if (!b_cookie_found) {
        return null;
    }
}

function SetFontSize(SizeFlag) {
	
	obj = document.all;

	try {
	    if (SizeFlag == 'B') {
	        ContentCurrentFontSize = ContentCurrentFontSize + 1;
	        ContentCurrentLineHeight = parseInt(ContentCurrentFontSize * 1.6);
	        obj.content.style.fontSize = ContentCurrentFontSize + "px";
	        obj.content.style.lineHeight = ContentCurrentLineHeight + "px";


	    } else {
	        if (ContentCurrentFontSize > 0) {
	            ContentCurrentFontSize = ContentCurrentFontSize - 1;
	            ContentCurrentLineHeight = parseInt(ContentCurrentFontSize * 1.6);
	        }
	        obj.content.style.fontSize = ContentCurrentFontSize + "px";
	        obj.content.style.lineHeight = ContentCurrentLineHeight + "px";
	    }
	    setCookie("ContentCurrentFontSize", ContentCurrentFontSize, 0);
	    setCookie("ContentCurrentLineHeight", ContentCurrentLineHeight, 0);
	}
	catch (e) {

	}
}

function updateChar(maxByteNum)
{
	var theForm = document.forms['list'];
	var length = getMsgSize(theForm.cp_m_BBS_One1_tb_one.value);
	textlimit.innerText = length;
	if (length > maxByteNum) {
		alert("Max Limit exeed! Current length is " + maxByteNum + "!");
		theForm.cp_m_BBS_One1_tb_one.value = theForm.cp_m_BBS_One1_tb_one.value.replace(/\r\n$/, "");
		theForm.cp_m_BBS_One1_tb_one.value = assert_msglen(theForm.cp_m_BBS_One1_tb_one.value, maxByteNum);
	}
}

function myRound(num, pos) { 
	var posV = Math.pow(10, (pos ? pos : 2))
	return Math.round(num*posV)/posV
}
	
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf('#')!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function Open_Normal_Win (theURL, winName, features)
{
	window.open(theURL,winName,features);
}

function Open_Modal_Win(theURL, winName, features)
{
    aResult = window.showModalDialog(theURL,winName,features);
}
	
// select web hdd
function add_webhdd(file_name, file_size) {

parent.opener.opener_add_webhdd(file_name,file_size);
}

// select web hdd
function opener_add_webhdd(file_name, file_size)
{
	var temp = document.all.ListBox1;

	for (i=0;i<temp.options.length;i++)
	{ 
		if (temp.options[i].text == file_name)
		{
			return;
		}
	} 
	
	temp.options[temp.options.length] = new Option(file_name,file_size);

	//var temp_size = document.all.tb_size;
	
	//temp_size.value = myRound(eval(temp_size.value) + (file_size / (1024*1024)), 2);
}

function assert_msglen(message, maximum)
{
	var inc = 0;
	var nbytes = 0;
	var msg = "";
	var msglen = message.length;

	for (i=0; i<msglen; i++) {
		var ch = message.charAt(i);
		
		if(escape(ch).length >= 4){
			inc = 2;
		}
		else
		{
			if(escape(ch) !="%0D")
			{
				inc = 1;
		    }
		}

		if ((nbytes + inc) > maximum) {
			break;
		}
		nbytes += inc;
		msg += ch;
	}
	textlimit.innerText = nbytes;
	return msg;
}

function getMsgSize(thisStrvalue){
	var strLen = 0;

	for(i = 0; i < thisStrvalue.length;i++){
		if(escape(thisStrvalue.charAt(i)).length >= 4){
			strLen +=2;
		}
		else{
			if(escape(thisStrvalue.charAt(i)) !="%0D")
				strLen++;
		}
	}
		return strLen;
}

function BBS_Down_File()
{
    var theForm = document.forms['list'];
	var f = theForm.cp_m_lb_attach_list;
	var bbs_id = theForm.cp_m_hf_bbs_id.value;
	var idx = theForm.cp_m_hf_idx.value;
	var v = f.selectedIndex;

	if (v > -1)
	{
		document.target = "_blank";
		document.location = '../DownLoad/DownLoad.aspx?type=bbs&bbs_id=' + bbs_id + '&idx=' + idx + '&file_name=' + f.options[v].value;
	}
	
	return false;
}

function fnBBSMultiPrint() {
    //required 'msg_select_required' declaration
    var boardIDs = fnGetSelected(document.all.chkSelect);
    var bbsIDs = fnGetSelectedValues(document.all.chkSelect, "bbsid");

    var arrBoardID = boardIDs.split(",");

    if (boardIDs == "") {
        alert(msg_select_required);

        return false;
    }

    fnBBSMultiPrint_1(bbsIDs, boardIDs);
}

function fnBBSMultiPrint_1(bbsIDs, boardIDs) {
    
    if (boardIDs == "") {
        alert(msg_select_required);

        return false;
    }

    Open_Normal_Win('Print.aspx?bbs_id=' + bbsIDs + '&idx=' + boardIDs, 'Print', 'toolbar=no,resizable=yes,scrollbars=yes,width=790,height=600,status=1');
}

function Review_BBS(bbsID, boardID) {

    if (boardID == "") {
        alert(msg_select_required);

        return false;
    }

    Open_Normal_Win('Review.aspx?bbs_id=' + bbsID + '&idx=' + boardID, 'Review', 'toolbar=no,resizable=yes,scrollbars=yes,width=400,height=420,status=1');
}

function fnDocVersion(bbsID, boardID) {

    if (boardID == "") {
        alert(msg_select_required);

        return false;
    }

    Open_Normal_Win('File_Version.aspx?bbs_id=' + bbsID + '&idx=' + boardID, 'Version', 'toolbar=no,resizable=yes,scrollbars=yes,width=560,height=440,status=1');
}

function fnOpenEventWrite(mode, type, select_date, idx) {
    Open_Normal_Win('Write.aspx?mode=' + mode + '&type=' + type + '&select_date=' + select_date + '&idx=' + idx, 'Calendar', 'toolbar=no,resizable=yes,scrollbars=yes,width=800,height=800,status=1');
}

function fnOpenAddressContact(mode, type, id, idx) {
    Open_Normal_Win('../Contact/Write.aspx?by=cal&mode=' + mode + '&type=' + type + '&group_id=' + id + '&idx=' + idx, 'Calendar', 'toolbar=no,resizable=yes,scrollbars=yes,width=800,height=900,status=1');
}

function fnOpenOrgContact(mode, type, id, idx) {
    Open_Normal_Win('../Contact/Write.aspx?by=cal&mode=' + mode + '&type=' + type + '&x_user_id=' + id + '&x_domain_idx=' + idx, 'Calendar', 'toolbar=no,resizable=yes,scrollbars=yes,width=800,height=900,status=1');
}

function fnOpenEventWriteFromMailRead(mode, type, select_date, idx) {
    Open_Normal_Win('../Calendar/Write.aspx?mode=' + mode + '&type=' + type + '&select_date=' + select_date + '&idx=' + idx, 'Calendar', 'toolbar=no,resizable=yes,scrollbars=yes,width=800,height=900,status=1');
}

function acePopulated(sender, e) {

    var behavior = $find('AutoCompleteEx');

    var target = behavior.get_completionList();
    if (behavior._currentPrefix != null) {
        var prefix = behavior._currentPrefix.toLowerCase();
        var i;
        for (i = 0; i < target.childNodes.length; i++) {
            var sValue = target.childNodes[i].innerHTML.toLowerCase();
            if (sValue.indexOf(prefix) != -1) {

                var fstr = target.childNodes[i].innerHTML.substring(0, sValue.indexOf(prefix));
                var pstr = target.childNodes[i].innerHTML.substring(fstr.length, fstr.length + prefix.length);
                var estr = target.childNodes[i].innerHTML.substring(fstr.length + prefix.length, target.childNodes[i].innerHTML.length);
                target.childNodes[i].innerHTML = "<div class='autocomplete-item'>" + fstr + '<strong>' + pstr + '</strong>' + estr + "</div>";


            }
        }
    }

}

function aceSelected(sender, e) {
    try {
        var value = e.get_value();
        if (!value) {
            if (e._item.parentElement && e._item.parentElement.tagName == "LI")
                value = e._item.parentElement.attributes["_value"].value;
            else if (e._item.parentElement && e._item.parentElement.parentElement.tagName == "LI")
                value = e._item.parentElement.parentElement.attributes["_value"].value;
            else if (e._item.parentNode && e._item.parentNode.tagName == "LI")
                value = e._item.parentNode._value;
            else if (e._item.parentNode && e._item.parentNode.parentNode.tagName == "LI")
                value = e._item.parentNode.parentNode._value;
            else value = "";
        }
        var searchText = tb_list.value;
        searchText = searchText.replace('null', '');

        sender.get_element().value = searchText + value;
    }
    catch (e) {

    }
}


function show_new_schedule_compose(mode, type, select_date) {

    document.all.schedule_compose.style.display = "";
    document.ifrmCompose.location.href = "Write.aspx?mode=" + mode + "&type=" + type + "&select_date=" + select_date;
}

function show_view_schedule_compose(mode, type, select_date, idx) {

    document.all.schedule_compose.style.display = "";
    document.ifrmCompose.location.href = "Write.aspx?mode=" + mode + "&type=" + type + "&select_date=" + select_date + "&idx=" + idx;
}

function show_view_address_contact(mode, type, id, idx) {

    document.all.schedule_compose.style.display = "";
    document.ifrmCompose.location.href = "../Contact/Write.aspx?by=cal&mode=" + mode + "&type=" + type + "&group_id=" + id + "&idx=" + idx;
}


function show_view_org_contact(mode, type, id, idx) {

    document.all.schedule_compose.style.display = "";
    document.ifrmCompose.location.href = "../Contact/Write.aspx?by=cal&mode=" + mode + "&type=" + type + "&x_user_id=" + id + "&x_domain_idx=" + idx;
}

function hide_schedule_compose() {
    window.location.reload(true);
    document.all.schedule_compose.style.display = "none";
}

function close_schedule_compose() {
    document.ifrmCompose.location.href = "Blank_Page.aspx";
    document.all.schedule_compose.style.display = "none";
}

function show_Compose_Email(url, data, _check) {

    hide_Compose_Layer();

    document.all.ModalPopupPanel_Email.style.display = "";
    document.ifrmEmail.location.href = url + "/Instant_EMAIL.aspx?" + _check + "=" + encodeURI(data);
}

function show_Compose_SMS(url, data, _check) {

    hide_Compose_Layer();

    document.all.ModalPopupPanel_SMS.style.display = "";
    document.ifrmSMS.location.href = url + "/Instant_SMS.aspx?" + _check + "=" + encodeURI(data);
}

function show_Compose_SMS_File(url, data, _check) {

    hide_Compose_Layer();

    document.all.ModalPopupPanel_SMS_File.style.display = "";
    document.ifrmSMS_File.location.href = url + "/Instant_SMS_File.aspx?" + _check + "=" + encodeURI(data);
}

function show_Compose_FAX(url, data, _check) {

    hide_Compose_Layer();

    document.ifrmFAX.location.href = url + "/Instant_FAX.aspx?" + _check + "=" + encodeURI(data);
    document.all.ModalPopupPanel_FAX.style.display = "";
}

function show_Compose_Address(url, data, _check) {

    hide_Compose_Layer();

    document.all.ModalPopupPanel_Address.style.display = "";
    document.ifrmAddress.location.href = url + "/Instant_Address.aspx?" + _check + "=" + encodeURI(data);
}

function show_Compose_vCard(url, data, _check) {

    hide_Compose_Layer();

    document.all.ModalPopupPanel_vCard_Input.style.display = "";
    document.ifrmvCard.location.href = url + "/Instant_vCard.aspx?" + _check + "=" + encodeURI(data);
}

function show_Compose_Conf(url, data, _check) {

    hide_Compose_Layer();

    document.all.ModalPopupPanel_Conf.style.display = "";
    document.ifrmConf.location.href = url + "/Instant_Conf.aspx?" + _check + "=" + encodeURI(data);
}

function show_Compose_Download(url, data, _check) {

    hide_Compose_Layer();

    document.all.ModalPopupPanel_Download.style.display = "";
    document.ifrmDownload.location.href = url + "/Instant_Download.aspx?" + _check + "=" + encodeURI(data);
}

function hide_Compose_Layer() {

    try {
        var blank_url = Get_Cookie("url") + "ContextMenu/Blank_Page.aspx";

        try {
            document.ifrmEmail.location.href = blank_url;
            document.all.ModalPopupPanel_Email.style.display = "none";
        }
        catch (e) {

        }

        try {
            document.ifrmSMS.location.href = blank_url;
            document.all.ModalPopupPanel_SMS.style.display = "none";
        }
        catch (e) {

        }

        try {
            document.ifrmSMS_File.location.href = blank_url;
            document.all.ModalPopupPanel_SMS_File.style.display = "none";
        }
        catch (e) {

        }

        try {
            document.ifrmFAX.location.href = blank_url;
            document.all.ModalPopupPanel_FAX.style.display = "none";
        }
        catch (e) {

        }

        try {
            document.ifrmAddress.location.href = blank_url;
            document.all.ModalPopupPanel_Address.style.display = "none";
        }
        catch (e) {

        }

        try {
            document.ifrmConf.location.href = blank_url;
            document.all.ModalPopupPanel_Conf.style.display = "none";
        }
        catch (e) {

        }

        try {
            document.ifrmDownload.location.href = blank_url;
            document.all.ModalPopupPanel_Download.style.display = "none";
        }
        catch (e) {

        }

        try {
            document.ifrmvCard.location.href = blank_url;
            document.all.ModalPopupPanel_vCard_Input.style.display = "none";
        }
        catch (e) {

        }
    }
    catch (e) {

    }
}

function Confirm_Top_Page_Move(msg, url) {
    var answer = confirm(msg);
    if (answer) {
        try {
            if (parent.parent.name != "fraBody") {
                if (parent.parent.parent.name != "fraBody") {

                    if (parent.parent.parent.parent.name != "fraBody") {
                        alert("This popup page is not allow page move!");
                        parent.hide_Compose_Layer();
                    }
                    else {
                        parent.parent.parent.parent.location = encodeURI(url);
                    }
                }
                else {
                    parent.parent.parent.location = encodeURI(url);
                }

            }
            else {
                parent.parent.location = encodeURI(url);
            }
        }
        catch (e) {

        }
    }

    return false;
}

function SetUniqueRadioButton(nameregex, current) {
    re = new RegExp(nameregex);
    for (i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i]
        if (elm.type == 'radio') {
            if (re.test(elm.name)) {
                elm.checked = false;
            }
        }
    }
    current.checked = true;
}


function Status_Text() {
    window.status = "CrossSender Massaging System";
    setTimeout("Status_Text()", 0);
}


//Status_Text();





