/*
'------------------------------------------------------
' Developed by : Karim
' Company : Grønn Jobb AS
' WWW : www.gronnjobb.no
' File : Green-Job JS
'------------------------------------------------------
*/
//alert(top.location.href + " - " + "https://system.gronnjobb.no/");
if(top.location.href != "https://system.gronnjobb.no/"){
top.location.href = "https://system.gronnjobb.no/";
}
function Msg(vobjParent, vstrText, vblnConfirm){
if(vblnConfirm){ //---- JS Confirm Message ----
vobjParent.ShowCanvas(true);
var blnConfirm = confirm(vstrText);
vobjParent.ShowCanvas(false);
return blnConfirm;
}else{ //---- JS Alert Message ----
vobjParent.ShowCanvas(true);
alert(vstrText);
vobjParent.ShowCanvas(false);
return false;
}
}
function AutoResizeFrame(){
var objframeContent = document.getElementById("iframe-content");
var objTransFrame = parent.document.getElementById("transFrame");
if(objTransFrame && objframeContent){
//alert("transFrame: " + objTransFrame.style.height + "\nY: " + objframeContent.offsetTop + "\nH: " + objframeContent.offsetHeight + "\n" + (objframeContent.offsetTop + objframeContent.offsetHeight));
//objTransFrame.style.height = parseInt(objframeContent.offsetHeight) + parseInt(objframeContent.offsetTop) + "px";
}
}
//------------------------------- Start: Details -------------------------------
function FilesToggle(vInt){
if($("#divFiles_" + vInt).is(":hidden")){ //Close all
$(".divfile").slideUp("slow");
$("#divFiles_" + vInt).slideToggle();
}else{
$("#divFiles_" + vInt).slideUp("slow");
}
}
function Details(vInt,vIntEvent,vblnLoad){
if($("#divDetails_" + vInt).is(":hidden") || vblnLoad){ //Close all
$(".divdetail").slideUp("slow");
LoadDetails(vInt,vIntEvent);
}else{
$("#divDetails_" + vInt).slideUp("slow");
}
}
function LoadDetails(vInt,vIntEvent){
var strSRC, blnLoad = true;
switch(vIntEvent){
case 1: //---- Attachments ----
strSRC = "../Employees_Attachments/Default.asp?eid=" + vInt;
break;
default: //---- ----
blnLoad = false;
}
if(blnLoad){
$.get(strSRC,function(data,status){
//alert("Data: " + data + "\nStatus: " + status);
$("#divDetails_" + vInt).html(data);
$("#divDetails_" + vInt).slideDown("slow");
});
}else{
$("#divDetails_" + vInt).slideToggle();
}
}
//------------------------------- Start: Edit -------------------------------
var glbIntFrameHeight;
var glbIntEvent = "";
function Edit(vstrID, vInt, vIntEvent, vInt2){
if(glbIntEvent != vIntEvent || $("#" + vstrID + vInt).is(":hidden")){
if($("#" + vstrID + vInt).is(":hidden")){ //Close all
$(".divedit").slideUp("slow");
}
glbIntEvent = vIntEvent;
LoadIframe(vstrID,vInt,vIntEvent,vInt2);
}else{
$("#" + vstrID + vInt).slideUp("slow");
}
}
function LoadIframe(vstrID, vInt, vIntEvent, vInt2){
var strSRC, intHeight, strScroll = "no";
switch(vIntEvent){
case 1: //---- Print ----
strSRC = "Print.asp?id=" + vInt + "&id2=" + vInt2;
intHeight = glbIntFrameHeight;
strScroll = "auto";
break;
case 2: //---- Attachments: add new attachment ----
strSRC = "../Employees_Attachments/Edit.asp?id=new&eid=" + vInt2;
intHeight = intFrameHeight;
strScroll = "no";
break;
case 3: //---- Attachments: edit existing attachment ----
strSRC = "../Employees_Attachments/Edit.asp?id=" + vInt + "&eid=" + vInt2;
intHeight = intFrameHeight;
strScroll = "no";
break;
case 4: //---- Sickness: add new ----
strSRC = "../Employees_Sickness/Edit.asp?id=" + vInt + "&eid=" + vInt2;
intHeight = intFrameHeight;
strScroll = "no";
break;
case 5: //---- Timesheet: add new ----
strSRC = "../Employees_Timesheets/Edit.asp?id=" + vInt + "&id2=" + vInt2;
intHeight = intFrameHeight;
strScroll = "no";
break;
default: //---- Edit ----
strSRC = "Edit.asp?id=" + vInt + "&id2=" + vInt2;
intHeight = glbIntFrameHeight;
strScroll = "no";
break;
}
//$("#" + vstrID + vInt).html("");
$("#" + vstrID + vInt).html("");
$("#" + vstrID + vInt).slideDown("slow");
return true;
}
//------------------------------- ResizeIFrame -------------------------------
var objTransFrame;
function ResizeIFrame(vInt,vValue){
if(!objTransFrame){
objTransFrame = parent.document.getElementById("divEdit_" + vInt).firstChild;
}
if(objTransFrame){
//alert("$(objTransFrame).height(): " + $(objTransFrame).height());
$(objTransFrame).height($(objTransFrame).height() + vValue);
}
}
//------------------------------- RequiredField -------------------------------
function RequiredField(vobj,vblnError){
var strClass = vobj.className;
vblnError = (vblnError || vobj.value == "");
if(vblnError){
if(vobj.type == "file"){
strClass = strClass + " error error_border";
}else{
strClass = strClass + " error";
}
}else{
if(vobj.type == "file"){
strClass = strClass.replace(" error error_border","");
}else{
strClass = strClass.replace(" error","");
}
}
vobj.className = strClass;
return vblnError;
}
//------------------------------- SubmitEnter -------------------------------
function SubmitEnter(myfield,e){
var keycode;
if(window.event){
keycode = window.event.keyCode;
}else if(e){
keycode = e.which;
}else{
return true;
}
if (keycode == 13){
myfield.form.submit();
return false;
}else{
return true;
}
}
//------------------------------- onBlur/onFocus on editable fields -------------------------------
function FldBlur(vobj){
if(vobj.value == ''){vobj.value = vobj.getAttribute("fldname");}
}
function FldFocus(vobj){
if(vobj.value == vobj.getAttribute("fldname")){vobj.value = '';}
}
//------------------------------- Employee: load drop list function -------------------------------
function LoadEmpoyeeDL(vgid, veid, vint){
var strHREF;
switch(vint){
case "0": strHREF = "../Employees_Attachments/Default.asp";
break;
case "1": strHREF = "../Employees_Sickness/Default.asp";
break;
case "2": strHREF = "../Employees_eDocuments/Default.asp";
break;
case "3": strHREF = "../Employees_Timesheets/Default.asp";
break;
default: strHREF = "";
break;
}
window.location.href = strHREF + "?gid=" + vgid + "&eid=" + veid + "&slcSelectMenu=" + vint;
}
//------------------------------- Upload file: Get filename function -------------------------------
function GetFileName(obj){
//var strFilename = $('input[type=file]').val().replace(/.*(\/|\\)/, '');
var strFilename = obj.value.replace(/.*(\/|\\)/, '');
if(strFilename.length == 0){
strFilename = document.getElementById("tdFileName").getAttribute("fldname");
}else if(strFilename.length > 23){
strFilename = strFilename.substring(0,23) + "...";
}
//alert("filename: " + filename);
$("#tdFileName").text(strFilename);
}
//------------------------------- GetDateDiff: JS get date diff. in days -------------------------------
function GetDateDiff(vfromDate, vtoDate){
var arrDate = vfromDate.split(".");
vfromDate = new Date(arrDate[2] + "-" + arrDate[1] + "-" + arrDate[0]);
arrDate = vtoDate.split(".");
vtoDate = new Date(arrDate[2] + "-" + arrDate[1] + "-" + arrDate[0]);
// date difference in millisec
var diff = new Date(vtoDate - vfromDate);
// date difference in days
return diff/1000/60/60/24 + 1;
}
//------------------------------- Get2DigitsNum -------------------------------
function Get2DigitsNum(vintValue){
if(vintValue == ""){
return "00";
}else if(vintValue < 10){
return "0" + vintValue;
}else{
return vintValue;
}
}
//------------------------------- ConvertToTime -------------------------------
function ConvertToTime(vValue){
if(vValue == ""){vValue = ":";}
if(vValue.search(":") >= 0){
var arrPrvTime;
arrPrvTime = vValue.split(":");
arrPrvTime[0] = Get2DigitsNum(arrPrvTime[0]);
arrPrvTime[1] = Get2DigitsNum(arrPrvTime[1]);
return arrPrvTime.join(":");
}else{
return vValue;
}
}