var Info;
function popup (which) {
	Info = window.open('?page=phonebook&letter=ALL&action=sms&which='+which, 'Info', 'width=600,height=400,left=0,top=0,scrollbars=yes');
}

//globale Instanz von XMLHttpRequest
var xmlHttp = false;
 
//XMLHttpRequest-Instanz erstellen
//... f�r Internet Explorer
try {
    xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    try {
        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
        xmlHttp  = false;
    }
}

//... f�r Mozilla, Opera, Safari usw.
if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
}

function loadDataStart()
{		
	if (xmlHttp) {	
		   
	    xmlHttp.open('GET', '?page=myVoipways', true);
	    xmlHttp.onreadystatechange = function () {
			    
	        if (xmlHttp.readyState == 4) {			        	
	        		var xmldoc = xmlHttp.responseText;
	        		var Anfang = xmldoc.indexOf('BeginMail'+'BOX')+20;
	        		var Ende   = xmldoc.indexOf('EndMail'+'BOX');
	        		
					var output = xmlHttp.responseText;
					
	        		if(Anfang != -1 && Ende != -1) {
	        			output=xmldoc.substring(Anfang,Ende);
	        			document.getElementById("asb_content").innerHTML = output;	
	        		}
	        }
	    }
	    xmlHttp.send(null);
	}
}

function correctPNG() {
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML		            
            i = i-1
         }
      }
   }    
}

function switchlayer(Layer_Name) {
  var GECKO = document.getElementById? 1:0 ;
  var NS = document.layers? 1:0 ;
  var IE = document.all? 1:0 ;

  if (GECKO)
       {document.getElementById(Layer_Name).style.display=
	   (document.getElementById(Layer_Name).style.display=='block') ? 'none' : 'block';}
  else if (NS)
       {document.layers[Layer_Name].display=(document.layers[Layer_Name].display==
	   'block') ? 'none' : 'block';}
  else if (IE)
       {document.all[Layer_Name].style.display=(document.all[Layer_Name].style.display==
	   'block') ? 'none' : 'block';}
}

function changeButton (id, style) {
	document.getElementById(id).style.background = "url(img/softclient/buttons/button_"+style+".png)";
//	document.getElementById(id).src = style;
}

function toggleStyle(id, fromStyle, toStyle) {
	var style = document.getElementById(id).className;
	var setStyle = (style == fromStyle) ? toStyle : fromStyle;
	
	return document.getElementById(id).className = setStyle; 
}

function changeBGHover (id, eventType) {	
	var getID = document.getElementById(id);
	
	if(!getID.className) {
		return getID.className = 'trHover1'; 
	} else if (getID.className == "trHover2") {
		return getID.className = 'trHover2';
	} else {
		return getID.className = '';
	}	
}
function changeBGClick (id, eventType) {
	var getID = document.getElementById(id);	
	return getID.className = (getID.className == 'trHover2') ? 'trHover1' : 'trHover2';
}

function toggleSlide(divid){	
	document.getElementById(divid).style.display = (document.getElementById(divid).style.display == 'none') ? 'block' : 'none';
	document.getElementById(divid).style.padding = (document.getElementById(divid).style.padding == '8px') ? '0px' : '8px';
}

function calcZeilen(text,width) {
	var hardlines = text.split('\n');
	var total = hardlines.length;
	for (var i=0, len=hardlines.length; i<len; i++) {
//		total += Math.max(Math.round(hardlines[i].length / width), 1);
		total += Math.max(Math.round(hardlines[i].length / width), 1) - 1;
	}
//	alert(total);
	return total;
}

function resizeTextArea (id, rows, parentSite) {
	if(parentSite == true) {
		t = parent.document.getElementById(id);
	} else {
		t = $(id);
	}
	if(calcZeilen(t.value,t.cols) > t.rows) {
		t.rows = Math.round(t.rows+1);
	}
	if(calcZeilen(t.value,t.cols) < rows) {
		t.rows = rows;
	}
}

function textCounter() {

	if($('message').value.length < 160) {
		$('maximalwert').value = 160;
		$('countSMS').value = 1;
	}
	if($('message').value.length > 160 && $('message').value.length < 296) {
		$('maximalwert').value = 296;
		$('countSMS').value = 2;
	}
	if($('message').value.length > 296) {
		$('maximalwert').value = 444;
		$('countSMS').value = 3;
	}
	if($('message').value.length > 444) {
		$('message').value = $('message').value.substring(0,444);
	}

	$('remLength').value = $('message').value.length;
	
	resizeTextArea('message', 12);
	
}

function showANDhide(id) {
	$(id).style.visibility = ($(id).style.visibility == 'visible') ? 'hidden' : 'visible';
}

intImage = 2;
function trunTV (pictureID, pic1, pic2) {
	switch (intImage) {
		case 1:
			$(pictureID).src = pic2
			intImage = 2
			return(false);
		case 2:
			$(pictureID).src = pic1
			intImage = 1
			return(false);
		}

//	$(pictureID).src = ($(pictureID).src == pic1) ? pic2 : pic1;
}