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://my.screenname.aol.com/images/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/aol-body/ajax_loader" style="padding-right:5px;float:left;"/><p style="background:#fff;border:1px solid #C8E4F0;padding:2px 4px;float:left;color:#76B6D2;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"><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"><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"><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"><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"><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: '#555',
      accentcolor2: '#ccc'
    },
    // content definition:
    Content:
      {
      'pagetitle':   { match: 'css', selector:'.artHeader h1' },
      'text':        { match: 'css', selector:'#mainArtNavHead' },
      'logo':        { match: 'match',  attr: 'src', value:'gmc-title', continueHooks: false, nodeContentType: 'image' }                       
    }
  },[]);
  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) {
    var sharePanel = document.createElement("div");
    var shareOverlay = document.createElement("div");
    $(sharePanel).attr("id", "shareWin");
    $(shareOverlay).attr("id", "shareOverlay");
    $("body").prepend(sharePanel);
    $("body").prepend(shareOverlay);
    var shareOffSet = $(".shareList").offset();
    $("#shareWin").css({ top:shareOffSet.top, left:shareOffSet.left });
var html =$.ajax({
  type: "GET",
  url: url,
  success: function(html){
    $("#shareWin").append(html);
    loadWin();
  }
});


}*/

function shareWin(url) {
    w = window.open(url,'GMCShared','resizable=yes,height=520,width=780');
    if (window.focus) {
      w.focus()
    }
	  loadWin();
    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;
  }
}
/* 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";
	 }
}

// Header2.0  (SEARCH BAR)
function p_o(o){return document.getElementById(o);}

function ai_posX(obj){
 var left=0;
 if(obj.offsetParent){
 while(obj.offsetParent){
 left+=obj.offsetLeft;
 obj=obj.offsetParent;
 }
 }else if(obj.x)left+=obj.x;
 return left;
}
function ai_posY(obj){
 var top=0;
 if(obj.offsetParent){
 while(obj.offsetParent){
 top+=obj.offsetTop;
 obj=obj.offsetParent;
 }
 } else if(obj.x)top+=obj.y;
 return top;
}

function togMore(e,state){
 var oDiv=p_o('smore');
 if(state=='show'){
 posMore(e);
 oDiv.style.zIndex='99999999';
 oDiv.style.display='block';
 } else {
 oDiv.style.display='none';
 }
 return false;
}
function posMore(e){
 var oDiv=p_o('smore');
 var oLnk=p_o('smorea');
 posY = findMousePos(e);
 oDiv.style.left='638px';
 oDiv.style.top='28px';
}

function fttogMore(e,state){
 var oDiv=p_o('ft-smore');
 if(state=='show'){
 ftposMore(e);
 oDiv.style.zIndex='99999999';
 oDiv.style.display='block';
 } else {
 oDiv.style.display='none';
 }
 return false;
}
function ftposMore(e){
 var oDiv=p_o('ft-smore');
 var oLnk=p_o('ft-smorea');
 posY = findMousePos(e);
 oDiv.style.left='582px';
 oDiv.style.top='28px';
}


// Begin : Headers 2 code
String.prototype.trim = function() {
 return this.replace(/^\s+|\s+$/g,"");
}


function searchTarget(url, newWindow, newTarget, searchFrm) {
    // Set the target for the form
if (searchFrm == 1){
    document.bot_form.action = url;
    if (newWindow) {
        document.bot_form.target = '';
    } else {
        document.bot_form.target = '';
    }
    // Update the tabs classes to allow highlighting of the selected
    var arrElements = getElementsByClassName ('ft-searchCatBg', 'li');
    for (var i=0; i<arrElements.length; i++) {
        arrElements[i].className = '';
    }
    document.getElementById(newTarget).className = 'ft-searchCatBg';    
}else {
    document.top_form.action = url;
    if (newWindow) {
        document.top_form.target = '_blank';
    } else {
        document.top_form.target = '';
    }
    
    // Update the tabs classes to allow highlighting of the selected
    var arrElements = getElementsByClassName ('selected', 'li');
    for (var i=0; i<arrElements.length; i++) {
        arrElements[i].className = '';
    }
    document.getElementById(newTarget).className = 'selected';    
}

var searchfield=document.getElementById('queryname');
  if(document.getElementById(newTarget).id == 'search-tab-blog'){
  searchfield.name='q';
  } else {
   searchfield.name='query';
  }
  var searchfield=document.getElementById('queryname1');
  if(document.getElementById(newTarget).id == 'search-tab-blog2'){
  searchfield.name='q1';
  } else {
   searchfield.name='query';
  }


    return false;
}


function getElementsByClassName(strClass, strTag, objContElm) {
 strTag = strTag || "*";
 objContElm = objContElm || document;
 var objColl = objContElm.getElementsByTagName(strTag);
 if (!objColl.length && strTag == "*" && objContElm.all) objColl = objContElm.all;
 var arr = new Array();
 var delim = strClass.indexOf('|') != -1 ? '|' : ' ';
 var arrClass = strClass.split(delim);
 for (var i = 0, j = objColl.length; i < j; i++) {
 var arrObjClass = objColl[i].className.split(' ');
 if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
 var c = 0;
 comparisonLoop:
 for (var k = 0, l = arrObjClass.length; k < l; k++) {
 for (var m = 0, n = arrClass.length; m < n; m++) {
 if (arrClass[m] == arrObjClass[k]) c++;
 if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
 arr[arr.length] = objColl[i];
 //arr.push(objColl[i]);
 break comparisonLoop;
 }
 }
 }
 }
 return arr;
}

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;
}

function submitHeaderSearch(event) {
 if (event == "onclick" || eventIsEnterKey(event)) {
 return srchSub2();
 } else {
 return true;
 }
}

function srchSub2() {
 var frm=p_o("search");
 var queryval = frm.topquery.value.trim();
 queryval = queryval.replace( /\+/, " ");
 var newurl = frm.action + queryval;
 if (frm.target == '_blank') {
 window.open(newurl, '_blank', '');
 } else {
 window.location = newurl;
 }
 return false;
}

// Shared functions

function findMousePos(e) {
	var posY = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posY = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posY = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	return posY;
}


//This function hides the more popup on the //header when a user clicks anywhere on the document

function hideHeaderMore(e) {
    var targ;

	if (!e) var e = window.event;

	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
    
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;

		if(targ.id != 'smorea' && p_o('smore')) {
        var oDiv=p_o('smore');
         
        if(oDiv.style.display.toLowerCase() == "block") 
            oDiv.style.display='none';
    }
    if(targ.id != 'ft-smorea' && p_o('ft-smore')) {
        var oDiv=p_o('ft-smore');
         
        if(oDiv.style.display.toLowerCase() == "block") 
        oDiv.style.display='none';
    }    
}
document.onclick = hideHeaderMore;

 var submitReq = function () {

        if ($("form #emailTo").val() =='' || $("form #emailMsg").val() =='') {
          alert('To and Message fields are required.');
          return;
        }
        var emailMsg = $("form #message2").val();
        var emailTo = $("form #emailTo").val();
        var emailSubject = $("form #emailSubject").val();
        var emailFrom = $("form #emailFrom").val();
        //$.post('eventHandler.jsp?emailMsg=' + escape(emailMsg) + '&emailSubject=' + escape(emailSubject)+ '&emailFrom=' + escape(emailFrom)+ '&emailTo=' + escape(emailTo)+ '&linkTitle='+ linkTitle + '&linkUrl='+ pageId);
        $.ajax({
        type:"POST",
        url: "/experts/eventhandler",
        data: 'emailMsg=' + escape(emailMsg) + '&emailSubject=' + escape(emailSubject)+ '&emailFrom=' + escape(emailFrom)+ '&emailTo=' + escape(emailTo)+ '&linkTitle='+ linkTitle + '&linkUrl='+ pageId ,
        async: false,
        success: function(msg){
         $("#formMsg").text("Message Successful");
        },
        error: function(msg){
        $("#formMsg").text("There was a problem with the request.");
        }
        
    });
  }
      

      function sendDisabled(val,btnId) {
        if (val == 1) {
 
          $(btnId).attr("disabled","disabled");  
        }
        if (val == 0) {
          $(btnId).attr("disabled","");
        }                
      }
  
      
      function onFieldFocus(id,msg) {
        if($(id).val() == msg){
            $(id).val(''); 
        }
      }
      
      function onFieldBlur(id,msg) {
        
        if($(id).val() == ''){
            $(id).val(msg); 
        }
      }
/* Jquery events */
/* onload functions */
onload = function(){

   // Share Asset
   $("#emailShar, #imShar, #bookMarkShar").click(function(){
       var tab =null;
       switch(this.id){
       case 'emailShar':
       tab = 'email';
       break;
       case 'imShar':
       tab = 'im';
       break;
       case 'bookMarkShar':
       tab = 'bookmark';
       break;         
       default:
       break;
        }
       if(_sns_isLoggedIn!=true) AsnsSignIn(getEl('ShareModule'), 82, -10,'snsMiniUI');
       else{return shareWin('/experts/share?page='+currentUrl+'&tab='+tab+'&asset='+assetName);}
   });
   $(".feedImg").click(function(){
    aol_feeds_subscribe.show(this,null,this.href);return false;
    });
    
    //Print
    $(".print").click(function(){
    MakePDF();
    });
    
    // Copy onclick select
    $("#snaggableInput").click(function(){
       this.select();
    });

 };

// Loads and binds events for share window
function loadWin() {

    $("#bookMarkTb, #imTb, #emailTb").click(function(){
        $(".leftpnlMain li").removeClass("selectedTab");
        $(this).addClass("selectedTab");
        $("#container .container").removeClass("select");
        switch(this.id){
            case 'bookMarkTb':
                $('#BookMarks').addClass("select");
            break;
            case 'imTb':
                $('#IM').addClass("select");
            break;
            case 'emailTb':
                $('#EMail').addClass("select");
            break;            
            default:
            break;
        }
    });
    // EMAIL to bound events
    $("#emailTo").focus(function(){
    onFieldFocus('#emailTo','Enter your recipients\' e-mail addresses.');
    });
    $("#emailTo").blur(function(){
    onFieldBlur('#emailTo','Enter your recipients\' e-mail addresses.');
    });
    $("#emailTo").click(function(){
    sendDisabled(0,'#sendauth');
    });
    
    //TextArea Bound Events
    $("#message2").focus(function(){
    onFieldFocus('#message2','Enter your personal message here.');
    });
    $("#message2").blur(function(){
    onFieldBlur('#message2','Enter your personal message here.');
    });
    $("#message2").click(function(){
    sendDisabled(0,'#sendauth');
    });

   // RESET Button
   $(".frmdivclearbttn").click(function(){
       $(forms[0]).reset();
   });
   // Submit Mail form
   $("#sendauth").click(function(){
        if ($("form #emailTo").val() =="Enter your recipients' e-mail addresses." || $("form #emailMsg").val() =='Enter your personal message here.') {
          alert('To and Message fields are required.');
          return;
        }
       submitReq();
   });

 //share remove popup window
    $(".closeBtn").click(function(){
		window.close();
	});
    
};
/*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*/


/*  Parentdish SEARCH function */

  function SubmitForm(){

					document.solrSearchForm.searchTerm.value = document.solrSearchForm.searchTerm.value.replace(/[^a-z0-9\-\+\s]*/gi,"").replace(/\s{2,}/g," ");
					if(document.solrSearchForm.searchTerm.value.replace(/\s/g,"")=="") { return; }

					document.solrSearchForm.action='/experts/'+document.solrSearchForm.sExpert.value+'/search-results/'+document.solrSearchForm.searchTerm.value;
                    document.solrSearchForm.submit();
					
                } 
