//check if the input field is empty
function checkform ( form ) {

    if (form.domain.value == "") {
        form.domain.focus();
        document.getElementById('errormsg').innerHTML="<div class=\"errormsg\"><div class=\"tl\"><div class=\"tr\"></div></div><p>please enter a valid domain name</p><div class=\"bl\"></div><div class=\"br\"><div class=\"point\"></div></div></div>";
        return false ;
    }
    return true ;
}
function saveShortUrl(domain, short) {
    Ext.Ajax.request({
        url: '/service/saveShortURL.php',
        method: 'POST',
        params: {
            'domain': domain,
            'short':  short,
        },
        scope: this,
    });
}

function feedbackShow(done) {
    message  = document.getElementById('wasSend');
    feedback = document.getElementById('formular');
    if (done) {
        document.getElementById('fromEmail').value = "";
        document.getElementById('fullname').value = "";
        document.getElementById('message').value = "";
        message.style.display  = "block";
        feedback.style.display = "none";
    }else {
        message.style.display  = "none";
        feedback.style.display = "block";
    }
}

function sendMail() {
    if(document.getElementById('message').value != "" && document.getElementById('fromEmail').value != "") {
        $.ajax({
            url: '/feedback/',
            global: false,
            type: "POST",
            data: ({
                'fromEmail': document.getElementById('fromEmail').value,
                'message':   document.getElementById('message').value,
                'fullname':  document.getElementById('fullname').value,
                'send': 1
            }),
            dataType: "html",
            success: function(msg){
                if (msg == 'true') {
                    feedbackShow(true);
                }else {
                    feedbackShow(false);
                }
            }
         }
      )
    }return false;
}
var pdfToolTip;
function PDFToolTip() {
    pdfToolTip = new Ext.ToolTip({
        anchor: 'left',
        autoHide: false,
        target: document.getElementById("pdfLink"),
        hidden: true,
        title: '<br/>Information',
        width: 200,
        layout: 'fit',
        constrainPosition: 'false',
        html: 'PDF function will come soon!'
    });
}