// JavaScript Document
 var temp;
 
 $(function() {
    
	get_left($(".left:eq(0)"),$class[0],1);
	get_left($(".left:eq(1)"),$class[1],2);	
	get_left($(".left:eq(2)"),$class[0],1);
	get_left($(".left:eq(3)"),$class[1],2);	
	
	$('.lefta,.leftb').hover(
	 function(oEvent){
		$(this).find('.left').stop(true,true).slideDown();					  
	 },
	 function(oEvent){
		$(this).find('.left').stop(true,true).slideUp();		 
	 });
	
	 for(i=0;i<$(".lefta").length;i++){
	   var position = $('.lefta:eq('+i+')').parent().position();
	   var left = position.left + 180;
	   var top  = position.top + 5;
	   
	   $('div.left:eq('+(i+2)+')').css('left',left).css('top',top).fadeTo(0,0.8).hide(0);	   
	 }
	 for(i=0;i<$(".leftb").length;i++){
	   var position = $('.leftb:eq('+i+')').parent().position();
	   var left = position.left;
	   var top  = position.top+ 40;
	   
	   $('div.left:eq('+i+')').css('left',left).css('top',top).fadeTo(0,0.8).hide(0);	   
	 }
	
 });
 
 
 function go_back(){
  $('#output').html(temp);
 }
 
 
 function productnew(){
  
 $.ajax({
      url: 'product_list_new.php',         
	  cache: false,         
	  dataType: 'html',             
	  type:'GET',         
	  data: {},
	  error: function(xhr) { alert('Ajax request 發生錯誤'); }, 
	  success: function(response) {$('#output').html(response); $('#left_container').css("display","block");}
	  });
 
 }
 
 
 
 function productlist($id,$page){
  
 $.ajax({
      url: 'product_list.php',         
	  cache: false,         
	  dataType: 'html',             
	  type:'GET',         
	  data: { upid: $id,page: $page},
	  error: function(xhr) { alert('Ajax request 發生錯誤'); }, 
	  success: function(response) {$('#output').html(response); $('#left_container').css("display","block");}
	  });
 
 }
 
 function productsearch($s,$page){
  
 $.ajax({
      url: 'product_search.php',         
	  cache: false,         
	  dataType: 'html',             
	  type:'GET',         
	  data: { s: $s,page: $page},
	  error: function(xhr) { alert('Ajax request 發生錯誤'); }, 
	  success: function(response) {$('#output').html(response); $('#left_container').css("display","block");}
	  });
 
 }
 
 
 function productpress($id){
 
 temp = $('#output').html();
 
 $.ajax({
      url: 'product_press.php',         
	  cache: false,         
	  dataType: 'html',             
	  type:'GET',         
	  data: { id: $id},
	  error: function(xhr) { alert('Ajax request 發生錯誤'); }, 
	  success: function(response) {$('#output').html(response); $('#left_container').css("display","none");}
	  });
 
 }
 
 function get_left($to,$get,$upid){

 $.ajax({
      url: $get,         
	  cache: false,         
	  dataType: 'html',             
	  type:'GET',         
	  data: {upid:$upid},
	  error: function(xhr) { alert('Ajax request 發生錯誤'); }, 
	  success: function(response) {$to.html(response);}
	  });
  
 }
 

 
