var $body;
var dimmer = '<div id="dimmer"></>';
var cerrar = '<a class="cerrar">CLOSE</a>';
var c = '<div id="c"></div>';
var $dimmer; var $w; var $c;
var rh; var topC; var leftC;
$(document).ready(function() {
	$body = $('body');
});
function setCerrar() {
	$('.cerrar').click(function() {
		$c.fadeOut('fast', function() { $c.remove(); $dimmer.fadeOut('fast', function() { $dimmer.remove(); }); });
		/*$c.animate({ 'left': (($dimmer.width() * .5) + 'px'), 'width': '1px' }, 700, 'easeOutQuad', function() {
			$c.animate({ 'top': (($dimmer.height() * .5) + 'px'), 'height': '1px' }, 700, 'easeOutQuad', function() {
				$c.remove(); $dimmer.fadeOut('fast', function() { $dimmer.remove(); });
			});
		});*/
	});
}
function setDimmer() {
	$w = $('#wrapper'); var wrapperH = $w.height();
	$body.append(dimmer); $dimmer = $('#dimmer'); 
	$body.append(c); $c = $('#c');
	$dimmer.css('width', ('100%')); $dimmer.css('height', (wrapperH + 'px'));
	$dimmer.css('top', 0); $dimmer.css('opacity', 0); $dimmer.fadeTo('slow', .9);
}
function setCont() {
	$c.prepend(cerrar); rh = $('#c').height();
	topC = (($dimmer.height() - $('#c').height()) * .5);
	//leftC = (($dimmer.width() - $('#c').width()) * .5);
	leftC = (($dimmer.width() - 660) * .5);
	//$c.css({ 'left': (leftC + 'px'), 'width': '660px', 'top': (topC + 'px'), 'height': (rh + 'px'), 'opacity' : 0 });
	//$c.fadeTo('fast', 1);
	$c.css({ 'top': (($dimmer.height() * .5) + 'px'), 'left': (($dimmer.width() * .5) + 'px'), 'width': '1px', 'height': '1px' });
	$c.animate({ 'left': (leftC + 'px'), 'width': '660px' }, 700, 'easeOutQuad', function() {
		$c.animate({ 'top': (topC + 'px'), 'height': (rh + 'px') }, 700, 'easeOutQuad');
	});
}
function designANDdrawings() {
	setDimmer();
	//container
	$c.html('<iframe src="http://www.kclcutsheets.com/merkolat/" frameborder="0" border="0" width="640" height="420" align="center"></iframe>');
	setCont();
	//cerrar
	setCerrar();
}

function login() {
	//set the dimmer
	var ima = '<img src="assets/Merkolat_Site_Banner2.jpg" width="600" height="40" />'	
	setDimmer();
	//container
	$c.html('<iframe src="5.php" frameborder="0" border="0" width="640" height="380" align="center"></iframe>');
	$c.prepend(ima);
	setCont();
	//cerrar
	setCerrar();
}
function getdirections() {
	//set the dimmer
	var ima = '<img src="assets/Merkolat_Site_Banner2.jpg" width="600" height="40" />'	
	setDimmer();
	//container
	$c.html('<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=merkolat&amp;sll=37.0625,-95.677068&amp;sspn=38.638819,86.572266&amp;ie=UTF8&amp;hq=merkolat&amp;hnear=&amp;ll=26.822692,-80.295296&amp;spn=0.085185,0.169086&amp;z=13&amp;iwloc=A&amp;cid=1087693743052000097&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=es&amp;geocode=&amp;q=merkolat&amp;sll=37.0625,-95.677068&amp;sspn=38.638819,86.572266&amp;ie=UTF8&amp;hq=merkolat&amp;hnear=&amp;ll=26.822692,-80.295296&amp;spn=0.085185,0.169086&amp;z=13&amp;iwloc=A&amp;cid=1087693743052000097" style="color:#0000FF;text-align:left">Ver mapa más grande</a></small>');
	$c.prepend(ima);
	setCont();
	//cerrar
	setCerrar();
}
function bringvideo(video) {
	setDimmer();
	//container
	$c.html('<div><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/'+ video +'?fs=1&amp;hl=es_ES"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+ video +'?fs=1&amp;hl=es_ES" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></div>');
	setCont();
	//cerrar
	setCerrar();
}
