// ---------------------------------------
// Angry Web Developers JavaScript
// ... MAIN DOCUMENT
// copyright (c) AWD-Team F. Dargos

var nav = navigator.appName;

var jsMemory = {

		magTxt: false,
		jumPer: 25,
		konTxt: null,
		width: 150,
		memAlt: null

	}

// ----------------------
	
function jsMtext() {

	var jsMainTxt = document.getElementById("mainFrame");
	
	if (jsMemory.magTxt == true ) {
	
		jsMainTxt.style.font = "12px 'Trebuchet MS', 'Georgia', Helvetica, Arial, Verdana, sans-serif;";
		jsMemory.magTxt = false;
	
	} else {
	
		jsMainTxt.style.font = "14px 'Trebuchet MS', 'Georgia', Helvetica, Arial, Verdana, sans-serif;";
		jsMemory.magTxt = true;
	
	}

}

// ----------------------

function getMouse(evt) {

	jsCoord = new Array();

	if(nav != 'Netscape') {
	
		jsCoord[0] = event.x + document.documentElement.scrollLeft;
		jsCoord[1] = event.y + document.documentElement.scrollTop;
	
	} else {
	
		jsCoord[0] = evt.pageX;
		jsCoord[1] = evt.pageY;
	
	}
	
	return jsCoord;

}

// ----------------------
// HELP !

function jsHelp() {

	var tagName = new Array('a', 'img', 'acronym');

	for (i=0; i<=tagName.length; i++) {
	
		var element = document.getElementsByTagName(tagName[i]);
		var jsHelpDiv = document.getElementById("help");
		
		for(var x = 0; x <= element.length; x++) {
		
			
			if ( element[x] != null && element[x].getAttribute('title') && element[x].title != "" ) {
			
				element[x].onmouseover = function(evt) {
					
					jsHelpDiv.innerHTML = this.title;
					jsMemory.konTxt = this.title;
					this.title = '';
					if ( this.getAttribute('alt') ) {
						jsMemory.memAlt = this.alt;
						this.alt='';
					}
					jsHelpDiv.style.visibility = "visible";
					jsHelpDiv.style.display = "block";
				
				}
				
				element[x].onmousemove = function(evt) {
				
					mikemouse = getMouse(evt);
					
					scrW = document.body.clientWidth ? document.body.clientWidth : window.innerWidth;
					scrH = document.documentElement.scrollTop;
					if ( mikemouse[0]+jsMemory.jumPer+jsMemory.width+20 >= scrW ) {
					
						jsHelpDiv.style.left = mikemouse[0]-jsMemory.jumPer-jsMemory.width+"px";
					
					} else {
					
						jsHelpDiv.style.left = mikemouse[0]+jsMemory.jumPer+"px";
						
					}
					
					if ( scrH >= mikemouse[1]-jsMemory.jumPer ) {
					
						jsHelpDiv.style.top = mikemouse[1]+jsMemory.jumPer+"px";
						
					} else {
					
						jsHelpDiv.style.top = mikemouse[1]-jsMemory.jumPer+"px";
						
					}
				
				}
				
				element[x].onmouseout = function() {
				
					if ( jsMemory.konTxt != '' && jsMemory.konTxt != null ) {
				
						if ( this.getAttribute('alt') ) {
							this.alt = jsMemory.memAlt;
							jsMemory.memAlt = '';
						}
						jsHelpDiv.style.visibility = 'hidden';
						jsHelpDiv.style.display = 'none';
						jsHelpDiv.style.top = '-200px';
						jsHelpDiv.style.left = '-100px';
						this.title = jsMemory.konTxt;
						jsMemory.konTxt = null;
					
					}
				
				}
			}
		
		}
	
	}

}

// ----------------------
// insert BBCODE

function inserttag(dTag, iTag) { 
	
	KE = document.forms[1].clansTEXT;
	
	KE.focus();
	
	if ( nav != 'Netscape' ) {
		var selectat = document.selection.createRange();
		
		var inTag = selectat.text;
				
		if ( inTag.length > 0 ) {
			selectat.text = dTag+inTag+iTag;
			selectat = document.selection.createRange();
		} else {
			KE.value += dTag+iTag;
		}
	
	} else {
	
		f_ind = KE.selectionStart;
		
		f_end = KE.selectionEnd;
		
		if ( f_ind != f_end ) {
	
			var ROY = KE.value;
			
			KE.value = ROY.substring(0, f_ind) + dTag + ROY.substring(f_ind, f_end) + iTag + ROY.substring(f_end, ROY.length);
		
		} else {
		
			KE.value += dTag+iTag;
			
		}
	
	}

}

// ----------------------

var memory = new Object();
memory._on = false;

function preview(img, w, h, comment) {

	var padd = 10;
	var Enam = document.getElementById("popup");
	screen_x = window.innerWidth ? window.innerWidth : document.body.clientWidth;
	screen_y = window.innerHeight ? window.innerHeight : document.body.clientHeight;
	abc = (screen_x/2) - (w+padd)/2;
	bcd = document.documentElement.scrollTop + 50;
	memory.we = w;
	memory.he = h;
	Enam.innerHTML = "<p><span class='box_txt'>"+comment+"</span></p><a href=\"javascript:hide()\"><img src='"+img+"' alt='Close ...' /></a>";
	Enam.style.display = "block";
	Enam.style.visibility = "visible"; 
	Enam.style.left = abc+15+"px";
	Enam.style.top = bcd+"px";
	Enam.style.width = "auto";
	Enam.style.height = "auto";
	Enam.style.padding = padd+"px";
	memory.pad = padd;
	memory._on = true; 
	padd = 0;

}

function hide() {

	var Enam = document.getElementById("popup");
	Enam.innerHTML = "";
	Enam.style.display = "block";
	Enam.style.visibility = "hidden";
	Enam.style.left = "0px";
	Enam.style.top = "0px"
	Enam.style.padding = "0px";
	memory._on = false;

}

// ---------------------------

function move() {

	if ( memory._on == true ) {

		var Enam = document.getElementById("popup");
		screen_x = window.innerWidth ? window.innerWidth : document.body.clientWidth;
		screen_y = window.innerHeight ? window.innerHeight : document.body.clientHeight;
		left_v = (screen_x/2) - (memory.we+memory.pad)/2;
		top_v = document.documentElement.scrollTop + 50;
		Enam.style.left = left_v+15+"px";
		Enam.style.top = top_v+"px";
	
	}

}

function scrul() {

	if ( document.documentElement.scrollTop != memory._y || document.documentElement.scrollLeft != memory._x) {
	
		move();
	
	}
	
	memory._x = document.documentElement.scrollLeft;
	memory._y = document.documentElement.scrollTop;
	setTimeout('scrul();', 50);
	

}
function showpage() {
 document.getElementById('loader').style.display = "none"; 
 document.getElementById('content').style.display = "block"; 
}

// ---------------------------


window.onresize = function() { move(); }

// ----------------------

window.onload = function() { 

	scrul();
	jsHelp();
	showpage();
	
}

