// JavaScript Document

function addEvent(element, event, listener)
{
	if (event == 'load' && (navigator.userAgent.indexOf('Gecko/') != -1 ||
		typeof window.opera == 'object' && parseInt(window.opera.version()) > 8))
	{
		event = 'DOMContentLoaded';
	}

	if (typeof window.addEventListener != 'undefined')
	{
		element.addEventListener(event, listener, false);
	}
	else if (typeof window.attachEvent != 'undefined')
	{
		element.attachEvent('on' + event, listener);
	}
}

function redirectOnAccessKeyPress(e)
{
	var charCode = typeof e.charCode != "undefined" ? e.charCode : e.keyCode;
	var character = String.fromCharCode(charCode).toLowerCase();

	var anchors = document.getElementsByTagName("a");
	for (var i = 0; i < anchors.length; i++)
	{
		if (anchors[i].getAttribute("accesskey") == character)
		{
			document.location = anchors[i].href;
			if (typeof e.preventDefault != "undefined")
			{
				e.preventDefault();
			}
			break;
		}
	}
}

addEvent(document, "keypress", redirectOnAccessKeyPress);


/* Profiseller */
var newwin;
function callURL_dsl_468x60()
{
	newwin = window.open("http://www.profiseller.de/shop1/mega/index.php3?shop=10&ps_id=P3365973");
}
/* Profiseller */

function cg_bg(el,cl) {
	tmp = document.getElementById(el);
	tmp.className = cl;
}

function display_div(id,sty) {
	document.getElementById(id).style.display=sty; 
}

// JavaScript Document
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function update_count(i) {
	document.getElementById("count_value").innerHTML = i;
}

function show_help(id) {

	switch(id) {
		
		case "4": // Admin Modul User
		alert('Wenn Sie dieses Feld leer lassen, bleibt das alte Passwort bestehen');
		break;
		
		case "6": // Admin Modul Einstellungen
		alert('Dieses Feld kann nicht editiert werden. Diese Information wurde vom Webmaster und Programmierer festgelegt.');
		break;
		
		case "8": // Admin Modul Einstellungen
		alert('Dies ist nicht die gleiche Emailadresse wie im Impressum. Diese EMail wird zum versenden von Mails benutzt. Die Emailadresse muss vorhanden sein, da dort Antwortmails eintreffen können.');
		break;
				
		default:
		alert('Es ist ein ein Fehler im System entstanden, bitte kontaktieren Sie den Administrator der Homepage');
		break;
	}


}

function open_image_big(id,w,h) {
	w = w + 2;
	h = h + 2;
	window.open("includes/show_pic.php?id="+id, "pic", "width="+w+",height="+h+"");
}

function check_form() {
	var f = document.form1;
	if (f.nachname.value == "") {
		alert("Bitte geben Sie den Nachnamen ein.");
		return false;
	}
	if (f.vorname.value == "") {
		alert("Bitte geben Sie den Vornamen ein.");
		return false;
	}
	/*if (f.firma.value == "") {
		alert("Bitte geben Sie Ihre Firma ein.");
		return false;
	}*/
	if (f.email.value == "") {
		alert("Bitte geben Sie Ihre Emailadresse ein.");
		return false;
	}
	if (f.text.value == "") {
		alert("Bitte geben Sie Ihren Text ein.");
		return false;
	}
	
	f.submit();
}


function hide_div(l) {
  if (document.getElementById(l)) {
    document.getElementById(l).style.display = "none";
  }
}
function clear_coord(l) {
	//automatically hide
	// hide_div(l)
  document.onmousedown = null;
}

var flv_id = "";
function save_coord(id) {
  flv_id = id
	document.onmousedown = prepare_data;
}

var xcoord = null;
var ycoord = null;
function prepare_data(e) {
  if( !e ) { ; e = window.event; }
  if( !e ) { return; }

  if( typeof( e.pageX ) == 'number' ) {
    //most browsers
    xcoord = e.pageX;
    ycoord = e.pageY;
  } else if( typeof( e.clientX ) == 'number' ) {
    //Internet Explorer and older browsers
    //other browsers provide this, but follow the pageX/Y branch
    xcoord = e.clientX;
    ycoord = e.clientY;
    var badOldBrowser = ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) ||
     ( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ||
     ( navigator.vendor == 'KDE' );
    if( !badOldBrowser ) {
      if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        //IE 4, 5 & 6 (in non-standards compliant mode)
        xcoord += document.body.scrollLeft;
        ycoord += document.body.scrollTop;
      } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        //IE 6 (in standards compliant mode)
        xcoord += document.documentElement.scrollLeft;
        ycoord += document.documentElement.scrollTop;
      }
    }
  } else {
    //total failure, we have no way of obtaining the mouse coordinates
    return;
  }
  
  xcoord = xcoord + 20;
  ycoord = ycoord + 20;
  
  if (!$('flv_div')) {
    alert("Dieser Film ist nicht vorhanden.");
    return false;
  }
  
  // GET DATA per AJAX
  ret = get_flv_content(flv_id);
  if (ret == false) {
    alert("breche hier ab");
    return false;
  }
}

var flv_width = 0;
var flv_height = 0;

function alertCoord(w, h) {

  div_h = parseInt(h);
  div_w = parseInt(w);
  
  sw = screen.availWidth - 150;
  sh = screen.availHeight - 150;

  if ((xcoord + div_w) > sw) {
    xcoord = sw - div_w - 100;
    if (xcoord <= 100) {
      xcoord = 100;
    }
  }

  if ((ycoord + div_h) > sh) {
    ycoord = sh - div_h - 100;
    if (ycoord <= 50) {
    	ycoord = 50;
    }
  }

  // display Layer
  $('flv_div').setStyle({ 
  	display: "block", 
  	left: xcoord+"px", 
  	top: ycoord+"px" 
  });

}
