﻿/*function changeCorresponenceAddressShow(cID, cValidator1ID) {
    if (document.getElementById(cID)) {
        if (document.getElementById(cID).style.display == "block") {
            document.getElementById(cID).style.display = "none";
            cValidator1ID
            ValidatorEnable(document.getElementById(cValidator1ID), false);
        }
        else {
            document.getElementById(cID).style.display = "block";
            ValidatorEnable(document.getElementById(cValidator1ID), true);
        }
    }

}*/

function PhoneNumber_OnBlur(oInput) {
    if (oInput.value == "+420") {
        oInput.value = "";
    }
}
function PhoneNumber_OnFocus(oInput) {
    if (oInput.value.length == 0) {
        oInput.value = "+420";
        
        //oInput.selectionStart = oInput.selectionEnd;
        //setCaretToEnd(oInput);
        setCaretPositionToEnd(oInput.id);
    }
}
function WebAddress_OnBlur(oInput) {
    if (oInput.value == "http://") {
        oInput.value = "";
    }
}
function WebAddress_OnFocus(oInput) {
    if (oInput.value.length == 0) {
        oInput.value = "http://";
        //setCaretToEnd(oInput);
        setCaretPositionToEnd(oInput.id);
    }
}

/*http://blog.josh420.com/archives/2007/10/setting-cursor-position-in-a-textbox-or-textarea-with-javascript.aspx*/
function setCaretPositionToEnd(elemId) {
    var elem = document.getElementById(elemId);
    if (elem != null) {
        if (elem.createTextRange) {
            var range = elem.createTextRange();
            range.move('character', elem.value.length);
            range.select();
        }
        else {
            if (elem.selectionStart) {
                //elem.focus();
                elem.setSelectionRange(ctrl.value.length, ctrl.value.length);
            }
            //else
                //elem.focus();
        }
    }
}

/* cast kodu z http://objectmix.com/javascript/506512-moving-cursor-insertion-point-input-text-field.html*/
function setCaretToEnd(ctrl) {

    // IE Support

     if (document.selection) { 
        if (ctrl.setSelectionRange) {
            ctrl.setSelectionRange(ctrl.value.length, ctrl.value.length);
        }
     }

     // Firefox support
     else if (ctrl.selectionStart || ctrl.selectionStart == '0') {
       ctrl.selectionStart  = ctrl.value.length;
       ctrl.selectionEnd  = ctrl.value.length;
       ctrl.focus ();
     } 
}
