var lightboxAction = 0;


var win;
function WinPrint(myVI,myVL,myId){
var wt=400;
var ht=100;
var lt=(screen.width/2)-(wt/2);
var tp=(screen.height/2)-(ht/2);

win=window.open("print/index.php?VSingle="+myVI+"&VL="+myVL, "id","status=yes, scrollbars=yes,menubars=no,resizable=yes,toolbars=no,height="+ht+",width="+wt+",top="+tp+",left="+lt)
win.focus;
}

function printer()
{
this.print();
this.close();



}


 function getPageSize() {

	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
//return [pageHeight];
		return [pageWidth,pageHeight];
	}



function initBackground(){

document.getElementById("boxMainJs").style.height = getPageSize() +"px";

}



function ActionResizeClose(myId, myName) {

lightboxAction=0;

document.getElementById("boxScreenAlpha").style.height = 0+"px";

document.getElementById("boxScreenAlpha").style.width = 0+"px";

document.getElementById("boxScreenContent").style.display = "none";



}



function ActionResize(myImageId,myId, myName,myType) {



initLightbox(1)





//ActionDisplay(myImageId, myId, myName,0,myType);



}















function createRequestObject() {

    var ro;

    var browser = navigator.appName;

    if(browser == "Microsoft Internet Explorer") {

        ro = new ActiveXObject("Microsoft.XMLHTTP");

    } else {

        ro = new XMLHttpRequest();

    }

    return ro;

}

var http = createRequestObject();





function ActionDisplay(myImageId, myId, myName, myStatus,myType) {



DivOut = "boxScreenContent";




  http.open('POST','ajax/AjaxGallery.php');

 http.onreadystatechange = handleResponse;

 http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

 http.send('AjVal=jdfeiUU56e3reww');



}

function  handleResponse() {

    if(http.readyState == 4){

        var response = http.responseText;

//alert(http.getAllResponseHeaders()  )  

      

        var update = new Array();

         

       if(response.indexOf('|' != -1)) {

            update = response.split('|');





//alert(DivOut)

//alert(response)



}

document.getElementById(DivOut).innerHTML = response; 

	}
}



function initLightbox(myType) {

var myType=1;


if(myType==1) {
	lightboxAction = 1;
//ActionDisplay();

}


document.getElementById("boxScreenContent").style.top = 120+"px";
document.getElementById("boxScreenContent").style.left = 120+"px";

document.getElementById("boxScreenContent").style.height = 250 +"px"; 
document.getElementById("boxScreenContent").style.width = 300+"px";


if(lightboxAction==1) {


document.getElementById("boxScreenAlpha").style.top = 140+"px";
document.getElementById("boxScreenAlpha").style.left = 198+"px";

document.getElementById("boxScreenAlpha").style.height = 500 +"px"; 
document.getElementById("boxScreenAlpha").style.width = 840+"px";


}


}







var varCountDown = 1;


function refreshStatus(varCountup)
{

varCountDown = varCountDown +varCountup;

countdown = "<div style=\"background-color:#0079B0; margin-top:1px; height:13px; width:"+varCountDown+"px;\"></div>";

document.getElementById("boxRefreshStatus").innerHTML = countdown;

if(varCountDown > 139)
{
alert(varCountDown)


//document.myformActivate.submit();
}
}



function startStatus()
{
setInterval("refreshStatus(1)",172)
}












function clearImage(mydiv)
{

window.document.myform.frm_bild.value = '';
document.getElementById(mydiv).innerHTML = "";

  
}


function translater()
{

VarUrlText = document.myform.frm_content.value



breite = 410;
hoehe = 200;
// Errechnet Koordinaten, um das Popup zentriert zu platzieren
      links = (screen.width/2)-(breite/2);
      oben = (screen.height/2)-(hoehe/2);

window.open("http://translate.google.com/translate_t?text="+VarUrlText+"&langpair=de|fr","mywin","height="+hoehe+",width="+breite+",status = yes,toolbar = no,menubar = no,location = no,resizable = no,titlebar = no,scrollbars = no,fullscreen = no,top ="+oben+",left ="+links)
//http://translate.google.com/translate_t?text=apple&langpair=en|de

}




function dialog(mytype,myname, myurl,mystatus)
{
if(mytype == 0)
 {

if(mystatus == 1)
{
abfrage=confirm("Soll «"+ myname + "» ausgeblendet werden ?")
 }
else
 {
abfrage=confirm("Soll «"+ myname + "» eingeblendet werden?")
 
 }
 }
else

{
abfrage=confirm("Soll «"+ myname + "» gelöscht werden?")
}
if(!abfrage)
{return (false)}
else{location.href=myurl;
}
}


var win;
function winOpen(url,wt,ht) {
lt=(screen.width/2)-(wt/2);
tp=(screen.height/2)-(ht/2);


win=window.open(url, "id","status=yes, scrollbars=yes,menubars=no,resizable=yes,toolbars=no,height="+ht+",width="+wt+",top="+tp+",left="+lt)
win.focus;

}




/////////////////////// 
///////////////////////
///////////////////////
///////////////////////
////CHeckboX FUNCZION
function checkAll(elm,name){
 for (var i = 0; i < elm.form.elements.length; i++)
  	if (elm.form.elements[i].name.indexOf(name) == 0)
	    elm.form.elements[i].checked = elm.checked;
}


/////////////////////// 
///////////////////////
///////////////////////
///////////////////////
////SEND NEWSLETTER
function sender(mytype,myname, myurl,mystatus)
{

abfrage=confirm("Soll der Newsletter «"+ myname + "» jetzt versandt werden ?")


if(!abfrage)
{return (false)}
else{location.href=myurl;
}


}





function myCopy(a, b)
	{
if(document.myform[b].value != "")
{
document.myform[a].value = document.myform[b].value;
}
}




/////////////////////// 
///////////////////////
///////////////////////
///////////////////////
////DOK FUNCZION
function mydok(myid,name, dat_name)
	{
	
		if (window.opener && !window.opener.closed)
{
if(myid == "hl")
{
			window.opener.document.myform.frm_dokumente.value = dat_name;
			window.close();

}
	}
		}


/////////////////////// 
///////////////////////
///////////////////////
///////////////////////
////Bild FUNCZION


function mybild(myid, name)
	{
	
	
		if (window.opener && !window.opener.closed)
{
if(myid == "hl")
{

window.opener.document.getElementById("adminBoxImage").innerHTML = "<img src=\"../img/up/"+name+"\">";

			window.opener.document.myform.frm_bild.value = name;
			window.close();
}
	}
		}








/////////////////////// 
///////////////////////
///////////////////////
///////////////////////
////VERWEIS FUNCZION
function mylink(myid, name,il, realname,ref)
	{
	
if(myid == "single")

{
eingabe=prompt("Bitte Name des Verweises eingeben - default ist link",realname)

old = window.opener.document.myform[ref].value + "\n" 



if(eingabe ==""  || eingabe == null)
{
eingabe = "link"
}

if(il == "dl")
{
notold = "[dlk="+ name +"]"+ eingabe +"[/dlk]";
}
else if(il == "il")
{
notold = "[ilk="+ name +"]"+ eingabe +"[/ilk]";
}
else
{
notold = "[lk="+ name +"]"+ eingabe +"[/lk]";
}

window.opener.document.myform[ref].value = old + notold
	window.close();


}
}


/////////////////////// BOLD
///////////////////////
///////////////////////
///////////////////////
function bold(myvar)
{
old=document.myform[myvar].value
eingabe=prompt("Bitte hier den zu bearbeitenden Text eingeben (Fett)","")

if(eingabe)

{ if(eingabe!="")
{
fett="[b]"+eingabe+"[/b]";
document.myform[myvar].value=old+ " "+ fett
}
}}



/////////////////////// ITALIC
///////////////////////
///////////////////////
///////////////////////
function italic(myvar)
{
old=document.myform[myvar].value
eingabe=prompt("Bitte hier den zu bearbeitenden Text eingeben (Italic)","")

if(eingabe)

{ if(eingabe!="")
{
fett="[i]"+eingabe+"[/i]";
document.myform[myvar].value=old+ " "+ fett
}
}}



/////////////////////// URL LINK
///////////////////////
///////////////////////
///////////////////////
function link(myvar)
{
old=document.myform[myvar].value
eingabe=prompt("Bitte hier die URL( z.b. www.sbb.ch)  eingeben","")
eingabel=prompt("Bitte hier den Namen eingeben (Optional)","")

if(eingabe)
{

if(eingabe.substr(0,7) == "http://")
{
eingabe = eingabe.substr(7,22222)
alert(eingabe)
}


if (eingabel == "")
{eingabel = eingabe}
fett="[url="+eingabe+"]"+eingabel+"[/url]";
document.myform[myvar].value=old+ " "+ fett
}}





////DELETE FUNCZION
function dialog3(dest,mytext,destfalse)
{

abfrage=confirm(mytext)

if(!abfrage)
{

location.href=destfalse
}
else{location.href=dest
}
}




function initLightbox(myType) {
var arrayPageSize = this.getPageSize();

		var height = arrayPageSize[1];
		var width = arrayPageSize[0];


		if(myType==1) {
			lightboxAction = 1;
		}

		//document.getElementById("boxScreenContent").style.top = getScrollXY()+"px";





if(lightboxAction==1) {



    var browser = navigator.appName;

    if(browser == "Microsoft Internet Explorer") {
            //document.getElementById("boxScreenAlpha").style.height = document.body.offsetHeight+"px";
    } else {
            
//var height = window.innerHeight;
if( window.scrollMaxY){
//height += window.scrollMaxY;

}




    
}



document.getElementById("boxScreenAlpha").style.top = 0 +"px";
document.getElementById("boxScreenAlpha").style.left = 0 +"px";
document.getElementById("boxScreenAlpha").style.height = height +"px";


document.getElementById("boxScreenContent").style.top = 120+"px";
document.getElementById("boxScreenContent").style.left =  parseInt((width/2)-150)+"px";

document.getElementById("boxScreenContent").style.height = 250 +"px"; 
document.getElementById("boxScreenContent").style.width = 300+"px";


//document.getElementById("boxScreenAlpha").style.width = 590+"px";
document.getElementById("boxScreenAlpha").style.width =  (width)+"px";



window.scrollTo(0,0);









var t = (height/2)-265;

var l = (document.body.offsetWidth/2)-360;





document.getElementById("boxScreenContent").style.display = "block";

}

}

window.onresize = initLightbox; 
//window.onload=initBackground;
