$(document).ready(function(){

	//$(document).pngFix();
	$('#logo').ifixpng(); 
	$('h2').ifixpng();
	//$('.play').ifixpng();
	
	var $el1 = $('.image_list_1 img.border_image');
	var $pl1 = $('.image_list_1 .play');
	var $el2 = $('.image_list_2 img.border_image');
	var $pl2 = $('.image_list_2 .play');
	
	$pl1.css('margin-top', '6px');
	$pl2.css('margin-top', '6px');
	$pl1.hide();
	$pl2.hide();
	
	$('img.border_image').parent().mouseover(function(){
		//$(this).find('.play').show();
	})
	$('img.border_image').parent().mouseout(function(){
		//$(this).find('.play').hide();
	});
	
	var $width1 = $el1.width();
	var $height1 = $el1.height();
	var $p_width1 = $pl1.parent().width();
	var $p_height1 = $el1.parent().height();		

	var $width2 = $el2.width();
	var $height2 = $el2.height();
	var $p_width2 = $pl2.parent().width();
	var $p_height2 = $el2.parent().height();		
	
	
	/*
	var $width3 = $el3.width();
	var $height2 = $el3.height();
	var $p_width3 = $pl3.parent().width();
	var $p_height3 = $el3.parent().height();		
	*/
	
	$pl1.width($p_width1);
	$pl1.height($height1);
	$pl2.width($p_width2);
	$pl2.height($height2);
	//$pl3.width($p_width3);
	//$pl3.height($height3);


	var $el3 = $('.gallery_links img.border_image');
	var $pl3 = $('.gallery_links .play');
	
	$pl3.hide();
	
	var $width3 = $el3.width();
	var $height3 = $el3.height();
	
	$pl3.css('margin-top', '3px');
	$pl3.css('margin-left', '3px');
	$pl3.width($width3);
	$pl3.height($height3);
	//alert($width3 + ' ' + $height3);
	

	var $select = $('.selectable');
	$select.change(function(){
		var $opt = $('selectable option:selected');
		var $val = $(this).val();
		var $id = $(this).attr('id');
		var $comment = $(this).parent().next();
		if ($id=='grooming' && $val==-5
			|| $id == 'service_procedure' && $val == -5
			|| $id == 'safety_procedure' && $val == -10
			|| $id == 'eurasia' && $val == 'yes')
		{
			$comment.removeClass('selectable_comment');
		}
		else{
			$comment.addClass('selectable_comment');
		}
		
		
	});
	//.trigger('change');
	
	/*
	var $selectable = $('.selectable option');
	
	$selectable.click(function(){
		var $val = $(this).val();
		var $parent = $(this).parent();
		var $parentId = $parent.attr('id');
		var $comment = $parent.parent().next();
		alert('aa');
		
		if ($parentId == 'grooming' && $val == -5
			|| $parentId == 'service_procedure' && $val == -5
			|| $parentId == 'safety_procedure' && $val == -10
			|| $parentId == 'eurasia' && $val == 'yes'
		){
			$comment.removeClass('selectable_comment');
		}
		else{
			$comment.addClass('selectable_comment');
		}
	
	});
	*/	
	
	
	/*
	$('.selectable').bind('mouseup', function(e){
		//var $opt = $(this).find('option');
		var $val = $(this).val();
		var $id = $(this).attr('id');
		var $parent = $(this).parent();
		var $comment = $parent.next();
		//alert($id);
		if ($id == 'grooming' & $val == -5){
			
		}
	});
	*/
	//$('label.comment').hide();
	/*
	$('select').bind("click", function(e){
		//var $opt = $this.filter()
		var $attr = $(this).attr('id');
		//alert($attr);
		$opt = $(this).find('option');
		//$attr.find('option').text('aaa');
	})
	*/
	$('.toggler').bind('click', function(e){
		
		//alert('aa');
		var $lista = $(this);
		var $container = $lista.parent().find('div');
		var $tables = $('body').find('.table_toggler'); 		
		//alert($tables.length);
		
		$tables.each(function(){
			//alert($(this).html());
			$(this).css('display', 'none');
		});
		
		//alert(list.text());
		$($container).css('display', 'inline-table');
		//$($container).toggleClass('visible');
		return false;
	});
	

});


function popUp(url, playerW, playerH)
{
	var playerW=playerW;
	var playerH=playerH;
	var popupx = Math.round((screen.availWidth-playerW)/2);
	var popupy = Math.round((screen.availHeight-playerH)/2);
	var prop='width='+playerW+',height='+playerH+',scrollbars=no,left='+popupx+',top='+popupy+',resizable=no';
	var day = new Date();
	var id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "','"+ prop+"');");
};
 