	//OPEN WINDOW
function newWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

  //Window Status Message
function CS(strMsg)
{
	window.status = strMsg
	
}

function DS()
{
	window.status = "Koike Aronson, Inc.";
	return true;
}

 //Open Window
function openWin_vert(url) {
win = window.open(url,'vert','status=no,width=270,height=400,scrollbars=no,resizable=yes')
win.focus()
}
function openWin_vertLG(url) {
win = window.open(url,'vertlg','status=no,width=350,height=380,scrollbars=no,resizable=yes')
win.focus()
}
function openWin_vertLG2(url) {
win = window.open(url,'vertlg','status=no,width=390,height=520,scrollbars=no,resizable=yes')
win.focus()
}
function openWin_horiz(url) {
win = window.open(url,'horiz','status=no,width=520,height=410,scrollbars=no,resizable=yes')
win.focus()
}
function openWin_horizLG(url) {
win = window.open(url,'horizlg','status=no,width=520,height=420,scrollbars=no,resizable=yes')
win.focus()
}
function openWin_square(url) {
win = window.open(url,'sqr','status=no,width=222,height=225,scrollbars=no,resizable=yes')
win.focus()
}
function openWin_LGsquare(url) {
win = window.open(url,'lgsqr','status=no,width=270,height=300,scrollbars=no,resizable=yes')
win.focus()
}
function openWin_WH(url,height,width) {
win = window.open(url,'WH','status=no,width=' + width + ',height=' + height + ',toolbar=no,location=no,scrollbars=yes,resizable=yes,status=no')
win.focus()
}
    
    //DROP DOWN MENU HOVER
topNavHover = function() {
	if (document.getElementById("topNav") != null) {
		var sfEls = document.getElementById("topNav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" topNavHover";
				window.status = '';
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" topNavHover\\b"), "");
				window.status = '';
			}
		}
	}
}
//topNavHover();	
if (window.attachEvent) window.attachEvent("onload", topNavHover);

/* list the Tabs */
var tabs = ["news","greatDeals"];
function showTab( tab ){
/* hide the Tab */
for(i=0; i < tabs.length; i++){
    var obj = document.getElementById(tabs[i]);
    obj.style.display = "none";
}          
/* show a Tab */
var obj = document.getElementById(tab);
obj.style.display = "block";     
}
//for applying a dynamic style to the help div on each page of the admin.
styleHelp = function() {
    var divID = 'helpDiv';
    if (document.getElementById(divID) != null) 
    {
        var helpDiv = document.getElementById(divID);
        try
        {
            var sfEls = document.getElementById(divID).getElementsByTagName("LI");
            for (var i=0; i<sfEls.length; i++) {
        	    sfEls[i].onmouseover=function() {
        		    this.style.backgroundColor='#e3e3e3';
        		    this.style.cursor='help';
        		    
        	    }
        	    sfEls[i].onmouseout=function() {
        		    this.style.backgroundColor='#FFFFFF';
        		    this.style.cursor='pointer';
        	    }
            }
        }
        catch (e)
        {   
            alert(e.description);
        }
    }
}

if (window.attachEvent) 
{
    window.attachEvent("onload", styleHelp);
}
else
{
    setTimeout(styleHelp,'1000');
}
function checkLength(formfield, targetlength)
{

    if (formfield.value.length > 0)
    {
        if (formfield.innerHTML.length > targetlength)
        {
            alert("Please enter only " + targetlength + " characters for this field");
            
            // Can either focus the element or remove exess.
            
            formfield.focus;
            formfield.select();
            return false;
        }
        else
        {
            return true;
        }
    }
}

/*  Summary:
    Used currently in the Machine Option save page within the machine folder of the manager.
    loops through the elements looking for checkboxes.
    
    Since there's only one implementation, I've chosen not to check any specific names for the elements but to
    loop through all elements looking for checkboxes.  This works well until you add another checkbox for IsAvailable or 
    in other words, something outside the treeview.
    
    For future implementations, we may rethink this and pass in the prefix for the control set we're working with and the 
    message we want to display when the count is greater than one.
*/
function checkCategories()
{
    //alert(document.getElementsByTagName("input").length);
    var x;
    var iCounter = 0;
    for (x in document.getElementsByTagName("input"))
    {
        //alert('inside for loop');
        //alert(x);
        //alert(document.getElementById(x));
        var frmElement = document.getElementById(x);
        if (frmElement != null)
        {
            if (frmElement.type == 'checkbox')
            {
                //alert('inside first if');
                if (frmElement.checked == true)
                {
                    //alert('inside second if');
                    iCounter += 1;
                }
            }
        }
    }
    //alert(iCounter);
    if (iCounter > 1)
    {
        alert('You can only put an option in one category.\n\nPlease modify your category selection and retry.');
        return false;
    }
    else
    {
        return true;
    }
}
//}
function showDiv(DivObject, ShowOrHide)
{
    if (ShowOrHide == true)
        {
            DivObject.style.visibility = 'visible';
        }
     else
        {
            DivObject.style.visibility = 'hidden';
        }
}
function colorDiv(DivObject, ShowOrHide)
{
    if (ShowOrHide == true)
        {
            DivObject.style.color = '#585858';
        }
     else
        {
            DivObject.style.color = 'red';
        }
}

function CheckAll(fmobj) {
  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
    if ((e.type=='checkbox')) {
      e.checked = true;
    }
  }
}
function UncheckAll(fmobj)
{
  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
    if ((e.type=='checkbox')) {
      e.checked = false;
    }
  }
}

function HandleDivs(bVisible)
{
    if(bVisible)
        {
            document.getElementById('RepDiv').style.display = 'inline';
            document.getElementById('RepDiv').setAttribute("class",'divOn');
            document.getElementById('ManagerDiv').setAttribute("class",'divOff');
            document.getElementById('ManagerDiv').style.display='none';
        }
        else
        {
            document.getElementById('RepDiv').style.display = 'none';
            document.getElementById('RepDiv').setAttribute("class",'divOff');
            document.getElementById('ManagerDiv').setAttribute("class",'divOn');
            document.getElementById('ManagerDiv').style.display='inline';
        }
}

function HandleShowHideDiv(element, onOff)
{
    if(onOff == true)
    {
        element.style.display = 'inline';
        element.setAttribute("class", 'divOn');   
    }else{
        element.style.display = 'none';
        element.setAttribute("class", 'divOff');
    }
    HandleDivs(onOff);
}

var req;

function UpdateNotes(QuoteID)
{
    try
    {
        if (typeof XMLHttpRequest != "undefined") 
        {
           req = new XMLHttpRequest();
        } 
        else if (window.ActiveXObject) 
        {
           req = new ActiveXObject("Microsoft.XMLHTTP");
        }
        var d = new Date();
        var t = d.getTime();
        var ctlNotes = document.getElementById("txtNotes");
        var NotesString= ctlNotes.value;
        NotesString = escape(NotesString)
        req.open("GET", 'AJAXUpdateNotes.aspx?QuoteID=' + QuoteID + '&Notes=' + NotesString + '&timeofrequest=' + t, true);
        req.onreadystatechange = AJAXCallback;
        req.send(null);
    }
    catch (err)
    {
        alert(err.message);
    }
}

function AJAXCallback()
{
    if (req.readyState == 4) 
    {
        if (req.status == 200) 
        {
            try
            {
                var ctlUpdateStatus = document.getElementById("litUpdateStatus");
                if (ctlUpdateStatus != null)
                    {
                        var xmlDoc = req.responseXML.documentElement;
                        var strUpdateStatus = xmlDoc.getElementsByTagName("updateStatus")[0].childNodes[0].nodeValue;

                        
                        ctlUpdateStatus.innerHTML = strUpdateStatus
                    }
            }
            catch (err)
            {
                alert(err.message);
            }
        }
        else if (req.status == 500)
        {
            var message = 'An error was encountered on the server when trying to add the item to the cart.';
            message += '\n\nPlease refresh the page and try adding the item again.';
            alert(message);
        }
    }
}

function submitForm()
{
    try
    {
    var docURL = '/results.aspx?query=' + document.forms.searchForm.elements[0].value;
    document.location.href = docURL;
    }
    catch(err)
    {
    alert(err.message);
    }
    return false;
}

    $(document).ready(function(){ 
        $("ul.sf-menu").superfish({ 
            animation: {height:'show'},   // slide-down effect without fade-in 
            delay:     500               // 0.5 second delay on mouseout 
        }); 
    }); 