/* Header functions*/
function loginCheck(sitedomain) {
  var sitedomain = "sitedomain="+encodeURIComponent(sitedomain);
  var url = "siteState=" + encodeURIComponent("OrigUrl=" + encodeURIComponent(window.location));
  if(_sns_isLoggedIn == 'true') {
    getEl("userspan").innerHTML="Logged In: "+_sns_current_user;
    getEl("loginlink").href="https://my.screenname.aol.com/_cqr/logout/mcLogout.psp?"+sitedomain+"&"+url;
    getEl("loginlink").title="Sign Out";  
    getEl("loginlink").innerHTML="Sign Out";
  } else {
    getEl("loginlink").href="https://my.screenname.aol.com/_cqr/login/login.psp?"+sitedomain+"&"+url;
    getEl("loginlink").title="Sign In";         
    getEl("loginlink").innerHTML="Sign In";
  }
}
// Tog More for Search
function togMore(sShow)
{
	if (sShow == "hide")
	{
		document.getElementById("srchMoreId").style.display = "none";
	}
	else
	{
		document.getElementById("srchMoreId").style.display = "block";
	}
	return false;
}

function togFootMore(sShow)
{
	if (sShow == "hide")
	{
		document.getElementById("srchFootMoreId").style.display = "none";
	}
	else
	{
		document.getElementById("srchFootMoreId").style.display = "block";
	}
	return false;
}

// Begin : Headers 2 code
function p_o(o){return getEl(o);}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function srchSub(ref){
  var frm=p_o("search");
  var queryval = frm.topquery.value.trim();
  queryval = queryval.replace( /\+/, " ");
  newurl = ref.href + queryval;
  window.location = newurl;
  return false;
}

function searchTarget(url, newWindow, newTarget) {
    // Set the target for the form
    document.bb_topform.action = url;
    if (newWindow) {
        document.bb_topform.target = '_blank';
    } else {
        document.bb_topform.target = '';
    }
    // Update the tabs classes to allow highlighting of the selected
    var arrElements = ["search-tab-1","search-tab-2","search-tab-3","search-tab-4","search-tab-5"];
    for (var i=0; i<arrElements.length; i++) {
        getEl(arrElements[i]).className = '';
    }
    getEl(newTarget).className = 'searchCatBg';


    return false;
}

function searchTarget2(url, newWindow, newTarget) {
    // Set the target for the form

    document.bb_bottomform.action = url;
    if (newWindow) {
        document.bb_bottomform.target = '_blank';
    } else {
        document.bb_bottomform.target = '';
    }
    // Update the tabs classes to allow highlighting of the selected
    var arrElements = ["search-tab-bot-1","search-tab-bot-2","search-tab-bot-3","search-tab-bot-4","search-tab-bot-5"];
    for (var i=0; i<arrElements.length; i++) {
        getEl(arrElements[i]).className = '';
    }
    getEl(newTarget).className = 'searchCatBg';


    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;
}

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 + URLEncode(queryval);
    if (frm.target == '_blank') {
        window.open(newurl, '_blank', '');
    } else {
        window.location = newurl;
    }
    return false;
}

function submitFooterSearch(event) {
    if (event == "onclick" || eventIsEnterKey(event)) {
        return srchSub4();        
    } else {
        return true;
    }
}

function srchSub4() {
    var frm=p_o("search2");
    var queryval = frm.Bottomquery.value.trim();
    queryval = queryval.replace( /\+/, " ");
    var newurl = frm.action + URLEncode(queryval);
    if (frm.target == '_blank') {
        window.open(newurl, '_blank', '');
    } else {
        window.location = newurl;
    }
    return false;
}


//Prevent IE flickr
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

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 != 'srchMoreAnc' && targ.id != 'srchMoreAnc2') {
 		document.getElementById("srchMoreId").style.display = 'none';
		document.getElementById("srchFootMoreId").style.display = 'none';
	}
}


// ====================================================================
//       URLEncode and URLDecode functions
//
// Copyright Albion Research Ltd. 2002
// http://www.albionresearch.com/
//
// You may copy these functions providing that 
// (a) you leave this copyright notice intact, and 
// (b) if you use these functions on a publicly accessible
//     web site you include a credit somewhere on the web site 
//     with a link back to http://www.albionresearch.com/
//
// If you find or fix any bugs, please let us know at albionresearch.com
//
// SpecialThanks to Neelesh Thakur for being the first to
// report a bug in URLDecode() - now fixed 2003-02-19.
// And thanks to everyone else who has provided comments and suggestions.
// ====================================================================
function URLEncode(textToEncode)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = textToEncode;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	return encoded;
};

document.onclick = hideHeaderMore;
/*end header functions*/

function getEl( id ){ return document.getElementById( id ); }


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 shareWin(url) {
    w = window.open(url,'holidaysShared','resizable=no,height=534,width=786');
    if (window.focus) {
        w.focus()
    }
    return false;
}

/* Recently Submitted Photos module JS Begins */

function ajaxCall(url) {
	var page_request = false;
	if (window.ActiveXObject){ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
		}
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
			}
		}
	else if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else
		return false
	page_request.open('GET', url, false) //get page synchronously
	page_request.send(null);
	return page_request.responseText;
}

/* Recently Submitted Photos module JS Ends */

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;
	}

/*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"><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 */

/*user comments*/
function addComment()
{
    document.commentAddForm.newCommentBody.value=document.commentAddForm.newCommentBody.value.replace(/^\s*/, "").replace(/\s*$/, "").replace(/\\/g,"");
    if(document.commentAddForm.newCommentBody.value.length==0 || document.commentAddForm.newCommentBody.value.indexOf("Type your own comment here")>-1){
        return false;}else{
        document.commentAddForm.submit();
    }
}

function fn_miniSignIn(obj, origPath, sitedomain,contextPath){

	//if(obj) {			
		var parDiv = document.createElement("div");
		parDiv.style.position="absolute";
		parDiv.style.zIndex="100";
		parDiv.style.display="inline";
        parDiv.style.margin="22 -17";
        contextPath = "/holidays";
        sitedomain = "channel.aol.com";
		var innerHtml = ajaxCall(contextPath+"/MiniSignInPopup.jsp?path="+encodeURL(origPath)+"&sitedomain="+sitedomain);			
		//flgFly = obj.parentNode.rowIndex;
		parDiv.innerHTML= "<div id='snsMiniUI' style='left: 0px; top: -49px; position: relative; z-index: 5000; display: block;'>"+innerHtml+"</div>";
		obj.appendChild(parDiv);
	//}

}

function ajaxCall(url) {
    var page_request = false;
    
    if (window.ActiveXObject){ // if IE
        try {
            page_request = new ActiveXObject("Msxml2.XMLHTTP")
        }
        catch (e){
            try{
                page_request = new ActiveXObject("Microsoft.XMLHTTP")
            }
            catch (e){}
        }
    }
    else if (window.XMLHttpRequest) // if Mozilla, Safari etc
        page_request = new XMLHttpRequest()
    else
        return false
    page_request.open('GET', url, false) //get page synchronously
    page_request.send(null);
    return page_request.responseText;
    
}

function clickclear(thisfield, defaulttext) {
    if (thisfield.value == defaulttext) {
        thisfield.value = "";
    }
}
/*end user comments*/

//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 h2' },
      '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 fn_miniSignIn(obj, origPath, sitedomain,contextPath){

	//if(obj) {			
		var parDiv = document.createElement("div");
		parDiv.style.position="absolute";
		parDiv.style.zIndex="100";
		parDiv.style.display="inline";
        parDiv.style.margin="22 -17";
        contextPath = "/holidays";
        sitedomain = "channel.aol.com";
		var innerHtml = ajaxCall(contextPath+"/MiniSignInPopup.jsp?path="+encodeURL(origPath)+"&sitedomain="+sitedomain);			
		//flgFly = obj.parentNode.rowIndex;
		parDiv.innerHTML= "<div id='snsMiniUI' style='left: 0px; top: -49px; position: relative; z-index: 5000; display: block;'>"+innerHtml+"</div>";
		obj.appendChild(parDiv);
	//}

}

//CHECK VALID EMAIL ADDRESS
function checkValidEmail(email) {
	var at = "@";
	var dot = ".";
	var atPos = email.indexOf(at);
	var dotPos = email.indexOf(dot);
	if(email.indexOf(at)==-1 || email.indexOf(dot)==-1) {
		alert("Please enter a valid e-mail address.");
		return false;
	}else if(email.indexOf(at)==0 || email.indexOf(at)==email.length-1) {
		alert("Please enter a valid e-mail address");
		return false;
	}else if(email.indexOf(dot)==0 || email.indexOf(dot)==email.length-1) {
		alert("Please enter a valid e-mail address");
		return false;
	}else if(!email.substring(atPos-1, atPos).match("[a-z0-9]") || !email.substring(atPos+1, atPos+2).match("[a-z0-9]")) {
		alert("Please enter a valid e-mail address");
		return false;
	}else if(!email.substring(dotPos-1, dotPos).match("[a-z0-9]") || !email.substring(dotPos+1, dotPos+2).match("[a-z0-9]")) {
		alert("Please enter a valid e-mail address");
		return false;
	}else{
	    return true;
	}
}
//SUBMIT REPORT THIS FORM VIA POP UP
function reportThisComment(umtHost, coco, violator, clip, deleteInfo, contextPath) {
    var yourEmailAddr=document.getElementById("yourEmailAddr").value;
    if (yourEmailAddr == null || yourEmailAddr == "") {
    	alert("Please enter your e-mail address.");
    } else {
    	if(checkValidEmail(yourEmailAddr) == false) {
    	   return;
    	}
    }
    var userComment=document.getElementById("additComments").value;
    var reportType=document.getElementById("reportType").value;
    var comment = encodeURIComponent(userComment + "<br>Report Type: " + reportType);
    clip = encodeURIComponent(clip + "<br><br>" + deleteInfo);
    //umtHost = "http://qaccare-ql02.tops.aol.com:9180/umt/queued_add.jsp";
    //umtHost = "/lyratest.jsp";        
    var reportAbuseData = "action=insert&reporter=" + yourEmailAddr + "&product=LivingComments%20Holidays&violator=" + violator + "&coco=" + coco + "&violator_url=" + encodeURIComponent(document.location) + "&clip=" + clip  + "&comment=" + comment;

    http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        //alert('Cannot create XMLHTTP instance');
        return false;
    }
    
    http_request.open('POST', umtHost, true);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", reportAbuseData.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(reportAbuseData);
    $.nyroModalRemove();
}

function cntCheckOfCommntsInNotify() {
	var	cnt=document.getElementById("notifyCommentsMaxLength");
	var	field=document.getElementById("additComments").value;
	var len=field.length;
	if(len > 1024){
		document.getElementById("additComments").value=field.substring(0,1024);
		cnt.innerText=0;
		cnt.innerHTML=0;
	}else{
	    cnt.innerText=1024-len;
	    cnt.innerHTML=1024-len;
	}
}
/*left nav search box clear start*/
function doClear(theText){
	if (theText.value == theText.defaultValue){
		theText.value = ""
	}
}
/*left nav search box clear end*/

/*left nav search submit start*/
function fn_submitHolidaysSearchForm(){		
    var searchFromActionValue="/holidays/results/";
	var searchBxValue=document.getElementById("searchBx").value.trim();

	seoSearchBxValue = searchBxValue.replace(/&+/g, '%26');
	seoSearchBxValue = seoSearchBxValue.toLowerCase();
    // remove all except a-z, 0-9 and dash
	seoSearchBxValue = seoSearchBxValue.replace(/[^a-z|0-9|-]/g, "-");
	
	// replace multiple dashes with one dash
	seoSearchBxValue = seoSearchBxValue.replace(/-+/g, "-");
	
	// remove leading and trailing dashes
	//seoSearchBxValue = seoSearchBxValue.replace(/^-+|-+$, "");

	if(searchBxValue!=null && searchBxValue!=''){
		document.searchFrm.action=searchFromActionValue+seoSearchBxValue+"/?q="+searchBxValue;
		document.searchFrm.submit();
	}
	else
		return;
}
/*left nav search submit ends*/

function encodeURL (string) {
    string = string.replace(/\r\n/g,"\n");
    var utftext = "";

    for (var n = 0; n < string.length; n++) {

        var c = string.charCodeAt(n);

        if (c < 128) {
            utftext += String.fromCharCode(c);
        }
        else if((c > 127) && (c < 2048)) {
            utftext += String.fromCharCode((c >> 6) | 192);
            utftext += String.fromCharCode((c & 63) | 128);
        }
        else {
            utftext += String.fromCharCode((c >> 12) | 224);
            utftext += String.fromCharCode(((c >> 6) & 63) | 128);
            utftext += String.fromCharCode((c & 63) | 128);
        }

    }

    return utftext;
}

function decodeURL(utftext) {
    var string = "";
    var i = 0;
    var c = c1 = c2 = 0;

    while ( i < utftext.length ) {

        c = utftext.charCodeAt(i);

        if (c < 128) {
            string += String.fromCharCode(c);
            i++;
        }
        else if((c > 191) && (c < 224)) {
            c2 = utftext.charCodeAt(i+1);
            string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
            i += 2;
        }
        else {
            c2 = utftext.charCodeAt(i+1);
            c3 = utftext.charCodeAt(i+2);
            string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }

    }

    return string;
}

//Sponsored Links JS
server_url="http://switcher.dmn.aol.com/sw/a";
params = {
       sch:"",
       ssch:"",
       squery:"",
       snum:"",
       stest:"",
       locale:"",
       z:"",
       page:"",
       nt:"",
       lf:"",
       callback:"",
       ssafe:"",
       sh_ie:"",
       sh_oe:"",
       sclient:"",
       spch:"",
       csp:"",
       scoco:"",
       sbrand:"",
       sview:"",
       sit:"",
       surl:"",
       skw:"",
       skwt:"",
       skw2:"",
       callback:"done"
};

function get_links() {
	document.getElementById(dmn_mod).style.display = "none";
	var s="";
	for (var anItem in params) if(params[anItem]!="") s+="&"+anItem+"="+escape(params[anItem]);
	text="<scr"+"ipt src='"+server_url+"?"+s.slice(1)+"' type='text/javascript'></scr"+"ipt>";
	document.write(text);
}

function done(sponsorData) {
	//If there is at least one results then create some sponsored links
	var s = "";
	if(sponsorData.length!=0) {
		//Build up a string of HTML to display the results
		for (i=0;i<sponsorData.length;i++) {
			if (i==0)
			{
				s+="<a class=\"spnsrHeader\" href=\"http://about-search.aol.com/#csl\" target=\"_blank\">Sponsored Links</a>";
			}
			s+="<div class=\"spnsrItm\">"
			+"<span class=\"spnsrTitle\"><a href=\""+sponsorData[i].redirect_url+"\" target=\"_blank\">"+sponsorData[i].title+"</a></span>"
			+"<span class=\"spnsrDesc\">"+sponsorData[i].d1+" "+sponsorData[i].d2+"</span>"
			+"<span class=\"spnsrUrl\"><a href=\""+sponsorData[i].redirect_url+"\" target=\"_blank\">"+sponsorData[i].url+"</a></span>"
			+"</a>"
			+"</div>";
		}
		document.getElementById(dmn_mod).style.display = "block";
	} 
	//Stuff the string of HTML into the DIV we created for it
	document.getElementById(dmn_mod).innerHTML = s;
}

// Custom Sponsor functions
function sponsorOnClick(url) {
   window.open(url);
}

function sponsorMouseOver(url) {
    window.status = url;
    document.body.style.cursor = 'pointer';
    return true;
}

function sponsorMouseOut() {
    window.status = "";
    document.body.style.cursor = 'default';
	return true;
}

/*****Start Favorites*********/
// check for favorites cookie 
var favoritesStr = "";
var favoritesDataArray = new Array();
var favoritesURL = 0;
var favoritesType = 1;
var favoritesTitle = 2;
var favoritesCategory = 3;
var favoritesTempDataArray = new Array();
var currentAssetType = "";
var currentAssetCategory = "";
var currentAssetURL = "";
var currentAssetTitle = "";
var favoritesMax = 10;
var favoritesSeeMoreBreak = 10;
var mainpage=0;
function buildFavoritesArray() {
    if(favoritesStr.length>0){
		favoritesDataArray = new Array(); 
		favoritesTempDataArray = favoritesStr.split(",");
		
		// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// + Let's populate the 'multidimensional' array          +
		// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		for (i = 0;i < favoritesTempDataArray.length; i++) {
	
		    favoritesCurrentBrokenDown = favoritesTempDataArray[i].split("||");
		    favoritesDataArray.push([favoritesCurrentBrokenDown[favoritesURL], favoritesCurrentBrokenDown[favoritesType], favoritesCurrentBrokenDown[favoritesTitle], favoritesCurrentBrokenDown[favoritesCategory]]);
	
		}
 
    }

}

function buildFavoritesHTML(){

        var addFavoritesStr = '<a href="javascript:favoritesAdd();" title="Add to Favorites: ' + currentAssetTitle + '" class="addfavorites">Save as a Favorite</a>';
        var addFavoritesStr2 = '<a href="javascript:favoritesAdd();" title="Add to Favorites: ' + currentAssetTitle + '" class="addfavorites">&nbsp;</a>';
		//build hash(or multidim array) first
		buildFavoritesArray();
		var favouritesHTMLStr = 'See something you like? Make it easy to find things again by saving them into your Holidays Favorites. To save to your Holidays Favorites click ' + addFavoritesStr2 + ' to save it to your list of Favorites.';
	    
	    if(favoritesStr.length<1 && mainpage==1){document.getElementById("mod_favorites").style.display = "none";return false;}
	    if(favoritesStr.length>0){
		//create favourites HTML String
		favouritesHTMLStr = '<table cellpadding= "0" cellspacing="0">';
		for(i = 0; i < favoritesDataArray.length && i < favoritesMax; i++) {
	            var assetType = favoritesDataArray[i][favoritesType];
	            var assetTitle = favoritesDataArray[i][favoritesTitle];
	            var assetURL = favoritesDataArray[i][favoritesURL];
	            var assetCategory = favoritesDataArray[i][favoritesCategory];
	            if(assetTitle.length>44)
	                assetTitle =assetTitle.substr(0,42) + '...';
	            if(assetCategory.length>16)
	                assetTitle =assetCategory.substr(0,15) + '...';
	
			favouritesHTMLStr += '<tr class="row' + i + '">';
			favouritesHTMLStr += '<td class="favourites_' + assetType + '">&nbsp;</td>';
			favouritesHTMLStr += '<td class="favourites_title"><a href="' + assetURL + '" title="' + favoritesDataArray[i][favoritesTitle] + '">' + assetTitle + '</a></td>';
			//favouritesHTMLStr += '<td class="favourites_category">' + assetCategory + '</td>';
			favouritesHTMLStr += '<td class="favourites_delete"><a href="javascript:favoritesDelete(' + i + ');" title="Remove From Favorites: ' + favoritesDataArray[i][favoritesTitle] + '">x</a></td>';
			favouritesHTMLStr += '</tr>';
	
		}
		favouritesHTMLStr += '</table>';
		
	    }
	    if(favoritesMax == favoritesSeeMoreBreak && favoritesSeeMoreBreak < favoritesDataArray.length){
	    //alert('inin');
	        favouritesHTMLStr += '<a class="favSeeMore" href="javascript:favoritesMax=1000;buildFavoritesHTML();">See More</a>';
	    }else if(favoritesMax > favoritesSeeMoreBreak && favoritesSeeMoreBreak < favoritesDataArray.length)
	        favouritesHTMLStr += '<a class="favSeeMore" href="javascript:favoritesMax=favoritesSeeMoreBreak;buildFavoritesHTML();">See Less</a>';
	        
	   if(favoritesStr.length>0 || mainpage!=1)
	   		 document.getElementById("favoritesMod").innerHTML = favouritesHTMLStr;
	   
	    var favAddCheck = document.getElementById("favoritesAdd");
	   if(favoritesStr.indexOf(currentAssetURL) > -1)
	       addFavoritesStr = "";
	   if(favAddCheck != null)
	      document.getElementById("favoritesAdd").innerHTML = addFavoritesStr;
}

function favoritesDelete(delIndex){
	favoritesDelStr = favoritesTempDataArray[delIndex];
	favoritesStr = favoritesStr.replace(favoritesDelStr , "");
    favoritesStr = favoritesStr.replace(",," , ",");
    favoritesStr = trimAll(favoritesStr);
	buildFavoritesHTML();
    setCookie("AOL_Holiday_Favorites",favoritesStr,365);
}

// this function trims leading and trailing commas
function trimAll(sString) {

    while (sString.substring(0,1) == ',') {
        sString = sString.substring(1, sString.length);
    }

    while (sString.substring(sString.length-1, sString.length) == ',') {
        sString = sString.substring(0,sString.length-1);
    }

    return sString;
}

function replaceAll( str, replacements ) {
    for ( i = 0; i < replacements.length; i++ ) {
        var idx = str.indexOf( replacements[i][0] );

        while ( idx > -1 ) {
            str = str.replace( replacements[i][0], replacements[i][1] );
            idx = str.indexOf( replacements[i][0] );
        }

    }

    return str;
}

function getCurrentPageFavSettings() {
    if(getCookie("AOL_Holiday_Favorites") != null)
        favoritesStr = getCookie("AOL_Holiday_Favorites");
    var galleryCheck = document.getElementById("galleryPlayer");
    var articleCheck = document.getElementById("articlePlayer");
    var videoCheck = document.getElementById("videoPlayer");
    var quizCheck = document.getElementById("quizPlayer");

    currentAssetCategory = (s_265.prop1).replace("liv : ","");
    currentAssetURL = document.URL;
    currentAssetTitle = document.title;

    if(galleryCheck != null)
	currentAssetType = "gallery";
    else if(articleCheck != null)
	currentAssetType = "article";
    else if(videoCheck != null)
	currentAssetType = "video";
    else if(quizCheck != null)
	currentAssetType = "quiz";

}

function favoritesAdd(){
    if(favoritesStr.length>0)
	favoritesStr += "," + currentAssetURL + "||" + currentAssetType + "||" + currentAssetTitle + "||" + currentAssetCategory ;
    else
	favoritesStr = currentAssetURL + "||" + currentAssetType + "||" + currentAssetTitle + "||" + currentAssetCategory;
    buildFavoritesHTML();
    setCookie("AOL_Holiday_Favorites",favoritesStr,365);
}

//general function to get cookie
function getCookie(NameOfCookie){
    if (document.cookie.length > 0) {              
        begin = document.cookie.indexOf(NameOfCookie+"=");       
        if (begin != -1) {           
            begin += NameOfCookie.length+1;       
            end = document.cookie.indexOf(";", begin);
            if (end == -1) end = document.cookie.length;
                return unescape(document.cookie.substring(begin, end));
        } 
    }
    return null;
}

//general function to set cookie
function setCookie(NameOfCookie, value, expiredays) {
    var ExpireDate = new Date ();
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

    document.cookie = NameOfCookie + "=" + escape(value) + 
    ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString())+";path=/";
}

/*****End Favorites*********/

