function image(url)
     {
     url='pic.php?url='+url;
     window.open(url,"_blank","alwaysRaised=yes,top=20,left=20,menubar=no,resizable=no,scrollbars=no,status=no");
     }

function show_cart()
     {
      win=window.open("index.php?w=basket", "basket","alwaysRaised=yes,top=20,left=20, width=750, height=600, menubar=no,resizable=yes,scrollbars=yes,status=no");
      win.focus();
     }


function OpenBasket(){
        win=window.open("index.php?w=basket", "basket","alwaysRaised=yes,top=20,left=20, width=750, height=600, menubar=no,resizable=yes,scrollbars=yes,status=no");
        win.focus();
}
//function cursor(name)
//    {
//    event.srcElement.style.cursor = name;
//    }
function changbask()
{
    $('#basket').load('left_basket.php');
}
function add_item(id)
     {
 //     if (document.all['qty'] != undefined)
 //         {qty=document.all['qty'].value;}
  //    else
      qty=1;
//      color='';
//      color_obj=document.item_frm.color;
//      if (color_obj)
//          {color=color_obj[color_obj.selectedIndex].value;}
      win=window.open("index.php?w=basket&lang=<?=$LANG?>&add="+id+"&qty="+qty, "basket","alwaysRaised=yes,top=20,left=20,width=750,height=600, menubar=no,resizable=yes,scrollbars=yes,status=no");
      win.focus();
     }
function info(id, show_flag)
     {
      win=window.open("index.php?hide_flag="+(1-show_flag)+"&w=item_info&id="+id,"_blank","alwaysRaised=yes,top=20,left=20,width=700,height=600,menubar=no,resizable=yes,scrollbars=yes,status=no");
      win.document.bgColor = '#EDE8DE';
      win.focus();
     }
function url(url) {document.location=url;}

function wscroll()
    {
     obj=document.getElementById('right_banners');
     obj.style.top=document.body.scrollTop+35;
    }

var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject()
{
 var xmlHttp;
 xmlHttp = false;
 if (window.ActiveXObject)
 {
  try
  { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e)
  { xmlHttp = false; }
 }
 else
 {
  try
  { xmlHttp = new XMLHttpRequest(); }
  catch (e)
  { xmlHttp = false; }
 }
 if (!xmlHttp) alert("Error in create XMLHttpReqest object!");
 else return xmlHttp;
}

function view_dir(element)
{
 if (xmlHttp)
 {
  try
  {
   xmlHttp.open("GET", "read_directories.php?cur_path="+element.innerHTML, true);
   xmlHttp.onreadystatechange = handleRequestStateChange;
   xmlHttp.send(null);
  }
  catch (e)
  { alert("Невозможно соединиться с сервером:\n"+e.toString()); }
 }
}

function handleRequestStateChange()
{
 if (xmlHttp.readyState == 4)
 {
  if (xmlHttp.status == 200)
  {
   try
   { handleServerResponse(); }
   catch (e)
   { alert("Ошибка чтения ответа сервера:\n"+e.toString()); }
  }
  else
  { alert("Возникли проблемы при получении данных:\n"+xmlHttp.statusText); }
 }
}

function handleServerResponse()
{
 element = document.getElementById("divOut");
 var response = xmlHttp.responseText;
 element.innerHTML = response;
}
function setPointer(theRow, theRowNum, theAction, thenewColor)
{
//alert('here');
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if (typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3



    // 5. Sets the new color...
//    if (thenewColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', thenewColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = thenewColor;
            }
        }
//    } // end 5

    return true;
} // end of the 'setPointer()' function


//Удаление куки по имени
function DelCookie (name)
{
      document.cookie = name + "=" + ";       path=/; expires=Mon, 02-Jan-2005 00:00:00 GMT";
}
 
//Ещё одна ф-ция необходимая для работы
//Получение позиции символа
function strpos( haystack, needle, offset)
{
    var i = haystack.indexOf( needle, offset );
    return i >= 0 ? i : false;
}
 
//Удаляем все куки
function FullClearCookie ()
{
    allcoockies = document.cookie.substring(0, document.cookie.length)+';';
    while (allcoockies)
    {
        var spos = strpos(allcoockies, ';',0);
        var val = allcoockies.substr(0, spos);
        allcoockies = allcoockies.substr(spos+2, allcoockies.length);
        coockie_param = val.substr(0, strpos(val, '=',0));
    //    if (coockie_param.toUpperCase() != 'PHPSESSID')
        {
            DelCookie (coockie_param);
            document.location.reload();
        }
    }
}

//Category Slide Text
$(document).ready(function(){
    $(".article-button").click(function(){
        $("#cat-slide-text").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });
});
$(document).ready(function(){
    $(".dostijenia").click(function(){
        $("#dostijenia-slide-text").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });
});
//Brand - Clients
$(document).ready(function(){
    $(".brand-block img").click(function(){
        $(this).next().fadeIn("slow");
    });
	$(".prewievs img").click(function(){
        $(this).next().fadeIn("slow");
    });
	$(".diploms img").click(function(){
        $(this).next().fadeIn("slow");
    });
	$(".photo-list img").click(function(){
        $(this).next().fadeIn("slow");
    });
	$(".brand-block-big").click(function(){
        $(this).fadeOut("slow");
    });
	$(".brand-block-bigg").click(function(){
        $(this).fadeOut("slow");
    });
	
});

//Form Slide
$(document).ready(function(){
    $(".form-slide-button").click(function(){
        $(".form-slide").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });
});

//Media
/*$(document).ready(function(){
	$('.media').media();
});*/

//1024
/*$(document).ready(function(){
	
	$(window).resize(function () {
		var width = $('body').outerWidth();
        if($(window)<1000)
		$('html').css("max-width","996px").css("position","fixed");
		
    });
});*/
//Metod
$(document).ready(function(){
$(".metod span").click(function(){
        $(this).next().fadeIn("slow").css("display","block");
    });
	$(".metod-main").click(function(){
        $(this).fadeOut("slow").css("display","none");
		
    });
	
	/*$("div:not(.metod)").click(function(){
		if($(".metod-main").css("display","block")){
        $(".metod-main").css("display","none");
		}
    });*/
	
	
});

//Checklist
$(document).ready(function(){
$('.vote-name input[type="radio"]').ezMark({checkboxCls: 'ez-checkbox', checkedCls: 'ez-checked'});
});

//Maps
$(document).ready(function(){
	function getScrollY()
{
scrollY = 0;
if (typeof window.pageYOffset == "number") {
scrollY = window.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop) {
scrollY = document.documentElement.scrollTop;
} else if (document.body && document.body.scrollTop) {
scrollY = document.body.scrollTop;
} else if (window.scrollY) {
scrollY = window.scrollY;
}
return scrollY;
}
function getInnerHeight()
{
height = 0;
if (window.innerHeight) {
height = window.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
height = document.documentElement.clientHeight;
} else if (document.body && document.body.clientHeight) {
height = document.body.clientHeight;
}
return height;
}
	

$(".map-block img").click(function(){
	var h=getInnerHeight();
	var scrol=getScrollY();
	var hel=$('.map-big-block').outerHeight();
	var hzoom=((h-hel)/2)+scrol;
	var hend=hzoom-130;
        $(this).next().fadeIn("slow").css("display","block").css("top",hend);
    });
	$(".map-x").click(function(){
        $('.map-big-block').fadeOut("slow").css("display","none");
    });
	
/*if($('.map-big-block').css("display","block")){
$(document).keyup(function(event){
if (event.keyCode == 27) {
$('.map-big-block').css("display","none");
}
});
}*/

});

//Player
/*$(document).ready(function(){
	$(".play-close img").live("click",function(){
		$("#sb-container").css("display","block").css("visibility","visible");
	});
	$(".flv-x").live("click",function(){
		$("#sb-container").css("display","none").css("visibility","hidden");
	});
});*/
