function openGallery(code, to){
	var url = 'http://www.alpitourworld.com/vacanze/photogallery.jsp?site=AWcom&code='+code+'&to='+to;
	var wnd = window.open(url, "GALLERY", "toolbar=no,height=550,width=680,status=no,menubar=no,scrollbars" )
	wnd.focus();
}

function openWindow(url){
	var wnd = window.open(url, "", "toolbar=no,height=700,width=800,title=no,status=no,location=no,menubar=no,scrollbars" );
	wnd.focus();
}

$(document).ready(function(){


	// popAlpiInfoBig HELP
	jQuery('.popAlpiInfoBig').popAlpiInfoBig();
	jQuery('#poaltoInfoBig').livequery(function(){
		jQuery(this).bgiframe();
	});	

	jQuery('.popAlpiModUtilizzo').popAlpiModUtilizzo();
	jQuery('#poaltoModUtilizzo').livequery(function(){
			jQuery(this).bgiframe();   
	}); 

	$('#chiudi_Div').click(function(){
	$('#poaltoModUtilizzo').draggable('destroy').remove();
		removeOpacity();
		});

	 $('.abstContainer').each(function(i){
				
		var code = $(this).attr("kvac").trim();
		var id = $(this).attr("id").trim();
		var sURL= "/EBookingWeb/DocumentumController?code="+code; 

		//setOpacity('#containerOpacity');
		
		$.ajax({
			url: sURL,
			type: 'GET',
			dataType:'xml',
			success: function(xmlData){	
				var txt = xmlData.getElementsByTagName("text")[0];
				$('#'+id).html(txt.firstChild.nodeValue);
				//removeOpacity();
				var linkSfogliaCatalogo = xmlData.getElementsByTagName("localita_sistemazione")[0];
				if(linkSfogliaCatalogo.firstChild != null)
					if(linkSfogliaCatalogo.firstChild.nodeValue !=null && linkSfogliaCatalogo.firstChild.nodeValue != '')
					$('#mostraLink'+id).html("<a href='#' onClick='javascript:openWindow(\""+linkSfogliaCatalogo.firstChild.nodeValue+"\");' style='color:black;font-weight:normal' ><u>MOSTRA PROPOSTE</u></a>");
		
			},	
			error: function(){
			//removeOpacity();
			}	
		});
	});


	$('.select_soluzione').click(function(){
		
		var idxRegalo = jQuery(this).attr('idxRegalo');
		
		var httpsUrl = jQuery(this).attr('httpsUrl');
		
		var Item_sku = jQuery(this).attr('Item_sku');
		var Item_name = jQuery(this).attr('Item_name');
		var Item_Category = jQuery(this).attr('Item_Category');
		var Page_name = jQuery(this).attr('Page_name');
		var Cart_id = jQuery(this).attr('Cart_id');
		var Item_qty = jQuery(this).attr('Item_qty');
		
	    var f= document.forms["RqDatiREGAForm"];
	        
       	f.idxRegalo.value = idxRegalo;
        f.method.value="selezionaSoluzione";
        f.action = httpsUrl;
        
        f.cartId.value = Cart_id;

        // Apertura carrello trackset
        sendevent('_addItem', Cart_id, Item_sku, Item_name, Item_Category, '0', Item_qty, Page_name);
				
        setTimeout(function() {f.submit()},1000);
	});

	$('.descrprod').each(function(){
		animatedcollapse.addDiv($(this).attr("id"), 'fade=1');
	});
	
	$('.showProps').each(function(){
		animatedcollapse.addDiv($(this).attr("dTarget"), 'fade=1');
	});
	
	animatedcollapse.init();	
	
	$('.showProps').click(function(){
		animatedcollapse.toggle($(this).attr("dTarget"));
		
		var val = ($(this).html() === "MOSTRA PROPOSTE")
                    ? "CHIUDI PROPOSTE" 
                    : "MOSTRA PROPOSTE";
     	$(this).html(val);
		
	});
	
	$('.imgchiudiprop').click(function(){
		animatedcollapse.toggle($(this).attr("dTarget"));
		
		var index = $(this).attr("idxIndex");	
		var val = ($('#mostraProp'+index).html() === "MOSTRA PROPOSTE")
                    ? "CHIUDI PROPOSTE" 
                    : "MOSTRA PROPOSTE";
     	$('#mostraProp'+index).html(val);
	});
	
	
	
	$('.propexp').click(function(){

		var schedaProd = jQuery(this).attr('schedaProd');        
		var divDest =  jQuery(this).attr('divDescrProd');

		var src = ($('#img'+schedaProd).attr("src") === "/ResEBook/img/weBox/box_rega_propexp.jpg")
                    ? "/ResEBook/img/weBox/box_rega_propcoll.jpg" 
                    : "/ResEBook/img/weBox/box_rega_propexp.jpg";
     	$('#img'+schedaProd).attr("src", src);
		

		var isEmptyDiv = $('#'+divDest).html();
		
		if(isEmptyDiv != ''){
	 		animatedcollapse.toggle(divDest);
			return;
		}
		setOpacity('#containerOpacity');
		var sURL= "/EBookingWeb/SchedaHotelWebox?codProd="+schedaProd;

		$.ajax({
			url: sURL,
			type: 'GET',
			dataType: 'html',
			success: function(htmlData){		
				$('#'+divDest).html(htmlData);
				
				if($('#'+divDest).html() == '')
					$('#'+divDest).html("<div style='width: 600px;margin-left: 20px;'>Nessun testo da visualizzare</div>");
				
		 		animatedcollapse.toggle(divDest);
		 		removeOpacity();
			},	
			error: function(){
				$('#'+divDest).html("<div style='width: 600px;margin-left: 20px;'>Nessun testo da visualizzare</div>");
				animatedcollapse.toggle(divDest);
				removeOpacity();
			}	
			})		
		});


});


