﻿var EnSite ="prgovEN";
var Assesibility = "#Accesibility a"; 
var HeadText1 = "#HT1";
var HeadText2 = "#HT2"; 
var FooterText1 = "#FT1";
var Normas = "#normas a"; 
var Terminos = "#terminos a"; 
var CopyRight = "#CopyRight";

// Traducciones areas del Master
var AssesibilityEn = "Accesible Lineal Version";
var HeadText1En = "Official Website of the";
var HeadText2En = "Government of Puerto Rico";
var FooterText1En = "Accessibility No-001-07     Under Act 229 of 2003";
var NormasEn = "Terms of Use";
var TerminosEn = "Privacy";
var CopyRightEn = "Government of Puerto Rico Copyright © 2010";

//---- Round Corners Settins ----
rad = 8;  
  settings = {
          tl: { radius: rad },
          tr: { radius: rad },
          bl: { radius: 0 },
          br: { radius: 0 },
          antiAlias: true,
          autoPad: true,
          validTags: ["a"]
      }
//--------------------------------        
      
$(document).ready(function() {
		
	// EnglishTranlation();
	
	$('#WeatherData').weatherfeed(['USPR0083'],{unit:"f",wind:false,link:false});
	 
	// $('.corner').corner(settings);
 
});

function EnglishTranlation()
{
	
	var MyUrl = SplitURL();
		if(myUrl[1].toLowerCase() == EnSite.toLowerCase())
		{
			$(Assesibility).text(AssesibilityEn);
			$(HeadText1).text(HeadText1En);
			$(HeadText2).text(HeadText2En);
			$(FooterText1).text(FooterText1En);
			$(Normas).text(NormasEn);
			$(Terminos).text(TerminosEn);
			$(CopyRight).text(CopyRightEn);
		}
			
}
      
 
function DisableStyleSheet() {		
	for(i=0; i < document.styleSheets.length; i++)
	{
		document.styleSheets[i].disabled = true;
	}		
}

     
	
function SetNewStyle(style)
{
	var myUrl = SplitURL();
	var newURL = '<style type="text/css">@import url(' + "http://" + myUrl[0] + "/" + myUrl[1] + "/" + myUrl[2] + "/" + style + ");</style>";	
    return newURL;			
}
			
function SetAtribute(id, atribute, file) 
{ 
	var myUrl = SplitURL();
	var newURL ="http://" + myUrl[0] + "/" + myUrl[1] + "/" + myUrl[2] + "/" + file;
	var imgDest = document.getElementById(id);
	imgDest.setAttribute(atribute, newURL);		
}	
			
function SplitURL()
{
	var url = document.location.href;
	url = url.replace("http://","");
	var myUrl = url.split("/");
	return myUrl;			
}
			


//------------------------------ | Carusel | -------------------------------------//
var WebURL = "";

// Set these properties on the initCallback:function() of the Carusel Settings;
//----------------------------------------------------------------------------------------
var spList; //Set the Image Library to be used for the Carousel
var CarType; //Identifier to Set How the Finish Carousel will Look
var ImgHeight; //Set The height of the Image
var ImgWidth; // Set the width of the image


function mycarousel_itemLoadCallback(carousel, state)
{	   
    if (state != 'init') return;
     
	$().SPServices({
		operation: "GetListItems",
		async: false,
	    webURL: WebURL,
		listName:  spList,
		completefunc: function(xData, Status) {
			
			mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xData);			
		}
		
	});
};


function mycarousel_itemAddCallback(carousel, first, last, data)
{

	var counter = 0;
	//if (navigator.appName == "Microsoft Internet Explorer")	{	data = parseXml(data);	}	
		
			//alert(data.responseText);
			$(data.responseXML).find("[nodeName=z:row]").each(function(i){
        		var cText =  $(this).attr("ows_Title");
        		var cLink =  $(this).attr("ows_RedirectionLink");
        		var cImage =  WebURL+ "/" + $(this).attr("ows_RequiredField");
        		var HideIcon = $(this).attr("ows_HideIcon");        		
		
				if( HideIcon != 1 || HideIcon === undefined  ) {      		
					
					carousel.add(counter,mycarousel_getItemHTML(cImage,cText,cLink));				
					counter = counter + 1;				
				}
     		});				
     		
     		carousel.size(counter);   
}
	
/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(url,alt,link)
{
	switch(CarType)
	{
		case 1:
  			return '<div><a href="'+ link +'"><a href="'+link+'"><img src="' + url + '" width="'+ImgWidth+'" height="'+ImgHeight+'" title="Banner: '+ alt + '" alt="Banner: '+alt +'" /></a><div>';
  			break;
		default:
  			return '<div><a style="border:none;" href="'+link+'"><img  src="' + url + '" width="'+ImgWidth+'" height="'+ImgHeight+'" title="Icono Transacción '+ alt + '" alt="Icono Transacción '+alt +'" /></a><div><div><a href="'+ link +'">'+alt+'</a></div>';
		}
		
		return null;
		
};



