/* **************************************************************************************
**   Copyright Notice    
**
**  Javascript Common Include -- ProApp ASP 3 Framework
**                                                              
**   2002 ProApp Design, Inc. All Rights Reserved.                                
**
**  All copyright notices must remain intact in the scripts.
**
**  You may NOT redistribute, repackage, or sell the whole or any part of this 
**  program even if it is modified or reverse engineered in whole or in part without express 
**  permission from the author.
**
**  You may not pass the whole or any part of this application off as your own work.
**   
**  This code is distributed WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR ANY OTHER 
**  WARRANTIES WHETHER EXPRESSED OR IMPLIED.
**
**  No official support is available for this program, because it is propreitary unsupported code
**
** http://www.proapp.net/
**************************************************************************************** */

function clearDiv(sourceid)
{
	sourcediv = document.getElementById(sourceid);
	sourcediv.innerHTML = "";
}

function toggleDiv(sourceid, targetid)
{
	sourcediv = document.getElementById(sourceid);
	targetdiv = document.getElementById(targetid);
	targetdiv.innerHTML = sourcediv.innerHTML;
}

function delete_object(pagetitle, confirmmsg, redir) 
{
	input_box=confirm("You are about to delete " + pagetitle + " and remove it from all \n\r related objects\n\r\n\r" + confirmmsg + "\n\r\n\rAre you sure you wish to delete this item and all its relations?");
	if (input_box==true)
	{ 
		// Output when OK is clicked
		window.navigate(redir);
	}
	else
	{
		// Output when Cancel is clicked
		alert ("Delete cancelled");
	}
}

function confirm_action(msgtext, redir) 
{
	input_box=confirm(msgtext);
	if (input_box==true)
	{ 
		// Output when OK is clicked
		eval(redir);
	}
	else
	{
		// Output when Cancel is clicked
		alert ("Action cancelled");
	}
}

	function openWin(href, height, width) {
		var newwin = window.open(href, 'newwin', 'height=' + height + 'px,width=' + width + 'px;');
		newwin.focus();
	}
	
	function openScrollWin(href, height, width) {
		var newwin = window.open(href, 'newwin', 'height=' + height + 'px,width=' + width + 'px,scrollbars,resizable');
		newwin.focus();
	}
	
	
	function openRelatedBrowser(href) {
		var newwin = window.open(href, 'newwin<%=replace(replace(formatdatetime(now(),3),":","")," ","")%>', 'height=500px,width=600px,scrollbars,resizable,toolbar,statusbar');
		newwin.focus();
	}

	
	function clearList(list) 
    {
    var i = 0;
    var o = list.options;

    for (i = o.length; i >= 0; --i)
		o[i] = null;
    list.disabled = true;
    }


function addElement(list, text_in, value_in)
    {
	list = eval(list)
    var o = list.options;
    var nIdx;
	if (o.length < 0) //IE for Mac 4.5 sets length to -1 if list is empty
		nIdx = 0;
	else
		nIdx = o.length;
		
	o[nIdx] = new Option(text_in, value_in);
	list.disabled = false;
    }


function setDefaultByText(list, text_in)
    {
    with (list)
        {
        for (var i = 0; i < (options.length); i++)
             {
             if (options[i].text == text_in)
                 {
                 selectedIndex = i;
                 return;
                 }
             }
        }
    }


function setDefaultByValue(list, value_in)
    {
    with (list)
        {
        for (var i = 0; i < (options.length); i++)
             {
             if (options[i].value == value_in)
                 {
                 selectedIndex = i;
                 return;
                 }
             }
        }
    }


function openChromelessWin(theURL, title, H, W) {
	//theURL="test.html"
	wname ="CHROMELESSWIN"
	//W=400;
	//H=200;
	windowCERRARa 		= "/img/close_a.gif"
	windowCERRARd 		= "/img/close_d.gif"
	windowCERRARo 		= "/img/close_o.gif"
	windowNONEgrf 		= "/img/none.gif"
	windowCLOCK		= "/img/clock.gif"
	windowREALtit		= "  Task title"
	//windowTIT 	    	= "<font face=verdana size=1>  Window title</font>"
	windowTIT 	    	= "<font face=verdana size=1>  " + title + "</font>"
	windowBORDERCOLOR   	= "#000000"
	windowBORDERCOLORsel	= "#999999"
	windowTITBGCOLOR    	= "#999999"
	windowTITBGCOLORsel 	= "#333333"
	openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit , windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel)
}

function maximize(val)
{
	document.getElementById(val).style.height=200;
	document.getElementById(val).style.width=400;
}
function minimize(val)
{
	document.getElementById(val).style.height=null;
	document.getElementById(val).style.width=null;
}

