function menu_hover() {
	var ArrayItemMenu=$('.img_menu');
	ArrayItemMenu.each(function(i) {
		$(this).hover (
			function(){
				var tmpimgurl=$(this).attr('src');
				$(this).attr('src', $(this).attr('rel'));
				$(this).attr('rel', tmpimgurl);
			},
			function() {
				var tmpimgurl=$(this).attr('src');
				$(this).attr('src', $(this).attr('rel'));
				$(this).attr('rel', tmpimgurl);
			}
		);
      });
}
function ViewDetails()
{
	$(".details").click(function () {
		var cur = $(this).parent().next();
		if(cur.css('display') == 'block')
		{
			cur.css('display','none');
		}
		else
		{
			$('.rel-list').css('display','none');
			cur.css('display','block');
		}
    });
	$('#mother').click(function () {
		if($('#mother-tree').css('display') == 'block')
		{
			$('#mother').removeClass('parent-active');
			$('#mother-tree').css('display','none');
			$('#mother-link').css('display','none');
		}
		else
		{
			$('#mother').addClass('parent-active');
			$('#mother-tree').css('display','block');
			$('#mother-link').css('display','block');

			$('#father').removeClass('parent-active');
			$('#father-tree').css('display','none');
			$('#father-link').css('display','none');
		}
    });
	$('#father').click(function () {
		if($('#father-tree').css('display') == 'block')
		{
			$('#father').removeClass('parent-active');
			$('#father-tree').css('display','none');
			$('#father-link').css('display','none');
		}
		else
		{
			$('#father').addClass('parent-active');
			$('#father-tree').css('display','block');
			$('#father-link').css('display','block');

			$('#mother').removeClass('parent-active');
			$('#mother-tree').css('display','none');
			$('#mother-link').css('display','none');
		}
    });
	return false;
}




function showMove_init(){	var ArrayItemVideo=$('.video-link');
	ArrayItemVideo.each(function(i) {
		$(this).click(function(){			ajaxMoveGet($(this).attr('rel'));
			return false;
		});
	});
}

function ajaxMoveGet(rel){	var urlb='/upage/'+rel+'.video.json?json-callback=?';
	$.ajax({
		type: "GET",
		url: urlb,
		dataType: "jsonp",
		jsonp: function (data){
			return data;
		},
		success: function(obj, textStatus){
			showMove(obj.property.value.value);
		}
	});
}


function htmlspecialchars_decode (string, quote_style) {
    var optTemp = 0,
        i = 0,
        noquotes = false;
    if (typeof quote_style === 'undefined') {
        quote_style = 2;
    }
    string = string.toString().replace(/&lt;/g, '<').replace(/&gt;/g, '>');
    var OPTS = {
        'ENT_NOQUOTES': 0,
        'ENT_HTML_QUOTE_SINGLE': 1,
        'ENT_HTML_QUOTE_DOUBLE': 2,
        'ENT_COMPAT': 2,
        'ENT_QUOTES': 3,
        'ENT_IGNORE': 4
    };
    if (quote_style === 0) {
        noquotes = true;
    }
    if (typeof quote_style !== 'number') {
        quote_style = [].concat(quote_style);
        for (i = 0; i < quote_style.length; i++) {
            if (OPTS[quote_style[i]] === 0) {
                noquotes = true;
            } else if (OPTS[quote_style[i]]) {
                optTemp = optTemp | OPTS[quote_style[i]];
            }
        }
        quote_style = optTemp;
    }
    if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
        string = string.replace(/&#0*39;/g, "'");
    }
    if (!noquotes) {
        string = string.replace(/&quot;/g, '"');
    }
    string = string.replace(/&amp;/g, '&');
    return string;
}


function showMove(code) {	console.log('!!! - '+htmlspecialchars_decode(code, 1));
	var move_block = document.createElement('div');
	var move_lock = document.createElement('div');
	var move_close = document.createElement('div');
	var body = document.getElementsByTagName('body');
	body = body[0];
	var leftPosition = (window.document.documentElement.offsetWidth - 980) / 2;
	var topPosition = jQuery(document).scrollTop() + 40;
	move_lock.id = 'dog_move_lock';
	move_block.id = 'dog_move';
	move_close.id = 'dog_move_close';
	move_close.title = 'закрыть';
	move_close.onclick = function() {
		body.removeChild(move_block);
		body.removeChild(move_lock);
	}
	move_block.style.top = topPosition + 'px';
	move_block.style.left = leftPosition + 'px';
	var content;
	move_block.innerHTML = '<table><tr><td>'+htmlspecialchars_decode(code, 1)+'</td></tr></table>';
	move_block.appendChild(move_close);
	body.appendChild(move_lock);
	body.appendChild(move_block);
}



function form_view(){	var formviewstatus=0;
	$('#formviewzakazdog').css('display', 'none');	$('#formview').click(function () {		if (formviewstatus==0) {  			$('#formviewzakazdog').css('display', 'block');
  			$('#formview').html('Скрыть анкету');
  			formviewstatus=1;
  		} else {  			$('#formviewzakazdog').css('display', 'none');
  			$('#formview').html('Хочу щенка');
  			formviewstatus=0;
  		}
	});}






jQuery(function(){
						jQuery(".gallery").jCarouselLite({
							btnNext: ".next",
							btnPrev: ".prev",
							mouseWheel: true,
							visible: 5
						});
						jQuery(".all-gallery").jCarouselLite({
							btnNext: ".next",
							btnPrev: ".prev",
							mouseWheel: true,
							visible: 4
						});
						jQuery(".champ-gallery").jCarouselLite({
							btnNext: ".next_ch",
							btnPrev: ".prev_ch",
							mouseWheel: false,
							visible: 3
						});
						jQuery(".champ-no-slyder").jCarouselLite({
							btnNext: ".next_ch",
							btnPrev: ".prev_ch",
							mouseWheel: false,
							visible: 3
						});
						jQuery("div.champ-gallery ul li, div.champ-no-slyder ul li").css('overflow','visible').css('height','auto');

});

$(document).ready(function() {
	$("a.lightbox").fancybox({
		'onComplete'	:	function() {
				$("#fancybox-wrap").hover(function() {
					$("#fancybox-title").show();
				}, function() {
					$("#fancybox-title").hide();
				});
		},
		'titlePosition' : 'over'
	});

	$("a#inline").fancybox({
		'hideOnContentClick': true
	});

	$("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600,
		'speedOut'		:	200,
		'overlayShow'	:	false
	});
	menu_hover();
	ViewDetails();
	showMove_init();
	form_view();
	/*
	$( "#dialog" ).dialog({		'autoOpen' : false	});
    $(".opisanie").css('height','80px').css('overflow-y','hidden').mouseover(function(){    	if($(this).html()!=""){
    	    $(this).css('cursor','pointer');
    	    $(this).click(function(){    	    	$("#dialog").html($(this).html());    	    	$("#dialog").dialog("open");
    	    });
    	}
    });
    */
    $(".opisanie").css('height','80px').css('overflow-y','hidden').mouseover(function(){    	if($(this).html()!=""){
    	    $(this).css('cursor','pointer');
    	    $(this).toggle(function(){    	    	$(this).css('height','auto');
    	    },function(){    	   		$(this).css('height','80px');    	    });
    	}
    });
});
