var popUp1;
var popUp2;
var popUp3;
var styleToSelect;

function LayerPos(Ereignis)
{
 alert(Ereignis.pageX);
 alert(Ereignis.pageY);
}  

function onOk() {
  alert("onOK()");
}

function SendeEintrag(from, to, entryType, entryId) {
  //alert("Hallo");
  ret = HorseATPortal.WebServices.EmailWebService.SendEntryPerMail(from, to, entryType, entryId, OnComplete, OnTimeOut, OnError);
  return(true);
}

function OnComplete(arg) {
  alert(arg);
}

function OnTimeOut(arg) {
  alert("TimeOut beim Ausführen der Funktion");
}

function OnError(arg) {
  alert("Fehler beim Ausführen der Funktion.");
}

function OpenCalendar(idname, postBack){
  //alert(document.forms[0].elements[idname].offsetX)
	//alert(document.forms[0].elements[idname].value)
	popUp = window.open('../Utility/Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=165,height=270,left=200,top=250');
}

function SetDate(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	if (postBack){
		__doPostBack(id,'');
	}
}		

function OpenEintrag(url, name, postBack, send, print, width, height){
  //alert(url);
  Telligent_Modal.Open(url + '&send='+ send +'&postBack=' + postBack + '&print=' + print,width,height,postBack); 
}

function OpenVideo(fileName){
  //alert("fileName: " + fileName);
	Telligent_Modal.Open('http://www.ich-habe-ein-pferd.com/Video/FAVideo/default.aspx?video=' + fileName, 335, 268, false); 
}

function OpenEintrag_original(url, name, postBack, send, print, width, height){
    //alert("Hallo");
    //alert("OpenEintrag: url=" + url + " / name: " + name + " / width: " + width + " / height: " + height + " / postBack: " + postBack + " / print: " + print + " / send: " + send );
	  popUp1 = window.open( url + '&send='+ send +'&postBack=' + postBack + '&print=' + print , 
	    "Eintrag", "width=" + width + ",height=" + height + ",left=10,top=10,scrollbars=1,toolbars=no,menubar=no,resizeable=1");
				
		popUp1.focus();
}

function OpenEintrag_old(url, merklistenId, postBack, print, send, width, height){
    //alert("Hallo");
		//alert("OpenEintrag: url=" + url + " / postBack: " + postBack + " / print: " + print + " / send: " + send )
	  popUp1 = window.open( url + '&MerklistenID=' + merklistenId + '&send='+ send +'&postBack=' + postBack + '&print=' + print +
		',width='+width+',height='+height+',left=10,top=10,scrollbars=1');
				
		popUp1.focus();
}

function OpenModalWindow(url){
  //alert("OpenModalWindow(url):" + url);
  Telligent_Modal.Open(url, 800, 600, true); 
  return false;
}

function OpenModalWindow(url, width, height){
  //alert(" OpenModalWindow(url, width, height): " + url + ", width:" + width + ", height:" + height);
  
  if(typeof(width) == "undefined"){
    width=800;
  }
  
  if(typeof(height) == "undefined"){
    height=600;
  }

  Telligent_Modal.Open(url, Number(width), Number(height), refreshURL); 
  return false;
}

function OpenStatistik(url, settingId, eintragTyp){	
  Telligent_Modal.Open(url + '?EntryID=' + settingId + '&EntryType=' + eintragTyp, 800, 600, false); 
}

function OpenEntryDelete(settingId, eintragTyp){
  Telligent_Modal.Open('../Member/EntryDelete.aspx?EntryID=' + settingId + '&EntryType=' + eintragTyp, 400, 400, refresh);
  return false;
}

function OpenEntryDuplicate(url){
  Telligent_Modal.Open(url, 800, 400, refreshURL);
  return false;
}

function OpenStatistik_old(url, settingId, eintragTyp){	
		//alert(url + " - " + settingId + " / " + eintragTyp + " / " )
	  popUp1 = window.open( url + '?EntryID=' + settingId + '&EntryTyp=' + eintragTyp 
		, 'Statistik'+settingId+''
		, 'width=800,height=600,left=10,top=10,scrollbars=1,resizable=yes');
		
		popUp1.focus();
}

function OpenImage(imgUrl){	
		//alert(imgUrl)
	  popUp1 = window.open( imgUrl 
		, 'Bild', 'width=500,height=500,left=10,top=10,scrollbars=1');
		popUp1.focus();
}

function addToMerkliste(eintragID, eintragTyp, merklistenID, clearFavs) {
  //alert("eintragID=" + eintragID + " / eintragTyp=" + eintragTyp + " / merklistenID" + merklistenID + " / clearFavs=" + clearFavs + " / " )
  if (document.all && !document.getElementById) document.getElementById = document.all;
  
  if(document.getElementById("universalFrame") == null){
		alert("Diese Funktion steht Ihnen nicht zur Verfügung!");
		return false;
	}
	
  if(clearFavs){
    if (confirm("Soll dieser Beitrag wirklich von Ihrer Merkliste entfernt werden?")){
      if(document.getElementById("universalFrame") != null){
        try{
          var frame = document.getElementById("universalFrame");
          frame.src = "http://www.ich-habe-ein-pferd.com/utility/AddToMerkliste.aspx?EntryID="+eintragID+'&EntryType='+eintragTyp+'&MerklistenID='+merklistenID+'&clearFavs='+clearFavs+'';
        }catch(Exception){
          alert("Fehler");
          return false;
        }
      }
    }
  }else{
    if (confirm("Soll dieser Beitrag Ihrer Merkliste hinzugefuegt werden? \n\r")){
      /*alert("universalFrame vorhanden? " + document.getElementById("universalFrame") != null)*/
      if(document.getElementById("universalFrame") != null){
        try{
        if(document.getElementById("universalFrame") == null){
        		alert("Diese Funktion steht Ihnen nicht zur Verfügung!")
        		return false;
        	}
        var frame = document.getElementById("universalFrame");
        frame.src = "http://www.ich-habe-ein-pferd.com/utility/AddToMerkliste.aspx?EntryID="+eintragID+'&EntryType='+eintragTyp+'&MerklistenID='+merklistenID+'&clearFavs='+clearFavs+'';
        //alert(document.getElementById("universalFrame").src);
        }catch(Exception){
          alert("Fehler");
          return false;
        }
      }
    }
  } 
}

function textCounter(field, countfield, maxlimit){
  //alert(field.value.length + " - " + maxlimit)
	if(field.value.length > maxlimit)
	 field.value = field.value.substring(0, maxlimit);
	else
	 countfield.value = maxlimit - field.value.length;
}

function FTP_SignCount(object){        
  //alert(":::" + object);    
  var iSumSign = 0;         
  iSumSign = object.value.length;    
  alert("Textlänge: " + iSumSign + " Zeichen");
}

function FTP_WordCount(object){
  //alert(":::" + object);
  var iSumWords = 0;
  var rng = object.createTextRange();
  rng.collapse(true);
  while(rng.move("word", 1)){      
    iSumWords++;
  }
  alert("Textlänge: " + iSumWords + " Worte");
}