function switchCookies () {
   if (((myReadCookie ('sessionid') != null) || (myReadCookie ('visitorid') != null)) && (myReadCookie ('dotCookies') != 'success')) {
      if (jQuery.browser.msie) {
         myCreateCookie ('sessionid', myReadCookie ('sessionid'), 365, '/', window.location.hostname);
         myCreateCookie ('visitorid', myReadCookie ('visitorid'), 365, '/', window.location.hostname);
      } else {
         myEraseCookie ('sessionid', '/', window.location.hostname);
         myEraseCookie ('visitorid', '/', window.location.hostname);
      }
      myCreateCookie ('dotCookies', 'success', 365, '/', window.location.hostname);
      window.location.reload ();
   } else if (myReadCookie ('dotCookies') != 'success'){
      myCreateCookie ('dotCookies', 'success', 365, '/', window.location.hostname);
   }
}

function bonusCookies (obj) {
	if (obj) {
		if (obj.checked) {
			myCreateCookie ('bonus', 1, 365, '/basket/', window.location.hostname);
		} else {
			myCreateCookie ('bonus', 0, 365, '/basket/', window.location.hostname);
		}
	} else if (myReadCookie ('bonus') == null || myReadCookie ('bonus') == 1) {
		$('#bonus').attr("checked", true);
		myCreateCookie ('bonus', 1, 365, '/basket/', window.location.hostname);
	} 
}

function myCreateCookie(name,value,days,path,domain) {
   if (days) {
      var date = new Date();
      date.setTime(date.getTime()+(days*24*60*60*1000));
      var expires = "; expires="+date.toGMTString();
   }
   else var expires = "";
   document.cookie = name+"="+value+expires+"; path="+path+"; domain="+domain;
}
function myReadCookie(name) {
   var nameEQ = name + "=";
   var ca = document.cookie.split(';');
   for(var i=0;i < ca.length;i++) {
      var c = ca[i];
      while (c.charAt(0)==' ') c = c.substring(1,c.length);
      if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
   }
   return null;
}
function myEraseCookie(name, path, domain) {
   if (myReadCookie(name)) {
      document.cookie = name + "=" +
         ((path) ? "; path=" + path : "") +
         ((domain) ? "; domain=" + domain : "") +
         "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

switchCookies ();


// tooltips
function simple_tooltip(target_items, name){
	$('.tool2del').remove();
	$(target_items).each(function(i){
		if ($(this).attr('oldtitle') && !$(this).attr('title')) $(this).attr('title', $(this).attr('oldtitle'));
		$("body").append("<div class='"+name+" tool2del' id='"+name+i+"'><p>"+($(this).attr('alt')?"<span>"+$(this).attr('alt')+"</span><br/>":"")+$(this).attr('title')+"</p></div>");
		var my_tooltip = $("#"+name+i);
		$(this).attr('oldtitle', $(this).attr('title')).removeAttr("title").mouseover(function(){
				my_tooltip.css({opacity:1, display:"none"}).fadeIn(150);
		}).mousemove(function(kmouse){
					if (new String (document.location.href).search (/checkout2.inc.php|delhowmuch/) > -1) {
						my_tooltip.css({left:kmouse.pageX - 160 
										+ Math.max(0, 160 - kmouse.pageX)//left offset
										- Math.max(0,  160 + 10 + kmouse.pageX - $(window).width())//right offset
									, top:kmouse.pageY-50});
									
					} else if (new String (document.location.href).search (/regedit|register|checkout|guru/) > -1) {
						my_tooltip.css({left:kmouse.pageX - 160 
										+ Math.max(0, 160 - kmouse.pageX)//left offset
										- Math.max(0,  160 + 10 + kmouse.pageX - $(window).width())//right offset
									, top:kmouse.pageY+20});
					} else {
						my_tooltip.css({left:kmouse.pageX + 15 
									, top:kmouse.pageY+15});
					}
		}).mouseout(function(){
				my_tooltip.fadeOut(150);
		});
	});
}
// end of tooltips
function ltrim(str) {
	   str = str.replace(/(^ *)/,"");
	   return str;
	   }
// Bukvica
(function($){
$.fn.miniature = function(options) {
var defaults = {
color:null,
float:null,
fontSize:null
};
return this.each(function() {
var html = $("<div />");
var doit=false;
$.each($(this).get(0).childNodes, function(i, o) {
if (o.nodeName=='A' && doit==false)
	doit=true;
if(o.nodeType == 3 && doit==false) { //text node
var text = ltrim($(o).text());
var regexp = /[A-Za-z0-9а-яА-Я]/gi;
if((text.length > 0) && (regexp.exec(text.charAt(0))!=null)) {
	var regexp_numeric= /[0-9]/gi;
	if (regexp_numeric.exec(text.charAt(0))) {
		//если первая цифра число, то все немного иначе
		var num='';
		var l=0;
		finder: for (i=0;i<text.length;i++) {
			regexp_numeric= /[0-9]/gi;
			if (regexp_numeric.exec(text.charAt(i))) {				
				num=num + text.charAt(i);
				l++;
			} else {
				break finder;
			}
		}
		var first = "<span class='-jquery-miniature -jquery-miniature-"+num.toLowerCase()+"'>"+num+"</span>";
		html.append(first + text.substr(l));
	} else {
		var first = "<span class='-jquery-miniature -jquery-miniature-"+text.charAt(0).toLowerCase()+"'>"+text.charAt(0)+"</span>";
		html.append(first + text.substr(1));
	}
	doit=true;
} else {
	html.append($(o).clone());	
}
}
else
html.append($(o).clone());
});
$(this).html(html.html());
});
};
})(jQuery);
// end of Bukvica


function CycleBan (name) {
	visible = $("#"+name+" li:visible");
	hidden = visible.next().first();
	if (0==hidden.length) hidden=$("#"+name+" li:first");
	visible.fadeOut('slow');
	hidden.fadeIn('slow');
/*	if ($("#"+name+" li:visible:first + li").length == 0) {
		$("#"+name+" li:hidden:first").fadeIn('slow');
		$("#"+name+" li:visible:last").fadeOut('slow');
	} else {
		$("#"+name+" li:visible:first + li").fadeIn('slow');
		$("#"+name+" li:visible:first").fadeOut('slow');
	}*/
}
function RotateBan (rotate) {
	if (rotate) {
		jQuery.each($ (".rotate"), function() { 
			if ($("#"+this.id+" li").length > 1) CycleBan(this.id);
		});
	}
	setTimeout("RotateBan (1)","10000");
}

function fancyToPictures(){
	if(0!=$("a.location").length){$("a.location").fancybox({'width':782,'height':658,'SpeedIn':0,'SpeedOut':0,'padding':0,'centerOnScroll':false,'onCleanup':fancyVideoClose /* 20110603,'onStart':function(a,d,o){o.href=fancyLocationHack(a)}*/ })};
	if(0!=$("a.pcards").length){$("a.pcards").fancybox({'width':420,'height':645,'padding':0,'centerOnScroll':false})};
}
function mwheelCarScroll(carInst){
	return mwheelCarScrollAll('div.jcarousel-container',carInst);	
}

function mwheelCarScrollAll(id,carInst){
jQuery(id).bind('mousewheel',function(event,delta){
if(delta>0){var tmp=carInst.options.scroll;carInst.options.scroll=1;carInst.options.animation='normal';carInst.prev();carInst.options.scroll=tmp;
}else{var tmp=carInst.options.scroll;carInst.options.scroll=1;carInst.options.animation='normal';carInst.next();carInst.options.scroll=tmp;}
return false;});
}

fsFirstPingDone=0;
function fsTimerPing (page,url){fsFirstPingDone=1;$.ajax({type:'post',url:'/ajax/timer.php',cache:false,data:'page='+page+'&url='+url});}

function fancyVideoClose(){
	$('#fancy_frame').contents().find('#fancy_frame').contents().find('#forvideo').html('');$('#fancy_frame').contents().find('#forvideo').html('');
	$('#fancybox-frame').remove();
}
function fancyLocationHack(a,o){
	tmpChar = (a[0].href.indexOf('?')>=0) ? '&' : '?';
	if (a[0].className.indexOf("selfhost") >= 0) {
		var new_href = new String (a[0].href).replace(/(http\:\/\/)([\w-.]+)(\w*?)/, "$3");
		return(new_href+tmpChar+'location=1');
	} else {
		return(a[0].href+tmpChar+'location=1');
	}
	return(true);
}

// add to bookmarks
function add_favorite(a){
    if (document.all) {
        window.external.AddFavorite("http://www.flower-shop.ru/", "Flower-shop.ru - Служба доставки цветов");
	}
    return false;
}

$(document).ready(function(){
//	$("div.i_pic img").fadeIn("slow");
//	$(".b_item img, .layer img").fadeIn("slow");

	fancyToPictures();
	bonusCookies ();

	if(0!=$("#email_id").length){$("#email_id").focus();};

	if(0!=$("#gal-carousel").length){$("#gal-carousel").jcarousel({scroll:3,initCallback:mwheelCarScroll});};

	simple_tooltip(".ttip","tooltip");

	if (0 != $(".bukvica").length) {
		$(".bukvica p:first").miniature();
		$(".bukvica p.let").miniature();
	};

	$.fn.fancyboxClose = function () {
		var original = $.fn.fancybox.close;
		var obj = this;
		$.fn.fancybox.close = function () {
			$(obj).parents('.onfocus').not('.disabled').find('.ttip_hidden').trigger("ToogleTooltip", [true]);
			original();
		}
		$(this).bind ('click', function (e) {
			$(this).parents('tr').find('.ttip_hidden').trigger("ToogleTooltip", [false]);
		});
		return this;
	}
	showIframe = function() {
		$(".fancy_loading").hide();
		$("#fancy_frame").show().fadeIn ("normal", function () {
			var doc;
			if( this.contentDocument ) // For NS6
				doc = this.contentDocument;
			else if( this.contentWindow ) // For IE5.5 and IE6
				doc = this.contentWindow.document;
			else if( this.document ) // For IE5
				doc = this.document;
			else //other browser
				doc = this.document;
			if (doc && doc.getElementById ('email_id')){
				doc.getElementById('email_id').focus()
			}
		});
	};

	if(0!=$("a.group").length){$("a.group").fancybox({'SpeedIn':400,'SpeedOut':400,'centerOnScroll':false,'titlePosition':'inside','cyclic':true})};
	if(0!=$("a.angles").length){$("a.angles").fancybox({'SpeedIn':400,'SpeedOut':400,'padding': 0,'centerOnScroll':false,'cyclic':true})};
	if(0!=$("a.angles-pop").length){$("a.angles-pop").fancybox({'SpeedIn':0,'SpeedOut':0,'padding': 0,'cyclic':true})};
	if(0!=$("a.inline_flash").length){$("a.inline_flash").fancybox({'width':593,'height':376,'padding':0,'centerOnScroll':false,'onCleanup':fancyVideoClose,'onStart':function(a,d,o){o.href=fancyLocationHack(a)}})};
	if(0!=$("a.inline_flash_section").length){$("a.inline_flash_section").fancybox({'width':593,'height':376,'padding':0,'centerOnScroll':false,'onCleanup':fancyVideoClose})};
	if(0!=$("a.inline_flash_youtube").length){$("a.inline_flash_youtube").fancybox({'width':593,'height':343,'padding':0,'centerOnScroll':false,'onCleanup':fancyVideoClose,'onStart':function(a,d,o){o.href=fancyLocationHack(a)}})};
		if(0!=$("a.youtube_clear").length){$("a.youtube_clear").fancybox({'width':696,'height':401,'padding':0,'centerOnScroll':false,'onCleanup':fancyVideoClose})};
	if(0!=$("a.fancytext").length){$("a.fancytext").fancybox({'width':695,'height':470,'padding':15,'centerOnScroll':false}).addClass("processed").fancyboxClose()};
	if(0!=$("a.fancytexta").length){$("a.fancytexta").fancybox({'width':500,'height':160,'padding':15,'centerOnScroll':false})};
	if(0!=$("a.fancytextf").length){
		$("a.fancytextf").each(function(index) {
			var href=$(this).attr('href');
			href=href.replace('catalog-cvetov/','flpopup/small_');
			if (href!='')
				$(this).fancybox({'href':href,'width':685,'height':292,'padding':15,'centerOnScroll':false});
		});
	};
	if (0 != $("a#qorder").length) {
		$("a#qorder").fancybox({
			hideOnContentClick: false,
			hideOnOverlayClick: false,
			showCloseButton: false,
			centerOnScroll: false
		});
	};
	if(0!=$("a.fancycalc").length && window.location.hostname == '8marta.flower-shop.ru'){$("a.fancycalc").fancybox({'width':510,'height':188,'padding':0,'centerOnScroll':false})
	} else if(0!=$("a.fancycalc").length){$("a.fancycalc").fancybox({'width':510,'height':203,'padding':0,'centerOnScroll':false})};
	if(0!=$("a.callme").length){$("a.callme").fancybox({'width':450,'height':215,'padding':0,'centerOnScroll':false})};
	if(0!=$("a.fancylit").length){$("a.fancylit").fancybox({'width':285,'height':240,'padding':20,'centerOnScroll':false})};
	if(0!=$("a.pic3d").length){$("a.pic3d").fancybox({'width':392,'height':500,'padding':0,'centerOnScroll':false,'onCleanup':fancyVideoClose,'onStart':function(a,d,o){o.href=fancyLocationHack(a)}})};

	//$(".moretext > div").hide();
	//$(".moretext h3").next("p").append('<span class="green dotted">Далее...</span>');
	//$(".moretext p").click(function(){
	//	$(this).next("div").slideDown("fast")
	//	.siblings("div:visible").slideUp("fast");
	//	$(this).addClass("active");
	//	$(this).siblings("p").removeClass("active");
	//});

	$('.filter ul ul').hide();
	$('.filter li p').click(function(){$(this).next().slideToggle('normal');$(this).addClass("opened");/*$(this).siblings("p").removeClass("opened");*/});

	RotateBan(0);

	(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(!g.colorInit){g.start=c(g.elem,e);g.end=b(g.end);g.colorInit=true}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);
	jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('<div class="wiggle-wrap"></div>').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"+="+o.travel},o.speed).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};

	if ((0 != $('.addthis_toolbox').length) && ('undefined' == typeof AddThisScript)) {
		var AddThisScript = document.createElement('script');
		AddThisScript.src = 'http://s7.addthis.com/js/250/addthis_widget.js#username=flowershopru';
		document.documentElement.firstChild.appendChild(AddThisScript);
	}

	
	if(0!=$("#vk_like").length){
		$.getScript('http://userapi.com/js/api/openapi.js?29', function() {
			if (window.location.hostname == 'www.flower-shop.ru') {
				VK.init({apiId: 2269069, onlyWidgets: true});	
				VK.Widgets.Like("vk_like", {type: "button"});
			}
			if (window.location.hostname == 'www.driedflowers.ru') {
				VK.init({apiId: 2324574, onlyWidgets: true});	
				VK.Widgets.Like("vk_like", {type: "button"});
			}
			if (window.location.hostname == 'ny.flower-shop.ru') {
				VK.init({apiId: 2340423, onlyWidgets: true});	
				VK.Widgets.Like("vk_like", {type: "button"});
			}
			if (window.location.hostname == 'www.wedflowers.ru') {
				VK.init({apiId: 2340420, onlyWidgets: true});	
				VK.Widgets.Like("vk_like", {type: "button"});
			}				
			if (window.location.hostname == 'decor.flower-shop.ru') {
				VK.init({apiId: 2340425, onlyWidgets: true});	
				VK.Widgets.Like("vk_like", {type: "button"});
				// VK.Widgets.Like("vk_like", {type: "button", pageUrl: "", pageImage: "", pageTitle: "", pageDescription: ""});
			}
				/*
				if ('undefined' != typeof vk_is_wish) {
					$.getScript('http://vkontakte.ru/js/api/merchant.js?13', function() {
  						$('#vkwish').html(VK.Merchant.wishbutton(prepareOrder));	
					});
				}
				*/
			});
		}
/*
	if ('function' == typeof paymentOrder) {
		$.getScript('http://userapi.com/js/api/openapi.js?26', function() {
			$.getScript('http://vkontakte.ru/js/api/merchant.js?13', function() {
				$('#vkpay').html(VK.Merchant.button(paymentOrder));	
			});
		});
	}
*/
	if(0!=$("#plus_one").length){
		$.getScript('https://apis.google.com/js/plusone.js', function() {
			$("#plus_one").append("<g:plusone size='medium'></g:plusone>");
		});
	}

	if (0 != $(".namedays-text").length) {
		$('.namedays-text').find('b:first').addClass('ruslan');
	}
	if(0 != $(".link_to_product").length){
		var href='';
		var img=new Array();
		var marketname='';
		var text='';
		var classname='';
		var paragraph='';
		var obj=null;
		//преобразовываем картинки у статей в красивые картинки
		$('.link_to_product').each(function(index) {
			//Получаем ссылку на объект
			href=$(this).attr("href");
			img[0]=$(this).find('img').attr("src");
			img[1]=$(this).find('img').attr("width");
			img[2]=$(this).find('img').attr("height");
			img[3]=$(this).find('img').attr("align");
			if (img[3]=='right') {
				classname=' rt';
			} else {
				classname='';
			}
			marketname=$(this).find('img').attr("alt");
			text='<div class="caption' + classname + '"><a href="' + href + '" title="' + marketname + '"><img alt="' + marketname + '" src="' + img[0] + '" height="' + img[2] + '" width="' + img[1] + '" alt="' + marketname + '" /></a><p>' + marketname + '</p></div>';
			obj=$(this).parent();
			if ($(obj).get(0).tagName=='P') {
			//удаляем ссылку
				$(this).remove();	
				paragraph=$(obj).html();
				text=text + '<p>' + paragraph + '</p>';
				$(obj).replaceWith(text);
			} else {
				$(this).replaceWith(text);
			}
		});
	}
	
	//20111110 доработка формы выборки товаров для веддинга
	if ($('#frmwedding').length==1) {
		$('#price').change(function() {
			if ($(this).val()!='999999') {
				//дизейблим
				$("#price_low").attr("disabled","disabled");
				$("#price_high").attr("disabled","disabled");
				if (!$("#price_low").hasClass("disabled"))
					$("#price_low").addClass("disabled");
				if (!$("#price_high").hasClass("disabled"))
					$("#price_high").addClass("disabled");				
			} else {
				//показываем
				$("#price_low").removeAttr("disabled");
				$("#price_high").removeAttr("disabled");
				$("#price_low").removeClass("disabled");
				$("#price_high").removeClass("disabled");				
			}
		});
		//только если мы на веддинге
		$('#frmwedding').submit(function() {
			var url='/livesearch/#s=51&page=1&sort=newdown';
			var i=0;
			$('#frmwedding select').each(function(index) {
				if ($(this).attr('name')!='' && $(this).attr('name')!='price') {
					url = url + '&';						
					if ($(this).val() == 0) {
						url=url + $(this).attr('name') + '=0';
					} else {
						url=url + $(this).attr('name') + 'a' + $(this).val() + '=on';
					}
					i++;
				} else if ($(this).attr('name')=='price') {
					switch ($(this).val()) {
						case '0':
							url=url + '&price_low=1000&price_high=40000';
							break;
						case '1':
							url=url + '&price_low=1000&price_high=2000';
							break;
						case '2':
							url=url + '&price_low=2000&price_high=3000';
							break;
						case '3':
							url=url + '&price_low=3000&price_high=4000';
							break;
						case '4':
							url=url + '&price_low=4000&price_high=5000';
							break;
						case '5':
							url=url + '&price_low=5000&price_high=40000';
							break;
						case '999999':
							var price_low=1000;
							if ($("#price_low").val()!='') {
								pl=parseFloat($("#price_low").val());
								if (!isNaN(pl))
									price_low=pl;								
							}
							var price_high=40000;
							if ($("#price_high").val()!='') {
								ph=parseFloat($("#price_high").val());
								if (!isNaN(ph))
									price_high=ph;
							}									
							url=url + '&price_low=' + price_low + '&price_high=' + price_high;
							break;
					}
				}
			});
			location.href=url;
			return false;
		});	
	}
});

$(window).load(function(){
	if ('function' == typeof showGoogle) {showGoogle()};
	$("#leave_comment span").click(function(){$("#leave_comment_form").slideDown("slow");});
	$("#show_order_data").toggle(function(){$("#view_order_data").slideDown("slow");$("#show_order_data").html("Скрыть информацию по заказу");},
	function(){$("#view_order_data").slideUp("slow");$("#show_order_data").html("Показать информацию по заказу");});
	// funcLinkAlert = jAlert;
	$(".popup.item").show("slow");
});

/* 20111213 функции по работе с видео вынесены в отдельный файл */
function ytPlayVideo(div){
	$('.youtube-page img').hide();						
	utPlayer=$('#ytvideo')[0];
	$(utPlayer).show();
}
function onYouTubePlayerReady(playerId){
	utPlayer.addEventListener('onStateChange','onYouTubePlayerStateChanged');
	utPlayer.playVideo();
}
function onYouTubePlayerStateChanged(){					
	if (0==utPlayer.getPlayerState()){
		$('.youtube-page img').show();						
		utPlayer=$('#ytvideo')[0];
		$(utPlayer).hide();							
	}
	/* 20111229 if (3==utPlayer.getPlayerState()){
		utPlayer.setPlaybackQuality('large');
	}*/
}

