
jQuery(function(){
	//configure highslide
	$('.highslide').each(function(i){
//		bindPopupPage($(this),'/service/service_'+this.id+'.html', 'popup-'+i);	
	});
});

//unused code: script handers are bound in html
function bindPopupPage(to, page, contentInPageId){
	//load contents of the page
	$.ajax({
       type: "POST",
       url: page,
       data: 'ajax=1',
       complete: function(msg){
         //succeeded request returned html-code of the page
         //extract contents and save them on the page
         jQuery(
         	function(){
         		$('body').append(
		     		wrapHtml( msg.responseText, 'hdn', contentInPageId)
		     	);
         	}
         );
//         '<div id="'+contentInPageId+'">'+msg.responseText+'</div>').appendTo('body');
         //bind callout with contents of *page* to the *to*
         $(to).attr('href',page);
         $(to).click(function(){
         		hs.htmlExpand(this, { objectType:'ajax', contentId: 'popup' } );
	     	}
	        );//click
	 	}//ajax:complete
	 });//ajax
}//bindPopupPage

function wrapHtml(html, cls, id){
	return '<div ' +
				(id? 'id="'+id+'"' : '') + (cls? 'class="'+cls+'"' : '') + '>' +
				html
			+ '</div>';/*
			"<div class='highslide-html-content "+cls+"' id='"+id+"' style='width: 200px'>"+
    		"<a href='#' onclick='hs.close(this)'>Закрыть</a>"+
    		"<div class='highslide-body'>"+html+
        	"</div></div>";*/
}

