// JavaScript Document
Image_array = new Array(
	"3", "2", "4", "1", "5", "6", "7", "8", "9"
);

opened=0
memory_restaurant=0
visibility_and_display = function(id, visibility, display){
	$(id).css("visibility", visibility)
	$(id).css("display", display)
}
Slide_show_Starter = function(){
		setTimeout("Image_handle_show()",1200);
}

Image_handle_show = function(){
		$("#image").animate({opacity: "1"}, 200, function(){/*visibility_and_display("image", "visible", "block"); */Append_image()})
		setTimeout("Image_handle_hide()",3000)
}

Image_handle_hide = function(){
		$("#image").animate({opacity: "0"}, 200/*, function(){visibility_and_display("image", "hidden", "block")}*/)
		$(".image_slideshow").remove();
		setTimeout("Image_handle_show()",1000)
}

Append_image = function(){
		$("#image").append("<img src=\"gallery/"+Image_array[opened]+".jpg\" class=\"image_slideshow\"/>")
		if(opened>=Image_array.length-1){opened=0}else{opened++}
}

opacity_transform = function(id){
	if(memory_restaurant==0){
		visibility_and_display("#"+id, "visible", "block")
		$("#"+id).animate({opacity: "1"}, 500)
		memory_restaurant=id
	}else{
		$("#"+memory_restaurant).animate({opacity: "0"}, 10, function(){
			visibility_and_display("#"+memory_restaurant, "hidden", "none")
			visibility_and_display("#"+id, 'visible', 'block')
			$("#"+id).animate({opacity: "1"}, 200)
			memory_restaurant=id
		})
	}
}

Hide_description = function(){
		visibility_and_display(".description", "hidden", "none")
}
show_desc = function(id){
	$("#"+id).css("background-color","#ccc");
	visibility_and_display("#desc_"+id, "visible", "block")
}
restore_desc = function(id){
	$("#"+id).css("background-color","#fff");
	visibility_and_display("#desc_"+id, "hidden", "none")
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\0/g,'\0');
str=str.replace(/\\\\/g,'\\');
return str;
}
id_mem=0
Show_description = function(id){
		if(id_mem!=0){
			visibility_and_display("#"+id_mem, "hidden", "none")
			visibility_and_display("#"+id, "visible", "block")
			id_mem=id
			if(id_mem==id){
				visibility_and_display("#"+id_mem, "hidden", "none")
				id_mem=0
			}else{}
		}else{ 
			visibility_and_display("#"+id, "visible", "block")
			id_mem=id
		}
}
id_opened=0;

Togle_Opacity = function(){
		$("#"+id_opened).remove();

		$("#gallery").animate({opacity: "1"}, 2000)
}
loadXMLDoc = function(metodo, div, page)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		Togle_Opacity();
		visibility_and_display('#gallery', "visible", "block");
    	document.getElementById(div).innerHTML=xmlhttp.responseText;
	}
    }
xmlhttp.open(metodo, page ,true)
xmlhttp.send()
}
id_opened=0;
open_big_preview=function(id){
	if(id_opened==0){
		visibility_and_display("#preview", "visible", "block")
		image_src=document.getElementById(id).src;
		the_width = $("#"+id).attr("width")
		the_height = $("#"+id).attr("height")
		if(parseInt(the_height)>parseInt(the_width)){
			the_dimension="width=\"400\"";
			the_margin="100px";
		}else{
			the_dimension="width=\"440\"";
			the_margin="20px";		
		}
		$('#show_image').append("<img src="+image_src+" id=\"img_"+id+"\" "+the_dimension+" onclick=\"open_big_preview(this.id)\"/>");
		id_opened="img_"+id
		$('#show_image').css("margin-left", the_margin)
	}else{
		$("#"+id_opened).remove();
		image_src=document.getElementById(id).src;
		the_width = $("#"+id).attr("width")
		the_height = $("#"+id).attr("height")
		if(parseInt(the_height)>parseInt(the_width)){
			the_dimension="width=\"400\"";
			the_margin="100px";
		}else{
			the_dimension="width=\"440\"";
			the_margin="20px";		
		}	
		$('#show_image').append("<img src="+image_src+" id=\"img_"+id+"\" "+the_dimension+" onclick=\"open_big_preview(this.id)\"/>");
		id_opened="img_"+id
		$('#show_image').css("margin-left", the_margin)
	}
}
