var cur_big_photo=0;
var cur_big_photo_ind=0;

var b="";
var flg_ie=0;
b=(function x(){})[-5]=='x'?'FF3':(function x(){})[-6]=='x'?'FF2':/a/[-1]=='a'?'FF':'\v'=='v'?'IE':/a/.__proto__=='//'?'Saf':/s/.test(/a/.toString)?'Chr':/^function \(/.test([].sort)?'Op':'Unknown'
if(b=="IE")
{flg_ie=1;}


function getNameBrouser() {
 var ua = navigator.userAgent.toLowerCase();
 // Определим Internet Explorer
 if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) {
 	flg_ie=1;
   return "IE"
 }
 // Opera
 if (ua.indexOf("opera") != -1) {
   return "opera"
 }
 // Gecko = Mozilla + Firefox + Netscape
 if (ua.indexOf("gecko") != -1) {
   return "gecko";
 }
 // Safari, используется в MAC OS
 if (ua.indexOf("safari") != -1) {
   return "safari";
 }
 // Konqueror, используется в UNIX-системах
 if (ua.indexOf("konqueror") != -1) {
   return "konqueror";
 }
 return "unknown";
} 

// standart string replace functionality
function str_replace(haystack, needle, replacement) {
	var temp = haystack.split(needle);
	return temp.join(replacement);
}

function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http1;
var nocache=0;

function stop_bottom_slider_scroll()
{
	$("#makeMeScrollable").smoothDivScroll("stopAutoScroll");
}

function start_bottom_slider_scroll()
{
	$("#makeMeScrollable").smoothDivScroll("startAutoScroll");
}

function screenSize() {
      var w, h; // Объявляем переменные, w - длина, h - высота
      w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
      h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
      return {w:w, h:h};
}

//показываем фото с галерее на странице с кухней
function show_kitchen_foto_from_galery(id)
{
	//alert(1)
	cur_big_photo=id;
	for(i=0; i<=a_medium_photo.length-1; i++)
	{
		if(a_medium_photo[i].src==hname+"img_galery/big/"+id+".jpg")
		{
			cur_big_photo_ind=i;
			break;
		}
	}
	$(".ul_preloadbox li").removeClass("upb_photo_a");
	$(".ul_preloadbox li").addClass("upb_photo_p");
	
	document.getElementById("li_bottom_galery"+id).className="upb_photo_a";
	//$("#kitchen_small_photo"+id).css({'display':'none'});
	
	
	$("#kitchen_big_foto").fadeOut(150,function () {
		document.getElementById("kitchen_big_foto").src=hname+"img_galery/big/"+id+".jpg";
		//document.getElementById("kitchen_small_photo"+id).src;
		//document.getElementById("kitchen_medium_foto").src=document.getElementById("kitchen_small_photo"+id).src;
		$("#kitchen_big_foto").fadeIn(150);
	});
	curpreviewimageid=document.getElementById("kitchen_small_photo"+id).alt;
}

//меняем средние фото
function show_prev_medium_photo()
{
	if((cur_big_photo_ind-1)<0)
	{return;}
	
	cur_big_photo_ind=cur_big_photo_ind-1;
	if(cur_big_photo_ind<0)
	{
		cur_big_photo_ind=a_medium_photo.length-1;
	}
	show_kitchen_foto_from_galery(a_medium_photo[cur_big_photo_ind]);
	
	$('#btn_prev_image').trigger('click');  
	
	if(document.getElementById("medium_photo_img_right").style.display=="none")
	{
		//document.getElementById("medium_photo_img_right").style.display="block";
	}
	
}

function show_next_medium_photo()
{
	if((cur_big_photo_ind+1)>=(a_medium_photo.length))
	{return;}
	
	cur_big_photo_ind=cur_big_photo_ind+1;
	if(cur_big_photo_ind>(a_medium_photo.length-1))
	{
		cur_big_photo_ind=0;
	}
	show_kitchen_foto_from_galery(a_medium_photo[cur_big_photo_ind])
	
	if((cur_big_photo_ind+1)<(a_medium_photo.length-1))
	{$('#btn_next_image').trigger('click');}
	
	if((cur_big_photo_ind+1)>=(a_medium_photo.length))
	{
		//document.getElementById("medium_photo_img_right").style.display="none";
	}
	
}

//показываем большое фото
function set_full_photo(kid,pid)
{
	if(cur_big_photo==0)
	{cur_big_photo=pid;}
	wf=window.open(hname+"show_full_photo2.php?w="+w+"&h="+h+"&kitchen_id="+kid+"&photo_id="+cur_big_photo,"FullImgWindow","menubar=0,status=1,toolbar=0,scrollbars=0,fullscreen=0,resizable=1");
	wf.focus();
	return;
}

function set_full_photo1(kid,pid)
{
	if(cur_big_photo==0)
	{cur_big_photo=pid;}
	wf=window.open(hname+"show_full_photo1.php?w="+w+"&h="+h+"&kitchen_id="+kid+"&photo_id="+cur_big_photo,"FullImgWindow","menubar=0,status=1,toolbar=0,scrollbars=0,fullscreen=0,resizable=1");
	wf.focus();
	return;
}

function set_medium_photo()
{
	return
	document.getElementById("kitchen_medium_foto").style.display="none";	
	document.getElementById("kitchen_big_foto").style.display="block";
}

function move_big_image(e)
{
	//document.getElementById("kitchen_medium_foto").style.left=e.pageX+"px";
}

//показываем стрелки на главной в большом слайдере
function show_main_arrow()
{
	$("div.slider-nav span.left").css("display","block");
	$("div.slider-nav span.right").css("display","block");
}
function hide_main_arrow()
{
	$("div.slider-nav span.left").css("display","none");
	$("div.slider-nav span.right").css("display","none");
}


