function checkall( checkAllBox )
{
	var frm = document.forms[0] ;
	var actVar = checkAllBox.checked ;
	for(i=0;i< frm.length;i++)
	{
		e=frm.elements[i];
		if ( e.type=='checkbox' && e.name.indexOf("cb_enq") != -1 )
		e.checked= actVar ;
	}
}

var popUp; 
function OpenCalendar(idname, postBack)
{
	popUp = window.open('../tools/Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal'+idname, 
		'width=180,height=220,left=200,top=250');
}

function SetValue(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	if(popUp)
		popUp.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}

function SetTxtBox(id, value) { FTB_API[id].InsertHtml(value); }

function insertAtCursor(idtb, value)
{
  var textbox = document.getElementById(idtb);
  if (document.selection)/* ie */
  {
    textbox.focus();
    document.selection.createRange().text=value;
  }
  else if (textbox.selectionStart != null) {/* moz */
    var s = textbox.selectionStart;
    var e = textbox.selectionEnd;
    textbox.value = textbox.value.substring(0, s) + value + textbox.value.substring(e);
    textbox.focus();
    textbox.selectionStart = textbox.selectionEnd = (s + value.length);
  }
  else
  {
    textbox.value += v;
  }
}

function getSelectedText(id) {return "";}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
// *****Fenetres modales*****************************

function GetRadWindow()
{
   var oWindow = null;
   if (window.radWindow) oWindow = window.radWindow;
   else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
   return oWindow;
}
    
function OpenModalWindow(url, width, height, onclose, onshow, onload)
{
    var oManager = GetRadWindowManager();
    var oWnd = oManager.GetWindowByName("RadWindow1");
    oWnd.SetUrl(url);
    oWnd.SetSize(width,height);
    oWnd.ClientCallBackFunction = onclose;
    if (onshow)
        oWnd.OnClientShow = onshow;
    oWnd.Show();
}

function btnOk_Click()
{
    //alert("js : btnOk_Click()");
    var arg = new Object();
    arg.WindowName = windowName;
    arg.ReturnButton = 'Ok';
    GetRadWindow().Close(arg);
}

function btnOk_Click(ReturnButton)
{
    var arg = new Object();
    arg.WindowName = windowName;
    arg.ReturnButton = ReturnButton;
    GetRadWindow().Close(arg);
}

function btnCancel_Click()
{
    var arg = new Object();
    arg.WindowName = windowName;
    arg.ReturnButton = 'Cancel';
    GetRadWindow().Close(arg);
}

function CallBackFunction(radWindow, returnValue)
{
    switch (returnValue.ReturnButton)
    {
        case 'reload':
            document.location.reload();
            break;
        case 'Cancel':
        case 'Ok':
            break;
    }
}

