$(document).ready(function(){

     $('#pcont').load('data/contacts_inc.html');

         	if ($('#accordionsearch').length) {
            $("#accordionsearch").load("data/accordionsearch.html");
		}


	$(".accordion h3:first").addClass("active");
	$(".accordion div:not(:first)").hide();

	$(".accordion h3").click(function(){
		$(this).next("div").slideToggle("fast")
		.siblings("div:visible").slideUp("fast");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});


		$(".menu li, .menuv li").click(function(){
	 	    if($(this).attr("id")!='nourl'){
    		window.location=$(this).find("a").attr("href");}
    		return false;
		});

	    $('.menuv ul li').hover(
        function() {
            $(this).addClass("active");
            $(this).find('ul').stop(true, true);
            $(this).find('ul').slideDown();
        },
        function() {
            $(this).removeClass("active");
            $(this).find('ul').slideUp('fast');
        });

$('#carton,#cart').live('click', function() {
    var popID = 'popup';

   $('#' + popID).fadeIn().css({ 'width': Number( 700 ) });

    var popMargTop = ($('#' + popID).height() + 80) / 2;
    var popMargLeft = ($('#' + popID).width() + 80) / 2;

    $('#' + popID).css({
        'margin-top' : -300,
        'margin-left' : -popMargLeft
    });
    $('body').append('<div id="fade"></div>');
    $('#fade').css({'filter' : 'alpha(opacity=50)'}).fadeIn();

    $("#popup").load("data/cart.html");

    return false;
	});

$('a.poplight[href^=#]').live('click', function() {
    var popID = $(this).attr('rel');
    var popURL = $(this).attr('href');

    var query= popURL.split('?');
    var dim= query[1].split('&');
    var popWidth = dim[0].split('=')[1];
    var popFile = dim[1].split('=')[1];

   $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) });

    var popMargTop = ($('#' + popID).height() + 80) / 2;
    var popMargLeft = ($('#' + popID).width() + 80) / 2;

    $('#' + popID).css({
        'margin-top' : -300,
        'margin-left' : -popMargLeft
    });
    $('body').append('<div id="fade"></div>');
    $('#fade').css({'filter' : 'alpha(opacity=50)'}).fadeIn();

    $("#popup").load("data/"+popFile+".html");


    return false;
	});


	$('a.close, #fade').live('click', function() {
	if($(this).attr('id')=='isclosesave') {
		if(confirm('Для сохранения окончательных изменений/очищения заказа (корзины) нужно нажать «Сохранить заказ/данные». Выйти без сохранения текущего заказа?')) {
	    $('#fade , .popup_block').fadeOut(function() {
	        $('#fade, a.close').remove();
	    });
	    }
	 } else {	    $('#fade , .popup_block').fadeOut(function() {
	        $('#fade, a.close').remove();
	    });	 }
    return false;
	});

	$("#normativ").load("data/normativ.html");

	$("#normativ350").load("data/normativ350.html");

//	$("#wood").load("data/wood.html");
	$("#wood").load("data/dnop.html");

//	$('#normativ,#normativ350').click(function(e){
	$('#normativ').click(function(e){
    		window.location.href='http://normativ.ua';
            return false;
	});

	$('#wood').click(function(e){
//    		window.location.href='http://build.org.ua/wood';
    		window.location.href='http://dnop.com.ua/ot/judiciarys.htm';
            return false;
	});

//alert('!');


}); //end  ready


    function SetCookie() {
  var name=arguments[0];
  var value=arguments[1];
  if (arguments.length==3) {
 	expires = new Date();
 	    if (value=='del')
        expires.setDate(expires.getDate() - 100);
        else
   		expires.setDate(expires.getDate() + arguments[2]);
    expires = expires.toUTCString();
  }  else  {
 	expires = new Date();
    expires.setDate(expires.getDate() + 365);
    expires = expires.toUTCString();
  }

    document.cookie = name + "=" + escape(value) + "; expires="+expires+"; path=/; ";

}




        function GetCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}


