﻿// JScript File
function showPage(url, params) 
{
    if (url == "") {
    url = "visitLog.asp";
   
    }
    url = url+ "?" + params;
        hgt= 700;
        wid = 550;
    
    winname = "_Blank"
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open(url,winname,"width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
}
function editVisit(url, params) 
{
    if (url == "") {
    url = "editService.asp";
   
    }
    url = url+ "?" + params;
        hgt= 600;
        wid = 500;
    
    winname = "_Blank"
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open(url,winname,"width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
}
function editJobNote(ci, vi) 
{

    url = "editJobNote.asp" + "?md=edit&sid=" + vi;
        hgt= 300;
        wid = 500;
    
    winname = "_Blank"
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open(url,winname,"width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
}
function editUser(ui) 
{

    url = "edCont.asp" + "?md=edit&sid=" + ui;
        hgt= 450;
        wid = 480;
    
    winname = "_Blank"
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open(url,winname,"width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
}
function edDisp(ui) 
{

    url = "edDisp.asp" + "?md=edit&sid=" + ui;
        hgt= 250;
        wid = 480;
    
    winname = "_Blank"
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open(url,winname,"width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
}
function edOff(ui) 
{

    url = "edOff.asp" + "?md=edit&sid=" + ui;
        hgt= 320;
        wid = 400;
    
    winname = "_Blank"
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open(url,winname,"width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
}

function printpage()
{
    window.print()
}

function addCont(custID) 
{
    url = "visitLog.asp";
    url = url+ "?custID=" + custID + "&md=new"
        hgt= 700;
        wid = 550;
    
    winname = "_Blank"
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open(url,winname,"width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
}

 function editCust(id)
    {
    hgt = 430;
    wid = 400;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("editcustomer.asp?mode=edit&sid=" + id,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }

function editCont(id,custID)
    {
    hgt = 370;
    wid = 400;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("editcontact.asp?md=edit&sid=" + id + "&ci=" + custID,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
function edItem(id)
    {
    hgt = 370;
    wid = 400;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("editem.asp?md=edit&sid=" + id ,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
    
function editAddr(id,custID)
    {
    hgt = 420;
    wid = 400;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("edDelAdd.asp?md=edit&sid=" + id + "&ci=" + custID,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
function viewOrd(id,ordno)
    {
    
   window.location.assign("vworder.asp?sid=" + id )
   }
function editCarr(id)
    {
    hgt = 200;
    wid = 400;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("edCarr.asp?md=edit&sid=" + id ,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
function editAddr(id)
    {
    hgt = 400;
    wid = 400;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("edDelAd.asp?md=edit&sid=" + id ,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
function addAddr(id)
    {
    hgt = 400;
    wid = 400;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("edDelAd.asp?md=edit&sid=0&ent1=" + id ,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
 
 function askConf()
    {
    if ( confirm("Do you want to set order status to 'Confirmed'") ) {
        document.forms[0].conf.value = "confirm";
        mailTo = document.forms[0].mailto.value;
        if ( confirm("Do you want to send an email to: \r"+ mailTo) ) {
            document.forms[0].md.value = "mail";
        }
    } else {
    document.forms[0].conf.value = "";
    }
    }
 function askDispEm()
    {
        mailTo = document.forms[0].mailto.value;
        if ( confirm("Do you want to send an email to: \r"+ mailTo) ) {
            document.forms[0].md.value = "mail";
        }

    document.forms[0].conf.value = "Dispatch";
    document.forms[0].submit();

    }
 function askDisp()
    {

    document.forms[0].conf.value = "Dispatch";
    document.forms[0].submit();

    }
function findcont()
    {
     sSrch = document.forms[0].contsrch.value;
   
    if ( sSrch != "" ) {
    document.forms[0].srch.value = sSrch;
    document.forms[0].md.value = "srch";
    document.forms[0].submit();
    
    } else {
        alert("Please enter a name to search!")
        return false;
    }
    }

function editAction(id,logID,contID)
    {
    hgt = 300;
    wid = 580;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("editAction.asp?sid=" + id + "&li=" + logID + "&ci=" + contID + "&md=edit" ,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
    
function edOrd(id)
    {
    hgt = 550;
    wid = 580;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("edOrder.asp?sid=" + id + "&md=edit" ,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
function editCust(id)
    {
    hgt = 250;
    wid = 580;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("edCust.asp?sid=" + id + "&md=edit" ,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
    

function edListProd(id)
    {
    hgt = 240;
    wid = 500;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("edListProd.asp?sid="  + id + "&md=edit" ,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }

function editProd(id)
    {
    hgt = 400;
    wid = 500;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("edProduct.asp?sid="  + id + "&md=edit" ,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
function addProdPrice(id)
    {
    hgt = 600;
    wid = 550;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("uploadProd.asp?sid="  + id + "&md=edit" ,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }


function editDisNote(id,logID,contID)
    {
    hgt = 320;
    wid = 650;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("editDisc.asp?md=edit&sid=" + id + "&li=" + logID + "&ci=" + contID ,"","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }


function upDet()
    {
    hgt = 330;
    wid = 450;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("updet.asp","","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
function addNewCust()
    {
    hgt = 450;
    wid = 400;
    setY = (window.screen.height - hgt)/2
    setX = (window.screen.width - wid)/2
    winNew = window.open("editcustomer.asp?mode=new","","width="+wid+", height="+hgt+", scrollbars=yes, toolbar=no, menubar=no, status=no, top="+setY+", left="+setX)
    winNew.focus()
    }
function setMail()
    {
    mailTo = document.forms[0].mailto.value;
    if ( confirm("Do you want to send an email to: \r"+ mailTo) ) {
    document.forms[0].md.value = "mail";
    document.forms[0].submit();
    
    }
    
    }
     
function setCustlet(sLet)
    {
    

    document.forms[0].selcustlet.value = sLet;
    document.forms[0].submit();
    
    }
function chkDelOpt()
{
    delOp = document.forms[0].delChoice.value;
    if (delOp == "" || delOp == "0") {
        //show the entry boxes
        alert("Please select your preferred delivery option!");
        return false;
    } 
    delAdd = document.forms[0].delAddID.value;
    delAddIn = document.forms[0].Address1.value;
    if ((delAdd == "new" && delAddIn == "") || delAdd == "") {
        //no deliver address
        alert("Please enter your preferred delivery address!");
        return false;

    }
}

function setAddView()
{
    delAdd = document.forms[0].delAddID.value;
    mydiv = document.getElementById("mydiv");
    if (delAdd == "new") {
        //show the entry boxes
        mydiv.style.display = "block"; //to show it

    } else {
        //hide the entry boxes
        mydiv.style.display = "none"; //to hide it
    }

}
function check(delOpt)
{
    document.forms[0].delChoice.value=delOpt;
}

function showDay( params) 
{
    document.forms[0].dt.value = params;
    document.forms[0].submit();
}
    
    function setMth(iMth)
    {
    
    document.forms[0].dt.value = 1;
    document.forms[0].mth.value = iMth;
    document.forms[0].submit();
    
    }
    function setEmp(iEmp)
    {
    
    document.forms[0].selEmp.value = iEmp;
    document.forms[0].submit();
    
    }
    function clrEmp()
    {
    
    document.forms[0].selEmp.value = "";
    document.forms[0].submit();
    
    }
  function clrlastsel()
{
	// clear the last highlighted row
	// NOTE getElementsByTagName used for compatibility with IE!! getElementsByName does not work
	 x=document.getElementsByTagName("TR")
	
	 for (i=0 ;i<x.length;i++)
	 {
	 	if (x[i].className == "highlightFocus") {
	 		x[i].className = "normal"
			}
	 }
	// alert(x.length)

	
}

function setCurLine(curLocID)
{
	// clear the last highlighted row
	// NOTE getElementsByTagName used for compatibility with IE!! getElementsByName does not work
	
	 x=document.getElementsByTagName("TR")
	if (curLocID == "null") return 
	strFind = "&locID=" + curLocID + "&"
	for (i=0; i<x.length;i++)
	 {
	 	if (x[i].innerHTML.indexOf(strFind) > 1 && x[i].className == "normal" ) {
	 		x[i].className = "highlightFocus"
			//alert("debug "&curLocID&" " &i&" "&strFind&" "&x[i].innerHTML)
			return
			}
	 }
	 	//alert("Help "&curLocID&" " &x.length&" "&strFind)

}

function rowUpdate(myRow)
{
	if (myRow.className == "highlightFocus") {
		return
		}
	myRow.className = "normal"
}

function rowFocus(myRow)
{
	if (myRow.className == "highlightFocus") {
		return
		}
	myRow.className = "highlight"
}
  

