function ajaxGet()
	{
	 	var request=false;
	 	try
	 	{
	 	request= new XMLHttpRequest();	 	
	 	}
	 	catch(err1)
	 		{
	 		try
	 			{
	 			request= new ActiveXObject("Msxml2.XMLHTTP");
	 			}
	 			catch(err2)
	 			{
	 			try
	 				{
	 				request=new ActiveXObject("Microsoft.XMLHTTP");
	 				}
	 			catch(err3)
	 				{
	 				request=false;
	 				}
	 			}
	 		}
	 	/*if (request==false) alert("No Ajax Object");
	 	else alert("Ajax Object creation OK");*/
	 	return request;
	 }
	 var http;
function getContents(subId,id)
{
http=new ajaxGet();
http.onreadystatechange=function ()
			{
			if (http.readyState==4)
				{
					if(http.status!=200)
						{
						return;
						}
					else
						{
						
							var Value=http.responseText;
							
							document.getElementById(id).innerHTML=Value;
						}
				}
			}
var url="serviceAjax.php?id="+subId

http.open("GET",url,true)
http.send(null)

}

// GALERIE HOME
function gh_center(obj){
	$p=$(obj);
	$p.parent('a').attr('href',$p.attr('src')).lightBox();
	var h=0;
	if ($p.height()>130)
		h=-Math.ceil(($p.height()-130)/2);
	else
		h=Math.ceil((130-$p.height())/2);
	$p.css('marginTop',''+h+'px');
	
}
function gh_showPic(pic,obj)
{
	$("#gal_preview img:first").attr('src',pic);
	$("#gal_btn .active").removeClass("active");
	$(obj).addClass("active");
}
function gh_populate_btn()
{
	var str="";
	for (var i=0;i<pics.length;i++)
	{
		str+='<div onclick="gh_showPic(\''+pics[i]+'\',this);">'+(i+1)+'</div>';
	}
	if (str!='')
	{
		$("#gal_btn").html(str);
		$("#gal_btn").children(":first").addClass("active").click();
		var w=0;
		$("#gal_btn").children().each(function(i,obj){w+=$(obj).width()+6;});
		$("#gal_btn").css('width',''+Math.ceil(w*1.1)+'px');
	}
}
var ghmoving=false;
function gal_left(){
	if (ghmoving) return false;
	var w=parseInt($("#gal_btn").css("marginLeft"));
	if (w<0){
		ghmoving=true;
		$("#gal_btn").animate({"marginLeft":"+=120px"},600,'linear',function(){ghmoving=false;});
	}
}
function gal_right(){
	if (ghmoving) return false;
	var w=parseInt($("#gal_btn").css("marginLeft"));
	if ($("#gal_btn").width()+w>150){
		ghmoving=true;
		$("#gal_btn").animate({"marginLeft":"-=120px"},600,'linear',function(){ghmoving=false;});
	}
}

// GALERIE TIP 2 - cu thumbnails in dreapta
function g2preview_center(obj)
{
	var $p=$(obj);
	$p.parent('a').attr('href',$p.attr('src')).lightBox();
	var h=0;
	if ($p.height()>253)
		h=-Math.ceil(($p.height()-253)/2);
	else
		h=Math.ceil((253-$p.height())/2);
	$p.css('marginTop',''+h+'px');
}
function g2_showPic(pic,obj)
{
	$(".gal2preview img:first").attr('src',pic);
	$("#g2thumbs .active").removeClass("active");
	$(obj).addClass("active");
}
function g2center(obj){
	if ($(obj).width()>57) 
		$(obj).css('marginLeft','-'+Math.ceil(($(obj).width()-57)/2)+'px'); 
	else $(obj).css('marginLeft',''+Math.ceil((57-$(obj).width())/2)+'px');
}
var g2moving=false;
function g2left()
{
	if (g2moving) return false;
	var w=parseInt($("#g2thumbs").css("left"));
	if (w<0){
		g2moving=true;
		$("#g2thumbs").animate({"left":"+=130px"},600,'linear',function(){g2moving=false;});
	}
}
function g2right(){
	if (g2moving) return false;
	var w=parseInt($("#g2thumbs").css("left"));
	if ($("#g2thumbs").width()+w>150){
		g2moving=true;
		$("#g2thumbs").animate({"left":"-=130px"},600,'linear',function(){g2moving=false;});
	}
}

//	Initializari datepicker si galerii

$(function(){
	if ($('.pick_date'))
		$('.pick_date').datepicker({
			gotoCurrent:true,
			firstDay:1,
			buttonImageOnly:true,
			buttonImage:"img/arrow.png",
			showOn:'both',
			dateFormat:'dd-mm-yy'
		});
	if ($('#gal_btn').length>0) //daca avem galeria de pe homepage 
		setTimeout(gh_populate_btn,10);
	if ($('#g2thumbs').length>0) //daca avem galerie tip 2 (cu thumbnails in dreapta) 
		setTimeout(function(){$("#g2thumbs").children(":first").children(":first").addClass("active").click();},10);
	if ($.browser['msie'] && $.browser['version']<=6)
		$(".ie6png").each(function(i,obj){
			$(obj).attr('src',$(obj).attr('src').replace(".png",".gif"));
		});
});

