this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 400;
		yOffset = -520;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview, a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.rel +"' alt='Image preview' />"+ c +"</p>");								 
		xcorr = e.pageX + yOffset;
		if(e.pageX<xOffset){
			xcorr = e.pageX + 20;
		}
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(xcorr) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview, a.screenshot").mousemove(function(e){
		xcorr = e.pageX + yOffset;
		if(e.pageX<xOffset){
			xcorr = e.pageX +20;
		}											
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(xcorr) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});

// rating stars

// Esta es para llamado de datos remotos via xmlHttpRequest

function datosServidor() {
};
datosServidor.prototype.iniciar = function() {
	try {
		// Mozilla / Safari
		this._xh = new XMLHttpRequest();
	} catch (e) {
		// Explorer
		var _ieModelos = new Array(
		'MSXML2.XMLHTTP.5.0',
		'MSXML2.XMLHTTP.4.0',
		'MSXML2.XMLHTTP.3.0',
		'MSXML2.XMLHTTP',
		'Microsoft.XMLHTTP'
		);
		var success = false;
		for (var i=0;i < _ieModelos.length && !success; i++) {
			try {
				this._xh = new ActiveXObject(_ieModelos[i]);
				success = true;
			} catch (e) {
				// Implementar manejo de excepciones
			}
		}
		if ( !success ) {
			// Implementar manejo de excepciones, mientras alerta.
			return false;
		}
		return true;
	}
}

datosServidor.prototype.ocupado = function() {
	estadoActual = this._xh.readyState;
	return (estadoActual && (estadoActual < 4));
}

datosServidor.prototype.procesa = function() {
	if (this._xh.readyState == 4 && this._xh.status == 200) {
		this.procesado = true;
	}
}

datosServidor.prototype.enviar = function(urlget,datos) {
	if (!this._xh) {
		this.iniciar();
	}
	if (!this.ocupado()) {
		this._xh.open("GET",urlget,false);
		this._xh.send(datos);
		if (this._xh.readyState == 4 && this._xh.status == 200) {
			return this._xh.responseText;
		}
		
	}
	return false;
}


// Este es un acceso rapido, le paso la url y el div a cambiar
function _gr(reqseccion,divcont) {
	remotos = new datosServidor;
	nt = remotos.enviar(reqseccion,"");
	document.getElementById(divcont).innerHTML = nt;
}



//Estas dos son para guardar
function stem_inzending(rating,imgId){
	if (rating == 0) return;

	$("#rating"+imgId).html("<img src='/wp-content/themes/ditc_default/images/ajax-loader-small.gif'>");
	var dataurl="/wp-content/plugins/ditc_options/front-end/ajax/stemmen.php"+'?rating='+rating+'&imgId='+imgId+"&sid="+Math.random();
	$.ajax({
		type: "GET",
		url: dataurl,
		dataType: "html",
		success: function(result){
					$("#rating"+imgId).html(result);
					rating = (rating * 25) - 8;
					$('#ratelinks'+imgId).css({display: 'none'});
			
					// we have pager at contest details page for designs
					// if rating is changed image will be placed at another page
					if ($("#designs_preview").length != 0){
						$("#designs_preview").trigger("designRatingEvent");
					}
				},
		error: function(error){
		}
	});
} 


function stem_vid_inzending(rating,vidId){
	if (rating == 0) return;

	$("#rating"+imgId).html("<img src='/wp-content/themes/ditc_default/images/ajax-loader-small.gif'>");
	var dataurl="/wp-content/plugins/ditc_options/front-end/ajax/stemmen.php"+'?rating='+rating+'&vidId='+vidId+"&sid="+Math.random();
	$.ajax({
		type: "GET",
		url: dataurl,
		dataType: "html",
		success: function(result){
					$("#rating"+imgId).html(result);
					rating = (rating * 25) - 8;
					$('#ratelinks'+imgId).css({display: 'none'});

					// we have pager at contest details page for designs
					// if rating is changed image will be placed at another page
					if ($("#designs_preview").length != 0){
						$("#designs_preview").trigger("designRatingEvent");
					}
				},
		error: function(error){
		}
	});
}

//funtion usr for rating on invited friend
function friendVoting(rating,designId,cotestId,fKey){	
	if (rating == 0) return;
	$("#rating"+designId).html("<img src='/wp-content/themes/ditc_default/images/ajax-loader-small.gif'>");
	var dataurl="/wp-content/themes/ditc_default/friend-votes.php"+'?rating='+rating+'&degId='+designId+"&cid="+cotestId+"&key="+fKey;
	$.ajax({
		type: "GET",
		url: dataurl,
		dataType: "html",
		success: function(result){
					$("#rating"+designId).html(result);
					rating = (rating * 25) - 8;
					$('#ratelinks'+designId).css({display: 'none'});
			
					// we have pager at contest details page for designs
					// if rating is changed image will be placed at another page
					if ($("#designs_preview").length != 0){
						
					}
				},
		error: function(error){
		}
	});
} 


function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 



var urlBase = "./ajax/stemmen.php?";


function relative_time(time_value) {

	  var values = time_value.split(" ");
	  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
	  var parsed_date = Date.parse(time_value);
	  var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
	  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
	  delta = delta + (relative_to.getTimezoneOffset() * 60);

	  var r = '';

	  if (delta < 60) {
		r = 'a minute ago';
	  } else if(delta < 120) {
		r = 'couple of minutes ago';
	  } else if(delta < (45*60)) {
		r = (parseInt(delta / 60)).toString() + ' minutes ago';
	  } else if(delta < (90*60)) {
		r = 'an hour ago';
	  } else if(delta < (24*60*60)) {
		r = '' + (parseInt(delta / 3600)).toString() + ' hours ago';
	  } else if(delta < (48*60*60)) {
		r = '1 day ago';
	  } else {
		r = (parseInt(delta / 86400)).toString() + ' days ago';
	  }

	  return r;
	
	}
	
	function twitter_callback ()
	
	{
		return true;
	}
	
function widgetOpen(key) {
		
		if ($(key).is(':visible')) {
		  $(key).hide();
		  $(key+"Arrow").removeClass("drop_close");
		} else {
		  $(key).show();
		  $(key+"Arrow").addClass("drop_close");
		}
		
	};
	
	$(document).ready(function() {
		$("div#header_try").delay(2500).fadeIn(4000);
		$(".feedback_help").tipsy({gravity: 'w',fade: true});
		$(".require_this").tipsy({gravity: 'w',fade: true});
	});

	function closePopup() {
		$('#popup').hide();
	};
		
	function setUserGroup(type){
		
		// set wait annoucement
		$('#progressImage').html('<img src="/wp-content/themes/ditc_default/images/ajax-loader-big.gif">');
		
		$.get(
			'/wp-content/plugins/ditc_login/ajax/set_userGroup.php?set='+type,
			function(data){
				if (data.success)
				{
					$("div#progressImage").html(data.message);
					window.location.reload( false );
				}
				else
				{
					$("div#progressImage").html(data.message);
				}
			},
			"json"
		);
	};
	
<!---Add contest to favorites of designer-------->

function setFavoriteContest(contest, contestPage){
		
	// set wait annoucement
	$('.favoriteContest'+contest).html('<img src="/wp-content/themes/ditc_default/images/ajax-loader-small.gif">');
	
	$.get(
		'/wp-content/plugins/ditc_options/front-end/ajax/set_FavoriteContest.php?contest='+contest+'&contestPage='+contestPage,
		function(data){
			if (data.success)
			{
				//$("div#progressImage").html(data.message);
				if(contestPage == 1){
					$('.favoriteContest'+contest).html('');
					alert(data.message);
				}else{
					$('.favoriteContest'+contest).html(data.message);
				};
			}
			else
			{
				//$("div#progressImage").html(data.message);
				alert(data.message);
			}
		},
		"json"
	);
};

function delFavoriteContest(contest){
		
	// set wait annoucement
	$('.favoriteContest'+contest).html('<img src="/wp-content/themes/ditc_default/images/ajax-loader-small.gif">');
	
	$.get(
		'/wp-content/plugins/ditc_options/front-end/ajax/set_FavoriteContest.php?contestDel='+contest,
		function(data){
			if (data.success)
			{
				//$("div#progressImage").html(data.message);
				$('.favoriteContest'+contest).html(data.message);
				$('#favoContest'+contest).hide('slow');
			}
			else
			{
				//$("div#progressImage").html(data.message);
				alert(data.message);
			}
		},
		"json"
	);
};

<!---Add contest to favorites of designer-------->

function setExpectEntry(type,contest){
		
	// set wait annoucement
	$('.expectEntry'+contest).html('<img src="/wp-content/themes/ditc_default/images/ajax-loader-small.gif">');
	
	$.get(
		'/wp-content/plugins/ditc_options/front-end/ajax/set_ExpectEntry.php?contest='+contest+'&type='+type,
		function(data){
			if (data.success)
			{
				$('.expectEntry'+contest).html(data.message);
			}
			else
			{
				//$("div#progressImage").html(data.message);
				alert(data.message);
			}
		},
		"json"
	);
};

