
// function to prevent right click

function clickIE4()
{
	if (event.button==2) {
		return false;
	}
}
function PreventRightClick() {

	if (document.all&&!document.getElementById){
		document.onmousedown=clickIE4;
	}

	document.oncontextmenu=new Function("return false;")
}

try {
	if (!window.parent.header.ProjectData.DebugMode) {
		PreventRightClick();
	}
}
catch (e) {
	PreventRightClick();	
}

function DecreaseTDBGRidSize(tDBGridId) {
	var myGrid = document.getElementById(tDBGridId);
	var height = parseInt(myGrid.height,10)	
	if (height > 200)
		myGrid.height = height - 100;
	else
	if (height > 120)
		myGrid.height = 100;
			
}

function IncreaseTDBGRidSize(tDBGridId) {
	var myGrid = document.getElementById(tDBGridId);
	var height = parseInt(myGrid.height,10)
	
	myGrid.height = height + 100;
}

function DecreaseTDBGRidSize2(tDBGridId, secondtDBGridId) {
	var myGrid = document.getElementById(tDBGridId);
	var myGrid2 = document.getElementById(secondtDBGridId);
	var height = parseInt(myGrid.height,10)	
	if (height > 200) {
		myGrid.height = height - 100;
		myGrid2.height = height - 100;
	}
	else {
		if (height > 120) {
			myGrid.height = 100;
			myGrid2.height = 100;
		}
	}
}

function IncreaseTDBGRidSize2(tDBGridId, secondtDBGridId) {
	var myGrid = document.getElementById(tDBGridId);
	var myGrid2 = document.getElementById(secondtDBGridId);
	var heigth = parseInt(myGrid.height,10)
	
	myGrid.height = heigth + 100;
	myGrid2.height = heigth + 100;
}

var ProjetDataAvailable = true;


function CheckProjectDataAvailable() {

	try
	{
		var agent = navigator.userAgent.toLowerCase(); 
		ProjetDataAvailable = true;
		
		if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
		document.write('<scr' + 'ipt language="VBScript"> \n');
		document.write('on error resume next \n');
		document.write('dim projectData \n');
		document.write('set projectData = CreateObject("ProjectData.ProjectDataCtrl2.1") \n');
		document.write('If IsObject(projectData) Then \n');
		document.write('    ProjetDataAvailable = True \n');
		document.write('Else \n');      
		document.write('    ProjetDataAvailable = False \n');
		document.write('    Alert("ProCG works as an ActiveX in your browser, It can not load - Please check that you run the setup program and that the browser security allows to run ActiveX!!") \n');
		document.write('End If \n');
		document.write('</scr' + 'ipt> \n');
		}
		else {
			alert("ProCG works as an ActiveX in your browser and your browser does not support ActiveX - Please try with Internet Explorer 4.0 and up!!")		
			ProjetDataAvailable = false;
		}
	}
	catch(exception)
	{
		alert("ProCG works as an ActiveX in your browser and your browser does not support ActiveX - Please try with Internet Explorer 4.0 and up!!")		
		ProjetDataAvailable = false;
	}
	return (ProjetDataAvailable);
}  
  
function CheckBrowser() {
	
	var browserIsOK = true;
	var agent = navigator.userAgent.toLowerCase(); 
	
	if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	}
	else {
	  alert("ProCG works as an ActiveX in your browser and your browser does not support ActiveX - Please try with Internet Explorer 4.0 and up!!");		
	  browserIsOK = false;
	}
	return (browserIsOK);
}  

function Register()
{
	// the check is done in Registration.asp
	document.location = "../procgapp/Registration.asp"
}
 
function Login()
{
	LoginTo("../procgapp/Index.asp");
}

function RegisterFromRoot()
{
	// the check is done in Registration.asp
	document.location = "procgapp/Registration.asp"
}
 
function LoginFromRoot()
{
	LoginTo("procgapp/Index.asp");
}

function LoginTo(url)
{
	var originLocation = document.location;
	var projectDataAvailable = CheckProjectDataAvailable();
	if (projectDataAvailable) {
		var indexWindow;
		indexWindow = window.open( url , "ProCG2" , "resizable=yes,titlebar=no,location=no,toolbar=no,menubar=no,status=yes")
		if (indexWindow == null) {
			alert("Can not open ProCG Application main window - Please check if it blocked");
		}
		else
		{
			document.location = originLocation;
		}
	}	

}