/* DOMScriptsLibrary.js contains highly reusable DOM scripts for use amongs all sites. Updated by JB 6th Nov 2007 */

/* Simplifies onload, you will no longer have to add an onload event call just call addLoadEvent */
function addLoadEvent(func,arg){

if (!arg){
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
}
}
  else{/*if the onload event has an argument/parameter cater for that*/
  if (arg){
  oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func(arg); 
	}
     window.onload = function() {
      oldonload();
      func(arg); 
    }
  }
}
}


/* function - remove content from an input on focus */
function clearInputContent(){
	if (!document.getElementById) return false;
	if (!document.observe) return false;
	if (!$$('input.resetText').length) return false;
		var elements = $$('input.resetText');
		 	for (var i=0; i<elements.length; i++){
				var originalValue = elements[i].readAttribute('value');
			 	elements[i].onfocus = function(){
					 if (this.value == originalValue){
						 this.clear();
							 this.onblur = function(){
								if (this.value==""){
								this.value = originalValue;	 
							}
						}
					}
				}
		 	}
}

function loadGAScript(){
	/*Check browser for Dom compatibility*/
if (!document.getElementsByTagName) return false;
/*Determines whether the page is using a secure or unsecure protocol*/
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
/*Writes in the script to the document head*/
var gaScript = document.createElement("script");
gaScript.setAttribute("src",gaJsHost +"google-analytics.com/ga.js");
gaScript.setAttribute("type","text/javascript");
var domHead = document.getElementsByTagName("head")[0]
domHead.appendChild(gaScript);
	}
	loadGAScript();

/*Calls the function*/
function callGA(){	
var pageTracker = _gat._getTracker("UA-5116637-28");
pageTracker._initData();
pageTracker._trackPageview();
}


/* track links with the class of rss */
function trackRss(){
if (!document.getElementsByTagName) return false; //added to test the browsers DOM compatibility
if (!document.getElementsByTagName('a')) return false; //added to test for any divs
var divs = document.getElementsByTagName('a');
 for(var i=0,j=divs.length;i<j;i++){
  if (divs[i].className.match('button')){ // .match to deal with multiple class names
   divs[i].onclick = function (){
		var pageTracker = _gat._getTracker("UA-5116637-28");
		pageTracker._initData();
		pageTracker._trackPageview("/sono-curioso.html"); 
   }
  }
 }
}



addLoadEvent(callGA);
addLoadEvent(trackRss);
