﻿function ViewLargeProduct(JobImageID) {
    winHeight = "340px"
    winWidth = "430px"
	
    if (window.showModelessDialog)
        winImagePreview = window.showModelessDialog("ViewLargeImage.aspx?JobImageID=" + JobImageID , null, "dialogHeight:" + winHeight + "px;dialogWidth:" + winWidth + "px;center: Yes;status:no;scroll:no")
    else {
        winImagePreview = window.open("ViewLargeImage.aspx?JobImageID=" + JobImageID , "Newwin", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + winWidth + ",height=" + winHeight)	
    }
}

function ViewPropertyImages(url) {
    winHeight = "600px"
    winWidth = "815px"
	
//    if (window.showModelessDialog)
//        winImagePreview = window.showModelessDialog("ViewLargeImage.aspx?JobImageID=" + JobImageID , null, "dialogHeight:" + winHeight + "px;dialogWidth:" + winWidth + "px;center: Yes;status:no;scroll:no")
//    else {
        winImagePreview = window.open(url , "Newwin", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + winWidth + ",height=" + winHeight)	
        winImagePreview.focus();
//    }

    }

    function ForceNumeric(num) {
        num = StripNonNumeric(num);
        if (isNaN(num)) num = 0;
        if (num == "") num = 0;
        return parseFloat(num);
    }

    function StripNonNumeric(sString) {
        var CharCode, Char;
        sString = String(sString);
        var sNumeric = "";
        for (var i = 0; i < sString.length; i++) {
            CharCode = sString.charCodeAt(i);
            Char = sString.substr(i, 1);
            if ((CharCode > 47 && CharCode < 58) || Char == "." || Char == "-") sNumeric = sNumeric + sString.substr(i, 1);
        }
        return sNumeric;
    }

    function FormatNumber(fValue, iDecimalPlaces, bIncludeLeadingZero, bUseParensForNegNums, bGroupDigits) {

        var sValue = String(ForceNumeric(fValue))

        var i, vNumber, vFraction, fFraction
        var sNumber = '';
        var sFraction = '';
        var bIsNegative = false;

        vNumber = parseInt(sValue, 10);
        fFraction = parseFloat(sValue) - vNumber;

        if (vNumber < 0) { bIsNegative = true; }

        if (iDecimalPlaces > 0) {

            fFraction = Math.round(fFraction * Math.pow(10, iDecimalPlaces));
            if (fFraction == 0) {
                sFraction = String(Math.pow(10, iDecimalPlaces));
                sFraction = sFraction.substring(1)
            }
            else if (fFraction == 100) {
                //overflow - increment the number by one
                sFraction = '00';
                vNumber++;
            }
            else {
                sFraction = String(fFraction);
                while (sFraction.length < iDecimalPlaces) {
                    sFraction = "0" + sFraction;
                }
            }

            sFraction = "." + sFraction
        }
        else
            sFraction = "";

        sNumber = vNumber.toString();

        //group the digits when requested (eg., 1,234,567.89)
        if (bGroupDigits) {

            if (sNumber.length > (bIsNegative ? 4 : 3)) {

                var tmpNumber = "";

                for (i = sNumber.length - 3; i >= 0; i -= 3) {
                    tmpNumber = "," + sNumber.slice(i, i + 3) + tmpNumber;
                }

                //window.status = tmpNumber;

                var sNumberMod3 = parseInt(sNumber.length % 3)

                sNumber = sNumber.substring(0, sNumberMod3) + tmpNumber;
                if (sNumber.indexOf(",") == 0) sNumber = sNumber.substring(1)
            }

        }

        //include leading digit
        if (bIncludeLeadingZero) {
            if (sNumber.length == 0) { sNumber = "0"; }
        }

        //put the number part and fractional part together
        sValue = sNumber + sFraction;

        //put in parens if number is negative	
        if ((bUseParensForNegNums) && (bIsNegative)) { sValue = '(' + sValue + ')'; }

        return sValue;

    }

    function Currency(val, dp) {
        if (val == '')
            return '';
        else
            return '$' + FormatNumber(val, dp, true, false, true);
    }
    function Number(val, dp) {
        if (val == '')
            return '';
        else
            return FormatNumber(val, dp, true, false, true);
    }
    function GetValue(ControlName) {
        var value = ForceNumeric(document.getElementById(ControlName).value);
        if (isNaN(value))
            return 0;
        else
            return value;
    }

    function DisableChildren(objElement) {
        //recursive function
        //form elements with custom attribute 'allowdisable="false"' are not touched
        //debugger

        for (var i = 0; i < objElement.children.length; i++) {

            if (objElement.children[i].getAttribute("allowdisable") != "false" && ingnorethiselement.id != objElement.children[i].id) {

                //disable form elements
                if (objElement.children[i].type) {
                    switch (String(objElement.children[i].type)) {
                        case "button":
                        case "submit":
                        case "text":
                        case "password":
                        case "hidden":
                        case "select-one":
                        case "textarea":
                        case "select-multiple":
                        case "checkbox":
                        case "radio":
                            objElement.children[i].disabled = true;
                            objElement.children[i].style.color = '#c0c0c0';
                            objElement.children[i].style.backgroundColor = '#dddddd';
                            if (objElement.children[i].value)
                                objElement.children[i].value = '';
                            break;
                    }
                }
                else
                //apply opacity filter to other elements
                    objElement.children[i].style.color = '#c0c0c0';


            }
            //recursive call for child elements
            DisableChildren(objElement.children[i]);
        }
    }

    function EnableChildren(objElement) {
        //recursive function
        //form elements with custom attribute 'allowdisable="false"' are not touched

        for (var i = 0; i < objElement.children.length; i++) {

            if (objElement.children[i].getAttribute("allowdisable") != "false" && ingnorethiselement.id != objElement.children[i].id) {

                //disable form elements
                if (objElement.children[i].type) {
                    switch (String(objElement.children[i].type)) {
                        case "button":
                        case "submit":
                        case "text":
                        case "password":
                        case "hidden":
                        case "select-one":
                        case "textarea":
                        case "select-multiple":
                        case "checkbox":
                        case "radio":
                            objElement.children[i].disabled = false;
                            objElement.children[i].style.color = '';
                            objElement.children[i].style.backgroundColor = '';
                            break;
                    }
                }
                else
                //apply opacity filter to other elements
                    objElement.children[i].style.color = '';

            }

            //recursive call for child elements
            EnableChildren(objElement.children[i]);
        }
    }

    function GetParentFromTagName(curElement, ParentElementTagName) {

        if (curElement.tagName.toLowerCase() == String(ParentElementTagName).toLowerCase())
            return curElement;
        else
            return GetParentFromTagName(curElement.parentNode, ParentElementTagName);

    }

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function IMG1_onclick() {
    location.href='upcomingauction.aspx';
}