/* Header functions*/
// Tog More for Search
// 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-Stylelist","search-tab-Web","search-tab-Blog","search-tab-Video","search-tab-News","search-tab-Images","search-tab-Local"];
                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-Stylelist2","search-tab-Web2","search-tab-Blog2","search-tab-Video2","search-tab-News2","search-tab-Images2","search-tab-Local2"];
            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*/

/* clear input box */
function enterTxt(id) {
    var txt = document.getElementById(id);   
    if (txt.defaultValue == txt.value) {
        txt.value = '';
    }
}
/* shared module popup */
function shareWin(url) {
    w = window.open(url,'stylelistShared','resizable=yes,height=534,width=770');
    if (window.focus) {
        w.focus()
    }
    return false;
}
/* common */
var ratingFlg = true; // If user login info available, change this to true else false
var usrRate = 0;
var isAvgFlag;
function fn_miniSignIn(obj, parentUrl, hostname) {
    
    alert("fn_miniSignIn");
    var parDiv = document.createElement("div");
    parDiv.style.position="absolute";
    parDiv.style.zIndex="100";
    parDiv.style.display="inline";
    parDiv.style.margin="22 -17";
    var innerHtml = ajaxCall("miniSignIn.jsp?parentUrl="+encodeURL(parentUrl)+"&hostname="+hostname);
    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;
    
}

var channelURN = "";
var galId = "";
var user = "";

// Login 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 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 loginCheck(sitedomain) {
    var sitedmn = "sitedomain="+sitedomain;
    var origPath = "" + window.location + "";
    var url="siteState="+encodeURIComponent("OrigUrl="+encodeURIComponent(origPath));
    if(_sns_isLoggedIn) {
        getEl("userspan").innerHTML="Logged In: "+_sns_current_user;
        getEl("loginlink").href="https://my.screenname.aol.com/_cqr/logout/mcLogout.psp?"+sitedmn+"&"+url;
        getEl("loginlink").title="Sign Out";
        getEl("loginlink").innerHTML="Sign Out";
    } else {
    getEl("loginlink").href="https://my.screenname.aol.com/_cqr/login/login.psp?"+sitedmn+"&"+url;
    getEl("loginlink").title="Sign In";
    getEl("loginlink").innerHTML="Sign In";
}
}
/* end of login*/

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 galChRate(obj,aStr,rating) {
    var ratColl = document.getElementById("gRat").getElementsByTagName("div");	
    for(i=0;i<ratColl.length;i++) {
        ratColl[i].className = i<rating?"backPicFill":"backPicEmpty";
    }
    if(aStr=="Average Rating") {
        obj.parentNode.innerHTML = "<span  onclick=\"javascript:galChRate(this,'Your Rating',"+avgRating+");\" style=\"color:#3094C6;cursor:pointer;\">Avg Rating </span>";
        isAvgFlag=0;
    }
    else{
        obj.parentNode.innerHTML = "<span  onclick=\"javascript:galChRate(this,'Average Rating',"+yourRating+");\" style=\"color:#3094C6;cursor:pointer;\">Your Rating </span>";
        isAvgFlag=1;
    }
    galRate();
}

function galRate() {
    if(isAvgFlag==1){return;}
    var ratColl = document.getElementById("gRat").getElementsByTagName("div");
    var rateTemp = usrRate==0 && ratColl[0].parentNode.getAttribute("rating")>0?ratColl[0].parentNode.getAttribute("rating"):usrRate;
    for(i=0;i<ratColl.length;i++) {
        ratColl[i].className = i<rateTemp?"backPicFill":"backPicEmpty";
    }
}

function galRatingIn(obj) {
    if(isAvgFlag==1){return;}
    var ratColl = document.getElementById("gRat").getElementsByTagName("div");
    for(i=0;i<ratColl.length;i++) {
        ratColl[i].className = i<obj.id.replace("star","")?"backfillash":"backPicEmpty";
    }
}

function galRateItPhotoStream(obj,photoURN,catId,userGUID){
    usrRate = obj.id.replace("star","");
    ajaxCall("rateItPhotoStream.jsp?rating="+usrRate+"&photoURN="+galleryId+"&catid="+catId+"&uname="+userGUID);
    yourRating=usrRate;
}

function galRateIt(obj,galleryId,catId,userGUID) {
    usrRate = obj.id.replace("star","");
    ajaxCall("rateIt.jsp?rating="+usrRate+"&galleryURN="+galleryId+"&catid="+catId+"&uname="+userGUID);
    yourRating=usrRate;
}

function fDate(){
    var todayDate = new Date();
    var montharray = new Array(12);
    
    montharray[0]="January";
    montharray[1]="February";
    montharray[2]="March";
    montharray[3]="April";
    montharray[4]="May";
    montharray[5]="June";
    montharray[6]="July";
    montharray[7]="August";
    montharray[8]="September";
    montharray[9]="October";
    montharray[10]="November";
    montharray[11]="December";
    
    theDay=todayDate.getDay();
    switch (theDay)
    {
        case 6:
        todayDate.setDate(todayDate.getDate() - 1);
        break;
        case 0:
        todayDate.setDate(todayDate.getDate() - 2);
        break;
    }
    if (document.getElementById("todayDate"))
        document.getElementById("todayDate").innerHTML = montharray[todayDate.getMonth()] + " " + todayDate.getDate() + ", " + todayDate.getFullYear();
}
window.onload = fDate;

var ratingFlg = true; // If user login info available, change this to true else false
var usrRate = 0;
var isAvgFlag = 0;
var userRating = 0;
function getEl( id ){ return document.getElementById( id ); }
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 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 galRate() {
    if(isAvgFlag==1){return;}
    var ratColl = document.getElementById("gRat").getElementsByTagName("div");
    var rateTemp = usrRate==0 && ratColl[0].parentNode.getAttribute("rating")>0?ratColl[0].parentNode.getAttribute("rating"):usrRate;
    for(i=0;i<ratColl.length;i++) {
        ratColl[i].className = i<rateTemp?"backPicFill":"backPicEmpty";
    }
}
function galRateItAs(obj,path,assetURN,catId,userGUID,assetType)
{
    //alert("radha");
    //if(!ratingFlg) {return;}
    if(userRating==1){return;}
    usrRate = obj.id.replace("star","");
    //alert("gallery: " + galleryId + "catId: " + catId + "userGUID: " + userGUID);
    ajaxCall(path+"/rateIt?rating="+usrRate+"&assetURN="+assetURN+"&catid="+catId+"&userGUID="+userGUID+"&type="+assetType);
    //ratingFlg = false;
    yourRating=usrRate;
    userRating=1;
}
function galRatingIn(obj)
{	
    //alert(userRating);
    //alert(isAvgFlag);
    if(isAvgFlag==1){return;}
    if(userRating==1){return;}
    //if(!ratingFlg) {return;}
    var ratColl = document.getElementById("gRat").getElementsByTagName("div");
    for(i=0;i<ratColl.length;i++) {
        ratColl[i].className = i<obj.id.replace("star","")?"backfillash":"backPicEmpty";
    }
    //userRating=1;
}
function galChRate(obj,aStr,rating,pgName)
{	
    var ratColl = document.getElementById("gRat").getElementsByTagName("div");	
    for(i=0;i<ratColl.length;i++) {
        ratColl[i].className = i<rating?"backPicFill":"backPicEmpty";
    }
    if(aStr=="Average Rating"){
        obj.parentNode.innerHTML = "<span  onclick=\"javascript:galChRate(this,'Your Rating',"+avgRating+",'"+pgName+"');\" style=\"color:#3094C6;cursor:pointer;\">Avg Rating </span>";
        document.getElementById("ratingTitle").innerHTML="Your Rating";
        isAvgFlag=0;
    }
    else{
        obj.parentNode.innerHTML = "<span  onclick=\"javascript:galChRate(this,'Average Rating',"+yourRating+",'"+pgName+"');\" style=\"color:#3094C6;cursor:pointer;\">Your Rating </span>";
        if(pgName=="gallery")
            document.getElementById("ratingTitle").innerHTML="Avg Rating";
        else
            document.getElementById("ratingTitle").innerHTML="Photo Avg Rating";
        isAvgFlag=1;
    }
    galRate();
}
function shareWin(url) {
    var winurl=new String(window.location);
    winurl=replaceAll(winurl, '&', '!');
    url+="&parentUrlEncoded="+winurl;
    w = window.open(url,'stylelistShared','resizable=yes,height=534,width=770');
    if (window.focus) {
        w.focus()
    }
    return false;
}
function replaceAll(winurl, pcFrom, pcTo){
    var i = winurl.indexOf(pcFrom);
    var c = winurl;
    while (i > -1){
        c = c.replace(pcFrom, pcTo);
        i = c.indexOf(pcFrom);
    }
    return c;
}

function copy(text2copy,path) {	
    if (window.clipboardData) {
        window.clipboardData.setData("Text",text2copy);
    } 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="'+path+'/_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
    
}
}
function clickclear(thisfield, defaulttext) {
    if (thisfield.value == defaulttext) {
        thisfield.value = "";
    }
}

function fn_miniSignIn(obj, parentUrl, 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";
    var innerHtml = ajaxCall(contextPath+"/miniSignIn.jsp?parentUrl="+encodeURL(parentUrl)+"&sitedomain="+sitedomain);
    //flgFly = obj.parentNode.rowIndex;
    parDiv.innerHTML= "<div id='snsMiniUI' style='left: -103px; top: -49px; position: relative; z-index: 5000; display: block;'>"+innerHtml+"</div>";
    obj.appendChild(parDiv);
    //}
    
}

/* Begin: Code for video promo module*/

var vpObject = function() {
    this.totalImg = 0;
    this.vpTimer = 0;
    this.currImg = 0;
    this.imgSrcArray = new Array();
    this.imgCrdArray = new Array();
    this.ovrArray = new Array();
    this.vpOpTimer = 0;
    this.rotInt = 5;
    this.fadeSpeed = 50;
}

function vpClass() {
    
    var setOpacity = function(mId,id,value) {
        
        var object = ge(id).style;
        //beat the IE bug
        if(document.all)
            object.zoom=1;
        
        object.opacity = (value / 10);
        object.MozOpacity = (value / 10);
        object.KhtmlOpacity = (value / 10);
        object.filter = "alpha(opacity=" + value*10 + ")";
    }
    
    var ovrlayDomCreate = function(mId){
        var mI = window['vpMod_'+mId];
        var d = window.document;
        var pLnk = ge('vpImgLnk_'+mId);
        var imgCnt = ge('vpImgCnt_'+mId);
        
        a = d.createElement('a');
        a.className = 'ovrLay';
        a.id = 'vpOvrLnk_'+mId;
        a.href = pLnk.href;
        a.innerHTML = '&nbsp;';
        
        wd = d.createElement('div');
        wd.className = 'overLayWrp';
        wd.appendChild(a);
        imgCnt.appendChild(wd);
        pLnk.onclick = ge('lkLst'+mId+'_'+mI.currImg).onclick;
    }
    
    var next = function(mId) {
        var ovrlayDiv = '<div class="overLayWrp"><a href="http://food.aol.com/tyler-florence?video=3" class="ovrLay" id="vpOvrLnk_12190">&nbsp;</a></div>';
        var objId = 'vpMod_'+mId;
        var mI = window[objId];
        var fadeInt = 0;// fading speed
        //it is necessary to clear the previous timer as the user's next click may break the sequence
        clearTimeout(mI.vpTimer);
        setOpacity(mId,'vpImgCnt_'+mId,10);
        
        //current highlighted list item
        var curlkLst = 'lkLst'+mId+'_'+mI.currImg;
        //fade out the current image
        for(var i=10;i>=0;i--) {
            fn = "vpClassObj.setOpac('"+mId+"','vpImgCnt_" + mId + "','" + i + "')";
            setTimeout(fn,fadeInt);
            fadeInt+=mI.fadeSpeed;;
        }
        
        //remove the highlight from current list item
        fn = "document.getElementById('"+curlkLst+"').className=''";
        setTimeout(fn,fadeInt);
        
        fn = "window.vpClassObj.showNextWrap('"+mId+"')";
        mI.vpTimer = setTimeout(fn,fadeInt);
    }
    
    var showNext = function(mId) {
        var objId = 'vpMod_'+mId;
        var mI = window[objId];
        
        var fadeInt = 0;//fading speed
        
        if(++mI.currImg >= mI.totalImg) {
            mI.currImg = 0;
        }
        
        //remove highlight from the current link and add to next link
        var curlkLst = 'lkLst'+mId+'_'+mI.currImg;
        ge(curlkLst).className = "highlight";
        
        //update credit text , image and the overlay image
        ge('ptCredit_'+mId).innerHTML = mI.imgCrdArray[mI.currImg];
        ge('vpImgCnt_'+mId).innerHTML = mI.imgSrcArray[mI.currImg];
        if(mI.ovrArray[mI.currImg] == 1) {
            ovrlayDomCreate(mId);
        }
        //fade in the new image
        for(var i=0;i<=10;i++) {
            fn = "vpClassObj.setOpac('"+mId+"','vpImgCnt_" + mId + "','" + i + "')";
            mI.vpTimer=setTimeout(fn,fadeInt);
            fadeInt+=mI.fadeSpeed;
        }
        scroll(mId,(mI.rotInt-(mI.fadeSpeed/1000)));
    }
    
    var prev = function(mId) {
        var objId = 'vpMod_'+mId;
        var mI = window[objId];
        var fadeInt = 0;// fading interval
        //it is necessary to clear the previous timer as the user's next click may break the sequence
        clearTimeout(mI.vpTimer);
        setOpacity(mId,'vpImgCnt_'+mId,10);
        
        //current highlighted list item
        var curlkLst = 'lkLst'+mId+'_'+mI.currImg;
        //fade out the current image
        for(var i=10;i>=0;i--) {
            fn = "vpClassObj.setOpac('"+mId+"','vpImgCnt_" + mId + "','" + i + "')";
            setTimeout(fn,fadeInt);
            fadeInt+=mI.fadeSpeed;;
        }
        
        //remove the highlight from current list item
        fn = "document.getElementById('"+curlkLst+"').className=''";
        setTimeout(fn,fadeInt);
        
        fn = "window.vpClassObj.showPrevWrap('"+mId+"')";
        mI.vpTimer = setTimeout(fn,fadeInt);
    }
    
    var showPrev = function(mId) {
        var objId = 'vpMod_'+mId;
        var mI = window[objId];
        
        var fadeInt = 0;//fading speed
        
        if(--mI.currImg < 0) {
            mI.currImg = parseInt(mI.totalImg-1);
        }
        
        //remove highlight from the current link and add to next link
        var curlkLst = 'lkLst'+mId+'_'+mI.currImg;
        ge(curlkLst).className = "highlight";
        
        //update credit text and image
        ge('ptCredit_'+mId).innerHTML = mI.imgCrdArray[mI.currImg];
        ge('vpImgCnt_'+mId).innerHTML = mI.imgSrcArray[mI.currImg];
        if(mI.ovrArray[mI.currImg] == 1) {
            ovrlayDomCreate(mId);
        }
        //fade in the new image
        for(var i=0;i<=10;i++) {
            fn = "vpClassObj.setOpac('"+mId+"','vpImgCnt_" + mId + "','" + i + "')";
            mI.vpTimer=setTimeout(fn,fadeInt);
            fadeInt+=mI.fadeSpeed;
        }
        scroll(mId,(mI.rotInt-(mI.fadeSpeed/1000)));
    }
    
    var scroll = function(mId,time) {
        var objId = 'vpMod_'+mId;
        mI = window[objId];
        var fn = "window.vpClassObj.vpNextImg('"+mId+"')";
        mI.vpTimer = setTimeout(fn,1000*time);
    }
    
    var ge = function(id){return document.getElementById(id);}
    
    return {
        
        vpNextImg : function(mId) {
            next(mId);
        },
        
        vpPrevImg : function(mId) {
            prev(mId);
        },
        
        autoScroll : function(mId,time) {
            scroll(mId,time);
        },
        
        stopScroll : function(mId) {
            var objId = 'vpMod_'+mId;
            mI = window[objId];
            clearTimeout(mI.vpTimer);
        },
        
        setOpac : function(mId,objId,value) {
            setOpacity(mId,objId,value);
        },
        
        showNextWrap: function(mId) {
            showNext(mId);
        },
        
        showPrevWrap: function(mId) {
            showPrev(mId);
        }
        
    };
    
}

var vpClassObj = new vpClass();
/* End code for video promo module */

//begin HP Tabblo code for Print Article
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

//LocalNav dynamic hilight
function selCatAsset() {
    if(document.getElementById("LocalNav").getElementsByTagName("ul")) {
        var ulObjARR = document.getElementById("LocalNav").getElementsByTagName("ul")[0];
        for(i=0;i<ulObjARR.getElementsByTagName("a").length;i++) {
            if(ulObjARR.getElementsByTagName("a")[i].href.indexOf(catSTR+"/"+assetSTR)>-1) {
                ulObjARR.getElementsByTagName("a")[i].className = "picLocalNavDflt";
            }
        }
    }
}
//End of LocalNav dynamic hilight
