/* ----------------------------------
jQuery browserSizr

tested with jQuery v1.3+
©2009 CSSLab.cl
free for any use, of course... :D
instructions: http://www.csslab.cl/2009/07/22/jquery-browsersizr/


no se te ocurra usar esto, esta pichigatiado para que funcione con la altura de la pagina y no el ancho!
mejor usa el que csslab gentilmente entraga.
---------------------------------- */

var resizeTimer = null;

jQuery.fn.browserSizr = function(options){
	// default plugin settings
	settings = jQuery.extend({
		containerDiv: '#todo',		// value: any HTML tag of #id, default to #container
		debug: 'off', 					// value: on | off, default to 'off'
		smartphones: 'off',				// value: on | off, default to 'off'
		lower1024: 'on',				// value: on | off, default to 'on'
		over1024: 'off',				// value: on | off, default to 'on'
		over1280: 'on'					// value: on | off, default to 'off'
	}, options);

	// do you want to debug the browser width?
	var debug = settings.debug;

	$(function(){
		// let's draw the debug window
		if(settings.debug=='on') {
			$('body').append('<div id="debug" style="position:absolute;left:1em;top:1em;background:rgba(0,0,0,0.7);-moz-box-shadow:#000 0 0 0.5em;-webkit-box-shadow:#000 0 0 0.5em;border: 2px solid rgba(255,255,255,0.7);padding:0.5em;-moz-border-radius:1em;-webkit-border-radius:1em;color:#fff;text-align:center;"><small style="font-size:0.7em;">The current browser width is:</small><br /><big id="currentWidth" style="font-size:2em;text-shadow:#000 0 0 0.2em"></big><br /><small style="font-size:0.7em;">The current container class is:</small><br /><big id="currentClass" style="font-size:1.6em;text-shadow:#000 0 0 0.2em"></big></div>')
		}
	});

	$(window).bind('resize load', function(e) {
		// get browser width and Height
		var browserHeight = $('.cuadro_left').height();
		var browserWidth = $('.cuadro_gris').width();

		// search for the layout's container to inject the class'es
		var containerDiv = settings.containerDiv;
		
		// get de current class of the container an insert it to the debug window
		var containerClass = $(settings.containerDiv).attr('class');
		
		// filling the debug window with the current browser's width
		if(settings.debug=='on') {
			$('#debug #currentWidth').text(browserHeight+'px');
			if(containerClass == "") {
				$('#debug #currentClass').text('-');
			} else {
				$('#debug #currentClass').text(containerClass);
			};
		};

		// if statements for each resolution
				if(settings.lower1024=='on'){
					if(browserWidth>315 && browserWidth<1000) {
						$(containerDiv).removeClass();
						if (resizeTimer) clearTimeout(resizeTimer);
						resizeTimer = setTimeout(lower1024, 5);
						elvalor = 10;
					};
				} else if(settings.lower1024=='off') {
					if(browserWidth<1000 && browserWidth>311) {
						$(containerDiv).removeClass();
					};
				};
				if(settings.smartphones=='on'){
					if(browserWidth<310) {
						if (resizeTimer) clearTimeout(resizeTimer);
						resizeTimer = setTimeout(smartphones, 5);
					};
				};
				if(settings.over1024=='on'){	
					if(browserWidth>1001 && browserWidth<1279 || browserWidth==1001) {
						if (resizeTimer) clearTimeout(resizeTimer);
						resizeTimer = setTimeout(over1024, 5);
					};
				} else if(settings.over1024=='off') {
					if(browserWidth>1001 && browserWidth<1279 || browserWidth==1001) {
						$(containerDiv).removeClass();
						elvalor = 40;
					};
				};
				if(settings.over1280=='on'){	
					if(browserWidth>1280 || browserWidth==1280) {
						if (resizeTimer) clearTimeout(resizeTimer);
						resizeTimer = setTimeout(over1280, 5);
						elvalor = 50;
					};
				};

				function lower1024() {
					$(containerDiv).removeClass().addClass('lower1024');
				};
				function smartphones() {
					$(containerDiv).removeClass().addClass('smartphones');
				};
				function over1024() {
					$(containerDiv).removeClass().addClass('over1024');
				};
				function over1280() {
					$(containerDiv).removeClass().addClass('over1280');
				};
		
					
	
			$('.texto').css({'margin-right' : (1440 - browserWidth + elvalor )+'px'});
			
			$('.paginas').css({'height' : (browserHeight)+'px'});
			$('.contenido').css({'margin-top' : (browserHeight*120/600)+'px'});
			//$('.contenido').css({'margin-left' : (browserWidth*60/1380)+'px'});
			
							
				function lower1024() {
					$(containerDiv).removeClass().addClass('lower1024');
				};
				function smartphones() {
					$(containerDiv).removeClass().addClass('smartphones');
				};
				function over1024() {
					$(containerDiv).removeClass().addClass('over1024');
				};
				function over1280() {
					$(containerDiv).removeClass().addClass('over1280');
				};

			});

		};
