﻿function jumpToPageTop(e) {
	UAGENT = navigator.userAgent.toUpperCase();
	if (UAGENT.indexOf("MSIE") >=0) {
		pos = event.y;
	} else {
		pos = e.pageY;
	}
	pageScroll(pos);
}

function pageScroll(posi) {
	dist = posi / 6;
	nPos = parseInt(posi - dist);
	scrollTo(0,nPos);
	if (nPos > 0) {
		setTimeout("pageScroll(nPos)",10);
	}
}

function openNewWin(url)
{
    var x = window.open(url, 'surveywindow', 'status=0, toolbar=0, scrollbars=1, menubar=0, resizeable=0, width=800,height=550;');
    
    //x.focus();
} 

function reloadparent()
{
    try
    {
        if (window.opener && !window.opener.closed)
            window.opener.location.reload();
    }
    catch (Error)
    {
    }
}


function getText(ref_obj) 
{
    if (ref_obj !== null) {
        try {

            if (isChrome) { return ref_obj.textContent; }
            else {return ref_obj.innerText; }
        }
        catch (errormsg) {
            ErrorReport(errormsg, "unexpected error when trying to get text property");
            return "";
        }
    }
    else 
    {
        ErrorReport(null, "cannot get text from null object");
        return "";
    }
}

function setText(ref_obj, tmp_value) 
{
    if (ref_obj !== null && tmp_value !== null) {
        try {
            if (isChrome) { ref_obj.textContent = tmp_value; }
            else { ref_obj.innerText = tmp_value; }
        }
        catch (errormsg) {
            ErrorReport(errormsg, "unexpected error when trying to set text property");
        }
    }
    else {
        if (ref_obj === null)
        { 
            ErrorReport(null, "cannot set text on null object");         
        }
        else if (tmp_value === null)
        { 
            ErrorReport(null, "cannot set null text on object"); 
        }
    }
}


function ErrorReport(ERROR_OBJECT , ERROR_CUSTOM_DETAILS) 
{

    var TMP_EMAIL_MESSAGE;
    var Incident_Date = new Date();

    var TMP_EMAIL_ERROR_DETAILS = "";

    TMP_EMAIL_MESSAGE = "\n\nFor support team: ";
    TMP_EMAIL_MESSAGE += "\n\t" + "Incident time: " + Incident_Date.getDay() + "/" + Incident_Date.getMonth() + "/" + Incident_Date.getYear() + " " + Incident_Date.getHours() + ":" + Incident_Date.getMinutes();
    TMP_EMAIL_MESSAGE += "\n\t" + BrowserDetect.browser + " " + BrowserDetect.version + " on " + osversion;
    if (ERROR_CUSTOM_DETAILS != "")
    { TMP_EMAIL_MESSAGE += "\n\tDETAILS: " + ERROR_CUSTOM_DETAILS; }
    if (getURLParam("filename") != "")
    { TMP_EMAIL_MESSAGE += "\n\t" + "firmware file name: " + getURLParam("filename"); }
    if (getURLParam("p") != "")
    { TMP_EMAIL_MESSAGE += "\n\t" + "platform detected: " + getURLParam("p"); }
    if (getURLParam("year") != "")
    { TMP_EMAIL_MESSAGE += "\n\t" + "searching: " + getURLParam("year") + " " + getURLParam("make") + " " + getURLParam("model"); }
    if (getURLParam("ps") != "")
    { TMP_EMAIL_MESSAGE += "\n\t" + "searching product state: " + getURLParam("ps"); }
    if (getURLParam("s") != "")
    { TMP_EMAIL_MESSAGE += "\n\t" + "showing all platforms in search: " + getURLParam("s"); }
    if (document.getElementById("CABActivex") !== null)
    { TMP_EMAIL_MESSAGE += "\n\t" + "xpressvip activex version: " + document.getElementById("CABActivex").codeBase + " " + document.getElementById("CABActivex").classid; }
    TMP_EMAIL_MESSAGE += "\n\t" + "page: " + window.location;

    if (ERROR_CUSTOM_DETAILS !== null) {
        if (ERROR_CUSTOM_DETAILS != "") {
            TMP_EMAIL_ERROR_DETAILS += "\n\t\t" + "Technical custom details: ";
            TMP_EMAIL_ERROR_DETAILS += "\n\t\t\t" + ERROR_CUSTOM_DETAILS;
        }
    }
    if (ERROR_OBJECT !== null) {

        TMP_EMAIL_ERROR_DETAILS += "\n\t\t" + "Technical details: ";
        TMP_EMAIL_ERROR_DETAILS += "\n\t\t\tEXCEPTION TYPE: " + ERROR_OBJECT._exceptionType;
        TMP_EMAIL_ERROR_DETAILS += "\n\t\t\tMESSAGE: " + ERROR_OBJECT._message;
        TMP_EMAIL_ERROR_DETAILS += "\n\t\t\tSTACK TRACE: " + ERROR_OBJECT._stackTrace;
        TMP_EMAIL_ERROR_DETAILS += "\n\t\t\tSTACK CODE: " + ERROR_OBJECT._stackCode;
        TMP_EMAIL_ERROR_DETAILS += "\n\t\t\tTIMEDOUT: " + ERROR_OBJECT._timedOut;
    }

    var TMP_PAST_ERRORS;
    TMP_PAST_ERRORS = $.cookie("PAST_ERRORS");
    if (TMP_PAST_ERRORS === null) {
        TMP_PAST_ERRORS = "";
    }
    //periodically clear the errors buffer if it gets too big
    if (TMP_PAST_ERRORS.length > 1000) {
        $.cookie("PAST_ERRORS", TMP_EMAIL_ERROR_DETAILS);
    }
    else {
        $.cookie("PAST_ERRORS", TMP_EMAIL_ERROR_DETAILS + TMP_PAST_ERRORS  )
    }
    
    var TMP_Full_Body;
    TMP_Full_Body = escape("Hello Support Team, ");
    if (ERROR_CUSTOM_DETAILS == "")
    { TMP_Full_Body += escape("\n\n I had a problem while i was on xpresskit.com, <provide details here>"); }
    TMP_Full_Body += escape("\n\n" + ERROR_CUSTOM_DETAILS);
    TMP_Full_Body += escape("\n\nPlease help me resolve this problem. ");
    TMP_Full_Body += escape(TMP_EMAIL_MESSAGE);
    TMP_Full_Body += escape(TMP_EMAIL_ERROR_DETAILS + TMP_PAST_ERRORS);


    if (document.getElementById("A_HELP") !== null && ERROR_OBJECT === null && ERROR_CUSTOM_DETAILS=== null) {
        //document.getElementById("A_HELP").href = link;

        var link = "";
        link = "mailto:";
        link += "vipsupport@directed.com";
        link += "?subject=xpresskit error";
        link += "&body=" + TMP_Full_Body;

        win = window.open(link, 'emailWindow');
        if (win && win.open && !win.closed) win.close();

    }

    if (IS_TEST_MODE) 
    {
        alert(TMP_EMAIL_MESSAGE + TMP_EMAIL_ERROR_DETAILS + TMP_PAST_ERRORS);
    }

    return;    

    
}

function initialize()
{
    $('ul#navigationmenu > li').hover(
        function() { $(this).addClass('hover'); },
        function() { $(this).removeClass('hover'); }
    );
    
    $('ul#navigationmenu > li > ul').hover(
        function() { $(this).parents('li').addClass('hover'); },
        function() { $(this).parents('li').removeClass('hover'); }
    );
    
    var ps = 1;
    try
    {
        ps = parseInt(getURLParam("ps"));
    }
    catch (Error)
    {
    }           
    if (ps < 0 || ps > 3)
    {
        ps = 1;
    }
    try
    {
        document.getElementsByName('rbState')[ps-1].checked = true;    
    }
    catch (Error)
    {
        document.getElementsByName('rbState')[0].checked = true; 
    }
}

function getURLParam(strParamName) {
    var strReturn = "";
    var strHref = window.location.href;
    if (strHref.indexOf("?") > -1) {
        var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
        var aQueryString = strQueryString.split("&");
        for (var iParam = 0; iParam < aQueryString.length; iParam++) {
            if (
aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1) {
                var aParam = aQueryString[iParam].split("=");
                strReturn = aParam[1];
                break;
            }
        }
    }
    return unescape(strReturn);
}


function ClearDropdown(dropdown) {
    // Set select to the element "selectbox."   
    var select = document.getElementById(dropdown);
    // Set options to an array of all "option" tags that   
    // are children of the select element.   
    var options = select.getElementsByTagName("option");
    var i;
    // Loop through the array of options and remove each   
    // each one from the parent's childNode list.   
    for (i = options.length - 1; i >= 0; i--) {
        if (options[i].value != "Select Year" && options[i].value != "Select Make" && options[i].value != "Select Model")
        { select.removeChild(options[i]); }
    }
}

function SelectDropDown(dropdown, Value) {
    var select = document.getElementById(dropdown);
    var options = select.getElementsByTagName("option");
    var i;

    for (i = options.length - 1; i >= 0; i--) {
        if (options[i].value == Value)
        { select.selectedIndex = i; }
    }
}

$(document).ready(function(){ 
    //$(document).pngFix(); 
}); 

/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.1, 11.09.2007
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(s($){3.1s.1k=s(j){j=3.1a({12:\'1m.1j\'},j);8 k=(n.P=="r 10 Z"&&U(n.v)==4&&n.v.E("14 5.5")!=-1);8 l=(n.P=="r 10 Z"&&U(n.v)==4&&n.v.E("14 6.0")!=-1);o(3.17.16&&(k||l)){3(2).L("1r[m$=.M]").z(s(){3(2).7(\'q\',3(2).q());3(2).7(\'p\',3(2).p());8 a=\'\';8 b=\'\';8 c=(3(2).7(\'K\'))?\'K="\'+3(2).7(\'K\')+\'" \':\'\';8 d=(3(2).7(\'A\'))?\'A="\'+3(2).7(\'A\')+\'" \':\'\';8 e=(3(2).7(\'C\'))?\'C="\'+3(2).7(\'C\')+\'" \':\'\';8 f=(3(2).7(\'B\'))?\'B="\'+3(2).7(\'B\')+\'" \':\'\';8 g=(3(2).7(\'R\'))?\'1d:\'+3(2).7(\'R\')+\';\':\'\';8 h=(3(2).1c().7(\'1b\'))?\'19:18;\':\'\';o(2.9.y){a+=\'y:\'+2.9.y+\';\';2.9.y=\'\'}o(2.9.t){a+=\'t:\'+2.9.t+\';\';2.9.t=\'\'}o(2.9.w){a+=\'w:\'+2.9.w+\';\';2.9.w=\'\'}8 i=(2.9.15);b+=\'<x \'+c+d+e+f;b+=\'9="13:11;1q-1p:1o-1n;O:W-V;N:1l;\'+g+h;b+=\'q:\'+3(2).q()+\'u;\'+\'p:\'+3(2).p()+\'u;\';b+=\'J:I:H.r.G\'+\'(m=\\\'\'+3(2).7(\'m\')+\'\\\', D=\\\'F\\\');\';b+=i+\'"></x>\';o(a!=\'\'){b=\'<x 9="13:11;O:W-V;\'+a+h+\'q:\'+3(2).q()+\'u;\'+\'p:\'+3(2).p()+\'u;\'+\'">\'+b+\'</x>\'}3(2).1i();3(2).1h(b)});3(2).L("*").z(s(){8 a=3(2).T(\'N-S\');o(a.E(".M")!=-1){8 b=a.X(\'1g("\')[1].X(\'")\')[0];3(2).T(\'N-S\',\'1f\');3(2).Q(0).Y.J="I:H.r.G(m=\'"+b+"\',D=\'F\')"}});3(2).L("1e[m$=.M]").z(s(){8 a=3(2).7(\'m\');3(2).Q(0).Y.J=\'I:H.r.G\'+\'(m=\\\'\'+a+\'\\\', D=\\\'F\\\');\';3(2).7(\'m\',j.12)})}1t 3}})(3);',62,92,'||this|jQuery||||attr|var|style|||||||||||||src|navigator|if|height|width|Microsoft|function|padding|px|appVersion|margin|span|border|each|class|alt|title|sizingMethod|indexOf|scale|AlphaImageLoader|DXImageTransform|progid|filter|id|find|png|background|display|appName|get|align|image|css|parseInt|block|inline|split|runtimeStyle|Explorer|Internet|relative|blankgif|position|MSIE|cssText|msie|browser|hand|cursor|extend|href|parent|float|input|none|url|after|hide|gif|pngFix|transparent|blank|line|pre|space|white|img|fn|return'.split('|'),0,{}))
