/* --------------------------------------------------------------------------
	Browserüberprüfung
-------------------------------------------------------------------------- */
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);

var is_gecko = (agt.indexOf('gecko') != -1);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")==-1) );
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
var is_ie6 = (is_ie  && (is_major == 4) && (agt.indexOf("msie 6.0") !=-1));
var is_mac = (agt.indexOf("mac")!=-1);


/* --------------------------------------------------------------------------
	Zerlegen des Query-Strings und die in arrPattern definierten
	Query-Parameter herausholen und in die sidpat-Variablen schreiben
-------------------------------------------------------------------------- */
var sidpat_js ='';
var sidpat0_js = '';
var sidpat3_js = '';

arrPattern = new Array('id','si');
arrSidpat = new Array();
var count = 0;

if (window.location.search.indexOf("<") == -1 && window.location.search.indexOf(">") == -1){
	if(window.location.search != ""){
		var queryString = "&"+window.location.search.substr(1);
		var querys = queryString.split("&");
		for (i=0; i<querys.length; i++){
			if (querys[i].indexOf("=") != -1){
				nameValue = querys[i].split("=");
				for (j=0; j<arrPattern.length; j++){
					if (arrPattern[j] == nameValue[0]){
						count++;
						// Sonderfall "id=V00..."
						if (nameValue[0] == "id" && nameValue[1].substr(0,4) == "V00-"){
							arrSidpat[count] = nameValue[0]+"="+nameValue[1].substr(4);
						} else {
							arrSidpat[count] = nameValue[0]+"="+nameValue[1];
						}
					}
				}
			}
		}
	}
	
	// Zusammenbauen der sidpats-Strings
	if (arrSidpat.length > 0){
		for (i=1; i<arrSidpat.length; i++){
			sidpat3_js += "&"+arrSidpat[i];
		}
		sidpat_js = "?"+sidpat3_js.substr(1);
		sidpat0_js = sidpat3_js.substr(1);
	}

}

function select(imgName,stat) {
	if (document.images) {
		document [imgName].src = eval(imgName + "_" + stat + ".src");
	}
}


function fenster(jurl,name,menbar,toolbar,statbar,breite,hoehe){
	makePopup(jurl, name, breite, hoehe, 100, 100, 1, 1, menbar, toolbar, 0, 1, 'yes', statbar);
	/*
	if (jurl.indexOf("?") != -1){
		jurl = jurl+sidpat3_js;
	} else {
		jurl = jurl+sidpat_js;
	}
	neuesfenster = window.open(jurl,name,"width="+breite+",height="+hoehe+",menubar="+menbar+",toolbar="+toolbar+",resizable=1,scrollbars=1,location=1,top=50,left=50,status="+statbar);
	neuesfenster.focus();
	*/
}

function fensterextern(jurl,name,menbar,toolbar,statbar,breite,hoehe){
	makePopup(jurl, name, breite, hoehe, 100, 100, 1, 1, menbar, toolbar, 0, 1, 'yes', statbar);
	/*
	extfenster = window.open(jurl,name,"width="+breite+",height="+hoehe+",menubar="+menbar+",toolbar="+toolbar+",resizable=1,scrollbars=1,status="+statbar);
	extfenster.focus();
	*/
}


function selectText1(t_area) {
	document.copsform.elements["rv_content#"+t_area].focus();
	document.copsform.elements["rv_content#"+t_area].select();
}



function popup (jurl,name,width,height,top,left,location,menubar,resizable,scrollbars,status,toolbar,session){
}


function makePopup(popupURL, popupName, breite, hoehe, xpos, ypos, resize, locbar, menbar, toolbar, personal, scroll, session, statbar){

	if (resize == '1'){
		resize = 'yes';
	} else {
		if (resize == '0'){
			resize = 'no';
		} else {
			if (!resize){
				resize = 'yes';
			}
		}
	}

	if (scroll == '1'){
		scroll = 'yes';
	} else {
		if (scroll == '0'){
			scroll = 'no';
		} else {
			if (!scroll){
				scroll = 'yes';
			}
		}
	}

	//alert(locbar);
	if (locbar == '1' || locbar == 'yes'){
		//locbar = 'yes';
		locbar = 1;
	} else {
		//locbar = 'no';
		locbar = 0;
	}

	if (menbar == '1' || menbar == 'yes'){
		menbar = 'yes';
	} else {
		menbar = 'no';
	}

	if (personal == '1' || personal == 'yes'){
		personal = 'yes';
	} else {
		personal = 'no';
	}

	if (toolbar == '1' || toolbar == 'yes'){
		toolbar = 'yes';
	} else {
		toolbar = 'no';
	}

	if (parseInt(breite) == 0 || String(parseInt(breite)) ==  'NaN'){
		breite = 800;
	}

	if (parseInt(hoehe) == 0 || String(parseInt(hoehe)) ==  'NaN'){
		hoehe = 600;
	}

	if (parseInt(xpos) == 0 || String(parseInt(xpos)) ==  'NaN'){
		xpos = 100;
	}

	if (parseInt(ypos) == 0 || String(parseInt(ypos)) ==  'NaN'){
		ypos = 100;
	}

	if (!popupName){
		popupName = 'standardWindow';
	}

	if (session != 'no'){
		if (popupURL.indexOf("?") != -1){
			popupURL = popupURL+sidpat3_js;
		} else {
			popupURL = popupURL+sidpat_js;
		}
	}
	//alert(locbar);
        newPopup = window.open(popupURL,popupName,"width="+breite+",height="+hoehe+",menubar="+menbar+", personalbar="+personal+", toolbar="+toolbar+",resizable="+resize+",scrollbars="+scroll+",location="+locbar+",left="+xpos+",top="+ypos+",status="+statbar);    
        //newPopup = window.open(popupURL,popupName,"width="+breite+",height="+hoehe+",menubar="+menbar+", personalbar="+personal+", toolbar="+toolbar+",resizable="+resize+",scrollbars="+scroll+",location=1,left="+xpos+",top="+ypos+",status="+statbar);    
        newPopup.focus();
}

function closePopup(){

	if (parent.document.getElementById("popupFk")){
		parent.document.getElementById("popupFk").style.display = 'none';
	} else {
		self.close();
	}

}

function reloadTheOpener(){
	if (parent.opener != null){
		var openerUrl = ""+parent.opener.location;
		if (openerUrl.indexOf("?") != -1){
			openerUrl += sidpat3_js;
		} else {
			openerUrl += sidpat_js;
		}
		parent.opener.location.href = openerUrl;
	}
}

function initLinks(){
	var links = document.getElementsByTagName('a');
	for (var i=0; i<links.length; i++) {
		links[i].onclick=function() {
			linkurl = this.href;
		}
	}
}

// --- Adwords Logging ---

var linkurl;
var start;
var timeStart;

function logTimerStart() {
	start = new Date();
	timeStart = start.getTime();
} 

function logTimerStop() {
	var stop = new Date();
	var timeStop = stop.getTime();
	var timeElapsed = Math.floor((timeStop - timeStart) / 1000);
	var ajaxUrl = '/-adwordslog.htm';
	var ajaxParams = 'logurl='+encodeURIComponent(actUrl)+'&logpagename='+encodeURIComponent(actPageName)+'&time='+timeElapsed+'&linkurl='+encodeURIComponent(linkurl)+'&referrer='+encodeURIComponent(document.referrer)+'&useragent='+encodeURIComponent(navigator.userAgent);
	httpRequest(ajaxUrl,ajaxParams);
}

function httpRequest(url,params) {
	if (window.XMLHttpRequest) {
		// branch for native XMLHttpRequest object
		req = new XMLHttpRequest();
		req.open("POST", url, false);
		req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		req.setRequestHeader("Content-length", params.length);
		req.setRequestHeader("Connection", "close");
		req.send(params);
	} else if (window.ActiveXObject) {
		// branch for IE/Windows ActiveX version
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.open("POST", url, false);
			req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			req.setRequestHeader("Content-length", params.length);
			req.setRequestHeader("Connection", "close");
			req.send(params);
		}
	}
}
function selectIdent(loginboxNr) {
	var newActionUrl = document.createAttribute("action");
	if(document.getElementById('fklogin'+loginboxNr).ident[1].checked == true) {
		newActionUrl.nodeValue = "https://login.doccheck.com";
		document.getElementById('fklogin'+loginboxNr).setAttributeNode(newActionUrl);
		document.getElementById('fklogin'+loginboxNr).username.value = document.getElementById('fklogin'+loginboxNr).benutzername.value;
		document.getElementById('fklogin'+loginboxNr).password.value = document.getElementById('fklogin'+loginboxNr).passwort.value;
	}
	return true;
}

function selectIdentClick(loginboxNr) {
	if (document.getElementById('fklogin'+loginboxNr).ident != undefined) {
		selectIdent(loginboxNr);
	}
	document.getElementById('fklogin'+loginboxNr).submit();
}

function selectIdentOnEnter(loginboxNr, e) {
	var evt = e || window.event;
	if (evt.keyCode == 13) {
		selectIdentClick(loginboxNr);
	}
	return false;
}

function checkMaxChars(obj, maxLength)
{
	var inValue = obj.value;
	if (inValue != undefined && inValue != '' && inValue.length > maxLength){
		inValue = inValue.substr(0,maxLength);
		obj.value = inValue;
		alert('max. '+maxLength+' Zeichen');
	}
}
