﻿// JScript File

var VarDate;

function StartClock(st_time)
{
    if(st_time != "") VarDate = new Date(st_time);
    var TempDate = VarDate;
    VarDate.setSeconds(TempDate.getSeconds() + 1);
    /////////////////////////////////////////////////////////////
    var nhours = VarDate.getHours();
    var nmins = VarDate.getMinutes();
    var nsecn = VarDate.getSeconds();
    var nday = VarDate.getDay();
    var nmonth = VarDate.getMonth();
    var ntoday = VarDate.getDate();
    var nyear = VarDate.getYear();
    var AorP=" ";

    if(nhours >= 12) AorP = "PM";
    else AorP = "AM";


    if(nhours >= 13) nhours -= 12;

    if(nhours == 0) nhours=12;

    if(nsecn < 10) nsecn = "0" + nsecn;

    if(nmins < 10) nmins = "0" + nmins;

    if(nday == 0) nday = "Sunday";
    if(nday == 1) nday = "Monday";
    if(nday == 2) nday = "Tuesday";
    if(nday == 3) nday = "Wednesday";
    if(nday == 4) nday = "Thursday";
    if(nday == 5) nday = "Friday";
    if(nday == 6) nday = "Saturday";
	
    if(nmonth == 0) nmonth = "January";
    if(nmonth == 1) nmonth = "February";
    if(nmonth == 2) nmonth = "March";
    if(nmonth == 3) nmonth = "April";
    if(nmonth == 4) nmonth = "May";
    if(nmonth == 5) nmonth = "June";
    if(nmonth == 6) nmonth = "July";
    if(nmonth == 7) nmonth = "August";
    if(nmonth == 8) nmonth = "September";
    if(nmonth == 9) nmonth = "October";
    if(nmonth == 10) nmonth = "November";
    if(nmonth == 11) nmonth = "December";

	

    if(nyear <= 99) nyear = "19" + nyear;

    if((nyear > 99) && (nyear < 2000)) nyear += 1900;
    /////////////////////////////////////////////////////////////
    document.getElementById('TextDate').value = nday + ", " + nmonth + " " + ntoday + ", " + nyear;
    document.getElementById('TextTime').value = nhours + ":" + nmins + ":" + nsecn + " " + AorP + " EST";
    setTimeout("StartClock('')",1000);	
}



function showCal(b,c)
{
	var calendar , calWidth , calHeight;
	calWidth = 150+70;
	calHeight = 172+28;
	calendar = window.open(c+'Controls/Objects/DataPicker.aspx?fn='+document.getElementById(b).value+'&fr='+b,'cal','width='+calWidth+',height='+calHeight);
	var X = window.screen.availWidth;
	var Y = window.screen.availHeight;
	var X = (X - calWidth) / 2;
	var Y = (Y - calHeight) / 2;
	calendar.moveTo(X,Y);
}

function showCal1(b)
{
	var calendar , calWidth , calHeight;
	calWidth = 150+70;
	calHeight = 172+28;
	calendar = window.open('../../Controls/Objects/DataPicker.aspx?fn='+document.getElementById(b).value+'&fr='+b,'cal','width='+calWidth+',height='+calHeight);
	var X = window.screen.availWidth;
	var Y = window.screen.availHeight;
	var X = (X - calWidth) / 2;
	var Y = (Y - calHeight) / 2;
	calendar.moveTo(X,Y);
}


var isNav;
var isIE;
function checkKey(e){var keyChar;if(isNav == 0){if(e.which < 48 || e.which > 57) e.RETURNVALUE = false;} else {if(e.keyCode < 48 || e.keyCode > 57) e.returnValue = false;}}

function ExportHTML()
{
    window.open("../../CommonFiles/ExportToHTML.aspx",'Export','toolbars=no,scrollbars=no,width=800,height=600');
}

var w;
function printImage (img) {
  img = img.src ? img.src : img;
  if (w && !w.closed)
    w.close();
  w = open ('', 'imagePrint', 
       'menubar=1,locationbar=0,statusbar=0,resizable=1'
       + ',scrollbars=1,width=400,height=400');
  var html = '';
  html += '<HTML><BODY ONLOAD="if (window.print) window.print(); '
           + 'setTimeout(\'window.close()\', 10000);">';
  html += '<IMG SRC="' + img + '">';
  html += '<\/BODY><\/HTML>';
  w.document.open();
  w.document.write(html);
  w.document.close();
}


function myParser(a)
{
    var b=new String(a);
    while(b.charAt(0) == "0" )
    {
        b=b.substr(1,b.length-1);
    }
    //document.getElementById("a")
    if(isNaN(b)==true)b=0;
    return b;
}

function CalculateOrderTotal(a,b)
{
    //document.getElementById('OrderTotalQty')
    if(a != null)
    {
        var total;
        total=0;
        var trul=document.body.getElementsByTagName("span");
		for (i=0;i<trul.length;i++)
		{
			if (trul[i].id.indexOf('_Total')!=-1)
			{
				total=total+parseInt(trul[i].innerHTML);
			}
		}
		a.innerHTML = total;
		b.value = total;
    }
    
}
