﻿/*
 *
 * hivesoft - hivesoft 2.0 web site
 * 
 * 2003-2008, (c) hivesoft di Christian Assante - www.hivesoft.it - www.hivesoft.eu
 * 
 * Name: hivesoft.js
 * Function: general purpose javascript library.
 *
 */

function getSiteNews() {
    if (typeof baseURL=='string') 
        $("#siteNews").load(baseURL+"/news.ashx");
}

function setBlankLink() {
    $("a[rel=bl]").click(function (event) {
        window.open(this.href);
        return false;
    });
}

function setContacts(obj) {
    var nosnif="";
    
    obj=$('#contacts.general');
    if (obj.length==1) {
        nosnif="Mobil";
        nosnif=nosnif+"e: +39 3";
        nosnif=nosnif+"35 5325086<br />Fa";
        nosnif=nosnif+"x: +39 3";
        nosnif=nosnif+"6335 5325086<br />eM";
        nosnif=nosnif+"ail:&nbsp;";
        obj.append(nosnif);
        
        nosnif="<";
        nosnif=nosnif+"a hre";
        nosnif=nosnif+"f=\"mai";
        nosnif=nosnif+"lto:inf";
        nosnif=nosnif+"o\x40h";
        nosnif=nosnif+"ivesof";
        nosnif=nosnif+"t.it\">inf";
        nosnif=nosnif+"o\x40hives";
        nosnif=nosnif+"oft.it</";
        nosnif=nosnif+"a><br />Sk";
        obj.append(nosnif);

        nosnif="ype: <";
        nosnif=nosnif+"a hre";
        nosnif=nosnif+"f=\"cal";
        nosnif=nosnif+"lto:h";
        nosnif=nosnif+"ivesof";
        nosnif=nosnif+"t\">hives";
        nosnif=nosnif+"oft</";
        nosnif=nosnif+"a>";
        obj.append(nosnif);
    }
    
    obj=$('#contacts.currucula');
    if (obj.length==1) {
        nosnif="<";
        nosnif=nosnif+"a hre";
        nosnif=nosnif+"f=\"mai";
        nosnif=nosnif+"lto:curr";
        nosnif=nosnif+"icula\x40h";
        nosnif=nosnif+"ivesof";
        nosnif=nosnif+"t.it\">curri";
        nosnif=nosnif+"cula\x40hives";
        nosnif=nosnif+"oft.it</";
        nosnif=nosnif+"a>";
        obj.append(nosnif);
    }        
}

function sendContactForm() {
    var data;
    var strValue;
    var err=false;
    
    data="<sendContactForm>\n";
    $("#contactform input[type=\"text\"], #contactform textarea").each(function(i,ele) {
        if (ele.value.length>0) {
	        strValue=encodeURI(ele.value);
            data+="\t<" + ele.id + ">" + strValue + "</" + ele.id + ">\n";
            ele.className="";
        } else {
            ele.className="contacterror";
            err=true;
        }
    });
    data+="</sendContactForm>";

    if (err) return false;    
    
    $.post("contact.ashx", data, function(data, textStatus) {
        if (textStatus=="success") $("#contactform").html(data);
    }, "html");

    return false;
}

$(document).ready(function(){
    setBlankLink();
    setContacts();
    getSiteNews();
});
