function showHideBox(title, body)
{
  titleObj = $(title);
  bodyObj = $(body);
  if(titleObj == null || bodyObj == null )
    return;
  titleObj.toggleClassName("open");
	titleObj.toggleClassName("close");
  Effect.toggle(bodyObj,'slide',{duration:0.6});
}

function changeContent(elem, box, tagMenu, idMenu, classBoxContent)
{
  tabContainer = $(idMenu);
  menuItem = tabContainer.getElementsByTagName(tagMenu);
  boxItem = document.getElementsByTagName('div');
  boxToShow = $(box);
 	mainCont = $('conTab');
 //if(mainCont.style.display=='none'){
 		showHideBox(elem, 'conTab');
 //	} 
  for(var i=0; i < menuItem.length; i++)
  {
    //menuItem[i].className=""
  }
  for(var i=0; i < boxItem.length; i++)
  {
    if(boxItem[i].className.match(classBoxContent))
    {
      boxItem[i].style.display="none"
    }
  }
  //$(elem).className="active";
  boxToShow.setOpacity(0);
  boxToShow.style.display="block";
  var myEffect = new Effect.Opacity(boxToShow, { 
  duration: 0.7,
  transition: Effect.Transitions.linear,
  from: 0.0, 
  to: 1.0
});
}

function LoadLocalityMap(){
	Lightview.show({ href: '/aspx/localitiesMap.aspx?MapType=LOCATION', rel: 'iframe', options: { width: 750, height: 490 }});//{ width: 720, height: 450 }
}
//Lightview.hide();
//var leftVal = ((screen.width - 720) / 2)-20;
//var topVal = ((screen.height - 450 ) / 2)-20;
//var r = window.open( '/immobilsarda/aspx/localitiesMap.aspx', 'Gallura', 'width=720,height=450,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,left='+leftVal+',top='+topVal);
//if (r!=null) r.focus();
function LoadSend2MailForm(theLink){
	Lightview.show({ href: '/aspx/sendtofriends.aspx?theLink=' + theLink, rel: 'iframe', options: { width: 440, height: 450 }});//{ width: 720, height: 450 }
}


function LoadLightViewContent(src){
	Lightview.show({ href: src, rel: 'iframe'});//{ width: 720, height: 450 }
}

function LoadLightViewExtContent(src){
	Lightview.show({ href: src, rel: 'iframe', options: { width: 780, height: 600 }});//{ width: 720, height: 450 }
}

function DelWishListContent(psdpropertycode){
		TheForm=document.Form;
		TheForm._postbackman$WishListField2DEL.value=psdpropertycode;
		var cnt= parseInt(document.getElementById('_wishlist_tlWishListCnt').innerHTML);
		if (cnt>0) document.getElementById('_wishlist_tlWishListCnt').innerHTML =cnt-1;
		document.Form._postbackman$WishListBtnDel.click();
}

function AddWishListContent(psdpropertycode){
       var re = new RegExp(psdpropertycode,"gi");
		TheForm=document.Form;
		if (TheForm._wishlist$WishListValues.value.match(re)){
		    alert("Proprieta\' gia\' presente nella tua WishList");
		    return  false;
		}
		TheForm._postbackman$WishListField2ADD.value=psdpropertycode;
		if (document.getElementById("_wishlist_tlWishList").className=='close')
		    showHideBox('_wishlist_tlWishList','_wishlist_boxWishList');
		var cnt= parseInt(document.getElementById('_wishlist_tlWishListCnt').innerHTML);
		document.getElementById('_wishlist_tlWishListCnt').innerHTML =cnt+1;
		//window.navigate="#Top"
		window.scrollTo(0, 0);
        document.Form._postbackman$WishListBtn.click();
}

function AddWishListContentAndContact(psdpropertycode,actionTarget){
       var re = new RegExp(psdpropertycode,"gi");
		TheForm=document.Form;
		TheForm._postbackman$WishListField2ADD.value=psdpropertycode;
		if (document.getElementById("_wishlist_tlWishList").className=='close')
		    showHideBox('_wishlist_tlWishList','_wishlist_boxWishList');
		if (!TheForm._wishlist$WishListValues.value.match(re)){
		    var cnt= parseInt(document.getElementById('_wishlist_tlWishListCnt').innerHTML);
		    document.getElementById('_wishlist_tlWishListCnt').innerHTML =cnt+1;
		}
		TheForm._postbackman$UrlRedirectValue.value=actionTarget;
        document.Form._postbackman$WishListBtn.click();
}

function ContactPostManage(msg0,msg1,msg2,msg3,msg4){
		TheForm=document.Form;
		var error="";
		if (TheForm.ContactFirstName.value.trim()=='')
            error=msg1 + "\n"
		if (TheForm.ContactLastName.value.trim()=='')
            error= error + msg2 + "\n"
		if (TheForm.ContactEmail.value.trim()=='' && TheForm.ContactPhone.value.trim()=='')
		    error = error + msg3 + "\n"
		if (TheForm._dbresearchhome_p_business_scope_db.value.trim() == '')
		    error = error + msg4 + "\n"            
		if (error.length>0)
		{
		    alert(msg0 + '\n' + error);
		    return false;
		}
		TheForm.FormDisable.value='true';
		TheForm.submit();
}

function AnkSendPostManage(msg0,msg1,msg2,msg3){
		TheForm=document.Form;
		var error="";
		if (TheForm.txtSenderName.value=='')
            error=msg1 + "\n"
		if (TheForm.txtSenderEmail.value=='')
            error= error + msg2 + "\n"
		if (TheForm.txtDestinationMail1.value=='' )
            error=error + msg3 + "\n"
		if (error.length>0)
		{
		    alert(msg0 + '\n' + error);
		    return false;
		}
//		return true;
//		alert('AnkSendPostManage');
        TheForm.submit();
//		document.Form.ankSend.click();
}


function fireClickElement(objID) {
	var target=document.getElementById(objID);
	if(document.dispatchEvent) { // W3C
	var oEvent = document.createEvent( "MouseEvents" );
	oEvent.initMouseEvent("click", true, true,window, 1, 1, 1, 1, 1, false, false, false, false, 0, target);
	target.dispatchEvent( oEvent );
	}
	else if(document.fireEvent) { // IE
//alert("fireEvent->" + target.name);
	target.fireEvent("onclick");
	}
}

function SetDynamicBoxStyleProperty(DivID,BoxStyleHiddenField){
		TheForm=document.Form;
        var obj= eval("TheForm['" + BoxStyleHiddenField + "']");
        if(obj == null )
            return;
        if (document.getElementById(DivID).style.display=="none")
            obj.value="block";
        else
            obj.value="none";
        makeAJAXPostback()
}

function makeAJAXPostback()
{
    document.Form._postbackman$btnTDClicked.click();
}

function OpenWindow(pageName, widthWindow, heightWindow) 
{
    window.open(pageName, "_blank", "toolbar=1, top=0, left=" + ((screen.availWidth - widthWindow) / 2) + ", width=" + widthWindow + ", height=" + heightWindow);
}


function LoadPopupContent(src) {

    var h;
    var w;
    if (screen == null) {
        w = 800;
        h = 600;
    }
    else {
        w = screen.width;
        h = screen.height;
    }


    var stile = "top=10, left=10, width=" + ( w - 40 ) + ", height=" + ( h - 160 ) + ", status=no, menubar=no, toolbar=no, scrollbars=yes, resizable=no";
    window.open(src, '', stile);
}





