﻿// JavaScript - Access functions (utf-8-coded)
// Workzone - The Online Processing Management by medialink
// All rights reserved on concept, design and solution as well as on attached files
// Copyright by medialink 2008 - v9.05.005/27.05.2008
// -----------------------------------------------------------------------------------



//access-check
var accessOK  = false;
var msgError  = "Zugang nicht möglich! | Accès pas possible!\n\n";
var browserOK = false;
var screenOK  = false;
var cookieOK  = false;


//checking browser
if ((document.images) && (screen) && (document.getElementById)){
	browserOK = true;
}else{
	msgError = msgError + "Ihr Browser ist nicht aktuell | Votre navigateur n’est pas actuel\n\n"
}



//checking screenresolution
var	w = screen.width;
var	h = screen.height;
if ((w >= 1024) & (h >= 768)){
	screenOK = true;
}else{
	msgError = msgError + "Ihre Bildschirmauflösung ist unzureichend | La résolution de votre écran n’est pas suffisante\n\n"
}



//-----cookie-functions
//Derived from the Bill Dortch code at http://www.hidaho.com/cookies/cookie.txt
//Adapted by mediaLINK Switzerland - Version 1.0 / 22.09.2001
//-----------------------------------------------------------------------------------
var today = new Date();
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
	}

function GetCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return getCookieVal (j);
			}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
		}
	return null;
	}

function DeleteCookie(name,path,domain) {
	if (GetCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	}

function SetCookie(name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
	}


//checking cookie avalability
function cookieCheck(){
	SetCookie("cookieChecker","CheckingForCookieFunction",0,"/");	//when setting expTime: attn. GTM-problem NS4.05WIN
	if (GetCookie("cookieChecker") != null){
		cookieOK = true;
	}else{
		msgError = msgError + "Sie haben Cookies deaktiviert | Vous avez désactivé Cookies\n\n"
	}
}
cookieCheck();






//access-check

if ((browserOK == true) && (cookieOK == true) && (screenOK == true)){
	accessOK = true;
}else{
	msgError = msgError + "\nSollten sich die Probleme nicht lösen lassen, wenden Sie sich bitte direkt an den SVGW | Si les problèmes ne peuvent pas être résolus, adressez-vous directement à la SSIGE"
}


function access(l){
	if (accessOK == true){
		if ((document.formAccess.username.value != "") && (document.formAccess.password.value != "")){
			//checking password
			//top.location.href = "/content/" + l + "/?l=" + l;
		document.formAccess.action ="http://gasstatistic.svgw.ch/content/" + l + "/?l=" + l;
		document.formAccess.submit();

		}else{
			alert("Geben Sie bitte Ihre Zugangsdaten vollständig ein | Veuillez introduire complètement vos données d’accès");
		}	
	}else{
		alert(msgError);
	}
}


//--- end of file

