﻿
function openZoom(page, options, windowName)
{
  if (windowName == null) windowName = 'zoom';
  
	if (options == null) options = "";
	    window.open('../Popup/' + page + options, windowName, 'scrollbars=yes,resizable=yes,height=650').focus();
}
function openZoom1(page, options, windowName)
{
  if (windowName == null) windowName = 'zoom';
  
	if (options == null) options = "";
	    window.open('Popup/' + page + options, windowName,'scrollbars=yes,resizable=yes,height=650').focus();
}

/* CRM Functions */
function onRecordSelect(arrSelectedRecord){
   form1.submit();
}

function openCRMZoom(page, options, resizable) 
{
  var resizeString = ',resizable=yes';
  if ((resizable != null) && (!resizable))
    resizeString = ',resizable=no'
  
	if (options == null) options = "";
	    window.open('../../Popup/' + page + options,'zoom','scrollbars=yes,width=800,height=650' + resizeString).focus();
}

function openCRMProviderProductsZoom(page, options, resizable) 
{
  //debugger;
  var resizeString = ',resizable=yes';
  if ((resizable != null) && (!resizable))
    resizeString = ',resizable=no'
  
	if (options == null) options = "";
	    window.open('../Datatables/' + page + options,'zoom','scrollbars=no,width=810,height=750' + resizeString).focus();
}  

function openCRMSrchProviderProductsZoom(page, options, resizable) 
{
  //debugger;
  var resizeString = ',resizable=yes';
  if ((resizable != null) && (!resizable))
    resizeString = ',resizable=no'
  
	if (options == null) options = "";
	    window.open('../Datatables/' + page + options,'zoom','scrollbars=yes,width=810,height=700' + resizeString).focus();
}  

function openCRMZoomDim(page, options, resizable) 
{
  var resizeString = ',resizable=yes';
  if ((resizable != null) && (!resizable))
    resizeString = ',resizable=no'
  
	if (options == null) options = "";
	    window.open('../../Popup/' + page + options,'zoom','scrollbars=yes,width=800,height=500' + resizeString).focus();
} 

function openCaseManagerZoom(page, options, resizable) 
{ 
  var resizeString = ',resizable=yes';
  if ((resizable != null) && (!resizable))
    resizeString = ',resizable=no'
  
	if (options == null) options = "";
	    window.open('../../CaseManager/' + page + options,'zoom','scrollbars=yes,width=1000,height=750' + resizeString).focus();
} 


function openCRMZoomCase(page, options, resizable) 
{

  var resizeString = ',resizable=yes';
  if ((resizable != null) && (!resizable))
    resizeString = ',resizable=no'
  
	if (options == null) options = "";
	    window.open('../Popup/' + page + options,'zoom1','scrollbars=yes,width=800,height=500' + resizeString).focus();
} 

function openCRMZoomCampaign(page, options, resizable) 
{

  var resizeString = ',resizable=yes';
  if ((resizable != null) && (!resizable))
    resizeString = ',resizable=no'
  
	if (options == null) options = "";
	    window.open( page + options,'zoom1','scrollbars=yes,width=800,height=500' + resizeString).focus();
} 

function openCRMZoomLetters(page, options, resizable) 
{
  var resizeString = ',resizable=yes';
  if ((resizable != null) && (!resizable))
    resizeString = ',resizable=no'
  
	if (options == null) options = "";
	    window.open('../Popup/' + page + options,'zoom','scrollbars=yes,width=640,height=650' + resizeString).focus();
} 

function openCRMZoomMessages(page, options, resizable) 
{
  var resizeString = ',resizable=yes';
  if ((resizable != null) && (!resizable))
    resizeString = ',resizable=no'
  
	if (options == null) options = "";
	    window.open('../../Datatables/' + page + options,'zoom1','scrollbars=yes,width=680,height=650' + resizeString).focus();
} 



function openCRMZoom2(page, options, resizable) 
{
  var resizeString = ',resizable=yes';
  if ((resizable != null) && (!resizable))
    resizeString = ',resizable=no'
  
	if (options == null) options = "";
	    window.open('../Popup/' + page + options,'zoom','scrollbars=yes,width=640,height=650' + resizeString).focus();
}

function openCRMZoom1(page, options, resizable)  
{
  var resizeString = ',resizable=yes';
  if ((resizable != null) && (!resizable))
    resizeString = ',resizable=no'
    
	if (options == null) options = "";
	    window.open('../../Popup/' + page + options,'zoom','scrollbars=yes, width=850,height=700' + resizeString).focus();
}

function openPopupCRMZoom(page, options)
{
	if (options == null) options = "";
	    window.open(page + options,'zoom','scrollbars=yes,resizable=yes,width=640,height=650').focus();
}
function openPopupCRMBankBranchesZoom(page, options)
{
	if (options == null) options = "";
	    window.open(page + options,'zoom','scrollbars=yes,resizable=yes,width=880,height=500').focus();
}
/*End CRM functions*/

function SetFocus(controlName)
{
	var ctrl = document.getElementById(controlName);
	if (ctrl != null) 
		if (ctrl.disabled == false)
			ctrl.focus();
}

function FindPosition(obj)
{
	var curleft = 0;
	var curtop = 0;
	
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else 
	{
		if (obj.x) curleft += obj.x;
		if (obj.y) curtop += obj.y;
	}
	
	var r = { x: curleft, y: curtop };
	return r;
}

function GetValue(controlId)
{
	var control = document.getElementById(controlId)
	
	if (control != null)
		return control.value;
	else
		return '';
}

function ClearControl(controlId)
{
	var control = document.getElementById(controlId)
	
	if (control != null)
	{
		control.value = '';
	}
}

function ClearControls(controlId1, controlId2)
{
	ClearControl(controlId1);
	ClearControl(controlId2);
}

function ClearControls(controlId1, controlId2, controlId3)
{
	ClearControl(controlId1);
	ClearControl(controlId2);
	ClearControl(controlId3);
}

function ClearControls(controlId1, controlId2, controlId3, controlId4)
{
	ClearControl(controlId1);
	ClearControl(controlId2);
	ClearControl(controlId3);
	ClearControl(controlId4);
}

function ClearControls(controlId1, controlId2, controlId3, controlId4, controlId5)
{
	ClearControl(controlId1);
	ClearControl(controlId2);
	ClearControl(controlId3);
	ClearControl(controlId4);
	ClearControl(controlId5);
}

function PostBackHiddenControl(controlId)
{
	var control = document.getElementById(controlId)
	
	if (control != null)
	{
		control.value = (new Date()).toString();
		__doPostBack(controlId,'');
	}
}


function RicercaOnEnter(e, controlToClick)
{
	if (controlToClick != null)
	{
		if (!e) var e = window.event;
		var keyCode = (e.which) ? e.which : e.keyCode;
		
		if (keyCode == 13)
		{
			var ricercaControl = document.getElementById(controlToClick);
			//if (ricercaControl != null) ricercaControl.click();
			if (ricercaControl != null) __doPostBack(controlToClick,'');
		}
	}
}
function MoveCopyright()
{
	//debugger;
	div = document.getElementById('divCopy'); 
	if (div != null) div.style.left = document.body.offsetWidth - 230;
	
	div = document.getElementById('divMainMenu');
	hid = document.getElementById('MainMenu1_txtMainMenuHeight');
	if ((div != null) && (hid != null)) 
	{
		if (showSAIWebModules)
			div.style.top = document.body.offsetHeight + document.body.scrollTop - parseInt(hid.value) - 12;
		else
			div.style.left = -500;
	}
}
function ChangeWidthFromScreenSize(controlName, size)
{
    var divControl = document.getElementById(controlName);
    
    if (divControl != null)
        divControl.style.width = document.body.offsetWidth - size;
}

function SetBgColor(obj){
obj.style.backgroundColor = '#FFEC65';
}
//function SetBgColor(obj, strColor){
//obj.style.backgroundColor = strColor;
//}

function RemoveBgColor(obj){
obj.style.backgroundColor = '';
}

function VerifyMonths(varMonths)
 {
 var months = document.getElementById(varMonths);
 if (months != null)
  {
    if (months.value>11)
    {
    ClearControl(varMonths);
    }
  }
 }
 
 function VerifyDays(varDays)
 {

 var days = document.getElementById(varDays);
 if (days != null)
  {
    if (days.value>31)
    {
        ClearControl(varDays);
    }
  }
 }