$(window).resize(function() {
  DoBg();
});
function DoBg()
{
	var p = $(".contenedor");
	var offset = p.offset();
	//var offset = p.position();
	left=offset.left - 432;
	tope=offset.top - 233.5;
	ubicacion=left + "px " + tope + "px";
	$("body").css("backgroundPosition", ubicacion);
	//alert(ubicacion);
	//document.getElementById('body').style.backgroundPosition=ubicacion;

}
function ShowBg()
{
	$("body").show();
	DoBg();
}
(function($) {

	$.fn.jFlow = function(options) {
		var opts = $.extend({}, $.fn.jFlow.defaults, options);
		var randNum = Math.floor(Math.random()*11);
		var jFC = opts.controller;
		var jFS =  opts.slideWrapper;
		var jSel = opts.selectedWrapper;

		var cur = 0;
		var timer;
		var maxi = $(jFC).length;
		// sliding function
		var slide = function (dur, i) {
			$(opts.slides).children().css({
				overflow:"hidden"
			});
			$(opts.slides + " iframe").hide().addClass("temp_hide");
			$(opts.slides).animate({
				marginLeft: "-" + (i * $(opts.slides).find(":first-child").width() + "px")
				},
				opts.duration*(dur),
				opts.easing,
				function(){
					$(opts.slides).children().css({
						overflow:"hidden"
					});
					$(".temp_hide").show();
				}
			);
			
		}
		$(this).find(jFC).each(function(i){
			$(this).click(function(){
				dotimer();
				if ($(opts.slides).is(":not(:animated)")) {
					$(jFC).removeClass(jSel);
					$(this).addClass(jSel);
					var dur = Math.abs(cur-i);
					slide(dur,i);
					cur = i;
				}
			});
		});	
		
		$(opts.slides).before('<div id="'+jFS.substring(1, jFS.length)+'"></div>').appendTo(jFS);
		
		$(opts.slides).find("div").each(function(){
			$(this).before('<div class="jFlowSlideContainer"></div>').appendTo($(this).prev());
		});
		
		//initialize the controller
		$(jFC).eq(cur).addClass(jSel);
		
		var resize = function (x){
			$(jFS).css({
				position:"relative",
				width: opts.width,
				height: opts.height,
				overflow: "hidden"
			});
			//opts.slides or #mySlides container
			$(opts.slides).css({
				position:"relative",
				width: $(jFS).width()*$(jFC).length+"px",
				height: $(jFS).height()+"px",
				overflow: "hidden"
			});
			// jFlowSlideContainer
			$(opts.slides).children().css({
				position:"relative",
				width: $(jFS).width()+"px",
				height: $(jFS).height()+"px",
				"float":"left",
				overflow:"hidden"
			});
			
			$(opts.slides).css({
				marginLeft: "-" + (cur * $(opts.slides).find(":eq(0)").width() + "px")
			});
		}
		
		// sets initial size
		resize();

		// resets size
		$(window).resize(function(){
			resize();						  
		});
		
		$(opts.prev).click(function(){
			dotimer();
			doprev();
			
		});
		
		$(opts.next).click(function(){
			dotimer();
			donext();
			
		});
		
		var doprev = function (x){
			if ($(opts.slides).is(":not(:animated)")) {
				var dur = 1;
				if (cur > 0)
					cur--;
				else {
					cur = maxi -1;
					dur = cur;
				}
				$(jFC).removeClass(jSel);
				slide(dur,cur);
				$(jFC).eq(cur).addClass(jSel);
			}
		}
		
		var donext = function (x){
			if ($(opts.slides).is(":not(:animated)")) {
				var dur = 1;
				if (cur < maxi - 1)
					cur++;
				else {
					cur = 0;
					dur = maxi -1;
				}
				$(jFC).removeClass(jSel);
				//$(jFS).fadeOut("fast");
				slide(dur, cur);
				//$(jFS).fadeIn("fast");
				$(jFC).eq(cur).addClass(jSel);
			}
		}
		
		var dotimer = function (x){
			if((opts.auto) == true) {
				if(timer != null) 
					clearInterval(timer);
			    
        		timer = setInterval(function() {
	                	$(opts.next).click();
						}, 5000);
			}
		}

		dotimer();
	};
	
	$.fn.jFlow.defaults = {
		controller: ".jFlowControl", // must be class, use . sign
		slideWrapper : "#jFlowSlide", // must be id, use # sign
		selectedWrapper: "jFlowSelected",  // just pure text, no sign
		auto: false,
		easing: "swing",
		duration: 600,
		width: "100%",
		prev: ".jFlowPrev", // must be class, use . sign
		next: ".jFlowNext" // must be class, use . sign
	};
	
})(jQuery);

this.screenshotPreview = function(){	
	/* CONFIG */
		
		
	/* END CONFIG */
	$("a.pop").hover(function(){
		this.t = this.title;
		this.title = "";
		var place = $(this).offset();
		var izq = place.left -50;
		var tope =  place.top -88;

		var c = (this.t != "") ? "" + this.t : "";
		$("body").append("<div id='screenshot'><div class='loguito' style='background-image:url(logos_clientes/" + this.rel + ".gif);'></div><span>"+ c +"</span><div class='palito'></div></div>");								 
		$("#otros").fadeOut("fast");
		$("#screenshot")
			.css("top",(tope) + "px")
			.css("left",(izq) + "px")
			.fadeIn("slow");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
		$("#otros").fadeIn("fast");
    });				
};


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

function objetoAjax(){
 var xmlhttp=false;
  try{
   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  }catch(e){
   try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }catch(E){
    xmlhttp = false;
   }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
   xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function Pagina(orden,type,tipo, from){
 divContenido = document.getElementById('paginacion');
 
 ajax=objetoAjax();
  ajax.open("GET", "paginacion.php?orden="+orden+"&type="+type+"&tipo="+tipo+"&from="+from);

 divContenido.innerHTML= '';
 ajax.onreadystatechange=function() {
  if (ajax.readyState==4) {
   divContenido.innerHTML = ajax.responseText;
  }
 }
 ajax.send(null);
}
window.onload = DoBg(); 

