/*
 * 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;
		
    xOffset = 0;
    yOffset = 0;

		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview1").hover(function(e){

		this.t = this.title;
		this.title = "";	
                href = this.href;
                arr = href.split('&');
                this.w = arr[1];
                this.h = arr[2];
                this.ie = arr[3];
                var btop = 550;
                if (this.ie == "") {
             	      btop = 550;
                } else {
          	      btop = 490;
                }
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview1'><iframe " + this.w + " " + this.h + " src='"+ this.href +" scrolling='no' style='overflow: hidden;'></iframe>"+ c +"</p>");								 

                var xfrac = 65/100;  // 50/100
                var yfrac = 20/100;  // 20/100

                arr1 = this.h.split('=');
                height = arr1[1];
                if (height > 400) {
                  yfrac = 35/100;
                }
                if (height < 300) {
                  yfrac = 15/100;
                }
                
		$("#preview1")
		    //.css("top",(e.pageY - xOffset) + "px")
		    //.css("left",(e.pageX + yOffset) + "px")		    
                    .css({"top":(e.pageY - (e.pageY*yfrac)  ), "left":(e.pageX - (e.pageX*xfrac))}) /* to calculate the dynamic position - Babu */		    
   		    .fadeIn(100);
               },
               function(){
		this.title = this.t;	
		$("#preview1").remove();
               });	        
	$("a.preview1").mousemove(function(e){
		$("#preview1")
		    .css({"top": (e.pageY - (e.pageY*yfrac)), "left": (e.pageX - (e.pageX*xfrac))}); /* to calculate the dynamic position - Babu */	
		    //.css("top",(550) + "px")
		    //.css("left",(350) + "px")
		
     
	});			
};


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

  $("#prev").hover(
    function () {
      this.src = "images/left_arrow_hover_5.png";
      $("#prev").css("cursor", "hand");
    }, 
    function () {
      this.src = "images/left_arrow_5.png";
      $("#prev").css("cursor", "pointer");
    }
  );

  $("#next").hover(
    function () {
      $("#next").css("cursor", "hand");
      this.src = "images/right_arrow_hover_5.png";
    }, 
    function () {
      this.src = "images/right_arrow_5.png";
      $("#next").css("cursor", "pointer");
    }
  );
});

