﻿function rollover(obj) 
{
	obj.src = Left(obj.src, obj.src.length-5) + '1.gif';
}


function rollout(obj) 
{
	obj.src = Left(obj.src, obj.src.length-5) + '0.gif';
}

function Left(str, n)
{
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else
		return String(str).substring(0,n);
}

function Right(str, n)
{
	if (n <= 0)
	return "";
	else if (n > String(str).length)
	return str;
	else {
	var iLen = String(str).length;
	return String(str).substring(iLen, iLen - n);
	}
}

function DisableTextBoxTextArea()
{
	try
	{
		var a = document.getElementById('ctl00_ContentPlaceHolder1_DDValue1');
		var b = document.getElementById('ctl00_ContentPlaceHolder1_txtValue1');
		var c = document.getElementById('ctl00_ContentPlaceHolder1_txtValue1_Obs');

		if(a.value==3)
		{
			b.readOnly	=	true;
			b.className	=	"Box_Disabled";
			b.value		=	"";
			c.readOnly	=	true;
			c.className	=	"Box_Disabled";
			
		}
		else
		{
			b.readOnly	=	false;
			b.className	=	"Box_Number";
			c.readOnly	=	false;
			c.className	=	"textbox";
		}
	}
	catch(e){}
}

function DisableTextBoxOnly()
{
	try
	{
		var a = document.getElementById('ctl00_ContentPlaceHolder1_DDValue2');
		var b = document.getElementById('ctl00_ContentPlaceHolder1_txtValue2');

		if(a.value==3)
		{
			b.readOnly	=	true;
			b.className	=	"Box_Disabled";
			b.value		=	"";
			
		}
		else
		{
			b.readOnly	=	false;
			b.className	=	"Box_Number";
		}
	}
	catch(e){}
}

function ConfigAll(){
		for (x=1;x<20;x++)
		{
			try
			{
				var a = document.getElementById('ctl00_ContentPlaceHolder1_cmbValue' + x + 'Type');
				var b = document.getElementById('ctl00_ContentPlaceHolder1_txtValue' + x);
				var c = document.getElementById('ctl00_ContentPlaceHolder1_Value' + x + '_Obs');

				if(a.value>2)
				{
					b.readOnly	=	true;
					b.className	=	"Box_Disabled";
					b.value		=	"";
					
					c.readOnly	=	true;
					c.className	=	"Box_Disabled";
					c.value		=	"";
					
				}
				else
				{
					b.readOnly	=	false;
					b.className	=	"Box_Number";
					
					c.readOnly	=	false;
					c.className	=	"textbox";
				}
				
			}
			catch(e){}
		}
}

function ConfigAllDropDownList(from,to){
		for (x=from;x<=to;x++)
		{
			try
			{
				var a = document.getElementById('ctl00_ContentPlaceHolder1_DDValue' + x);
				var b = document.getElementById('ctl00_ContentPlaceHolder1_txtValue' + x);
				var c = document.getElementById('ctl00_ContentPlaceHolder1_Value' + x + '_Obs');

				if(a.value>2)
				{
					b.readOnly	=	true;
					b.className	=	"Box_Disabled";
					b.value		=	"";
					
					c.readOnly	=	true;
					c.className	=	"Box_Disabled";
					c.value		=	"";
					
				}
				else
				{
					b.readOnly	=	false;
					b.className	=	"Box_Number";
					
					c.readOnly	=	false;
					c.className	=	"textbox";
				}
				
			}
			catch(e){}
		}
}

function ConfigAllDropDownListYesNo(from,to){
	for (x=from;x<=to;x++)
	{
        enableAP(x);
	}
}


function enableAP(id)
{
	a = document.getElementById('ctl00_ContentPlaceHolder1_DDValue' + id);
	try
	{
		b = document.getElementById('ctl00_ContentPlaceHolder1_txtValue' + id + '_Km');
		
		if(a.value==1){
			b.readOnly	=	false;
			b.className	=	"textbox";
		}
		else{
			b.readOnly	=	true;
			b.className	=	"Box_Disabled";
			b.value		=	"";
		}
	}
	catch(e){}
	try
	{
		c =document.getElementById('ctl00_ContentPlaceHolder1_txtValue' + id + '_Obs'); 
		
		if(a.value==1){
			c.readOnly	=	false;
			c.className	=	"textbox";
		}
		else{
			c.readOnly	=	true;
			c.className	=	"Box_Disabled";
			c.value		=	"";
		}
	}
	catch(e){}
}
function ShowWindowNonConform(contx)
{
	try
	{
	    var urlstring = '/EMS/Forms/ModalNotConf.aspx?contx=' + contx;
		var resultado = window.showModalDialog(urlstring, '','dialogWidth:650px;dialogHeight:650px;help:no;status:no');	
	}
	catch(e){}	
}


function ShowWindowEMS_GRL_047_A_PopUp1(contx)
{
	try
	{
	    var urlstring = '/EMS/Forms/General/EMS_GRL_047_A_PopUp1.aspx?contx=' + contx;
		var resultado = window.showModalDialog(urlstring, '','dialogWidth:650px;dialogHeight:370px;help:no;status:no');	
	}
	catch(e){}	
}

function ShowWindowEMS_GRL_047_A_PopUp2(contx)
{
	try
	{
	    var urlstring = '/EMS/Forms/General/EMS_GRL_047_A_PopUp2.aspx?contx=' + contx;
		var resultado = window.showModalDialog(urlstring, '','dialogWidth:650px;dialogHeight:470px;help:no;status:no');	
	}
	catch(e){}	
}

function ShowWindow(urlpage)
{
	newWin = window.open(urlpage, 'newwindow', config='height=540, width=720, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, directories=no, status=no');
	
	newWin.focus();	
}
function ShowWindowMarketing(urlpage)
{
	newWin = window.open(urlpage, 'newwindow', config='height=540, width=800, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, directories=no, status=no');
	
	newWin.focus();	
}
function ShowWindowUser(urlpage)
{
	newWin = window.open(urlpage, 'newwindow', 'height=600, width=720, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, directories=no, status=no');
	newWin.focus();	

}

function ShowWindowRedefineUser(cntx)
{
	try
	{
	    var urlstring = '/Administration/Users/RedefineQuestion.aspx?cntx=' + cntx;
		var resultado = window.showModalDialog(urlstring, '','dialogWidth:430px;dialogHeight:220px;help:no;status:no');	
	}
	catch(e){}	
}

function DropDownListChangeWithTextBox(id)
{
	a = document.getElementById('ctl00_ContentPlaceHolder1_DDValue'+id);
	
	try
	{
		b = document.getElementById('ctl00_ContentPlaceHolder1_txtValue' + id);
		
		if(a.value>2){
			b.readOnly	=	true;
			b.className	=	"Box_Disabled";
			b.value		=	"";
			
		}
		else
		{
			b.readOnly	=	false;
			b.className	=	"box_number";
			b.value		=	"";
			
		}
	}
	catch(e){}
}

function DropDownChangeWithTextBox(id)
{
	a = document.getElementById('ctl00_ContentPlaceHolder1_cmbValue'+id+'Type');
	var cmbType6 = document.getElementById('ctl00_ContentPlaceHolder1_cmbValue6Type');
	try
	{
		if(id!=6)
		{
			b = document.getElementById('ctl00_ContentPlaceHolder1_txtValue' + id);
			
			if(a.value>2){
				b.readOnly	=	true;
				b.className	=	"Box_Disabled";
				b.style.textAlign = "right";
                b.value = "";
			}
			else
			{
				b.readOnly	=	false;
				b.className	=	"box_number";
				b.value		=	"";
				
			}
			
			if(id < 5 || id > 6)
			{
			    if(a.value==3)
			    {
			        cmbType6.value = 3;
			    }
			    else
			    {
                    Disabled6	=	0;			
				    try
                    {
				        for (x=1;x<5;x++)
				        {
						        a = document.getElementById('ctl00_ContentPlaceHolder1_cmbValue' + x + 'Type');
						        if(a.value==3)
						        {
							        Disabled6	=	1;
						        }
				        }
        				
				        var cmbval7 = document.getElementById('ctl00_ContentPlaceHolder1_cmbValue7Type');
				        if(cmbval7.value == 3)
				        {
				            Disabled6 = 1;
				        }
				    }
                    catch(e){}
                    
                    if(Disabled6)
                        cmbType6.value = 3;
                    else
                        cmbType6.value = 1;
			    }
			}
			
		}
	}
	catch(e){}
}


//EMS_GRL_046_A -- INICIO

function disable2RENDNA(id)
{
	a = document.getElementById('ctl00_ContentPlaceHolder1_value'+ id+'_Type');
	try
	{
		b = document.getElementById('ctl00_ContentPlaceHolder1_value' + id);
		
		if((a.value==3)||(a.value==4)){
			b.readOnly	=	true;
			b.className	=	"Box_Disabled";
			b.value		=	"";
		}
		else{
			b.readOnly	=	false;
			b.className	=	"box_number";
			b.value		=	"";
		}
	}
	catch(e){}
	try
	{
		c = document.getElementById('ctl00_ContentPlaceHolder1_value' + id + '_Obs');
		
		if((a.value==1)||(a.value==3)||(a.value==4)){
			c.readOnly	=	true;
			c.className	=	"Box_Disabled";
			c.value		=	"";
		}
		if(a.value==2){
			c.readOnly	=	false;
			c.className	=	"textbox";
			c.value		=	"";
		}
		
	}
	catch(e){}
}

function disable_1_PT_046_A(id)
{
	a = document.getElementById('ctl00_ContentPlaceHolder1_value'+ id+'_Type');
	try
	{
		b = document.getElementById('ctl00_ContentPlaceHolder1_value' + id);
		
		if((a.value==3)||(a.value==4)){
			b.readOnly	=	true;
			b.className	=	"Box_Disabled";
			b.value		=	"";
		}
		else{
			b.readOnly	=	false;
			b.className	=	"box_number";
			b.value		=	"";
		}
	}
	catch(e){}
	try
	{
		c = document.getElementById('ctl00_ContentPlaceHolder1_value' + id + '_Obs');
		
		if((a.value==3)||(a.value==4)){
			c.readOnly	=	true;
			c.className	=	"Box_Disabled";
			c.value		=	"";
		}
		if((a.value==2)||(a.value==1)){
			c.readOnly	=	false;
			c.className	=	"textbox";
			c.value		=	"";
		}
		
	}
	catch(e){}
}

function disable_1_PT_047_A(id)
{
	a = document.getElementById('ctl00_ContentPlaceHolder1_DDValue'+ id);
	try
	{
		b = document.getElementById('ctl00_ContentPlaceHolder1_txtValue' + id);
		c = document.getElementById('ctl00_ContentPlaceHolder1_txtValue' + id + '_Obs');
		
		if((a.value==3)||(a.value==4)){
			b.readOnly	=	true;
			b.className	=	"Box_Disabled";
			b.value		=	"";
			
			c.readOnly	=	true;
			c.className	=	"Box_Disabled";
			c.value		=	"";
			
		}
		else
		{
			b.readOnly	=	false;
			b.className	=	"box_number";
			b.value		=	"";
			
			c.readOnly	=	false;
			c.className	=	"textbox";
			c.value		=	"";
		}
	}
	catch(e){}
	
}

//EMS_GRL_046_A -- FIM

//EMS_GRL_043_B -- INICIO

function ManageCombo(ref)
{

	dd2 = document.getElementById('ctl00_ContentPlaceHolder1_DDValue' + ref + '2');
	dd3 = document.getElementById('ctl00_ContentPlaceHolder1_DDValue' + ref + '3');
	
	if(dd2.value==1)
	{
		dd3.disabled		=	true;
		dd3.className	=	"Box_Disabled";
	}
	else
	{
		dd3.disabled	=	false;
		dd3.className	=	"textbox";
	}
}

//EMS_GRL_043_B -- FIM

//PROJECT TEAMS

function projectteamspopup(parameters)
{
    var Link = '/ESRDV3/ManageProjectTeams/ProjectTeamsAssignment/AssignProjectTeamsPopUp.aspx?cntx='+parameters;

    var mywindow; 
    var winprops;
    var winl = (screen.width - 570) / 2;
    var wint = (screen.height - 200) / 2;
    winprops = 'height=200,width=570,top='+wint+',left='+winl+'resizable=0,scrollbars=1';
    mywindow = window.open(Link, "", winprops);
} 

function downloadstandardspopup(parameters)
{
    var Link = '/ESRDV2/DownloadStandardPDF.aspx?cntx='+parameters;

    var mywindow; 
    var winprops;
    var winl = (screen.width - 417) / 2;
    var wint = (screen.height - 200) / 2;
    winprops = 'height=200,width=417,top='+wint+',left='+winl+'resizable=0,scrollbars=1';
    mywindow = window.open(Link, "", winprops);
} 

function ShowHistoryWindow(url,cntx)
{
	try
	{
	    var winl = (screen.width - 720) / 2;
        var wint = (screen.height - 540) / 2;
	    var urlstring = '/EMS/FormsHistory/'+url+'?cntx=' + cntx;
	    var opstring = 'dialogWidth:720px;dialogHeight:540px;dialogLeft:'+winl+'px;dialogTop:'+wint+'px;help:no;status:no';
		var resultado = window.showModalDialog(urlstring, '',opstring);	
	}
	catch(e){}	
}

function GenerateLinkPopUp()
{
    var Link = '/ESRDV3/ManageStandards/CreateFileLinkPopUp.aspx';
    var mywindow; 
    var winprops;
    var winl = (screen.width - 500) / 2;
    var wint = (screen.height - 350) / 2;
    winprops = 'height=350,width=500,top='+wint+',left='+winl+'resizable=0,scrollbars=1';
    mywindow = window.open(Link, "", winprops);
} 


function StandardPreviewPopUp(parameters)
{
    //var Link = '/ESRDV3/ManageStandards/StandardPreviewPopUp.aspx?cntx='+parameters;
    //var mywindow; 
    //var winprops;
    //var winl = (screen.width - 675) / 2;
    //var wint = (screen.height - 700) / 2;
    //winprops = 'height=700,width=675,top='+wint+',left='+winl+'resizable=0,scrollbars=1';
    //winprops = 'height=700,width=675,top='+wint+',left='+winl+',resizable=0,scrollbars=1';
    //winprops = 'height=700,width=675px,left='+winl+'resizable=0,scrollbars=1';
    //mywindow = window.open(Link, "", winprops);
    
    var Link = '/ESRDV3/ManageStandards/StandardPreviewPopUp.aspx?cntx='+parameters;
    var mywindow = window.showModalDialog(Link, '','dialogWidth:675px;dialogHeight:700px;help:no;status:no');

} 

function GeneratePDFPopUp(parameters)
{
    var Link = '/ESRDV3/Standards/PrintPDFPopUp.aspx?cntx='+parameters;
    var mywindow; 
    var winprops;
    var winl = (screen.width - 450) / 2;
    var wint = (screen.height - 180) / 2;
    winprops = 'height=180,width=450,top='+wint+',left='+winl+'resizable=0,scrollbars=1';
    mywindow = window.open(Link, "", winprops);
} 

function StandardRevisionsPopUp(parameters)
{
    var Link = '/ESRDV3/ManageStandards/StandardRevisionsPopUp.aspx?cntx='+parameters;

    var mywindow; 
    var winprops;
    var winl = (screen.width - 570) / 2;
    var wint = (screen.height - 200) / 2;
    winprops = 'height=200,width=570,top='+wint+',left='+winl+'resizable=0,scrollbars=1';
    mywindow = window.open(Link, "", winprops);
} 

function ShowWindowNCFieldI(parameters,btnName)
{
	try
	{
	    var urlstring = '/EMS/Forms/General/NC_PopUps/NC_FieldI.aspx?cntx='+parameters;
		var resultado = window.showModalDialog(urlstring, '','dialogWidth:660px;dialogHeight:360px;help:no;status:no');
		__doPostBack(btnName,'');
	}
	catch(e){}	
}


function ShowWindowNCFieldII(parameters,btnName)
{
	try
	{
	    var urlstring = '/EMS/Forms/General/NC_PopUps/NC_FieldII.aspx?cntx='+parameters;
		var resultado = window.showModalDialog(urlstring, '','dialogWidth:660px;dialogHeight:550px;help:no;status:no');	
		__doPostBack(btnName,'');
	}
	catch(e){}	
}

function ShowWindowNCFieldIII(parameters,btnName)
{
	try
	{
	    var urlstring = '/EMS/Forms/General/NC_PopUps/NC_FieldIII.aspx?cntx='+parameters;
		var resultado = window.showModalDialog(urlstring, '','dialogWidth:660px;dialogHeight:645px;help:no;status:no');	
		__doPostBack(btnName,'');
	}
	catch(e){}	
}

function ShowWindowNCDetails(parameters)
{
	try
	{
	    var urlstring = '/EMS/Forms/General/NC_PopUps/NC_Details.aspx?cntx='+parameters;
		var resultado = window.showModalDialog(urlstring, '','scroll:yes;dialogWidth:730px;dialogHeight:545px;help:no;status:no');	
	}
	catch(e){}	
}

function ShowWindowCanceledComments(parameters)
{
	try
	{
	    var urlstring = '/EMS/Forms/General/NC_PopUps/CanceledComments.aspx?cntx='+parameters;
		var resultado = window.showModalDialog(urlstring, '','scroll:yes;dialogWidth:660px;dialogHeight:250px;help:no;status:no');	
	}
	catch(e){}	
}

function EditColor(id,status)
{
    dd2 = document.getElementById('ctl00_ContentPlaceHolder1_' + id);
  
   if(status==0)
   {
        dd2.style.backgroundColor  = '#fefefe';
        dd2.style.color  = 'black';
   }
   else
   {
        dd2.style.backgroundColor  = '#fafafa';
        dd2.style.color  = 'gray';
   }
}

function ShowStandardPopUp(parameters)
{
	try
	{
	    var urlstring = '/ESRDV3/Standards/StandardPopUp.aspx?cntx='+parameters;
		var resultado = window.showModalDialog(urlstring, '','dialogWidth:675px;dialogHeight:700px;help:no;status:no');
	}
	catch(e){}	
}