var DHTML=0, DOM=0, MS=0, NS=0, OP=0;

var Pics=new Array();
var ImgNr;
var oldImg;
var blendings=0;
var blendingsDyn=0;

function DHTML_init(){
	if(window.opera){OP=1;}
	if(document.getElementById){DHTML=1;DOM=1;}
	if(document.all && !OP){DHTML=1;MS=1;}
	if(window.netscape && window.screen && !DOM && !OP){DHTML=1;NS=1;}
}


function oID(ID){
	if(DOM){if(typeof document.getElementById(ID)=='object')return(document.getElementById(ID)); else return(void(0));
	}else if(MS){if(typeof document.all[ID]=='object')return(document.all[ID]);else return(void(0));
	}else if(NS){if(typeof document[ID]=='object')return(document[ID]);else return(void(0));}
}
function oName(p2){
	if(DOM){if(typeof document.getElementsByName(p2)=="object")return(document.getElementsByName(p2)[0]);	else return(void(0));
	}else if(MS){if(typeof document[p2]=="object")return(document[p2]);	else return(void(0));
	}else if(NS){if(typeof document[p2]=="object")return(document[p2]);	else return(void(0));}
}
DHTML_init();

function myOnload(){
	oWin.init();
	var isPrinting=window.location.search;
	if(isPrinting.search(/print=1/) == -1){
		oID("bodyId").scroll="no";
		oID("outerWrapper").style.display="none";
		oID("outerWrapper").style.height=(parseInt(oWin.Height)-50)+"px";
		oID("outerWrapper").style.display="block";
		oID("content").style.height=(parseInt(oWin.Height)-370)+"px";
		oID("printIcon").style.display='block';
		window.setTimeout('Anim()',1000);
	}1
	oID("impressum").style.top=(parseInt(oWin.Height)-25)+"px";
	window.onresize=myOnload;
}
function Anim(){
	if(oWin.mPics.length > 1){
		oWin.curImgNr=0;
		ImageChanger(0)
	}
}
function GetPics(){
}
function oWIN(){
	this.Width;
	this.Height;
	this.mPics;
	this.curImgNr;
	this.init=_oWIN_init;
	this.AddPic=_oWIN_AddPic;
}

function _oWIN_init(){
	if((document.all)&&!OP){
		this.Width=document.all.bodyId.offsetWidth;
		this.Height=document.all.bodyId.offsetHeight;
	}else{
		this.Width=window.innerWidth;
		this.Height=window.innerHeight;
	}
	if(typeof this.Width=="string")this.Width=parseInt(this.Width);
	if(typeof this.Height=="string")this.Height=parseInt(this.Height);
}

function _oWIN_AddPic(Pic){
	oWin.mPics[oWin.mPics.length]=Pic;
}

function Impressum(){
	var iW=240,iH=320,iX=((screen.availWidth-iW-10)/2),iY=((screen.availHeight-iH-50)/2);
	wProp="titlebar=yes,toolbar=no,resizable=yes,scrollbars=no,status=no,menubar=no,height="+
			""+iH+",width="+iW+",screenX="+iX+",screenY="+iY+",left="+iX+",top="+iY;
	kontakt=window.open("./d_Impressum.php","Impressum",wProp);
	oID("Atarget").href="javascript:kontakt.focus()";
	oID("Atarget").click();
}

function noFlesh(obj){
obj.style.backgroundImage='none';
obj.style.paddingLeft='0px';
}

function butClicked(newsCat){
	oID('tx_ttnews[cat]').value=newsCat;
	oID('newscat').value=newsCat;
	oID('cHash').value=newsCat;
	document.FrmAnmeldung.submit();
}

function ImageChanger(ImgNr){
//	ImgNr=1+Math.floor(Math.random()*3);
	ImgInt=8000+Math.floor(Math.random()*25000);
	ImgInt=8000;
	oWin.curImgNr=ImgNr;
	if(oWin.curImgNr == (oWin.mPics.length-1))oWin.curImgNr=-1;
	ImgNr=oWin.curImgNr;
	window.setTimeout('ImageBlender('+(ImgNr+1)+')',ImgInt);
	if(ImgNr != oldImg){
	}else{
//		ImageBlender(ImgNr+1);
	}
}
function ImageBlender(ImgNr){
	oldImg = ImgNr;
	if((blendings % 2)==0){
		blendimage('imgM1','imgM2', 'fileadmin/Pictures/Menu/'+oWin.mPics[ImgNr],2000)
	}else{
		blendimage('imgM2','imgM1', 'fileadmin/Pictures/Menu/'+oWin.mPics[ImgNr],2000)
	}
	blendings+=1;
	ImageChanger(ImgNr)
}

function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
		if(opacity <= 0){
//			object.display='none';
		}else{
//			object.display='block';
		}		
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = 'alpha(opacity=' + opacity + ')';
}
function blendimage(OUTimageid, INimageid, imagefile, millisec) {
	if((oID(OUTimageid).filters)&&(oID(OUTimageid).filters['alpha'].opacity==='')){
//		oID(OUTimageid).style.display='none';
		oID(INimageid).src=imagefile;
//		oID(INimageid).style.display='block';
	}else{
    var speed = Math.round(millisec / 100);
    var timer = 0;
    changeOpac(0, INimageid);
    document.getElementById(INimageid).src = imagefile;
    for(i = 2; i <= 98; i=i+2) {
        setTimeout('changeOpac(' + i + ',\"' + INimageid + '\")',(timer * speed));
        setTimeout('changeOpac(' + (98-i) + ',\"' + OUTimageid + '\")',(timer * speed));
        timer+=2;
    }
    timer = 0;
	}
}
function echeck(str) {
	var at='@';
	var dot='.'
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){return false}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){return false}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){return false}
	if (str.indexOf(at,(lat+1))!=-1){return false}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){return false}
	if (str.indexOf(dot,(lat+2))==-1){return false}
	if (str.indexOf(' ')!=-1){return false}
 		return (true)					
}
function formSubmit(){
	strError = '';
	if((oID('password').value == '') || (oID('password').value != oID('passwordconf').value) ){
		strError += '£- Password and confirmation do not match or are empty';
	}
	alert(1)
	if (!echeck(oID('email').value)) {
		strError = strError + "£- Username is not a valid E-mail-address";
	}
	if (oID('famname').value == ''){
		strError = strError + "£- Family Name is required";
	}
	if (oID('address').value == ''){
		strError = strError + "£- Street Address is required";
	}
	if (oID('postalcode').value == ''){
		strError = strError + "£- Postal Code is required";
	}
	if (oID('town').value == ''){
		strError = strError + "£- Town is required";
	}
	if ( (oID('emailparent1').value != '') && (!echeck(oID('emailparent1').value))) {
		strError = strError + "£- Primary E-mail Address is not valid";
	}
	if ( (oID('emailparent2').value != '') && (!echeck(oID('emailparent2').value))) {
		strError = strError + "£- Secundary E-mail Address is not valid";
	}
	if ((oID('emailparent1').value+oID('emailparent2').value) == ''){
		strError = strError + "£- Enter at least 1 E-mail Address";
	}
	
	if(strError == ''){
		oID('frmStudTime').submit();
	}else{
//		oID('frmStudTime').submit();
		strError = strError.replace(/£/g,'\n')
		alert(strError)
	}
}
function myformSubmit(){
//alert(oID('frmStudTime'))
	formSubmit()
}
