var win = null;
    var currentRowNo = "0";
    var isPageLoaded = true;

    function setPageLoaded() {
        isPageLoaded = true;
    }
    function NewWindow(mypage, myname, w, h, scroll) {
        var asis = new Image();
        asis.src = "/no_cache/ac/modeloverview_videotab_help_clicks_nocount.asis";
        var winl = (screen.width - w) / 2;
        var wint = (screen.height - h) / 2;
        var settings = 'height=' + h + ',';
        settings += 'width=' + w + ',';
        settings += 'top=' + wint + ',';
        settings += 'left=' + winl + ',';
        settings += 'scrollbars=' + scroll + ',';
        settings += 'resizable=yes';
        win = window.open(mypage, myname, settings);
        if (parseInt(navigator.appVersion) >= 4) {
            win.window.focus();
        }
    }
    function MM_openBrWindow(theURL, winName, features) {
        window.open(theURL, winName, features);
    }

    //function to break the long str in FF, requires hasBlank in util.js
    function titleWordBreak(str) {
        var GEL_CHAR_LIMIT=13;
        var ret_str="";
        if (!is_ie5up) {
            if (str.length<=GEL_CHAR_LIMIT)return str;
            //case for no spaces
            if (!hasBlank(str)) {
                for(var i=0; i<str.length; i++) {
                    if(str.length>(i+1)*GEL_CHAR_LIMIT) {
                        if(i==0) ret_str += str.substring(i,(i+1)*GEL_CHAR_LIMIT)+"<br />";
                        else ret_str += str.substring(i*(GEL_CHAR_LIMIT+1),(i+1)*GEL_CHAR_LIMIT)+"<br />";
                    } else {
                        ret_str += str.substring(i*(GEL_CHAR_LIMIT+1),str.length); break;
                    }
                }//end for
            }//end if
            else return str;
            return ret_str;
        }//end if !IE
        else return str;
    }//end function

    var clickFromLink = false;
    var multimediaToggle=false;
    function collapseMediaDiv() {
        var mediaSPDiv = new layerObj('mediaSpacer','auto','auto','0','0','1');
        with(mediaSPDiv.objRef.style){height="0px"; width="0px";}
    }

    function expandMediaDiv() {
        var mediaSPDiv = new layerObj('mediaSpacer','auto','auto','0','0','1');
        with(mediaSPDiv.objRef.style){height="5px"; width="5px";}
    }

    //function for reporting, Playbutton is being passed through the flash movie
    function reportMulttabclick(branch,dealerID,carID, tabValue) {
    if(clickFromLink)
    {
        clickFromLink = false;
        return;
    }
    var v = "association_id"+currentRowNo;
        //vdp for multimedia tab
    dealerID=((dealerID=="undefined")||(dealerID==null)||(dealerID==""))?document.getElementById('delaerID').value:dealerID;
     carID=((carID=="undefined")||(carID==null)||(carID==""))?document.getElementById('carID').value:carID;
        var reportCode = "mis=FCVDBDLNMM948&dealer_id="+dealerID+"&car_id="+carID+"&address=" + global_zip;  //video tab

        if (tabValue == 'photo') {
            reportCode = "mis=FCVDBDLNMM1225&dealer_id="+dealerID+"&car_id="+carID+"";
        } else if (tabValue == '360spins') {
            reportCode = "mis=FCVDBDLNMM1226&dealer_id="+dealerID+"&car_id="+carID+"";
        }

        //playbutton is for the playbutton being pressed on the flash movie
        if (branch=="PLAYBUTTON") {
            reportCode = "mis=FCVDBDMGMM949&dealer_id="+dealerID+"&car_id="+carID+"&rdpage=0"+"&address=" + global_zip;
            if (currentRowNo != null && document.getElementById(v) != null) {
                reportCode = "mis=FCVDBDMGMM949&dealer_id="+dealerID+"&car_id="+carID+"&rdpage=0&association_id="+document.getElementById(v).value+"&address=" + global_zip;
            }
            reportCode += "&media_id=";
            if(current_media_id != null)
            {
              reportCode += current_media_id;
            }
            if( videoType && videoType!=null && carType && carType != null ) {
               _reportClickToVs(videoType,carType);
            }
        }
        document.getElementById("reportFrame").src ="/redirect/redirector_link.jsp?to_url=/img/blank_dot.gif&"+reportCode;
               // CR


        clickFromLink = false;
    }

    function _reportClickToVs(vt,ct) {
       var reportCode = "/no_cache/vs/" + ct + "_car_video_played.asis?video_type=" + vt;
       ATC.utils.BIUtils.addAsISImgEveryClick(reportCode);
    }

    function reportSisterVideoclick(rowNo, slotNo, argId, dealerID, carID) {
        if(clickFromLink == false)
        {
            return;
        }
       reportVideoclick(rowNo, slotNo, argId, dealerID, carID);
       if( videoType && videoType!=null && carType && carType != null ) {
          _reportClickToVs(videoType,carType);
       }
    }

    function reportVideoclick(rowNo, slotNo, argId, dealerID, carID) {
        // vdp for the specific slot mis code
        dealerID=((dealerID=="undefined")||(dealerID==null)||(dealerID==""))?document.getElementById('delaerID').value:dealerID;
          carID=((carID=="undefined")||(carID==null)||(carID==""))?document.getElementById('carID').value:carID;
        var reportCode = "mis=FCVDBDMGMM949&dealer_id="+dealerID+"&car_id="+carID+"&rdpage="+slotNo+"&address=" + global_zip;
        if (slotNo == '3' || slotNo == '4') {
            reportCode = "mis=FCVDBDMGMM949&dealer_id="+dealerID+"&car_id="+carID+"&rdpage="+slotNo+"&association_id="+argId+"&address=" + global_zip;
        }
        reportCode += "&media_id=";
        if(current_media_id != null)
        {
          reportCode += current_media_id;
        }
        document.getElementById("reportFrame").src ="/redirect/redirector_link.jsp?to_url=/img/blank_dot.gif&"+reportCode;
        clickFromLink = true;
        currentRowNo = rowNo;
    }

    //report clicking on 360 internal and 360 external links
    function report360click(rdpage, dealerID, carID) {

        dealerID=((dealerID=="undefined")||(dealerID==null)||(dealerID==""))?document.getElementById('delaerID').value:dealerID;
        carID=((carID=="undefined")||(carID==null)||(carID==""))?document.getElementById('carID').value:carID;

        var reportCode = "mis=FCVDBDLNMM1226&dealer_id="+dealerID+"&car_id="+carID+"&rdpage="+rdpage;

        document.getElementById("reportFrame360").src ="/redirect/redirector_link.jsp?to_url=/img/blank_dot.gif&"+reportCode;
    }

    function noPhotosShow() {
        switchTabs('photo');//turn photo div on
        var photosDIV = document.getElementById('vehiclePhotosDiv');
        photosDIV.className="noPhotos";
        photosDIV.innerHTML="No photos are currently available for this vehicle."; //msg for photots div
        if(is_ie5up){photosDIV.style.marginLeft="0px";}
    }

    //matches what movie was clicked and switches the other rows off switches that row on
    function switchGelsOnOff(cellRef) {
        var mediaTableRows = document.getElementById('media-table').rows;
        for (var mtRowIter in mediaTableRows) {
            if(mediaTableRows[mtRowIter].innerHTML!=null)
                if(mediaTableRows[mtRowIter].innerHTML.indexOf(cellRef)!=-1){
                    turnMediaRowOnOFF(mediaTableRows[mtRowIter].cells,'on');
                }
                else {
                    turnMediaRowOnOFF(mediaTableRows[mtRowIter].cells,'off');
                }
        }
    }//end function

    function turnMediaRowOnOFF(mediaCells,val) {
        for(var rowCellsIter in mediaCells){
            if(mediaCells[rowCellsIter].className){
                mediaCells[rowCellsIter].className = mediaCells[rowCellsIter].className.substring(0,mediaCells[rowCellsIter].className.lastIndexOf('-'))+"-"+val;
            }
        }
    }//end function