// JavaScript Document
var time1;
var time2;
var time3;
var time4;
function load()
{
	getRegionSelect();
	getCategorySelect();
	cycle1();
	get_mod_list_cat_1();
	get_mod_list_cat_2();
	get_mod_list_cat_3();
	get_mod_list_cat_4();
	get_mod_list_cat_5();
	get_mod_list_cat_6();
}


function cycle1() 
{	
	$("#slideshowAndTextBox").css({"background":"url('http://cdn.closetopuertorico.com/images/slideshow_historicplaces.jpg') left top no-repeat"});
	$("#slideshowAndTextBox").fadeIn("fast");
	time1 = setTimeout('gotoCycle2()',5000);
}
function gotoCycle2() 
{
	clearTimeout(time1);
	$("#slideshowAndTextBox").fadeOut("fast", function() { cycle2(); });
}
function cycle2() 
{	
	$("#slideshowAndTextBox").css({"background":"url('http://cdn.closetopuertorico.com/images/slideshow_nightlife.jpg') left top no-repeat"});
	$("#slideshowAndTextBox").fadeIn("fast");
	time2 = setTimeout('gotoCycle3()', 5000);
}
function gotoCycle3() 
{
	clearTimeout(time2);
	$("#slideshowAndTextBox").fadeOut("fast", function() { cycle3(); }); 
}
function cycle3() 
{	
	$("#slideshowAndTextBox").css({"background":"url('http://cdn.closetopuertorico.com/images/slideshow_restaurants.jpg') left top no-repeat"});
	$("#slideshowAndTextBox").fadeIn("fast");
	time3 = setTimeout('gotoCycle4()', 5000);
}
function gotoCycle4() 
{
	clearTimeout(time3);
	$("#slideshowAndTextBox").fadeOut("fast", function() { cycle4(); }); 
}
function cycle4() 
{	
	$("#slideshowAndTextBox").css({"background":"url('http://cdn.closetopuertorico.com/images/slideshow_scuba.jpg') left top no-repeat"});
	$("#slideshowAndTextBox").fadeIn("fast");
	time4 = setTimeout('gotoCycle1()', 5000);
}	
function gotoCycle1() 
{
	clearTimeout(time4);
	$("#slideshowAndTextBox").fadeOut("fast", function() { cycle1(); }); 
}

function getRegionSelect()
{
	var xmlhttp_1;
	if (window.XMLHttpRequest)
	  {
	  xmlhttp_1=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp_1=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp_1.onreadystatechange=function()
	  {
	  if (xmlhttp_1.readyState==4 && xmlhttp_1.status==200)
	    {
	    document.getElementById("region_selectBox").innerHTML=xmlhttp_1.responseText;
	    }
	  }
	xmlhttp_1.open("GET","includes/regionSelects.php",true);
	xmlhttp_1.send();
}

function getCategorySelect()
{
	var xmlhttp_2;
	if (window.XMLHttpRequest)
	  {
	  xmlhttp_2=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp_2=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp_2.onreadystatechange=function()
	  {
	  if (xmlhttp_2.readyState==4 && xmlhttp_2.status==200)
	    {
	    document.getElementById("categoria_selectBox").innerHTML=xmlhttp_2.responseText;
	    }
	  }
	xmlhttp_2.open("GET","includes/categorySelects.php",true);
	xmlhttp_2.send();
}
function selectionCoquiSearch()
{
	var namePlace=document.getElementById("name_place_find").value;
	var regSelected=document.getElementById("region_select_find").value;
	var catSelected=document.getElementById("categoria_select_find").value;
	/*if(namePlace == "")
    {
	 alert("Para obtener resultados escriba una busqueda en 'Nombre del Lugar'");
     return false;
    }*/
   
	$("#textandContentBox").fadeIn("fast");
	$("#butt_back2").fadeIn("fast");
	getSelectionByRegCar(namePlace,regSelected,catSelected);
	CloseselectMapBox();
	return true;
}
function CloseselectCoSch()
{
	var namePlace=document.getElementById("name_place_find").value="";
	var regSelected=document.getElementById("region_select_find").selectedIndex = 0;
	var catSelected=document.getElementById("categoria_select_find").selectedIndex = 0;
	$("#textandContentBox").fadeOut("fast");
	$("#butt_back2").fadeOut("fast");
	$("#textandContentBoxInside").html("");
}

function getSelectionByRegCar(namePlace,regSelected,catSelected)
{
	var xmlhttp_3;
	$("#loaderSearch").fadeIn("fast");
	if (window.XMLHttpRequest)
	  {
	  xmlhttp_3=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp_3=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp_3.onreadystatechange=function()
	  {
	  if (xmlhttp_3.readyState==4 && xmlhttp_3.status==200)
	    {
			document.getElementById("textandContentBox").innerHTML=xmlhttp_3.responseText;
			fleXenv.fleXcrollMain("textandContentBoxInside");
			$("#loaderSearch").fadeOut("fast");
	    }
	  }
	xmlhttp_3.open("GET","includes/getlistC2PRbyRegCat.php?nameplace="+namePlace+"&region_select_find="+regSelected+"&categoria_select_find="+catSelected,true);
	xmlhttp_3.send();
}

function getBoxnoticias()
{
	$("#textandContentBox").fadeIn("fast");
	$("#butt_back4").fadeIn("fast");
	getNoticia();
	$.scrollTo('#slideshowAndTextBoxBlack',800);
	CloseselectMapBox();
}

function getBoxform1()
{
	$("#textandContentBox").fadeIn("fast");
	$("#butt_back5").fadeIn("fast");
	getForm1();
	$.scrollTo('#slideshowAndTextBoxBlack',800);
}


function getNoticia()
{
	var xmlhttp_11;
	$("#loaderSearch").fadeIn("fast");
	if (window.XMLHttpRequest)
	  {
	  xmlhttp_11=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp_11=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp_11.onreadystatechange=function()
	  {
	  if (xmlhttp_11.readyState==4 && xmlhttp_11.status==200)
	    {
			document.getElementById("textandContentBox").innerHTML=xmlhttp_11.responseText;
			fleXenv.fleXcrollMain("noticiasBoxInside");
			$("#loaderSearch").fadeOut("fast");
	    }
	  }
	xmlhttp_11.open("GET","includes/getNoticia.php",true);
	xmlhttp_11.send();
}

function getForm1()
{
	var xmlhttp_12;
	$("#loaderSearch").fadeIn("fast");
	if (window.XMLHttpRequest)
	  {
	  xmlhttp_12=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp_12=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp_12.onreadystatechange=function()
	  {
	  if (xmlhttp_12.readyState==4 && xmlhttp_12.status==200)
	    {
			document.getElementById("textandContentBox").innerHTML=xmlhttp_12.responseText;
			fleXenv.fleXcrollMain("form1BoxInside");
			$("#loaderSearch").fadeOut("fast");
	    }
	  }
	xmlhttp_12.open("GET","includes/getForm1.php",true);
	xmlhttp_12.send();
}


function postonFacebook()
{
	window.open("http://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fclosetopuertorico.com&t=Close+to+Puerto+Rico+-+La+Primera+Guia+Turistica+Virtual+de+Puerto+Rico");
}

function postonTwitter()
{
	window.open("http://twitter.com/intent/tweet?text=Close+to+Puerto+Rico+-+La+Primera+Guia+Turistica+Virtual+de+Puerto+Rico&url=http%3A%2F%2Fclosetopuertorico.com&source=sharethiscom");
}



