///Summary: The tools.js file contains commonly used functions
///Remarks: queryString(key) will return the key to search for, a 'false' if null
///Created By: sreichert, 9/24/07

//Summary: query object, retrieves entire page query and parses it
function PageQuery(q) {
  if(q.length > 1) this.q = q.substring(1, q.length);
  else this.q = null;
  
  this.keyValuePairs = new Array();
  
  if(q) {
    for(var i=0; i < this.q.split("&").length; i++) {
      this.keyValuePairs[i] = this.q.split("&")[i];
    }
  }
  
  this.getKeyValuePairs = function() { return this.keyValuePairs; }
  
  this.getValue = function(s) {
    for(var j=0; j < this.keyValuePairs.length; j++) {
      if(this.keyValuePairs[j].split("=")[0] == s){
        return this.keyValuePairs[j].split("=")[1];
      }
    }
    
    return false;
  }
  
  this.getParameters = function() {
    var a = new Array(this.getLength());
    
    for(var j=0; j < this.keyValuePairs.length; j++) {
      a[j] = this.keyValuePairs[j].split("=")[0];
    }
    
    return a;
  }
  
  this.getLength = function() { return this.keyValuePairs.length; } 
}

//Summary: retrieves a query key
function queryString(key){
  var page = new PageQuery(window.location.search); 
  return unescape(page.getValue(key)); 
}

//Summary: opens a pop up, retrieves size
function openPopUp(url, width, height, scrollbars){
  mywindow = window.open(url,"mywindow","location=0,status=0,scrollbars=" + scrollbars + ",width=" + width + ",height=" + height);
}

//author: LTello 7/3
//This wrapper function is used to make a google function call.

//Count the number of videos views when someone clicks on play.
/*
function googleVideoView(type, videoName){
    pageTracker._trackEvent("Advocates", "Video Name - "+videoName, ""+xmlDoc.FirstName+" "+xmlDoc.LastName);
    /* remove below
    if(type == "v"){
        pageTracker._trackEvent("Advocates", "Video Name - "+videoName, ""+xmlDoc.FirstName+" "+xmlDoc.LastName);
    }
    else if (type == "w"){
        pageTracker._trackEvent("Advocates", "Video Name - "+videoName, ""+xmlDoc.FirstName+" "+xmlDoc.LastName);
    }
    
}*/
/*
function googleVideoView(type, videoName) {
    if (type == "v") {
        videoTracker._trackEvent("Video View", "" + videoName);
    } else if (type == "w") {
        webcastTracker._trackEvent("Video View", "" + videoName);
    } else if (type == "a") {
        webcastTracker._trackEvent("Video View", "" + videoName);
    }
}*/

//tracking occurs every 25 percent
function googlePercentageView(type, percentage, videoName){
    pageTracker._trackEvent(""+type, ""+percentage, ""+videoName);
}
/*
function googlePercentageView(type, videoName) {
    if (type == "v") {
        videoTracker._trackEvent("Viewing Percentage", "" + videoName, 10);
    } else if (type == "w") {
        webcastTracker._trackEvent("Viewing Percentage", "" + videoName, 10);
    } else if (type == "a") {
        webcastTracker._trackEvent("Viewing Percentage", "" + videoName, 10);
    }
}*/

function capitalize(theString){
    return theString.charAt(0).toUpperCase() + theString.substring(1).toLowerCase();
}

function showHideKeppra(idName){
   if(idName == 'SubtierMaster_subtierContent_ProfileRegistration2_Q6_5_FLD_2'){
       document.getElementById('SubtierMaster_subtierContent_ProfileRegistration2_Q6_5_1_FLD_Container').style.display = 'block';
       $('.ques6_5').removeClass('whiteMotify');
       $('.ques6_5').addClass('blueMotify');
   }
   else if(idName == 'SubtierMaster_subtierContent_ProfileRegistration2_Q6_5_FLD_3'){
       document.getElementById('SubtierMaster_subtierContent_ProfileRegistration2_Q6_5_1_FLD_Container').style.display = 'none';
       $('.ques6_5').removeClass('blueMotify');
       $('.ques6_5').addClass('whiteMotify');
   }
   else if(idName == 'SubtierMaster_subtierContent_ProfileRegistration2_Q6_6_FLD_2'){
       document.getElementById('SubtierMaster_subtierContent_ProfileRegistration2_Q6_6_1_FLD_Container').style.display = 'block';
       $('.ques6_6').removeClass('whiteMotify');
       $('.ques6_6').addClass('blueMotify');
   }
   else if(idName == 'SubtierMaster_subtierContent_ProfileRegistration2_Q6_6_FLD_3'){
       document.getElementById('SubtierMaster_subtierContent_ProfileRegistration2_Q6_6_1_FLD_Container').style.display = 'none';
       $('.ques6_6').removeClass('blueMotify');
       $('.ques6_6').addClass('whiteMotify');
   }
   else if(idName == 'SubtierMaster_subtierContent_ProfileRegistration2_Q6_6_FLD_4'){
       document.getElementById('SubtierMaster_subtierContent_ProfileRegistration2_Q6_6_1_FLD_Container').style.display = 'none';
       $('.ques6_6').removeClass('blueMotify');
       $('.ques6_6').addClass('whiteMotify');
   }
   else if(idName == 'SubtierMaster_subtierContent_ProfileRegistration2_Q6_17_FLD_2'){
       document.getElementById('SubtierMaster_subtierContent_ProfileRegistration2_Q6_17_1_FLD_Container').style.display = 'block';
       $('.ques6_7').removeClass('whiteMotify');
       $('.ques6_7').addClass('blueMotify');
   }
   else if(idName == 'SubtierMaster_subtierContent_ProfileRegistration2_Q6_17_FLD_3'){
       document.getElementById('SubtierMaster_subtierContent_ProfileRegistration2_Q6_17_1_FLD_Container').style.display = 'none';
       $('.ques6_7').removeClass('blueMotify');
       $('.ques6_7').addClass('whiteMotify');
   }
   else if(idName == 'SubtierMaster_subtierContent_ProfileRegistration2_Q6_17_FLD_4'){
       document.getElementById('SubtierMaster_subtierContent_ProfileRegistration2_Q6_17_1_FLD_Container').style.display = 'none';
       $('.ques6_7').removeClass('blueMotify');
       $('.ques6_7').addClass('whiteMotify');
   }   
}

/************************************************************************
   created: LTello
   Date: 03/03/09
 
   Version: 0.1
   Description: Hide the purple can nation walk callouts on march 29
   
************************************************************************/

var UCB = UCB ||{};

UCB.Util = function(){
    var myDate=new Date();
    myDate.setFullYear(2009,2,29);
    
    var today = new Date();
    
    function checkDate(){
        var myDate=new Date();
        myDate.setFullYear(2009,2,29);
        var today = new Date();
        if(today < myDate){
            return true;
        }
        return false;
    }
    
    return{
       init: function(){        
         if(checkDate()){
           try{
             $('#middle_area').show();
             $('.purpleDay').show();
             $('.marchEvent').show();
             $('.nationalWalk').show();
             $('.marchEvent').show();
           }
           catch(e){
           }
         }
         else{
            $('.dadStory').show();
            $('.epilepsyCamp').show();
         }
       }
       
    }
}();

$(document).ready(function(){
    UCB.Util.init();
    var path = document.location.pathname;
    if (path == "/living-with-epilepsy/childhood.aspx" || path == "/epilepsy-support/articles.aspx" || path == "/living-with-epilepsy/awareness/about-epilepsy.aspx")
    {
        document.getElementById("SubtierMaster_webcast_callout").className = "webcast-callout-show";   
    }
});

function showdiv(id){
    var temp = document.getElementById(id);
    temp.style.display = "block";
}
function hidediv(id){
    var temp = document.getElementById(id);
    temp.style.display = "none";
}
function openWindow(){
    window.open("http://www.connect.facebook.com/login.php?connect_id=126245912663&popup=true","mywindow","menubar=1,resizable=1,scrollable=1width=650,height=450");
    //window.open("http://www.connect.facebook.com/login.php?connect_id=126245912663&popup=true","mywindow","menubar=1,resizable=1,width=650,height=450");
}