var touch_device;
var pageScroll;
var myScroll;

$(document).ready(function(){
						   
	touch_device = ('ontouchstart' in document.documentElement)?true:false;
	if ($.browser.webkit || $.browser.mozilla) {
		myScroll = new iScroll('mainFrame', { hScrollbar: false, vScrollbar: false, vScroll: false, zoom: false });
		myScroll.scrollTo(((2200-W)/2)*-1, 0, 0);
  	} else {
		$("#mainFrame").css({'overflow-y' : 'hidden', 'overflow-x' : 'scroll'});
  	}
	
	if (touch_device) {
		//document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
		//document.addEventListener('gesturestart', function (e) { e.preventDefault(); }, false);
		//document.addEventListener('gesturechange', function (e) { e.preventDefault(); }, false);
		//$('#output').text("* touch_device="+touch_device);
	}
	
	setTimeout(function () { loadWidget("box1", "widgets/Alumnos-01.html", 296, 240, 810, 0); }, 500);
	setTimeout(function () { loadWidget("box2", "widgets/Bienvenido.html", 438, 280, 1118, 0); }, 600);				 
	setTimeout(function () { loadWidget("box3", "widgets/LaSalleEsMas.html", 296, 238, 810, 240); }, 700);				 
	setTimeout(function () { loadWidget("box4", "widgets/Posgrados.html", 376, 187, 1118, 292); }, 800);
	setTimeout(function () { loadWidget("box5", "widgets/LaSalleYo.html", 200, 280, 598, 0); }, 900);
	setTimeout(function () { loadWidget("box6", "widgets/Biblioteca.html", 286, 186, 512, 292); }, 1000);
	setTimeout(function () { loadWidget("box7", "widgets/Alumnos-02.html", 202, 280, 1568, 0); }, 1100);
	setTimeout(function () { loadWidget("box8", "widgets/Admisiones.html", 265, 187, 1506, 292); }, 1200);
	setTimeout(function () { loadWidget("box9", "widgets/Mecatronica.html", 418, 280, 1782, 199); }, 1300);
	setTimeout(function () { loadWidget("box10", "widgets/Cursos.html", 211, 188, 1782, 0); }, 1400);
	setTimeout(function () { loadWidget("box11", "widgets/Disenio.html", 208, 188, 1993, 0); }, 1500);
	setTimeout(function () { loadWidget("box12", "widgets/Alumnos-03.html", 334, 280, 252, 0); }, 1600);
	setTimeout(function () { loadWidget("box13", "widgets/Instalaciones.html", 246, 186, 252, 292); }, 1700);
	setTimeout(function () { loadWidget("box14", "widgets/Idiomas.html", 286, 186, -16, 292); }, 1800);
	setTimeout(function () { loadWidget("box15", "widgets/Civil.html", 239, 280, 1, 0); }, 1900);
	
	
	//
	for (i=1; i<15; i++) {
		var h = ($("#box"+i).height() / 2) - 5;
		$("#box"+i+"Loader").css({'marginTop' : h});
	}
});

function loadWidget(box, url, w, h, ml, mt) {
	$("#"+box).css({'width' : w+"px"});
	$("#"+box).css({'height' : h+"px"});
	$("#"+box).css({'marginLeft' : ml+"px"});
	$("#"+box).css({'marginTop' : mt+"px"});
	$("#"+box).css({'display' : "block"});
	$("#"+box).load(url, function(response, status, xhr) {
  			if (status == "error") {
				var offset = ($("#"+box).height() / 2) - 5;
    			var msg = "<div class='errorText' style='margin-top: "+offset+"px;'>* NO DISPONIBLE *</div>";
    			$("#"+box).html(msg);
  			}
			if (status == "success") {
				$("#"+box).css({'border' : "none"});
			}
	});	
}
