stickycontent= "";
var mouse_X;
var mouse_Y;
var tip_active = 0;
function update_tip_pos_for_merken(){
var tempb = eval(document.body.offsetWidth-500);
var tempb2 = eval(document.body.offsetHeight-30);
if (navigator.userAgent.match('AppleWebKit')){
var tempb3 =eval(document.body.scrollTop-30);
}else{
var tempb3 =eval(document.documentElement.scrollTop-30);
}
if (mouse_X > tempb){
document.getElementById('sticky_holder').style.left = eval(mouse_X -90) +'px';
}else{
document.getElementById('sticky_holder').style.left = eval(mouse_X +20) +'px';
}
if (mouse_Y > tempb2){
document.getElementById('sticky_holder').style.top  = eval(mouse_Y-30) +'px';
}
else if (mouse_Y > tempb3){
document.getElementById('sticky_holder').style.top  = eval(mouse_Y-30) +'px';
}
else{
document.getElementById('sticky_holder').style.top  = eval(mouse_Y+10) +'px';
}
}

function Enterstickcontent(showsticky) {
stickycontent = '<table width=364 border=0 cellspacing=0 cellpadding=6 style=\"border: 3px solid #c93;background: #ffc\"><tr><td><img src=/images/blank.gif width=25 height=26  class=\"tooltip_img iconpos\"  id=favicon_comp></td><td align=right><a onClick="document.getElementById(\'sticky_layer\').style.display=\'none\';"><img src=/images/bb_close1.png width=12 height=12 alt=\'\' border=0></a></td></tr><tr><td style=\"padding-top:0px\" colspan=2><p style=\"font-size:14px;margin-bottom:5px;margin:0px\" >'+showsticky+'</td></tr></table>';
}
function tip_merken(which,  showsticky){
	if(which){
     update_tip_pos_for_merken('sticky_holder');
     version=0;
	 tip_active = 1;
	 Enterstickcontent( showsticky);
	 document.getElementById('sticky_layer').innerHTML = stickycontent;
	 setpos();
	} 
	
	else{
	  tip_active = 0;
	}
}
function setpos() {
    var chk1=document.getElementById('sticky_holder').style.left;
    var chk2=document.getElementById('sticky_holder').style.top;
    document.getElementById('sticky_layer').style.left=chk1;
    document.getElementById('sticky_layer').style.top=chk2;
    document.getElementById('sticky_layer').style.display = 'block';
}
function sticky_save_result(adid, temp_layer, sticky_layer) {
  if(!adid) {return;}
  document.getElementById(temp_layer).style.display = "block";
  document.getElementById(sticky_layer).style.display = "none";
  var param = 'adid=' + adid;
  x_ajax_sticky_save(param, '');
}

function save_sticky_display(str, title) {
  document.getElementById("sticky_top").style.display = "none";	
  if(str) {
   document.getElementById("sticky_save_top").style.display = "block";
  } else {//safe to close all opened layer
   document.getElementById("sticky_save_top").style.display = "none";
  }
}
var sticky_content;
var stickylink;
var sticky_sucess1;
var sticky_sucess2;
var sticky_sucess3;
function save_sticky(adid) {
  if(!adid) {return;}
  update_tip_pos_for_merken();
  version=0;
  tip_active = 1;
   Enterstickcontent(sticky_content);
  document.getElementById('sticky_layer').innerHTML = stickycontent;
  setpos();
  var param = 'adid=' + adid;
  x_ajax_sticky_save(param);
}
function save_sticky_display(str) {
  document.getElementById('sticky_layer').style.display = 'none';
  document.getElementById('sticky_layer').innerHTML = '';
  var result = sticky_sucess1+" <b>&quot;" + str + "&quot;<\/b> " +sticky_sucess2+ " <a href=\"" + stickylink + "\">"+sticky_sucess3;
  Enterstickcontent(result);
 // alert(sticky_sucess2);
  if(str) {
    document.getElementById('sticky_layer').innerHTML = stickycontent;
    setpos();
  }
}
this.screenshotPreview = 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 */
	$(".preview_thumb").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview_tip'><img src='"+ this.rel +"' alt=''>"+ c +"</p>");								 
		$("#preview_tip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview_tip").remove();
    });	
	$(".preview_thumb").mousemove(function(e){
		$("#preview_tip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


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

