//var $ = $uery.noConflict();

Shadowbox.init({
    handleOversize:     "drag",
    displayNav:         true,
    handleUnsupported:  "remove",
    autoplayMovies:     false
});

var zoomSrc = undefined;
var zoomSrcZoomed = undefined;
setInterval("test2();", 100);
function test2()
{

 
if ( zoomSrc != $('#zoomedBackImg').attr('src') )
    {	
        zoomSrc = $('#zoomedBackImg').attr('src');		
	 setTimeout('test3()',500);
    }
}

function test3()
{
	jQuery.fn.axZm.zoomTo({x1: 100, y1: 100, x2: jQuery.axZm.ow-100, y2: jQuery.axZm.oh-100, initial: false}); 
	 //console.log('make zoom');
}

$(document).ready(function(){
//---------- START DOCUMENT READY -------------//   
	
	
	// $('#pane1').each(function()
	// {
	 	$('#pane1').jScrollPane({showArrows:true, scrollbarWidth: 7});
	// });

	//  $('#pane2').each(function()
	// {
	 $('#pane2').jScrollPane({showArrows:true, scrollbarWidth: 7});
	// });
	// $('.pane').each(function()
	// {
	 $('.pane').jScrollPane({showArrows:true, scrollbarWidth: 7});
	// });
	
	// $("#big_img a img").each(function()
	// {	 
	 	$("#big_img a img").draggable({ cursor: 'move'});
	// });
	
	

	//setTimeout("bigImg()",500);
	
	$('.fededback').pngFix();
	 
	  var settings = {
      tl: { radius: 0 },
      tr: { radius: 0 },
      bl: { radius: 0 },
      br: { radius: 30 },
      antiAlias: true
    }
 /*
 	$(".prod").each(function()
 	{
   		curvyCorners(settings,".prod");
   	});*/
	 
//---------- STOP DOCUMENT READY -------------//  	 
 });

 function bigImg()
 {
/*
  $("#big_img a img").each(function()
	 {
	 	//$(this).css('display','block');
	 	var x = $(this).width() - 347;
	 	var y = $(this).height() - 281;
	 	//alert(x+' '+y);
	 	//$(this).css('display','none');
	 	if ( x > 0 ) { x = - x/2; $(this).css('cursor','move'); }
	 	if ( y > 0 ) { y = - y/2; $(this).css('cursor','move'); }
	 	$(this).css('left',x+'px');
	 	$(this).css('top',y+'px'); 		 	
	 	
	 });
	  $('#big_img img:first').fadeIn('slow');
*/
}
 
 
var inin_prod = 1;
var step = -220;//-300;
var elems = 0;
var elems_on_page = 4;//9;
var pages = 0;
 $(document).ready(function(){
//---------- START DOCUMENT READY -------------//   
	
	 $('.four').css('display','none');
	 $('.four').each(function()
	 {
	 	
	 	elems+=4;
	  if ( elems == 4 ) $(this).css('display','block');	
	  });
	 var four = 0;
	 var four_pagg = 0;
	 
	 
	 $('.prod').each(function()
	 {
	 	elems++;
	 });
	 pages = elems / elems_on_page;
	 pages = Math.ceil(pages);
	 pages--;
	 var mod = elems % elems_on_page;
	 if ( elems != 0 ) pages++;
	
	 	
	 for ( var i = 1; i <= pages; i ++ )
	 {
	 	$('<li><a>'+i+'</a></li>').insertBefore('#paggination li:last');
	 	
	 }
	 showHiddeArrows();
	 
	 $('#paggination .pright').click(function()
	 {
	 		inin_prod++;	 		 		
	 		$('#inin_prod').css('top',(inin_prod-1)*step+'px'); var four = 0;
		 	var four = 0;
		 	$('.four').each(function()
		 	{
		 		four++;
		 		if ( four == inin_prod ) $(this).css('display','block');
		 		else  $(this).css('display','none');
		 		
		 	});
		 	
		 	$('.prod a').each(function()
			{
		 		org_link = $(this).attr('href');
			 				
			 	if( typeof(org_link) != "undefined" )
			 	{
			 		$(this).attr('href', org_link.replace(/\?cp=\d{1,}/, '') + '?cp=' + inin_prod);
			 	} 			 			 		 		
			});
	 		showHiddeArrows();
	 		
	 });
	 $('#paggination .pleft').click(function()
	 {
	 		inin_prod--;	 	
	 		if ( inin_prod < 0 ) inin_prod = 0;	
	 		$('#inin_prod').css('top',(inin_prod-1)*step+'px');
	 		var four = 0;
	 		$('.four').each(function()
		 	{
		 		four++;
		 		if ( four == inin_prod ) $(this).css('display','block');
		 		else  $(this).css('display','none');
		 		
		 	});
	 		
	 		$('.prod a').each(function()
	 		{
	 			org_link = $(this).attr('href');
	 				
	 			if( typeof(org_link) != "undefined" )
	 			{
	 				$(this).attr('href', org_link.replace(/\?cp=\d{1,}/, '') + '?cp=' + inin_prod);
	 			} 			 			 		 		
	 		});
	 		showHiddeArrows()
	 });
	 
	 $('#paggination a').not('.pright').not('.pleft').click(function()
	 { 
	 
	 	inin_prod = $(this).html(); 
	 	$('#inin_prod').css('top',(inin_prod-1)*step+'px'); 
	 	var four = 0;
	 	$('.four').each(function()
	 	{
	 		four++;
	 		if ( four == inin_prod ) $(this).css('display','block');
	 		else  $(this).css('display','none');
	 		
	 	});
	 	
	 	$('.prod a').each(function()
	 	{
	 		org_link = $(this).attr('href');
	 		
	 		if( typeof(org_link) != "undefined" )
	 		{
	 			$(this).attr('href', org_link.replace(/\?cp=\d{1,}/, '') + '?cp=' + inin_prod);
	 		} 			 			 		 		
	 	});
	 	
	 	showHiddeArrows()
	 	
	 }); 
	 
	 
	 //SIMPLE
	 /*
	 var from_top = 121;
	 var img_list_h = $('#img_list ul').height();
	 var simple_h = 290; 
	 var ih = 0;
	
	 var diff = img_list_h - $('#img_list').height();
	
	 if ( diff < 0  )	 {
	 	 
	 	 $('#img_list ul').css('top',(diff/(-2)-(-15))+'px');
	 }
	
	*/
	 
	 $('#simple').mousemove(function(event)
	 {	 	
	
	 	if ( diff < 0 ) return true; 
	 ih = img_list_h - simple_h; 
	 	if ( ih > 0 )
	 	{ 
	 		var pY = event.pageY - from_top; 
	 		if ( pY < 1 ) return true;
	 		
	 		 var z = pY * ( ih/simple_h);
	 		 $('#img_list ul').css('top','-'+z+'px');	 	return true;
	 	}
	 	
	 });
	 
	 /*
	 $('#big_img img').each(function()
	 {
		if( $(this).height() > $(this).width() )
	 	{
	 		$(this).css('width', '347px');
	 	}
	 	else if( $(this).height() < $(this).width() )
	 	{
	 		$(this).css('height', '280px');	 			 		
	 	}
	 	else
	 	{
	 		$(this).css('width', '347px');
	 	}
		
	 });
	 */
	 
	 $('#zoomNaviML, #zoomNaviMR, #zoomNaviMB').css('margin','0px');
	 $('#zoomNaviMR').parent().css('width','6px');
	 $('#zoomNaviMB').css('margin-top','-1px');
	 $('#short li:first').fadeIn('slow');
	 $('#price ul li:first').fadeIn();
	
	 		 
	 $('#img_list li').click(function()
	 {	
		 		 
	 	var count = 1;
	 	var thisClick = $(this);
	 //	$('#shadow').attr('href',$(this).attr('background-image'));
		//alert($(this).find('div').attr('background-image'));
	 	$('#img_list li').removeClass('selected');
	 	$(this).addClass('selected');
	 
	 	$('#img_list li').each(function()
	 	{
	 		if ( thisClick[0] == $(this)[0] ) 
	 		{	 		
	 			return false;
	 		}
	 		count++;
	 	});
	 	
	 	var count2 = 1;	
	 	$('#big_img img').each(function()
	 	{
	 		if ( count2 == count ) 
	 		{
	 			$(this).fadeIn('slow');
	 		}
	 		else
	 		{	
	 			$(this).fadeOut('slow');
	 		}
	 		count2++; 
	 	});
	 	
	 	count2 = 1;	
	 	$('#short li').each(function()
	 	{
	 		if ( count2 == count ) 
	 		{
	 			$(this).fadeIn();
	 		}
	 		else
	 		{	
	 			$(this).fadeOut();
	 		}
	 		count2++; 
	 	});
	 	
	 	count2 = 1;	
	 	$('#price li').each(function()
	 	{
	 		if ( count2 == count ) 
	 		{
	 			$(this).fadeIn();
	 		}
	 		else
	 		{	
	 			$(this).fadeOut();
	 		}
	 		count2++; 
	 	});
	 	
	 });
	 
	$('#shadow').click(function(event)
	{ 
	event.preventDefault();
	  	Shadowbox.open({
	        content:    ''+$(this).attr('href'),
	        player:     "img",
	        title:      ""	        
	    });
    });
	 
//---------- STOP DOCUMENT READY -------------//  	 
 });
 var diff = 0 ;
 var from_top = 121;
 var simple_h = 285; 
 var ih = 0;
 var img_list_h = 0;
 function setImgList()
 {
	
	 img_list_h = $('#img_list ul').height();	
	 diff = img_list_h - $('#img_list').height();
	
	 if ( diff < 0  )	 {
	 	 
	 	 $('#img_list ul').css('top',(diff/(-2)-(-15))+'px');
	 }
	// $('#shadow').attr('href',url);
 }
 
 function toShadow(count,url)
 {
 	 $('#shadow').attr('href',url);
 	var count2 = 0;
 	$('#short li').each(function()
	 	{
	 		count2++; 
	 		if ( count2 == count ) 
	 		{
	 			$(this).fadeIn();
	 		}
	 		else
	 		{	
	 			$(this).fadeOut();
	 		}
	 		
	 	});
	 	count2 = 0;
	 	$('#price li').each(function()
	 	{
	 		count2++; 
	 		if ( count2 == count ) 
	 		{
	 			$(this).fadeIn();
	 		}
	 		else
	 		{	
	 			$(this).fadeOut();
	 		}
	 		
	 	});
 	$('#shadow').attr(url);
 }
 

 function changePage( page )
 {	  
	$('#inin_prod').css('top',(page-1)*step+'px'); 
	var four = 0;
	inin_prod = page;
	
	$('#paggination a').not('.pright').not('.pleft').each(function()
	{		
		$(this).removeClass('selected');
		four++;		
		if ( four == page )	$(this).addClass('selected');					 	
	});
	showHiddeArrows();
 } 
 
 function showHiddeArrows()
 {	 
 	$('#paggination a').each(function()
 	{
 		$(this).removeClass('selected');
 		if ( $(this).html() == inin_prod )
 		{
 			$(this).addClass('selected');
 		}
 	});
 if ( inin_prod < 2 ) 
	 {
	 	$('#paggination .pleft').css('visibility','hidden');
	 }
	 else
	 {
	 	$('#paggination .pleft').css('visibility','visible');
	 }
	 
	 if ( inin_prod > pages-1 )
	  {
	 	$('#paggination .pright').css('visibility','hidden');
	 }
	 else
	 {
	 	$('#paggination .pright').css('visibility','visible');
	 }
}
 
 function popupWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	window.open(mypage, myname, winprops)

}


 