﻿//###22.06.05/roettger: Popup durch <DIV> ersetzen
//owc('/afterbuy/Meldung.aspx')
//###22.06.05/roettger: Popup durch <DIV> ersetzen
//###30.08.05/czock: Link unter Logo entfernt (Sprungmarke: ##sc20050830)

function MM_swapImgRestore()
{ //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages()
{ //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d)
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage()
{ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function owc(seite)
  { 
	w1 = window.open( seite, 'LEAF','toolbar=no,status=no,width=700,height=550,directories=no,scrollbars=yes,location=no,resizable=yes,menubar=no');
  	w1.focus();
  }
  
function owdok(seite)
  { 
	w1 = window.open( seite, 'LEAF','toolbar=no,status=no,width=700,height=550,directories=no,scrollbars=yes,location=no,resizable=yes,menubar=no');
  	w1.focus();
  }

var activeSub=0;
var SubNum=0;
var mfree=0;

//function reDo(){ window.location.reload() }
    //window.onresize = reDo;


    //Define global variables

var timerID = null;
var timerOn = false;
var timecount = 1000;
var what = null;
var newbrowser = true;
var check = false;
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)

document.onmousemove = getMouseXY;
		
var tempX = 0
var tempY = 0
var tempMWX = 0
var tempMWY = 0
        
function getMouseXY(e)
{
    if (IE) { // grab the x-y pos.s if browser is IE
        try {
            tempX = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
            tempY = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
        } catch(ex) {
            tempX = 0;
            tempY = 0;
        }	    
        tempMWX = event.clientX; // + document.body.scrollLeft
	    tempMWY = event.clientY; // + document.body.scrollTop		    
  	} else {  // grab the x-y pos.s if browser is NS
        try {
    	    tempX = e.pageX
    	    tempY = e.pageY
    	} catch(ex) {
    	    tempX = 0;
    	    tempY = 0;
    	}
    	tempMWX = e.pageX
    	tempMWY = e.pageY
  	}  
  	if (tempX < 0){tempX = 0}
  	if (tempY < 0){tempY = 0}  
  	return true
}
		
function init()
{
	//  alert ("Running Init");
  	if (document.layers) {
   		//  alert ("Running Netscape 4");
   	    layerRef="document.layers";
        styleSwitch="";
        visibleVar="show";
		screenSize = window.innerWidth;
		what ="ns4";
	}else if(document.all){
        //  alert ("Running IE");
        layerRef="document.all";
        styleSwitch=".style";
        visibleVar="visible";
		screenSize = document.body.clientWidth + 18;
		what ="ie";
	}else if(document.getElementById){
        //  alert ("Running Netscape 6");
        layerRef="document.getElementByID";
        styleSwitch=".style";
        visibleVar="visible";
		what="moz";
  	}else{
  		//alert("Older than 4.0 browser.");
		what="none";
		newbrowser = false;
  	}
  
	window.status='status bar text to go here';
	check = true;
}

function MM_showHideLayers()
{ //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
		    obj.visibility=v;
		    //obj.left=tempX-15; 
		    //obj.top=tempY+35; 
		    }
		
		}
		
function chgBg(obj,color)
{
	if (document.all || document.getElementById)
		  document.getElementById(obj).style.backgroundColor=color;
}

//MM_showHideLayers('navstamm','','show')
function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}
		
function hideLayer(layerName)
{
	MM_showHideLayers(layerName,'','hide')
}

function showLayer(layerName)
{
	if(mfree == 1){
		MM_showHideLayers(layerName,'','show')}
	}
	
function hideAll()
{
	hideLayer('layer1');
	hideLayer('layer2');
	hideLayer('layer3');
	hideLayer('layer4');
	hideLayer('layer5');
	hideLayer('layer6');
	hideLayer('layer7');
	//hideLayer('layer8');
}

function hideAll2()
{
	mfree = 0;
	hideAll();
}

function makefree()
{
	if(mfree == 0) {
		mfree = 1;
	 }
	 else{
		 mfree = 0;
		 hideAll();
		 }
}

function startTime()
{
	if (timerOn == false) {
    	timerID=setTimeout( "hideAll2()" , timecount);
        timerOn = true;
        }
}

function stopTime()
{
	if (timerOn) {
    	clearTimeout(timerID);
        timerID = null;
        timerOn = false;
	}
}

function onLoad()
{
	init();
}

function popupme(destination,win_name,win_dim) {
    //alert(destination + " - " + win_name + " - " + win_dim);
	var MyLittlePopupWindow = window.open(destination ,win_name,win_dim + ',' + 'resizable=no,scrollbars=yes,toolbar=no,Left=250,Top=100,status=no,directories=no,menubar=no,location=tabelle');
    window.open (destination ,win_name,win_dim + ',' + 'resizable=no,scrollbars=yes,toolbar=no,Left=250,Top=100,status=no,directories=no,menubar=no,location=tabelle');
    MyLittlePopupWindow.focus();    
}

var SCount = 0;
function OneOnly (obj){
	SCount++;
	if (SCount > 1)
	{
	//alert('nana');
	}else{
	obj.submit()
	}
}

// TOOLBAR SETTINGS
var vdisplay = "";
vdisplay = "block";
var MyCookieName;
var MyCookieValue;
var Verfall = 1000*60*60*24*365;
var jetzt = new Date();
var Auszeit = new Date(jetzt.getTime() + Verfall);

imdata = new Array();
imdata[0] = "//static.afterbuy.de/afterbuy/images/abroot/open.gif";
imdata[1] = "//static.afterbuy.de/afterbuy/images/abroot/close.gif";
image = new Array();

for(var i=0;i<imdata.length;i++)
{
	image[i] = new Image();
	image[i].src = imdata[i];
}

function owstamm(seite)
  {
        wstamm = window.open('/' + seite, 'LEAF2', 'toolbar=no,status=no,width=800,height=600,directories=no,scrollbars=yes,location=no,resizable=yes,menubar=no');
        wstamm.focus();
  }

function Bildwechsel(Bildobj,nr)
{
	document.images[Bildobj].src = image[nr].src;
}

function anzeigen (vwert)
{
	document.getElementById(vwert).style.display = vdisplay;
}
function verstecken (vwert)
{
	try
	{
		document.getElementById(vwert).style.display = "none";
	}
	catch (e)
	{}
	finally
	{}
}


function aus(vwert, vbild)
{
	document.getElementById(vwert).style.display = "none";
	verstecken (vwert)
}

function readMyCookiesValue(mCookieName)
{
    var MyCookie = document.cookie.split(";");
    var TmpArray;
    var CompareArray;
    var iCheck = 0;
    //alert('MyCookieCompl: ' + document.cookie);
    //alert(MyCookie.length);
    for (i = 0; i < MyCookie.length; i++)
    {
        CompareArray = MyCookie[i].split("=")
        //alert(CompareArray[0]);
        if (CompareArray[0].replace(' ', '') == mCookieName)
        {
            iCheck++;
            TmpArray = MyCookie[i].split("=");
            break;
        }
    }

    if (iCheck != 0){return TmpArray[1];}else{return '-1';}
}

function insertLoadArea(elementID, AreaName)
{
	tajax('/afterbuy/interfaces/general_interface.aspx','art=LoadArea&LoadAreaName='+ AreaName,elementID,'','HTML','',0,0,'leer');
}

/*
Die folgende Funktion ermoeglicht es zur Laufzeit Aenderungen dynamisch am Stylesheet vorzunehmen
*/
function changeCssClass(className, styleName, styleValue) {
	var i=0, j=0;
	var cssRules = 'cssRules';
	if (document.all) {cssRules = 'rules';}
	className = '.' + className;
	for (i=0;i<document.styleSheets.length;i++) {
		for (j=0;j<document.styleSheets[i][cssRules].length;j++) {
			if (document.styleSheets[i][cssRules][j].selectorText == className) {
				//alert(document.styleSheets[i][cssRules][j].selectorText);
				if (document.styleSheets[i][cssRules][j].style[styleName]) {
					//alert('hier' + styleValue);
					document.styleSheets[i][cssRules][j].style[styleName] = styleValue;					
					//alert('hier');
					if (cssRules == 'rules' && styleName == 'background' && styleValue == '') {
						//alert('hier');
						document.styleSheets[i][cssRules][j].style.cssText = document.styleSheets[i][cssRules][j-1].style.cssText;
					}
				} else {
					//alert('hier');
					if (styleName.substring(0,7) == 'border-') {
						//alert(document.styleSheets[i][cssRules][j].style.cssText);
						document.styleSheets[i][cssRules][j].style.cssText =  document.styleSheets[i][cssRules][j].style.cssText + ';' + styleName + ':' + styleValue;
						//alert(document.styleSheets[i][cssRules][j].style.cssText);
					}
					if (cssRules == 'cssRules' && styleValue == '') document.styleSheets[i][cssRules][j].style.cssText =  styleName + ':' + styleValue;
					if (cssRules == 'cssRules' && styleName == 'background') document.styleSheets[i][cssRules][j].style.cssText =  styleName + ':' + styleValue;
					if (cssRules == 'rules') document.styleSheets[i][cssRules][j].style[styleName] = styleValue;
					if (styleName == 'text-align') document.styleSheets[i][cssRules][j].style.cssText = document.styleSheets[i][cssRules][j].style.cssText + ";text-align:" + styleValue;
				}
			}
		}
	}
}

function setFontSize(size) {
	var bodyTag = document.getElementsByTagName('body');
	var inputTag = document.getElementsByTagName('input');
	var selectTag = document.getElementsByTagName('select');
	for (var i = 0; i < bodyTag.length; i++) {
		if (bodyTag[i].style.fontSize) {
			var s = parseInt(bodyTag[i].style.fontSize.replace("%", ""));
		}
		else {
			var s = size;
		}
		if ((size >= 11) && (size <= 14)) {
			bodyTag[i].style.fontSize = size + "px";
		}
	}

	for (var i = 0; i < inputTag.length; i++) {
		if (inputTag[i].style.fontSize) {
			var s = parseInt(inputTag[i].style.fontSize.replace("%", ""));
		}
		else {
			var s = size;
		}
		if ((size >= 11) && (size <= 14)) {
			inputTag[i].style.fontSize = size + "px";
		}
	}

	for (var i = 0; i < selectTag.length; i++) {
		if (selectTag[i].style.fontSize) {
			var s = parseInt(selectTag[i].style.fontSize.replace("%", ""));
		}
		else {
			var s = size;
		}
		if ((size >= 11) && (size <= 14)) {
			selectTag[i].style.fontSize = size + "px";
		}
	}
}
function SendTFeed(ScriptUrl) {
	var dummy;
	//tajax('/afterbuy/interfaces/general_interface.aspx','art=saveCookie&cname=auktionsliste&vname=showHideClass_'+id+'&cvalue=show','tallow','','HTML','',1,0,'');

	var UserMess;
	UserMess = '';
	UserMess = URLEncode(document.getElementById('tpagetrans').value);

	dummy = tajax('/afterbuy/interfaces/tsugg.aspx', 'art=addnote&utext=' + UserMess + '&uurl=' + ScriptUrl, '', '', 'DirectReturn');
	//tajax('/afterbuy/interfaces/ntrfc_forum.aspx', params, 'scrollContentBlock', '', 'HTML', '', 1);
	//alert(dummy);
	if (dummy != '') {
		document.getElementById('tallow_in').style.display = 'block';
		if (dummy == '1') {
			document.getElementById('tallow_in').innerHTML = '<font color=green><b>Ihr Vorschlag wurde erfolgreich erfasst<br/>Vielen Dank!<' + '/b><' + '/font>';
			//setTimeout('ClosepageTranslationFeedback();', 3000);
			document.getElementById('tpagetrans').value = '';
		}
		else {
			document.getElementById('tallow_in').innerHTML = '<font color=red><b>Der Vorschlag konnte nicht gespeichert werden, bitte versuchen Sie es später noch einmal.<' + '/b><' + '/font>';
		}
	}
}
function ShowPageNotes() {
	SetTransDiVAtMousePos('tallow');
	document.getElementById('tallow').style.visibility = 'visible';
	document.getElementById('tpagetrans').value = '';
	document.getElementById('tallow_in').innerHTML = '';
	document.getElementById('tallow_in').style.display = 'none';
}

function SetTransDiVAtMousePos(MyDiV) {
	var i, p, v, obj
	if ((obj = MM_findObj(MyDiV)) != null) {
		obj.style.left = (tempX) + 'px';
		obj.style.top = (tempY + 10) + 'px';
	}
}

/* PageFeedBack - needs AJAX */
function ClearField(id) {
	var el;
	var text = "";
	if (id == "headline") {
		el = document.getElementById(id);
		text = el.value;
		if (text == "Ihre Überschrift") {
			el.value = "";
		}

	} else if (id == "verbesserung") {
		el = document.getElementById(id);
		text = el.value;
		if ((text.search(/Bitte erläutern Sie hier so genau wir möglich Ihren Verbesserungsvorschlag./i) > -1) || (text.valueOf(/Mindestens 100 Zeichen maximal 4.0000 Zeichen/i) > -1)) {
			el.value = "";
		}
	}
}


function CountInputLength(id, idChar) {
	var el;
	var elChar;
	var length;
	var maxchar = 4000;
	el = document.getElementById(id);
	length = el.value.length;
	if ((maxchar - length) <= 0) {
		el.value = el.value.substring(0, maxchar);
	}
	length = el.value.length;
	elChar = document.getElementById(idChar);
	elChar.innerHTML = (maxchar - length) + " Zeichen verfügbar";
}

function URLEncode(text) {
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" + 				// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZÄÜÖ" + // Alphabetic
					"abcdefghijklmnopqrstuvwxyzäüöß" +
					"-_.!~*'()"; 				// RFC2396 Mark characters

	var HEX = "0123456789ABCDEF";

	var plaintext = text;
	var encoded = "";

	for (var i = 0; i < plaintext.length; i++) {
		var ch = plaintext.charAt(i);
		ch = ch.replace("ä", "&auml;");
		ch = ch.replace("ö", "&ouml;");
		ch = ch.replace("ü", "&uuml;");
		ch = ch.replace("Ä", "&Auml;");
		ch = ch.replace("Ö", "&Ouml;");
		ch = ch.replace("Ü", "&Uuml;");
		ch = ch.replace("ß", "&szlig;");
		encoded += ch;
	}

	plaintext = encoded;
	encoded = "";

	for (var i = 0; i < plaintext.length; i++) {
		var ch = plaintext.charAt(i);
		if (ch == " ") {
			encoded += "+"; 			// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
			encoded += ch;
		} else {
			var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				/*alert("Unicode Character '"
				+ ch
				+ "' cannot be encoded using standard URL encoding.\n" +
				"(URL encoding only supports 8-bit characters.)\n" +
				"A space (+) will be substituted.");*/
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
				encoded = encoded.replace("%0A", "%0d%0a");
			}
		}
		encoded = encoded.replace("ä", "&auml;");
		encoded = encoded.replace("ö", "&ouml;");
		encoded = encoded.replace("ü", "&uuml;");
		encoded = encoded.replace("Ä", "&Auml;");
		encoded = encoded.replace("Ö", "&Ouml;");
		encoded = encoded.replace("Ü", "&Uuml;");
		encoded = encoded.replace("ß", "&szlig;");
	} // for

	//encoded = text;
	return encoded;
};
function URLDecode(text) {
	// Replace + with ' '
	// Replace %xx with equivalent character
	// Put [ERROR] in output if %xx is invalid.
	var HEXCHARS = "0123456789ABCDEFabcdef";
	var encoded = text;
	var plaintext = "";
	var i = 0;
	while (i < encoded.length) {
		var ch = encoded.charAt(i);
		if (ch == "+") {
			plaintext += " ";
			i++;
		} else if (ch == "%") {
			if (i < (encoded.length - 2)
					&& HEXCHARS.indexOf(encoded.charAt(i + 1)) != -1
					&& HEXCHARS.indexOf(encoded.charAt(i + 2)) != -1) {
				plaintext += unescape(encoded.substr(i, 3));
				i += 3;
			} else {
				//alert('Bad escape combination near ...' + encoded.substr(i));
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
			plaintext += ch;
			i++;
		}
	} // while
	return plaintext;
};

