/*
************************************
************************************
************************************
Kelvin Wong says: Dont steal, share is ok.
************************************
************************************
************************************
*/
/* formular submit */
     var http_request = false;
	 	   var str=""; //important
	   var last="";
	   var con = "";
   function POSTAJAX(url, str) 
   {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html'); //http_request.overrideMimeType('text/xml');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      
      http_request.onreadystatechange = function()
	  {
		   if (http_request.readyState == 4)
		   {
         if (http_request.status == 200)//finish
		 {
            document.getElementById('formular').innerHTML = http_request.responseText;            
         } 
      }
	  }
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", str.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(str);
   }

   function fsubmit(obj) {

for(i=0;i<document.fsubmit.fad.length;i++)
{
str += "fad[]=" + encodeURI(document.fsubmit.fad[i].value)+"&";
}
con = document.fsubmit.contentid.value;
last = str +"content_id="+con;
if(document.fsubmit.fad[0].value ==""){
alert("Name");
}
else
{
      POSTAJAX('http://www.topdix.ch/a/formadd.php', last);
}
	
   }
   /*********/

/* formular add more  */
function addform(id,value)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="http://www.topdix.ch/ajax/formular.php";
	url=url+"?id="+id;
	xmlHttp.onreadystatechange=stateChanged ;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {
	 document.getElementById(id).innerHTML=xmlHttp.responseText;
	 }
}
	xmlHttp.send(null);
}

/* PAGINATION */
function page(value)
{
	if(value!="")window.location = "http://www.topdix.ch/P/"+value;
}

function formularsite(value)
{

	if(value!="")window.location = "http://www.topdix.ch/Events/"+value;

}



/* AGENDA FADE */
function fade(id,i,ie)
{

document.getElementById(id).style.opacity   = '0.'+i;
document.getElementById(id).style.display = '';

	i++;
	if(i < 11)
	{
	window.setTimeout("fade('"+id+"','"+i+"')",150);
	}
	else
	{ 
	document.getElementById(id).style.MozOpacity  = '1.0';
	document.getElementById(id).style.opacity   = '1.0';
	}


}


 function off(id)
 {
	 document.getElementById(id).style.display ='none';
	 	 document.getElementById(id+"hidebox").style.display ='block';

 }
 
  function on(id)
 {
	 document.getElementById(id).style.display ='block';
 	 document.getElementById(id+"hidebox").style.display ='none';
 }
 
 
 function agena_hover(id)
 {
	document.getElementById(id).className ="agena_hover";
 }
 
  
 function agena_none(id)
 {
	document.getElementById(id).className ="agena_none";
 }
 
  function agenda_out(id)
 {
	document.getElementById(id).className ="agenda_out";
 }


 
 
 
 function abbrechen()
  {
    return "Möchtest du trotzdem abbrechen, obwohl die Laden noch nicht fertig ist, abwarten!!!!!?";
  }


function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

/*POST*/
function GetXmlHttpObjectPOST()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

//SEARCH BUTTON only INPUT
function kick()
{
document.cc.submit();
}

function nO(t)
{
document.getElementById(t).className ="navigationl_hover";
document.getElementById(t+"m").className ="navigationm_hover";
document.getElementById(t+"r").className ="navigationr_hover";
}

function no(t)
{
document.getElementById(t).className ="navigationl";
document.getElementById(t+"m").className ="navigationm";
document.getElementById(t+"r").className ="navigationr";
}


function csub() //SUBMIT
{	
	try
	{
	s = Bodys.document.body.innerHTML; //FF
	}
	catch (err)
	{
	s = Box.document.body.innerHTML; //IE
	}	
	dat = s.replace(/\r\n/g,"<br>"); //problem durch youtube url eingeben, kommt immer <br> auch wegen iframe abstand
	document.adminman.content.value = dat;
	document.adminman.submit();
}


function frisch()
{
	window.location=window.location;
}

/* kontakt form */
function ons(id)
{
if(id.texta.value==""){ id.texta.focus(); return false;}
if(id.email.value==""){ id.email.focus();	return false;}
if(id.vorname.value==""){ id.vorname.focus(); return false;}
if(id.name.value==""){ id.name.focus(); return false;}
id.submit();
}



//
// UPLOAD
//
function startUpload(file){
ext = file.slice(file.indexOf(".")).toLowerCase();
if(ext == ".zip")
{
		if(document.hoch.wer.value !="")
		{
			
			if(document.hoch.album.value != "")
			{
				if(document.hoch.email.value!="")
				{
				document.getElementById('f1_upload_process').style.visibility = 'visible';
				document.getElementById('f1_upload_form').style.visibility = 'hidden';
				document.hoch.submit();
				return true;
				}
				else
				{
					alert("Bitte gib deine gültige E-Mail-Adresse ein.");
				}
			}
			else
			{
			alert("Name für Fotoalbum");
			}
		}
		else
		{
		alert("Bitte gibt Deinen Name ein.");
		}

}
else
{
	alert("Bitte wählen Sie eine ZIP-Datei von Ihrem Computer.");
	 
}

}

function stopUpload(success){
      var result = '';
      if (success == 1){
         result = '<span class="msg">Die Datei wurde erfolgreich hochgeladen!<\/span><br/><br/>';
      }
      else {
         result = '<span class="emsg">Es war ein Fehler bei der Datei-Hochladen!<\/span><br/><br/>';
      }
     document.getElementById('f1_upload_process').style.visibility = 'hidden';
     document.getElementById('f1_upload_form').innerHTML = result + '<img src="/i/t/reload.png" onclick="frisch()">';
      document.getElementById('f1_upload_form').style.visibility = 'visible';      
      return true;   
}


//facebook
function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}

//newsletter
function valid()
{
	if(document.news.mad.value == ""){ document.news.mad.focus(); return false; //focus-5.tv??? lol
	}else{ document.news.submit();}
}

//hidde upload
function up()
{
	var x=document.getElementById('up');
	if(x.style.display == "none") x.style.display = 'block'
	else
	x.style.display='none';
}
