<!--
function openModal(parameters,style)
{
	if(style==null)
		style = "Status:1;dialogWidth:800px;dialogHeight:600px;scroll:1;center:1;resizable:1";

	var w = window.showModalDialog('../../ModalBase.htm?'+parameters,'',style);
	return w;
}

function openWindow(url, style){
	if(style == null)
		style = "status=0,scrollbars=0,center=1,resizable=1,toolbar=0,location=0,directories=0,menubar=0,width=700,height=450";
	
	var nw = window.open(url, 'NicWin', style);
}

function openSizedWindow(url,w,h){
	var style = "width="+w+",height="+h+",status=1,scrollbars=0,center=1,resizable=1,toolbar=0,location=0,directories=0,menubar=0";
	var nw = window.open(url, 'NicWin', style);
}

function openGallery(url)
{
    var w = window.screen.availWidth-10;
    var h = window.screen.availHeight-10;
    var s = "width="+w+",height="+h+",top=0,left=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1";
    openWindow(url,s);
}

function checkemail(str){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		return true;
	else
		return false;
}

function WriteDate()
{
    today = new Date();
	document.write(today.toLocaleDateString());
}

function DetailSwitch(view)
{
    
    switch(view)
    {
        case "mapContent":
            HideAllStructDetPanels(view);
            ShowElement(view);
            InitMap(defaultLat,defaultLng,defaultLvl,enableWheel,false); 
        break;
        case "pnlPrices":
            if(!CheckAndOpenDocument())
               ShowElement(view);
        break;
        case "SuppaDetail":
            HideAllStructDetPanels(view);
            OnMapClose();
            ShowElement(view);
        break;
    }
}

function HideAllStructDetPanels(view)
{
    var panels = new Array("mapContent","pnlPrices","SuppaDetail");//,"pnlGalleryTop"
    for(var i=0;i<panels.length;i++)
        if(view!=panels[i])
            HideElement(panels[i]);
}
function CheckAndOpenDocument()
{
    if(attachments && attachments.length==1)
    {
        window.open(attachments[0]);
        return true;
    }
    HideAllStructDetPanels("pnlPrices");
    OnMapClose();        
    return false;
}

function image_scroller_clicked(info)
{
    try{
        $get("hlkGallery").onclick();
    }catch(e){alert(e)}
}

function pSwitchImg(sec,home,srcEle)
{
   if(!sec)
        sec = 0;
    try
    {
        switch(home)
        {
            case "p":
                $get("pMap").src = "images/HomePuglia/mappa"+sec+".gif";
                break;
            case "i":
                $get("iMap").src = "images/HomeItalia/imap"+sec+".gif";
                break;
            case "b":
                $get("bMap").src = "images/HomeBenessere/bmap"+sec+".gif";
                break;
            case "r":
                $get("rMap").src = "images/HomeRaro/rmap"+sec+".gif";
                break;
        }
        if(sec>0)
        {
            var ele = $get("mi_"+sec);
            ele.className = 'menu_link_hover';
            srcEle.onmouseout = function(){ele.className='menu_link_out';pSwitchImg(0,home,null);};
        }
    }catch(e){}
}

function pImgPreload(vals,home)
{
    var defPath = "images/HomePuglia/mappa";
    
    switch(home)
    {
        case "i":
            defPath = "images/HomeItalia/imap";
            break;
        case "b":
            defPath = "images/HomeBenessere/bmap";
            break;
         case "r":
            defPath = "images/HomeRaro/rmap";
            break;
    }
   
   if(vals==null)
    vals = [1,2,3,4,5];
   
   var i;
   var imageObj = new Image();
   for(i=1; i<=vals.length; i++)      
       imageObj.src=defPath+vals[i]+".gif";     

}
var wm1 ;
function InitPage()
{
    if(OverrideSubTitle)
        OverrideSubTitle();
        
    window.setInterval("BlinkText()", 1000);
}
function BlinkText()
{
    $(".blink").each(function()
    {
        if ($(this).css("color") == "#ffffff")
            $(this).css("color", "#E2007A");
        else
            $(this).css("color","#ffffff");
    });
}

function OpenWebBooking(lang)
{
    switch(lang)
    {
        case 'en':
            alert("The Web Booking system will be available very shortly");
            break;
        default:
            alert("Il sistema di Web Booking non è ancora attivo.\nPuoi intanto registrarti \ne ti informeremo appena il servizio sarà disponibile.");
        
            break;
    }
}

function subscribe()
{
    var email = $("#mailing_mail").val();
    var key = $("#key").val();
    if(checkemail(email))
    {
        var btn = $("#submitMailing");
        btn.attr("disabled","true");
        $.post("Newsletter/Register.ashx", { email: email, key: key },
            function(data){
                alert(data);
                btn.removeAttr("disabled");
            });
        
    }else
        alert(msgs[0]);        
}

function MakeGallery(structureID)
{
    var tmp = eval("s_img_"+structureID);
    jQuery.slimbox(tmp, 0, {loop: true});
}

function ShowCatalogue(type)
{
    SwitchElement("FrameIssue");
    SwitchElement("CatalogFrameX");
    SwitchElement("MapFrameX");
}


function card_request()
{
    var email = $("#Email").val();
    var key = $("#key").val();
    if(checkemail(email))
    {
        var btn = $("#submitFormCard");
        btn.attr("disabled","true");
        $.post("Services/CardRequest.ashx"
            , { Email: email
                ,Name : ($("#Name").val()!=defMsgs[0])?$("#Name").val():''
                ,Surname : ($("#Surname").val()!=defMsgs[1])?$("#Surname").val():''
                ,Address : ($("#Address").val()!=defMsgs[2])?$("#Address").val():''
                ,City : ($("#City").val()!=defMsgs[3])?$("#City").val():''
                ,District : ($("#District").val()!=defMsgs[4])?$("#District").val():''
                ,Telephone : ($("#Telephone").val()!=defMsgs[5])?$("#Telephone").val():''
                ,AgencyName : ($("#AgencyName").val()!=defMsgs[6])?$("#AgencyName").val():''
                ,Zip : ($("#Zip").val()!=defMsgs[6])?$("#Zip").val():''
                , LANG : $("#LANG").val()
                , key: key },
            function(data){
                alert(data);
                btn.removeAttr("disabled");
            });
        
    }else
        alert(msgs[0]);        
}

function login(type)
{
    var name = $("#Name").val();
    var pwd = $("#Pwd").val();
    var key = $("#key").val();
    if(name!=null && name!="" && pwd!=null && pwd!="")
    {
        var btn = $("#submitFormCard");
        btn.attr("disabled","true");
        
        $.post("Services/" + (type=="card"?"Card":"Promoter") + "Login.ashx"
            , { Name : name
                ,Pwd : pwd
                , LANG : $("#LANG").val()
                , key: key },
            function(data){
                if(data!=null && data.length>3)
                {
                    if(data.substring(0,3)!="ok_")
                         alert(defMsgs[0]);
                    else
                    {
                        var cv = data.replace("ok_","");
                        $.cookie(defMsgs[1], cv, { path: '/'});
                        window.location.reload();
                    }
                }
                btn.removeAttr("disabled");
            });
    }
}

var variabileSearcher;
function OpenSelectLink(variabileSearcher)
{
	if(variabileSearcher == "puglia"){
		$('#imgCalCloseUnderFold1,#Listingpuglia,#imgCalOpenUnderFold2,#imgCalOpenUnderFold3,#imgCalOpenUnderFold4').css("display","block");
		$('#imgCalOpenUnderFold1,#Listingmareitalia,#Listingbollicine,#Listingraro,#imgCalCloseUnderFold2,#imgCalCloseUnderFold3,#imgCalCloseUnderFold4').css("display","none");
	} else if(variabileSearcher == "mareitalia"){
		$('#imgCalCloseUnderFold2,#Listingmareitalia,#imgCalOpenUnderFold1,#imgCalOpenUnderFold3,#imgCalOpenUnderFold4').css("display","block");
		$('#imgCalOpenUnderFold2,#Listingpuglia,#Listingbollicine,#Listingraro,#imgCalCloseUnderFold1,#imgCalCloseUnderFold3,#imgCalCloseUnderFold4').css("display","none");
	} else if(variabileSearcher == "bollicine"){
		$('#imgCalCloseUnderFold3,#Listingbollicine,#imgCalOpenUnderFold1,#imgCalOpenUnderFold2,#imgCalOpenUnderFold4').css("display","block");
		$('#Listingpuglia,#Listingmareitalia,#imgCalOpenUnderFold3,#Listingraro,#imgCalCloseUnderFold1,#imgCalCloseUnderFold2,#imgCalCloseUnderFold4').css("display","none");
	} else if(variabileSearcher == "raro"){
		$('#imgCalCloseUnderFold4,#Listingraro,#imgCalOpenUnderFold1,#imgCalOpenUnderFold2,#imgCalOpenUnderFold3').css("display","block");
		$('#imgCalOpenUnderFold4,#Listingpuglia,#Listingmareitalia,#Listingbollicine,#imgCalCloseUnderFold1,#imgCalCloseUnderFold2,#imgCalCloseUnderFold3').css("display","none");
	}
}

function CloseSelectLink()
{	
	$('#imgCalOpenUnderFold1,#imgCalOpenUnderFold2,#imgCalOpenUnderFold3,#imgCalOpenUnderFold4').css("display","block");
	$('#imgCalCloseUnderFold1,#imgCalCloseUnderFold2,#imgCalCloseUnderFold3,#imgCalCloseUnderFold4,#Listingpuglia,#Listingmareitalia,#Listingbollicine,#Listingraro').css("display","none");
}

function OpenIssu(url)
{
    var d = $('#jqwin').html('<iframe id="ifrm" width="900" height="450" style="width:900px;height:450px;" frameborder="0"></iframe>');
    d.dialog({ closeOnEscape: true, modal: true});
    $("#jqwin>#ifrm").attr("src", url);
	var p = $('#claimList').offset();
    d.dialog('option','position',[p.left,p.top+15]);
    d.dialog('option','width',960);
    d.dialog('option','height',550);
}

function ShowOffResDets(off_id,btn)
{
    var eleID = "#pnlOfferDetails"+off_id+",#pnlOfferButtons"+off_id;
    try{
        if(!$(eleID).is(':visible'))
        {
            $(eleID).slideDown();
            btn.innerHTML = btns.close;
        }
        else
        {
            $(eleID).slideUp();
            btn.innerHTML = btns.open;
        }
        
    }catch(e){}
}
function ExitSite()
{
    $.cookie('.ASPXAUTH',null,{path:'/'});
    document.location.reload();
}
//-->
