var win=null;
function NewWindow(sURL,sName,sSize,sMode,sAppendWebsiteKey)
{

	// default to large
	var w=750;
	var h=500;
	var winName='';

	if(sSize.toLowerCase()=='current' || sSize.toLowerCase()=='c'){w=window.document.body.offsetWidth-20;h=window.document.body.offsetHeight-20;mw=800;mh=600};
	if(sSize.toLowerCase()=='full' || sSize.toLowerCase()=='f'){w=900;h=600;mw=800;mh=600};
	if(sSize=='' || sSize.toLowerCase()=='large' || sSize.toLowerCase()=='l'){w=750;h=500;mw=750;mh=500};
	if(sSize.toLowerCase()=='medium' || sSize.toLowerCase()=='m'){w=650;h=400;mw=650;mh=400};
	if(sSize.toLowerCase()=='small' || sSize.toLowerCase()=='s'){w=400;h=200;;mw=400;mh=200};
	if(sSize.toLowerCase()=='help' || sSize.toLowerCase()=='h'){w=650;h=400;mw=650;mh=400};
	if(sSize.toLowerCase()=='print' || sSize.toLowerCase()=='p'){w=750;h=500;mw=750;mh=500};
	if(sSize.toLowerCase()=='flowchart' || sSize.toLowerCase()=='l'){w=790;h=515;mw=790;mh=515};	

    if ((sAppendWebsiteKey == null || sAppendWebsiteKey) && (typeof gWebsiteKey != 'undefined' && gWebsiteKey != 'null' && sURL.indexOf('&WebsiteKey=') < 0))
        sURL += '&WebsiteKey=' + gWebsiteKey;

	if (sName.indexOf("-") >= 1)
	{
		winName = sName.substr(0,9);
	}
	else
	{
		winName = sName;
    }

    //function ShowDialog_NoReturnValue(url, args, width, height, title, iconUrl, templateType, callBackFunction, windowName, closeWindowOnCommit, preserveStatefulBusinessContainer, dialogCloseFunction, sourceObject)
    ShowDialog_NoReturnValue(sURL, null, w, h, sName, null, 'D', null, winName, false, false, null, null);
}

function RefreshBySubmit()
{
	if(gPostBackFormObject != null)
	{
		gPostBackFormObject.submit();
	}
	else
	{
		if (document.forms.length > 0) 
		{
			document.forms[0].submit();
		}
		else
		{
			window.location.href = window.location.href;
		}
	}
}

function SetDefaultStyle(item)
{
	if (item.className != 'VTabSelectedStyle')
		item.className='VTabDefaultStyle';
}

function SetHoverStyle(item)
{
	if (item.className != 'VTabSelectedStyle')
		item.className='VTabHoverStyle';
}

function UpdateFormInputAndSubmit(name, val) 
{
	var docForms = document.forms;
	if (docFormsLen > 0) 
	{
		for (var i = 0, ic = docForms.length; i < ic; i++) 
		{
			if (docForms[i].elements[name] != null) 
			{
				docForms[i].elements[name].value = val;
				docForms[i].submit();
				break;
			}		
		}
	}
}

function toggleElement(targetId, controlImage)
{
	target = document.getElementById(targetId);
	switch (target.style.display)
	{
		case ("block") :
			target.style.display = "none";
			controlImage.src = gWebRoot + "/AsiCommon/Images/+.gif";
			break;
		default :
			target.style.display = "block";
			controlImage.src = gWebRoot + "/AsiCommon/Images/-.gif";
			break;
	}
}

//Append a fields value into another field
function fieldAppend(selectfield,fieldId)
{
	var selval = selectfield.options[selectfield.selectedIndex].value;
	var output = document.getElementById(fieldId);
	output.count = (typeof output.count == 'undefined') ? 1 : ++output.count;
	output.value += selval + ' \n';
}
