$(document).ready(function(){
   $('#p-tabs li a').click(function(){
   $('a').removeClass('hot');
   $(this).addClass('hot');
   var rel = $(this).attr('rel');
   var cat = "TAB:"+rel;
   var pid = this.id;
   /*hide all tabs*/
   $('#p-review').hide();
   $('#p-detail').hide();
   $('#p-experts').hide();
   $('#p-activities').hide();
   $('#p-bought').hide();
   $('#p-others').hide();
   loadContent();
   function loadContent(){
     switch(pid){
      case "p1":
         cmCreatePageElementTag("Product Details", ''+cat+'');
         $('#p-detail').show();
         break;
      case "p2":
         cmCreatePageElementTag("Product Review", ''+cat+'');
         $('#p-review').show();
         break;
      case "p3":
         cmCreatePageElementTag("Experts Suggest", ''+cat+'');
         $('#p-experts').show();
         break;
      case "p4":
         cmCreatePageElementTag("Contact Us", ''+cat+'');
         $('#p-others').show();
         break;
      case "p5":
         cmCreatePageElementTag("Activities Ideas", ''+cat+'');
         $('#p-activities').show();
         break;
      case "p6":
         cmCreatePageElementTag("Others Bought", ''+cat+'');
         $('#p-bought').show();
         break;
		case "t1":
			$('#testi').load("/pages/testimonial.php");
			break;
		case "t2":
			$('#testi').load("/pages/testimonial.php", {"inst" : "yes"});
			break;
      }
    }

  });
});
function getTabPos(){
   $('#p-tabs li a').removeClass('hot');
   $('#p2 a').addClass('hot');
   $('#p-box').hide();
   $('#p-detail').hide();
   $('#p-experts').hide();
   $('#p-activities').hide();
   $('#p-bought').hide();
   $('#p-others').hide();
   $('#p-review').show();
   $('#p-box').show();
   window.location="#p2";
}


function goDetail(){
   $('#p-tabs li a').removeClass('hot');
   $('#p1 a').addClass('hot');
   $('#p-box').hide();
   $('#p-review').hide();
   $('#p-experts').hide();
   $('#p-activities').hide();
   $('#p-bought').hide();
   $('#p-others').hide();
   $('#p-detail').show();
   $('#p-box').show();
   window.location="#p1";
}

/*
 * Image preview script
 * powered by jQuery (http://www.jquery.com)
 *
 * written by Alen Grakalic (http://cssglobe.com)
 *
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */

this.imagePreview = function(){
   /* CONFIG */

      xOffset = 10;
      yOffset = 30;

      // these 2 variable determine popup's distance from the cursor
      // you might want to adjust to get the right result

   /* END CONFIG */

   $("a.preview").click(function(){
      return false;
   });
   $("a.preview").hover(function(e){
      this.t = this.title;
      this.title = "";
      var c = (this.t != "") ? "<br/>" + this.t : "";
      $("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");
      $("#preview")
         .css("top",(e.pageY - xOffset) + "px")
         .css("left",(e.pageX + yOffset) + "px")
         .fadeIn("fast");
    },
   function(){
      this.title = this.t;
      $("#preview").remove();
    });
      $("a.preview").mousemove(function(e){
      $("#preview")
         .css("top",(e.pageY - xOffset) + "px")
         .css("left",(e.pageX + yOffset) + "px");
   });
};


// starting the script on page load
$(document).ready(function(){
   imagePreview();
});

