﻿document.onfocusin = gain_focus;document.onfocusout = loose_focus;
function gain_focus(e) {var e = window.event; if (e.srcElement.type == 'text' || e.srcElement.type == 'password' || e.srcElement.type == 'textarea') {e.srcElement.style.background = '#FFFFDD';}	e=null;}
function loose_focus(e) {if (!e) var e = window.event; if (e.srcElement.type == 'text'|| e.srcElement.type == 'password' || e.srcElement.type == 'textarea') {e.srcElement.style.background = '#FFFFFF';}e=null;}
function getForm(){var theForm = document.forms['aspnetForm'];if (!theForm) {theForm = document.aspnetForm;}return theForm;}
function toggleEdit(id){var ctrl = document.getElementById(id);if(ctrl.style.display == "none"){ctrl.style.display = "inline";}else {ctrl.style.display = "none"; }}
function toggleEditOver(id){var ctrl = document.getElementById(id);ctrl.style.display = "inline";}
function toggleEditOut(id){var ctrl = document.getElementById(id);ctrl.style.display = "none";}
function reloadMe(){var theForm = document.forms['aspnetForm'];if (!theForm) {theForm = document.aspnetForm;}theForm.submit();}
function reloadParent(){var theForm = document.forms['aspnetForm'];if (!theForm) {theForm = document.aspnetForm;}top.theForm.submit();}
function getSortPicto(field){var theForm = document.forms['aspnetForm'];if (!theForm) {theForm = document.aspnetForm;}var sortDir = theForm.elements['ctl00_ContentPlaceHolder1_HiddenFieldSortDir'].value;var sortField = theForm.elements['ctl00_ContentPlaceHolder1_HiddenFieldSortField'].value;if(sortDir == "asc" && sortField == field) {document.write("<IMG title=\"Ascending\" SRC=\"/iFleet/images/fleche_haut.gif\" />");}else if(sortDir == "desc" && sortField == field) {document.write("<IMG title=\"Descending\" SRC=\"/iFleet/images/fleche_bas.gif\" />");}}
function sort(field) {var theForm = document.forms['aspnetForm'];if (!theForm) {theForm = document.aspnetForm;}var sortDir = theForm.elements['ctl00_ContentPlaceHolder1_HiddenFieldSortDir'].value;var sortField = theForm.elements['ctl00_ContentPlaceHolder1_HiddenFieldSortField'].value;if(sortDir == "asc" && sortField == field) {sortDir = "desc";}else if(sortDir == "desc" && sortField == field) {sortDir = "asc"}else if(sortField != field) {sortDir = "asc";}theForm.elements['ctl00_ContentPlaceHolder1_HiddenFieldSortField'].value = field;theForm.elements['ctl00_ContentPlaceHolder1_HiddenFieldSortDir'].value = sortDir;theForm.submit();field=null;dir=null;}
function setCookie(c_name,value){var exdate=new Date();var expiredays=365;deleteCookie(c_name);exdate.setDate(exdate.getDate()+expiredays);var content = c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toUTCString());top.document.cookie=content; }
function getCookie(c_name){if (top.document.cookie.length>0){c_start=top.document.cookie.indexOf(c_name + "=");if (c_start!=-1){ c_start=c_start + c_name.length+1; c_end=top.document.cookie.indexOf(";",c_start);if (c_end==-1) c_end=top.document.cookie.length;return unescape(top.document.cookie.substring(c_start,c_end))} }return "";} 
function deleteCookie(c_name) {if ( getCookie( c_name ) ) top.document.cookie = c_name + "=" + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";}
function openUrlChild(iframeURL, iframe, entity, id, absoluteURL) {if(entity == 'd'){setCookie('selectedDepartmentId', id);setCookie('selectedVehicleId', '');}else if(entity == 'v'){setCookie('selectedVehicleId', id);setCookie('selectedDepartmentId', '');}setCookie('url', 'http://localhost:8081'+ absoluteURL);top.document.getElementById(iframe).setAttribute('src', iframeURL);  }  
function openUrlTopMap(iframeURL){setCookie('url', iframeURL);top.document.getElementById('map').setAttribute('src', getCookie('url')); top.ToggleTabs('map'); var url = top.itrack.location.href;} 
function openUrlTopmap(iframeURL){setCookie('url', iframeURL);top.document.getElementById('map').setAttribute('src', getCookie('url')); top.ToggleTabs('map'); var url = top.itrack.location.href;} 
function openUrlTopitrack(iframeURL){setCookie('url', iframeURL);top.document.getElementById('itrack').setAttribute('src', getCookie('url')); top.ToggleTabs('itrack'); var url = top.itrack.location.href;} 
function openUrlTopifleet(iframeURL){setCookie('url', iframeURL);top.document.getElementById('ifleet').setAttribute('src', getCookie('url')); top.ToggleTabs('ifleet'); var url = top.itrack.location.href;} 
function openUrlTopreport(iframeURL){setCookie('url', iframeURL);top.document.getElementById('report').setAttribute('src', getCookie('url')); top.ToggleTabs('report'); var url = top.itrack.location.href;} 
function modalFadeIn(){var ctrl = document.getElementById(document.getElementById('selectedFrame').getAttribute('value'));ctrl.className = "";}
function modalFadeOut(){var ctrl = document.getElementById(document.getElementById('selectedFrame').getAttribute('value'));ctrl.className = "";}
