﻿var externWin;var newWin;function openPopupName(strName,strURL,intHeight,intWidth,intTop,intLeft,blnLocation,blnMenuBar,blnResizable,blnScrollbars,blnStatus,blnToolbar){if(!externWin||externWin.closed){externWin=window.open(strURL,strName,"height="+intHeight+",width="+intWidth+",top="+intTop+",left="+intLeft+",location="+blnLocation+",menubar="+blnMenuBar+",resizable="+blnResizable+",scrollbars="+blnScrollbars+",status="+blnStatus+",toolbar="+blnToolbar);}else{externWin.location=strURL;externWin.focus();}}
function print_mail_to_link(lhs,strName,rhs){document.write("<A HREF=\"mailto");document.write(":"+lhs+"@");document.write(rhs+"\">"+strName+"<\/a>");}
function checkSearchTerm(searchBox){if(searchBox.value=='Search'){searchBox.value='';}}
function showProdSection(strSectionId){if(document.getElementById(strSectionId)&&document.getElementById(strSectionId).style.display!="block"){hideProdSection("prodDescription");hideProdSection("prodAccessories");hideProdSection("prodAppNotes");hideProdSection("prodControllers");hideProdSection("prodModes");document.getElementById(strSectionId).style.display="block";if(document.getElementById('option_'+strSectionId)){document.getElementById('option_'+strSectionId).className="prodSectionOn";}}}
function hideProdSection(strSectionId){if(document.getElementById(strSectionId)){document.getElementById(strSectionId).style.display="none";if(document.getElementById('option_'+strSectionId)){document.getElementById('option_'+strSectionId).className="prodSectionOff";}}}
function showProdSectionSubItem(strSectionPrefix,intAccNum,intNumAcc){if(document.getElementById(strSectionPrefix+'_'+intAccNum).style.display!="block"){for(i=0;i<intNumAcc;i++){if(i!=intAccNum){document.getElementById(strSectionPrefix+'_'+i).style.display="none";document.getElementById(strSectionPrefix+'Link_'+i).className="prodUlOff";}}document.getElementById(strSectionPrefix+'_'+intAccNum).style.display="block";document.getElementById(strSectionPrefix+'Link_'+intAccNum).className="prodUlOn";}}
function unCheckMe(myObj){myObj.selected=false;}
function unhide(){document.getElementById('moreid').style.display='block';document.getElementById('hidemore').style.display='none';}
function hide(){document.getElementById('moreid').style.display='none';document.getElementById('hidemore').style.display='block';}
function setAJAXVar(strKey,strValue){var myForm=document.frmTimesheets;url='/includes/AJAXSetVar.aspx?key='+strKey+'&value='+strValue;if(window.XMLHttpRequest){req=new XMLHttpRequest();req.open("GET",url,true);req.send(null);}else if(window.ActiveXObject){req=new ActiveXObject("Microsoft.XMLHTTP");if(req){req.open("GET",url,true);req.send();}}}
function countChars(boxToCount,boxToUpdate,allowedChars){boxToUpdate.value=(allowedChars-boxToCount.value.length);}
function swapDefaultSearch(mySearch) { if (mySearch.value == 'Search') { mySearch.value = ''; } }
function swapDefaultZipCode(myZipCode) { myZipCode.value = ''; }
function swapDefaultPostalCode(myZipCode) { myZipCode.value = ''; }
function toggleSlideShowArrow(myElem,myImage){myElem.setAttribute('src',myImage);}
function initLinkModifications(){if(document.getElementsByTagName){var hrefs=document.getElementsByTagName("a");for(var l=0;l<hrefs.length;l++){var path=hrefs[l].pathname+hrefs[l].search;var isDoc=path.match(/(?:doc|eps|exe|jpg|pdf|png|ppt|svg|vsd|xls|zip)($|\&)/);if(isDoc){if(hrefs[l].onclick){startListening(hrefs[l],"mousedown",hrefs[l].onclick);}
startListening(hrefs[l],"mousedown",trackExternalLinks);}
var isAskAQ=path.match(/(?:ask-a-question.aspx.*)($|\&)/);if(isAskAQ){hrefs[l].href="/frequently-asked-questions/ask-a-question.aspx?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=425&width=600&modal=false";hrefs[l].className="thickbox"}}}}
function startListening(obj,evnt,func){if(obj.addEventListener){obj.addEventListener(evnt,func,false);}else if(obj.attachEvent){obj.attachEvent("on"+evnt,func);}}
function trackExternalLinks(evnt){var e=(evnt.srcElement)?evnt.srcElement:this;while(e.tagName!="A"){e=e.parentNode;}
var lnk=(e.pathname.charAt(0)=="/")?e.pathname:"/"+e.pathname;if(e.search&&e.pathname.indexOf(e.search)==-1)lnk+=e.search;if(typeof(pageTracker)=="object")pageTracker._trackPageview(lnk);}
function createCookie(name, value, days) {if (days) {var date = new Date();date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));var expires = "; expires=" + date.toGMTString();}else var expires = "";document.cookie = name + "=" + value + expires + "; path=/";}
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 eraseCookie(name) { createCookie(name, "", -1); }
$(document).ready(function () {
    $("input[class='swapImg'], a[class='swapImg'], img[class='swapImg'], a[class='ShareIcon'], img[class='ShareIcon']").mouseover(function () {
        $(this).attr('src', $(this).attr('src').replace("_up", "_over"));
    }).mouseout(function () {
        $(this).attr('src', $(this).attr('src').replace("_over", "_up"));
    });

    var currHref = window.location.pathname.toLowerCase().replace("default.aspx", "");
    //Track external links and downloads
    var filetypes = /\.(zip|exe|pdf|doc*|xls*|ppt*|mp3|mov|avi|wmv)$/i;
    $('a').each(function () {
        //if ($(this).attr('href')) {
        // alert(($(this).attr('href')));
        // }
        if (!($(this).attr('name'))) {
            var href = $(this).attr('href');
            //alert(href);
            if (href != undefined) {
                if ((href.match(/^https?\:/i)) && (!href.match(document.domain))) {
                    $(this).click(function () {
                        var extLink = href.replace(/^https?\:\/\//i, '');
                        // pageTracker._trackPageview('/outgoing-link/' + extLink);
                        // _gaq.push(['_setAccount', 'UA-4468083-3']);
                        _gaq.push(['_trackPageview', '/outgoing-link/' + currHref + '//' + extLink]);
                        //alert('/outgoing-link' + currHref + extLink);
                    });
                }
                else if (href.match(/^mailto\:/i)) {
                    $(this).click(function () {
                        var mailLink = href.replace(/^mailto\:/i, '');
                        //pageTracker._trackPageview ('/mail-link/' + mailLink);
                        // _gaq.push(['_setAccount', 'UA-4468083-3']);
                        _gaq.push(['_trackPageview', '/mail-link/' + currHref + mailLink]);
                        //alert('/mail-link/' + currHref + mailLink);
                    });
                }
                else if (href.match(filetypes)) {
                    $(this).click(function () {
                        var extension = (/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined;
                        var filePath = href.replace(/^https?\:\/\/(www.)mydomain\.com\//i, '');
                        //alert ('/file-link/' + extension  + filePath);
                        //pageTracker._trackPageview ('/file-link/' + extension  + filePath);
                        //  _gaq.push(['_setAccount', 'UA-4468083-3']);
                        _gaq.push(['_trackPageview', '/file-link' + currHref + 'DownloadFrom/' + extension + filePath]);
                        //alert('/file-link' + currHref + 'DownloadFrom/' + extension + filePath);
                    });
                }
            }
        }
    });

});
function getProductData(oID) {
    var URL = "/includes/get-product-data.aspx?oID=" + oID;
    $.getJSON(URL, function (data) {
        document.title = data.ppPageTitle;
        $("#ppCopyTitle").html(data.ppCopyTitle);
        $("#BreadcrumbTrail").html(data.ppBreadcrumbTrail);
        if (data.ppImage.length == 0) {
            $("#ppImage").css('padding-right', '0px');
            $("#ppImage").html('');
        } else {
            $("#ppImage").css('padding-right', '12px');
            $("#ppImage").html(data.ppImage);
        }
        $("#ppTitleTagLineAndIntro").html(data.ppTitleTagLineAndIntro);
        $("#ppBodyCopyAndConclusion").html(data.ppBodyCopyAndConclusion);
        $("#ppRelatedDocuments").html(data.ppRelatedDocuments);
        $("#ppProductPager").html(data.ppProductPager);
        $("#LeftColHeader").html(data.ppLeftColHeader);
        $("#LeftNavSectionSubHead").html(data.ppLeftNavSectionSubHead);
        $("#LeftNavListOfLinks").html(data.ppLeftNavigation);
    });
}
