function vidTracker(vidProg){
	if (vidName==null)	vidName='Unnamed Grow Up Great Video - English';
	if (vidType==null)	vidType='English Video';
	//alert(vidName+", "+vidType+", "+vidProg);
	switch(vidProg){
	
		case "p":
			dcsMultiTrack( 'WT.clip_n', vidName, 'WT.clip_t', vidType, 'WT.clip_ev', vidProg );			
			break;
		case "25":
			dcsMultiTrack( 'WT.clip_n', vidName, 'WT.clip_t', vidType, 'WT.clip_ev', vidProg );		
			break;
		case "50":
			dcsMultiTrack( 'WT.clip_n', vidName, 'WT.clip_t', vidType, 'WT.clip_ev', vidProg );			
			break;
		case "75":
			dcsMultiTrack( 'WT.clip_n', vidName, 'WT.clip_t', vidType, 'WT.clip_ev', vidProg );			
			break;
		case "f":
			dcsMultiTrack( 'WT.clip_n', vidName, 'WT.clip_t', vidType, 'WT.clip_ev', vidProg );			
			break;	
	}	
} 

var currentLanguage = "en";

function createCookie(name,value) {
	document.cookie = name+"="+value+";path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	
	return null;
}

function eraseCookie(name) {
	//alert("erase cookie");
	var path="/";
	var domain="";
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function addStyleSheet(path) {
  if(document.createStyleSheet) {
    document.createStyleSheet(path);
  } else {
    var newSS=document.createElement('link');
    newSS.rel='stylesheet';
    newSS.href=path;
    document.getElementsByTagName("head")[0].appendChild(newSS);
  }
}

String.prototype.endsWith = function(str) 
{ 
    return (this.match(str+"$")==str);
} 


var spanishPath;
//var spTest = spanishPath.substring(0,12);
var spTest = window.location.hostname;
//alert(spTest);
switch(spTest){
	case "localhost":
		spanishPath = "http://localhost/crezcaconexito/"
		break;
	case "webdev.pncsites.com":
		spanishPath = "http://webdev.pncsites.com/crezcaconexito/";
		break;
	case "webqa.pncsites.com":
		spanishPath = "http://webqa.pncsites.com/crezcaconexito/";
		break;
	case "webqa.pncgrowupgreat.com":
		spanishPath = "http://webqa.pnccrezcaconexito.com/";
		break;
	case "pncsites.com":
		spanishPath = "http://www.pncsites.com/crezcaconexito/";
		break;
	case "www.pncsites.com":
		spanishPath = "http://www.pncsites.com/crezcaconexito/";
		break;
	case "pncgrowupgreat.com":
		spanishPath = "http://www.pnccrezcaconexito.com/";
		break;
	case "www.pncgrowupgreat.com":
		spanishPath = "http://www.pnccrezcaconexito.com/";
		break;
}


if(getParameterByName("lang")=="sp"){
	if(readCookie("lang")!="sp"){
		createCookie("lang", "sp");
	}
}
	
if(readCookie("lang")=="sp"){
	var nav_flashvars =
	{
	  bgColor: window.navBgColor || "0x3383EA",
	  language: window.hasSpanish ? currentLanguage : "",
	  homePath: spanishPath+"index.html",
	  aboutPath: spanishPath+"sobre_nosotros/index.html",
	  parentsCaregiversPath: spanishPath+"padres/index.html",
	  educatorsPath: path+"educators/index.html?lang=sp",
	  philanthropyPath: path+"philanthropy/index.html?lang=sp",
	  mediaPath: path+"media/index.html?lang=sp",
	  hasSpanish: window.hasSpanish,
	  currentPage: window.location.hostname,
	  currentHref: window.location.href,
	  langPageURL: window.langURL,
	  currentLang: "sp"
	}
} else{
	var nav_flashvars =
	{
	  bgColor: window.navBgColor || "0x3383EA",
	  language: window.hasSpanish ? currentLanguage : "",
	  homePath: path+"index.html",
	  aboutPath: path+"about/index.html",
	  parentsCaregiversPath: path+"parents_caregivers/index.html",
	  educatorsPath: path+"educators/index.html",
	  philanthropyPath: path+"philanthropy/index.html",
	  mediaPath: path+"media/index.html",
	  hasSpanish: window.hasSpanish,
	  currentPage: window.location.hostname,
	  currentHref: window.location.href,
	   langPageURL: window.langURL,
	  currentLang: currentLanguage
	}
}

var tip_flashvars =
{
  languageCode: currentLanguage,
  tipXMLURL_en: "swf/english_tips.xml",
  tipXMLURL_sp: "swf/spanish_tips.xml",
  moreTipsURL: "parents_caregivers/tips.html",
  signUpForTipsURL: "parents_caregivers/email_signup.html"
}

var tips_flashvars =
{
  languageCode: currentLanguage,
  tipXMLURL_en: "../swf/english_tips.xml",
  tipXMLURL_sp: "../swf/spanish_tips.xml",
  forwardTipURL: "../about/forward_to_friend.html",
  submitTipURL: "../about/contact_us.html"
}

var activities_flashvars =
{
  cleanroom_boy_en: "http://content.pncmc.com/live/pnc/growupgreat/downloads/cleanroom_boy_en.pdf",
  cleanroom_boy_sp: "http://content.pncmc.com/live/pnc/growupgreat/downloads/cleanroom_boy_sp.pdf",
  cleanroom_girl_en: "http://content.pncmc.com/live/pnc/growupgreat/downloads/cleanroom_girl_en.pdf",
  cleanroom_girl_sp: "http://content.pncmc.com/live/pnc/growupgreat/downloads/cleanroom_girl_sp.pdf"
}

var params = {
  allowScriptAccess: "Always"
};
/************************** inserting new code ***********************/
function showCalendar(){
	var pageUrl = "https://www.pnc.com/webapp/sec/Blank.do?siteArea=/PNC/pncbk/grow+up+great+events+calendar";  // WCM URL
	var width = 570;
	var height = 680;
	var screenleft=(screen.width)?(screen.width-width)/2:100;
	var screentop=10;
	var winNew = window.open(pageUrl,"pncGUG_Calendar","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left="+screenleft+",top="+screentop);

	
}

function showVideoMessage(pageUrl){
	
	var width = 660;
	var height = 370;
	var screenleft=(screen.width)?(screen.width-width)/2:100;
	var screentop=77;
	var winNew = window.open(pageUrl,"video_message","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left="+screenleft+",top="+screentop);

	
}

swfobject.embedSWF(path+"swf/mainNav.swf", "main-nav", "970", "115", "9.0.0", null, nav_flashvars, params);
swfobject.embedSWF(path+"swf/RandomTip.swf", "random-tip", "519", "424", "9.0.0", null, tip_flashvars);
swfobject.embedSWF(path+"swf/TipSelector.swf", "tips-selector", "830", "446", "9.0.0", null, tips_flashvars);
swfobject.embedSWF(path+"swf/GUGgames.swf", "flash-activities", "954", "483", "9.0.0", null, activities_flashvars);

$(function() {
  if(window.hasSpanish) {
    $(".to-spanish").show();
    $(".to-english").show();
  }
});
function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}
function Get_Cookie( name ) {

var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
