﻿//FORM FUNCTIONS
//==============
function ajaxMockup() {
    var result = true;
    //CHECK CONTACT NAME
    if (document.getElementById("ctl00_ContentPlaceHolder1_txtName").value.length < 2) {
        document.getElementById("ctl00_ContentPlaceHolder1_txtName").style.border = "solid 1px red";
        result = false;
    }
    //CHECK CONTACT PHOME
    if (document.getElementById("ctl00_ContentPlaceHolder1_txtPhone").value.length < 2) {
        document.getElementById("ctl00_ContentPlaceHolder1_txtPhone").style.border = "solid 1px red";
        result = false;
    }
    //CHECK CONTACT EMAIL
    if (document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").value.length < 4) {
        document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").style.border = "solid 1px red";
        result = false;
    }
    return result;
}

function mockupTiming() {
    document.getElementById("ctl00_ContentPlaceHolder1_btnSendContact").src = "../img/loading.gif";
    document.getElementById("ctl00_ContentPlaceHolder1_btnSendContact").enabled = false;
    return true;
}


//SEO FUNCTIONS
//=============

//REDIRECT THE USER VIA JAVASCRIPT TO KEEP THE STRENGTH OF ANOTHER LINK
function JSLink(url, target) {
    if (target == 0) {
        document.location.href = url;
    }
    else {
        window.open(url);
    }
}

//SHARE BAR FUNCTIONS
//===================

//FACEBOOK
function shareFacebook(url) {
    var urlToGo = "http://www.facebook.com/sharer.php?u=" + url;
    window.open(urlToGo, "FacebookShare", "height=436", "width=635", "left=200", "top=100", "location=no", "menubar=no", "resizable=yes",
 "scrollbars=yes", "status=no", "titlebar=no", "toolbar=no");
}

//BOOKMARK
function shareBookMark(title, url) {
    if (window.sidebar) window.sidebar.addPanel(title, url, "");
    else if (window.opera && window.print) {
        var elem = document.createElement('a');
        elem.setAttribute('href', url); elem.setAttribute('title', title); elem.setAttribute('rel', 'sidebar'); elem.click();
    }
    else if (document.all) window.external.AddFavorite(url, title);
}

//REDIRECT TO PRINT FREINDLY PAGE
function sharePrint(url) {
    window.open(url, "",
 "height=800, width=1024, left=200, top=100, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=YES");
}

//SHARE A FRIEND
function shareWithAFriend(url) {
    window.open(url, "",
"height=400, width=550, left=200, top=100, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no");
}

//POP FUNCTIONS
//=============
//SHOWS AN ELEMENT
function ShowPop(id) {
    var popId = "pop" + id;
    document.getElementById(popId).style.display = "block";
}

//HIDES EN ELEMENT
function HidePop(id) {
    var popId = "pop" + id;
    document.getElementById(popId).style.display = "none";
}
