function changeContext(url){
	window.top.contextFrame.treeFrame.location.href = url;
}

function changeMain(url){
	window.top.mainFrame.location.href = url;
}

function resize(){
		h = document.body.scrollHeight; 
        try{
            window.parent.document.getElementById('TransparentFrame').height = h;
        }
        catch(err){}
}

function updateTitle(){
	var currentNode = webFXTreeHandler.selected;
	var isRoot      = currentNode.parentNode == null;
	var strTitle    = currentNode.text;	
	while(!isRoot){
		currentNode = currentNode.parentNode;
		strTitle    = currentNode.text + "/ " + strTitle;
		isRoot      = currentNode.parentNode == null;
	}
	window.top.frames.topFrame.context = strTitle;
	window.top.frames.topFrame.redrawTitle();
}
function ShowPopUp(Url, name, width, height){
	window.open(Url,name,'width=' + width + ',height=' + height + ',left=' + ((screen.availWidth-width)/2) + ',top=' + ((screen.availHeight-height)/2) + ',menu=no,status=no');
}

function OpenHelpWin(URL,width,height) {
	window.open(URL,'AZT_Help','width=' + width + ',height=' + height + ',left=' + ((screen.availWidth-width)/2) + ',top=' + ((screen.availHeight-height)/2) + ',menu=no,status=no');
}

function ConfirmDialog(msg) {
	return window.showModalDialog('/Gateway/Templates/Dialogs/ConfirmDialog.aspx',msg,'dialogWidth:400px;dialogHeight:150px;status:no;help:no') == true ? true : false;
}

function ShowDatePicker(arg,window,dFormat,dSeparator,templatePath,scriptPath,cssPath,lang){
	var argument = new Object();
	argument.arg = arg;
	argument._window = window;
	argument.cssPath = cssPath;
	window.showModalDialog((templatePath != null ? templatePath : '') + 'DatePicker.aspx?dFormat=' + dFormat + '&dSeparator=' + dSeparator + '&scriptPath=' + scriptPath + '&lang=' + lang + '&GUID=' + (parseInt(Math.random()*10000000000000000).toString()+parseInt(Math.random()*10000000000000000).toString()),argument,'dialogWidth=205px;dialogHeight=200px;center:Yes;edge:Raised;status:No;help:No;unadorned:yes');
}

function ChangeCursorStatus(){
	document.body.style.cursor = "wait";
}
function DisableControls(){
	nr = document.forms[0].all.length;
	for(i=0;i<nr;i++){
		if(document.forms[0].all(i).tagName == "SELECT" || (document.forms[0].all(i).tagName == "INPUT" && (document.forms[0].all(i).type == "radio" || document.forms[0].all(i).type == "checkbox" || document.forms[0].all(i).type == "button") ))
		document.forms[0].all(i).disabled = true;
	}
}

function OpenReportPage(url)
{
	window.open(url,'Raport','toolbar = no, menubar=no, resizable=no, width=500, height=320,left=' + ((window.screen.availWidth-380)/2) + ',top='+((window.screen.availHeight-280)/2));
}

function OpenReportPage2(url, pageWidth, pageHeight)
{
	window.open(url,'Raport','toolbar = no, menubar=no, resizable=no, width=' + pageWidth + ', height=' + pageHeight + ',left=' + ((window.screen.availWidth-380)/2) + ',top='+((window.screen.availHeight-280)/2));
}

function OpenChangePasswordWindow()
{
	window.open('/Administration/UserManagement/ChangePassword.aspx?isOut=1&lang=Ro','Select','toolbar = no, menubar=no, resizable=no, width=380, height=160,left=' + ((window.screen.availWidth-380)/2) + ',top='+((window.screen.availHeight-132)/2));
}

function OpenChangePasswordEn()
{
	window.open('/Administration/UserManagement/ChangePassword.aspx?isOut=1&Lang=En','Select','toolbar = no, menubar=no, resizable=no, width=380, height=160,left=' + ((window.screen.availWidth-380)/2) + ',top='+((window.screen.availHeight-132)/2));
}

function OpenChangeDefaultAppWindow()
{
	window.open('/Administration/UserManagement/DefaultApplication.aspx?isOut=1','Select','toolbar = no, menubar=no, resizable=no, width=350, height=80, left=' + ((window.screen.availWidth-350)/2) + ', top='+((window.screen.availHeight-100)/2));
}

function OpenAddPartnerWindow(PartnerName1Control,PartnerName2Control,PartnerIDControl)
{
	window.open('/CRM.Web/PartnerDetails.aspx?Action=AddPartner&Mode=popup' + (PartnerName1Control ? '&PartnerName1Control=' + PartnerName1Control : '') + (PartnerName2Control ? '&PartnerName2Control=' + PartnerName2Control : '') + (PartnerIDControl ? '&PartnerIDControl=' + PartnerIDControl : ''),'AddPartner','toolbar = no, menubar=no, resizable=no, width=750, height=480,left=' + ((window.screen.availWidth-750)/2) + ',top='+((window.screen.availHeight-480)/2));
}

function GetQueryString(url,string){
	string = string + "=";
	var returnString = null;
	var index = url.indexOf(string);
	if (index != -1){
		var nextParamIndex = url.indexOf("&",index+3);
		if (nextParamIndex == -1)
			returnString = url.substr(index+3);
		else
			returnString = url.substr(index+3,nextParamIndex-index-3);
	}
	return returnString;
}

function setFocus(controlName){
	_ctrl = getControl(controlName);
	if (_ctrl != null)
		_ctrl.focus();
}

function getControl(controlName){
	for(i = 0; i<document.forms[0].all.length; i++){
		if ( (document.forms[0].all(i).tagName == "SELECT" || document.forms[0].all(i).tagName == "INPUT") && (document.forms[0].all(i).id != null && document.forms[0].all(i).id.indexOf(controlName)!= -1)) {
			return document.forms[0].all(i);
			break;
		}
	}
	return null;
}


function DetectBrowser(){
if(navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled )){
	return "KDE";
}
if(navigator.vendor == 'KDE'){
	return "KDE";
}
if(document.childNodes && !document.all && !navigator.taintEnabled && !accentColorNames){
	return "Safari";
}
if(document.childNodes && !document.all && !navigator.taintEnabled && accentColorName){
	return "OmniWeb 4.5+ ";
}
if(navigator.__ice_version){
	return "ICEbrowser ";
}
if(window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1){
	return "iCab 3-";
}
if(window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 && !document.createElement){
	return "iCab 2- ";
}
if(window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 && document.createElement){
	return "iCab 3";
}
if(navigator.userAgent.toLowerCase().indexOf('hotjava') + 1 && typeof( navigator.accentColorName ) == 'undefined'){
	return "HotJava";
}
if(document.layers && !document.classes){
	return "OmniWeb 4.2-";
}
if(document.layers && document.classes && !navigator.mimeTypes['*']){
	return "Escape 4";
}
if(document.layers && navigator.mimeTypes['*']){
	return "Netscape 4";
}
if(document.all && document.getElementById && navigator.savePreferences){
	return "Escape/Evo 5";
}
if(navigator.userAgent.toLowerCase().indexOf('opera') + 1){
	return "Opera	";
}
if(navigator.userAgent.toLowerCase().indexOf('opera') + 1 && !window.opera){
	return "Opera 4-";
} 
if(window.opera && !window.print){
	return "Opera  5";
}
if(window.opera && window.print && !document.childNodes){
	return "Opera  6";
}
if(window.opera && document.childNodes){
	return "Opera  7+";
}
if(navigator.appName.indexOf('WebTV') + 1){
	return "WebTV";
}
if(navigator.userAgent.toLowerCase().indexOf( 'ipanel' ) + 1){
	return "iPanel MicroBrowser - I'm guessing this one";
}
if(navigator.userAgent.toLowerCase().indexOf( 'netgem' ) + 1){
	return "Netgem NetBox";
}
if(navigator.userAgent.toLowerCase().indexOf( 'opentv' ) + 1){
	return "OpenTV ";
}
if(document.getElementById && !document.childNodes){
	return "Clue Browser ";
}
if(navigator.product == 'Gecko' && !navigator.savePreferences){
	return "Netscape 6+, Mozilla and other Gecko ";
}
if(navigator.product == 'Gecko' && !window.find && !navigator.savePreferences){
	return "Netscape 6, Mozilla 0.9- and reduced Gecko";
}
if(navigator.product == 'Gecko' && window.find && !navigator.savePreferences){
	return "Netscape 7+, Mozilla 1+ and advanced Gecko ";
}
if(document.getElementById && ( ( navigator.userAgent.toLowerCase().indexOf( 'netfront' ) + 1 ) || navigator.appName == 'Blazer' || ( navigator.product == 'Gecko' && navigator.savePreferences ) || ( navigator.appName.indexOf('PSP') + 1 ) || ( navigator.appName.indexOf('PLAYSTATION 3') + 1 ))){
	return "NetFront ";
}
if(document.all){
	return "Internet Explorer ";
}
if(document.all && !document.getElementById){
	return "Internet Explorer 4  ";
}
if(document.getElementById && !document.compatMode){
	return "Internet Explorer 5 ";
}
if(None_of_the_above && document.getElementById && document.compatMode && !window.XMLHttpRequest){
	return "Internet Explorer 6 ";
}
if(document.getElementById && document.compatMode && window.XMLHttpRequest && !document.documentMode){
	return "Internet Explorer 7 ";
}
if(document.getElementById && document.compatMode && window.XMLHttpRequest && document.documentMode){
	return "Internet Explorer 8 ";
}
if(window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf( 'msie' ) + 1){
	return "Pocket Internet Explorer ";
}
return "n/a";
}
