
/**
 * 2008/10/05
 * 
 * @author Nahuel Scotti / nahuel.scotti@gmail.com
 * @author singuerinc	 / info@singuerinc.com
 * ======================================
 * Main GenerationCopyPaste Core
 * ======================================
 * @version 1.0
 * @copyright SinguerInc
 * 
 */

$(document).ready(
	function()
	{
		//Add clicks to topNavigationBar & footerNavigationBar
	
		setUpNavBarLinks("#navBar");
		setUpNavBarLinks("#footerNavBar");
		
		//Add click to Logo image
		$("#logoGeneration").click(
			function(event)
			{
				event.preventDefault();
				location.href = "muro.php";
			}
		);
		
		$("#logoGeneracionCopyPasteImg").addClass("clickable");
		
		//Add style to lists	
		$("ul.listTitleAndText span").addClass("normalTitle");
	
		//[inSonora.php]
		if(location.pathname == "/inSonora.php")
		{
			$("#logoInSonora").click(
				function(event)
				{
					window.open("http://www.in-sonora.com/");
				}
			);
		}
		//Import scripts
		//[index.php]
		if(location.pathname.indexOf("muro.php") != -1 || location.pathname == "/")
		{
			$.ajax({url:'js/swfobject.js', type:"GET", async: false, dataType: 'script'});
			$.ajax({url:'js/com/singuerinc/display/Align.js', type:"GET", async: false, dataType: 'script'});
			$.ajax({url:'js/com/generationcopypaste/map/Map.js', type:"GET", async: false, dataType: 'script'});
			$.ajax({url:'js/com/generationcopypaste/core/copyPasteApp.js', type:"GET", async: false, dataType: 'script'});
		}
		
		if(location.pathname.indexOf("muro.php") == -1)
		{
			$("#header_subtitle02").remove();
			$("#copypasteados").remove();
			$("#copypasteadosText").remove();
			$("#leftBackground").css
			(
				{
					"background-image": "url(../images/sf.jpg)"
				}
			);
		}
		
		var bgHeight;
		switch(location.pathname)
		{
			case "/sobreLaGeneracionCopyPaste.php":		bgHeight = 250;		break;
			case "/instrucciones.php":					bgHeight = 700;		break;
			case "/laTrintxera.php":					bgHeight = 600;		break;
			case "/download.php":						bgHeight = 200;		break;
			case "/inSonora.php":						bgHeight = 700;		break;
			default:									bgHeight = 0;		break;
		}
		
		$("#leftBackground").css
		(
			{
				height: bgHeight + "px"
			}
		);
		
		$("#downloadLink").mouseover
		(
			function(event)
			{
				$(this).css
				(
					{
						backgroundColor: "#00CC00"
					}
				);
			}
		);
		
		$("#downloadLink").mouseout
		(
			function(event)
			{
				$(this).css
				(
					{
						backgroundColor: "#d8dfea"
					}
				);
			}
		);
	}
);

function setUpNavBarLinks(divName)
{
	$("#help").click(
		function(event)
		{
			event.preventDefault();
			location.href = "/instrucciones.php";
		}
	);
	
	$(divName + " a").click(
		function(event)
		{
			event.preventDefault();
			
			switch(event.target.className)
			{
				case "homeMuro":						location.href = "muro.php";							break;
				case "sobreLaGeneracionCopyPaste":		location.href = "sobreLaGeneracionCopyPaste.php";		break;
				case "instrucciones":					location.href = "instrucciones.php";					break;
				case "laTrintxera":						location.href = "laTrintxera.php";						break;
				case "download":						location.href = "download.php";						break;
				case "inSonora":						location.href = "inSonora.php";						break;
				default:								alert("Link no definido!");								break;
			}
		}
	);
}

