function playVideo(_8) 
{
   window.open(_8, "", "width=800,height=800,location=yes,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes,status=yes,directories=yes");
}
/* Header functions*/
// Begin : Headers 2 code

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function getEl( id ){ return document.getElementById( id ); }

// Login Functions
function AsnsSignIn( obj, leftOffSet, topOffSet, ele ) {
	if (!leftOffSet) leftOffSet = 0;
	if (!topOffSet) topOffSet = 0;
	var pSNS = getEl(ele);
	pSNS.innerHTML = "";
	pSNS.innerHTML += _sns_var_;
	if ( document.all ) {
		var pos = findPos(obj);
		pSNS.style.position = 'absolute';
		pSNS.style.left = (pos[0] + leftOffSet - 138) + 'px';
		pSNS.style.top =  (pos[1] + topOffSet + 12)  + 'px';
} else {
		obj.appendChild(pSNS);
		pSNS.style.left = leftOffSet + 'px';
		pSNS.style.top =  topOffSet  + 'px';
		pSNS.style.position = 'relative';
		}
	var close = document.createElement("span");
	var a = document.createElement("a");
	a.href = 'javascript:AsnsClose("'+ele+'")';
	a.title = "close";
	var img = document.createElement("img")
	img.src = "http://www.aolcdn.com/ch_living/10x10_x.gif";
	img.style.border = "0px"
	a.appendChild(img);
	close.appendChild(a);
	spans = pSNS.getElementsByTagName("span");
	spans[1].style.cssFloat = "right";
	spans[1].style.styleFloat = "right";
	spans[1].style.margin = "1px 0px 0px 10px";
	close.style.cssFloat = "right";
	close.style.styleFloat = "right";
	close.style.margin = "2px 2px 0px 0px";
	spanPar = spans[1].parentNode;
	spanPar.insertBefore(close,spans[1]);
	pSNS.style.zIndex = 5000;
	pSNS.style.display = "block";
}
function closeSNS(ele) {
	getEl(ele).innerHTML = '';
}

function AsnsClose(ele) {
	pSNS = getEl(ele);
	pSNS.style.display = "none";
}

function findPos(obj) {
	var curleft = curtop = 0;
	curleft = getX(obj);
	curtop = getY(obj);
	return [curleft,curtop];
}
function getY( oElement )
{
	var iReturnValue = 0;
	while( oElement != null ) {
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}

function getX( oElement )
{
	var iReturnValue = 0;
	while( oElement != null ) {
		iReturnValue += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}

function srchSub(ref){
  var frm=p_o("search");
  var queryval = frm.topQuery.value.trim();
  queryval = queryval.replace( /\+/, " ");
  if(ref == 'a'){
   var newurl = frm.action + queryval;
     if (frm.target == '_blank') {
        window.open(newurl, '_blank', '');
      } else {
        window.location = newurl;
      }
  }else{
  var newurl = ref.href + queryval;
  window.location = newurl;
 }
  return false;
}

function eventIsEnterKey(event) {
    if (event && event.which == 13 || window.event && window.event.keyCode == 13 || event && event.which == 3 || window.event && window.event.keyCode == 3) {
        return true;
    }
    return false;
}

//Prevent IE flickr
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

/*end header functions*/

function showToolTip(oCaller, ttID){document.getElementById(ttID).style.display = "block";}
function hideToolTip(oCaller, ttID){document.getElementById(ttID).style.display = "none";}

// Tag Cloud/List (Blog Chatter)
function showTags()
{
	if (iTagType == 1) // Show as Cloud
		{
			caption = "List";
			iTagType = 2;
			document.getElementById("tagCloud").style.display = "block";
			document.getElementById("newsTagList").style.display = "none";
		} 
		else // Show as List
		{
			caption = "Cloud";
			iTagType = 1;
			document.getElementById("tagCloud").style.display = "none";
			document.getElementById("newsTagList").style.display = "block";
		}
			document.getElementById("newsTagTypeAnc").innerHTML = caption;
}
// End: Tag Cloud/List (Blog Chatter)
function showToolTip(oCaller, ttID){document.getElementById(ttID).style.display = "block";}
function hideToolTip(oCaller, ttID){document.getElementById(ttID).style.display = "none";}

/*video-hub-grid*/
function changeBkgrnd(vidHub){
	if(vidHub.className == "item"){
           vidHub.className="active";
		   }
    else{
	vidHub.className="item";
	}
}

function showHide(){
	var adSrch = document.getElementById("drpBox");
	if(adSrch.style.display == "block"){
		adSrch.style.display="none";
		}
	else{
		adSrch.style.display = "block";
	}
}

function changeSort(obj){
  setPref("sort", obj.id);
  document.getElementById('frmHubSrt').submit()
  return false;
}

function changeSource(element)
{
  //var sources = new Array();
  //var sourcesIndex = 0;
  //for (var i=0; i < document.sourceForm.source.length; i++)
  //{
  //  if (document.sourceForm.source[i].checked)
  //    {
  //      sources[sourcesIndex] = document.sourceForm.source[i].value;
  //      sourcesIndex++;
   //   }
  // }
  setPref("sources",element.id);
  document.sourceForm.submit();
}

function goToHub() {
    var searchField = document.getElementById("searchField");
    var query = searchField.value;
    if((query != null) && (query.length > 0)) {
        window.location = "/vce/video-hub/?query=" + escape(query);
    }
 }
 
 function changeVw(bkgrnd,vw){
	  if(vw == "grid"){
		  if(bkgrnd.className == "grdViwBttn"){
                       bkgrnd.className = "gridViwOff";
					   document.getElementById("listBk").className="lstViwBttn";
		        }
          else{
	                 bkgrnd.className="grdViwBttn";
					 document.getElementById("listBk").className="listViwOff";
	         }
     }
	 else{
		 if(bkgrnd.className == "lstViwBttn"){
                       bkgrnd.className = "listViwOff";
					   document.getElementById("gridBk").className="grdViwBttn";
		        }
          else{
	                 bkgrnd.className="lstViwBttn";
					 document.getElementById("listBk").className="gridViwOff";
	         }
	 }
	 document.getElementById("hubContainer").className = vw;
	 setPref("view", vw);
	 //document.frmHubSrt.hubVw.value=vw;
     return true;
	
	
	
}

/*user ratings starts */
function iterateHover(mode, curNum, selectedNum, linkId) {
  for (var n=1; n <= selectedNum; n++) {
    var linkObj = getEl(linkId+n);
    var c;
    ((curNum > 0) && (curNum < 1)) ? (curNum = 1) : (curNum = curNum)
    if (mode == 'over') {
      c = 'over';
    } else if (mode == 'out') {
      (n <= curNum) ? (c = 'on') : (c = 'off')
    }
    linkObj.setAttribute('class',c); // FF & Safari
    linkObj.className = c; // IE
  }
}

function submitRating(trriAppName, videoUri, category, assetType, screenName, newRating, ratingScale, url){
  var request = getHTTPObject();
  var starList = getEl('ratingStarList');
  starList.innerHTML = '<img src="http://o.aolcdn.com/art/ch_living/gmc-ajax-loader" style="padding-right:5px;float:left;"/><p style="border:1px solid #555;padding:2px 4px;float:left;color:#555;margin-top:6px;margin-right:15px;">SAVING...</p>'; 
  if(request){
    request.onreadystatechange = function(){
      displayRatingResponse(request, newRating);
    };
    request.open("POST", url, true);
    request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    request.send("trriAppName="+trriAppName+"&videoUri="+videoUri+"&category="+category+"&assetType="+assetType+"&screenName="+screenName+"&newRating="+newRating+"&ratingScale="+ratingScale);
  }
}

function displayRatingResponse(request, newRating){
  var starList = getEl('ratingStarList');
  if(request.readyState != 4){
    
  } else {
    var element = getEl('dtRatings');
    element.innerHTML = request.responseText;
    switch(newRating){
      case '1':
        starList.innerHTML = '<li><span id="ratingStar1" class="on"> </span></li><li><span id="ratingStar2" class="off"> </span></li><li><span id="ratingStar3" class="off"> </span></li><li><span id="ratingStar4" class="off"> </span></li><li><span id="ratingStar5" class="off"> </span></li>';
        break;
      case '2':
        starList.innerHTML = '<li><span id="ratingStar1" class="on"> </span></li><li><span id="ratingStar2" class="on"> </span></li><li><span id="ratingStar3" class="off"> </span></li><li><span id="ratingStar4" class="off"> </span></li><li><span id="ratingStar5" class="off"> </span></li>';
        break;
      case '3':
        starList.innerHTML = '<li><span id="ratingStar1" class="on"> </span></li><li><span id="ratingStar2" class="on"> </span></li><li><span id="ratingStar3" class="on"> </span></li><li><span id="ratingStar4" class="off"> </span></li><li><span id="ratingStar5" class="off"> </span></li>';
        break;
      case '4':
        starList.innerHTML = '<li><span id="ratingStar1" class="on"> </span></li><li><span id="ratingStar2" class="on"> </span></li><li><span id="ratingStar3" class="on"> </span></li><li><span id="ratingStar4" class="on"> </span></li><li><span id="ratingStar5" class="off"> </span></li>';
        break;
      case '5':
        starList.innerHTML = '<li><span id="ratingStar1" class="on"> </span></li><li><span id="ratingStar2" class="on"> </span></li><li><span id="ratingStar3" class="on"> </span></li><li><span id="ratingStar4" class="on"> </span></li><li><span id="ratingStar5" class="on"> </span></li>';
        break;
    }    
  }
}

/*user ratings ends */
function changeCnt(cnt) {
   //document.navcountgen.numrecrd.value=cnt;
   setPref("resultsNbr", document.navcountgen.resultsNbr.value)
   document.navcountgen.submit();
   return true;
}

var type_error = "error";
var type_debug = "debug";
var isdebug = false;

function log( type, msgs ) {
    var result = "";
	for (var i = 0; i < arguments.length; i++){
		result += " " + arguments[i];
	}
	if (type == type_debug && isdebug ) alert(result);
}

var logger = new function() {
	this.error = function(msgs){ log(type_error,msgs); };
	this.debug = function(msgs){ log(type_debug,msgs); };
}

if (typeof console == "undefined" || !console.error) {
	var console = {};
	console= logger;
}

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 setPref(param, value){
	var prefCookieName = "VCE-PREFS";
	var prefCookieString = "";
	var prefDelim = "&";
	var keyvalDelim = ":";
	var prefArray;
	var prefCookie = getCookie(prefCookieName);
	if ( prefCookie ) {
		prefArray = prefCookie.split(prefDelim);
	} else {
		prefArray = new Array();
	}

	var re = "^" + param + keyvalDelim;
	for (var i=0;i<prefArray.length;i++){
		if ( prefArray[i].search(re) <  0 ){
			if (prefCookieString != "" ){
				prefCookieString += prefDelim;
			}
			prefCookieString += prefArray[i];
		}
	}
	if (prefCookieString != "" )
		prefCookieString += prefDelim;

	prefCookieString += (param + keyvalDelim + value);
  setCookie(prefCookieName,prefCookieString,null);
	//document.cookie = prefCookieName + "=" + prefCookieString + "; path=/";
	console.debug("prefCookieString: ",prefCookieString);
	}

function getHTTPObject() {
 var xhr = null;
 if (window.XMLHttpRequest) {
  xhr = new XMLHttpRequest();
 } else {
  if (window.ActiveXObject) {
   try {
    xhr = new ActiveXObject("Msxml2.XMLHTTP");
   }
   catch (e) {
    try {
     xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) {
     xhr = null;
    }
   }
  }
 }
 return xhr;
}

function cutString (str, maxchars) {
		if(str&&str.length<maxchars) return str;
		else if(str) return (str.substring(0,maxchars).lastIndexOf(" ")>0)?str.substring(0,str.substring(0,maxchars).lastIndexOf(" ")):str.substring(0,maxchars);
		else return "";
	}

//ajax callback function
function displayResponse(request, elementId){
  if(request.readyState == 4){
    var element = document.getElementById(elementId);
    element.innerHTML = request.responseText;
  }
}


//sets a cookie with the specified
//name, value and expiration date
function setCookie(name,value,expiredays){
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path=/";
}

//returns the value of the
//specified cookie
function getCookie(cookieName){
  if (document.cookie.length>0){
    var start=document.cookie.indexOf(cookieName + "=");
    if (start!=-1){ 
      start=start + cookieName.length+1; 
      var end=document.cookie.indexOf(";",start);
      if (end==-1){
        end=document.cookie.length;
      }
      return unescape(document.cookie.substring(start,end));
    } 
  }
  return null;
}


//removes the specified element from the
//current array
function removeFromArray(array, element){
  var newArray = new Array(array.length - 1);
  var ni = 0;
  var i = 0;
  for(; i < array.length;){
    if(array[i].indexOf(element) == -1){
      newArray[ni] = array[i];
      ni=ni+1; 
    }
    i=i+1;
  } 
  return newArray; 
}

//adds the specified element to the
//current array
function addToArray(array, element){
  var newArray = new Array(array.length + 1);
  var l = array.length;
  var i = 0;
  for(; i < array.length; ){
    newArray[i] = array[i];
    i=i+1;
  }
  newArray[i] = element;
  return newArray;     
}

function otherVidsHoverStyle(id) {
  var idImgTags = id.getElementsByTagName('IMG');
  idImgTags[0].style.background = '#b2b9bc';
  idImgTags[0].style.border = '1px solid #b2b9bc';
  var idAnchorTags = id.getElementsByTagName('A');
  idAnchorTags[0].style.color = '#555';
  idAnchorTags[0].style.textDecoration = 'underline';
  id.style.background = '#E7E7E9';
}

function otherVidsHoverOutStyle(id) {
  var idImgTags = id.getElementsByTagName('IMG');
  idImgTags[0].style.background = '#fff';
  idImgTags[0].style.border = '1px solid #c7e3ef';
  var idAnchorTags = id.getElementsByTagName('A');
  idAnchorTags[0].style.color = '#3952a2';
  idAnchorTags[0].style.textDecoration = 'none';
  id.style.background = '#fff';
}

function tabSwitcher(id) {
  var activeId = document.getElementById(id);
  var tabOne = document.getElementById('tabMod_tabOne');
  var tabTwo = document.getElementById('tabMod_tabTwo');
  var tabThree = document.getElementById('tabMod_tabThree');
  var oneBody = document.getElementById('tabMod_oneLayer');
  var twoBody = document.getElementById('tabMod_twoLayer');
  var threeBody = document.getElementById('tabMod_threeLayer');

  if (activeId == tabOne) {
    activeTab(tabOne, oneBody);
    inActiveTab(tabTwo, twoBody);
    inActiveTab(tabThree, threeBody);
  } else if (activeId == tabTwo) {
    activeTab(tabTwo, twoBody);
    inActiveTab(tabOne, oneBody);
    inActiveTab(tabThree, threeBody);
  } else if (activeId == tabThree) {
    activeTab(tabThree, threeBody);
    inActiveTab(tabOne, oneBody);
    inActiveTab(tabTwo, twoBody);
  }
}

function activeTab(tabId, bodyId) {
  if (tabId == document.getElementById('tabMod_tabOne')) {
    tabId.innerHTML = '<span>BOOK</span>';
  } else if (tabId == document.getElementById('tabMod_tabTwo')) {
    tabId.innerHTML = '<span>BIO</span>';
  } else if (tabId == document.getElementById('tabMod_tabThree')) {
    tabId.innerHTML = '<span>POLL</span>';
  }
  bodyId.style.display = 'block';
  tabId.style.background = '#DAEDF4 url(http://o.aolcdn.com/art/aol-body/coaches_rtrl_selected) repeat-x';
}

function inActiveTab(tabId, bodyId) {
  if (tabId == document.getElementById('tabMod_tabOne')) {  
    tabId.innerHTML = '<a href="#" onClick="javascript:tabSwitcher(\'tabMod_tabOne\');return false;">BOOK</a>';
  } else if (tabId == document.getElementById('tabMod_tabTwo')) {
    tabId.innerHTML = '<a href="#" onClick="javascript:tabSwitcher(\'tabMod_tabTwo\');return false;">BIO</a>';
  } else if (tabId == document.getElementById('tabMod_tabThree')) {
    tabId.innerHTML = '<a href="#" onClick="javascript:tabSwitcher(\'tabMod_tabThree\');return false;">POLL</a>';
  }  
  bodyId.style.display = 'none';
  tabId.style.background = '#DAEDF4 url(http://o.aolcdn.com/art/aol-body/coaches_rtrl_tab) repeat-x';
}

function printDiv() {
    var d = window.open('','','width=300,height=300,resizable=yes');
    d.document.open('text/html');
    d.document.write(document.getElementById('article').innerHTML);
    d.document.close();
    d.print();
}

function addComment() {
  if (_sns_isLoggedIn!=true) {
    AsnsSignIn(getEl('commentAddForm'), 100, -80,'snsMiniUI');
  } else {
    if ((getEl('commentBox').value == '') || (getEl('commentBox').value == 'Type your own comment here.')) {
      return;
    } else {
      getEl('commentAddForm').submit();
    }
  }
}

//begin HP Tabblo code
function __TABBLO_TPT_LOAD() {
    Tabblo.embedded.sites.SettingsObject.preprocess.apply({

        Properties:
        {
            template: 'news_large'
        },
        FixedContent:
        {
            accentcolor: '#741037',
            accentcolor2: '#b08431',
			'logo': 'http://www.aolcdn.com/ch_home/print-logo'
        },
        // content definition:
        Content:
        {
            'pagetitle':   { match: 'css', selector:'.articleTitle' },
            'text':        { match: 'css', selector:'#mainArtNavHead' }
		}
    },[]);
    Tabblo.embedded.printabulous();
}

function MakePDF() {
    // append tabblo print script on demand
    var _tpt_script_loaded = false;
    if (!_tpt_script_loaded) {
	_tpt_script_loaded = true;
    	var tpS = document.createElement('script');
    	tpS.setAttribute('type','text/javascript');
    	tpS.setAttribute('charset', 'utf-8');
    	tpS.setAttribute('src','http://h30405.www3.hp.com/edit/tptboot/1.0');
    	document.getElementsByTagName('body').item(0).appendChild(tpS);
    } else {
	Tabblo.embedded.detect.setup(Tabblo.embedded.printabulous.bind(null,false));
    }
}
//end HP Tabblo code

function shareWin(url) {
    w = window.open(url,'GMCShared','resizable=yes,height=520,width=755');
    if (window.focus) {
      w.focus()
    }
    return false;
}

// GPL'd courtesy of http://www.jeffothy.com/weblog/clipboard-copy
// Needs swf file at http://www.aolcdn.com/_media/ch_music2/_clipboard.swf
function copyElToClip(el) {
  var inElement = document.getElementById(el);
  if (inElement.createTextRange) {
    var range = inElement.createTextRange();
    if (range)
      range.execCommand('Copy');
  } else {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="http://www.aolcdn.com/_media/ch_music2/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
}
/* Bottom search functions start */
function searchTargetBot(url, newWindow, newTarget) {
 // Set the target for the form
 document.bb_botform.action = url;
 if (newWindow) {
 document.bb_botform.target = '_blank';
 } else {
 document.bb_botform.target = '';
 }

 // Update the tabs classes to allow highlighting of the selected
 var arrElements = getElementsByClassName ('searchCatBgBot', 'li');
 for (var i=0; i<arrElements.length; i++) {
 arrElements[i].className = '';
 }
 document.getElementById(newTarget).className = 'searchCatBgBot';

 return false;
}

function submitFooterSearch(event) {
 if (event == "onclick" || eventIsEnterKey(event)) {
 return srchSub2Bot();
 } else {
 return true;
 }
}

function srchSub2Bot() {
 var frm=p_o("search");
 var queryval = frm.botquery.value.trim();
 queryval = queryval.replace( /\+/, " ");
 var newurl = frm.action + queryval;
 if (frm.target == '_blank') {
 window.open(newurl, '_blank', '');
 } else {
 window.location = newurl;
 }
 return false;
}

/* Bottom search functions end */


/* SNS Login Verification */
function loginCheck() {
    var sitedomain1 = 'sitedomain='+sitedomain;
    var url="siteState="+encodeURIComponent("OrigUrl="+encodeURIComponent(window.location));
    if(_sns_isLoggedIn) {
        getEl("userspan").innerHTML="Logged In: "+_user_display_name;        
		getEl("loginlink").href="https://my.screenname.aol.com/_cqr/logout/mcLogout.psp?"+sitedomain1+"&"+url;
        getEl("loginlink").title="Sign Out";
        getEl("loginlink").innerHTML="Sign Out";
    } else {
       	getEl("loginlink").href="https://my.screenname.aol.com/_cqr/login/login.psp?"+sitedomain1+"&"+url;
        getEl("loginlink").title="Sign In";
        getEl("loginlink").innerHTML="Sign In";
    }
}
/*this is for clearing the textarea of the Ask the pro modules starts*/
  function checkTxt(id, defaulttxt){
    if(id == "prosTxt"){
      if(defaulttxt == "Have a question for the pros? Every week they'll pick two as part of the featured Pros' Pick below. But the pros can't get to everyone, so the community will help too.") {
        getEl(id).value = "";
      }      
    } else if(id == "innxbox"){			
      if(defaulttxt == "Ask "+expNameDenormalized+" a question here."){
        getEl(id).value = "";
      }
    }
  }
  function txtReset(id, defaulttxt){
    if(defaulttxt == "") {
      if(id == "prosTxt"){
        getEl(id).value = "Have a question for the pros? Every week they'll pick two as part of the featured Pros' Pick below. But the pros can't get to everyone, so the community will help too."; 
      } else if(id == "innxbox"){
        getEl(id).value = "Ask "+expNameDenormalized+" a question here.";
      }
    }
  }
  /*this is for clearing the textarea of the Ask the pro modules ends*/

  function SubmitForm(){

					document.HomeSearchForm.searchTerm.value = document.HomeSearchForm.searchTerm.value.replace(/[^a-z0-9\-\+\s]*/gi,"").replace(/\s{2,}/g," ");
					if(document.HomeSearchForm.searchTerm.value.replace(/\s/g,"")=="") { return; }

					document.HomeSearchForm.action='/'+document.HomeSearchForm.sCategory.value+'/experts/'+document.HomeSearchForm.sExpert.value+'/search-results/'+document.HomeSearchForm.searchTerm.value;
                    document.HomeSearchForm.submit();
					
                } 
