var filenumber;
var filenumber2;

function getBrowserWindowSize()
{
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' )
{
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
}
else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
{
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
}
else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
{
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}

alert ("myWidth: " + myWidth + " myHeight: " + myHeight );

return {width:myWidth, height:myHeight};
}

function submitHitparade () {
  // alert ("submitHitparade");
  // alert ( "kantongruppe obj: " + document.forms[0].kantongruppe );

  var kantongruppe = document.forms[0].kantongruppe.value;

  // alert ( "kantongruppe: " + kantongruppe );

   if ( kantongruppe=="0" || kantongruppe=="") {
     alert ("Erg\344nzen Sie die Region");
     document.forms[0].kantongruppe.focus();
     return false;
   }
  
  var yearslistselect = document.forms[0].yearslistselect.value;
  // alert ( "yearslistselect: " + yearslistselect );

   if ( yearslistselect=="0") {
     alert ("Erg\344nzen Sie das Jahr");
     document.forms[0].yearslistselect.focus();
     return false;
   }


   // 2009,de.html
   strAction = yearslistselect + "," + kantongruppe + ".html";
  //  alert("strAction: " + strAction);
   
   
   document.forms[0].action=strAction;
   document.forms[0].submit();
  
}



function refreshYearsList () {
 //  alert ("refreshYearsList test ff ie");



  var kantongruppe = document.forms[0].kantongruppe.value;
  
  // alert ( "kantongruppe: " + kantongruppe );
  if ( kantongruppe == 0 ) {
    return false;
  }
  

// Remove previos select
var myPara=document.getElementById("yearslist");
myselect=document.getElementById("yearslistselect");
// alert ("myselect: " + myselect );

if ( myselect!= null ) {
   myPara.removeChild(myselect);
}


// Build new select
  // de: 2000-2009
  // fr: 2007-2009
  // it: 2007-2009

//  theText=document.createTextNode("Erg\344anzen Sie das Jahr");
//  myPara.appendChild(theText); 

  
  var yearfrom = 2007;
  var yearto = 2009;
  
  if ( kantongruppe == "de" ) {
     var yearfrom = 2000;
  }

  // Build select
  myselect = document.createElement("select");
  myselect.setAttribute("id","yearslistselect");
  myselect.setAttribute("name","yearslistselect");



  theOption=document.createElement("OPTION");
  theText=document.createTextNode("Jahr w\344hlen");
  theOption.appendChild(theText);
  theOption.setAttribute("value","0");

  myselect.appendChild(theOption);
  
  
  
  for ( i=yearfrom; i <= yearto; i++) {
	  theOption=document.createElement("OPTION");
	  theText=document.createTextNode(i);
	  theOption.appendChild(theText);
	  theOption.setAttribute("value",i);
	  
	  myselect.appendChild(theOption);
  }
  
  
  myPara.appendChild(myselect); 
  
  // objSelect.add(objOption);}
  
}


function buildLinkUrl (hreflink) {

  // alert ("buildLinkUrl hreflink: " + hreflink);
  // hreflink = hreflink.replace(" ","_");
  hreflink = hreflink.replace(/ /g,"_");
  // alert ("buildLinkUrl hreflink reemplazado: " + hreflink);
  
  return hreflink;
  
}


function emailvalidation(entered, alertbox)
{
with (entered)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}


function launchCenter(url, name, height, width) {

 // alert ( "launchCenter url: " + url);
  // alert ( "launchCenter2");
 
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }

  // alert ( "launchCenter3");
  window.open(url, name, str);

  
  return;
}




function validateSendEmail() {

        // alert ("validateSendEmail2");



   var namesender =document.forms[0].namesender.value;
   
   if ( namesender == "" ) {
     alert ("Sie sollen Ihre Name erg\344nzen");
     document.forms[0].namesender.focus();
     return false;
   }


   var nameempfanger =document.forms[0].nameempfanger.value;
   
   if ( nameempfanger == "" ) {
     alert ("Sie sollen die Name des Empfangers erg\344nzen");
     document.forms[0].nameempfanger.focus();
     return false;
   }


	// Email
	var emailempfanger =document.forms[0].emailempfanger;

        
	 if ( emailempfanger.value == "" ) {
	     alert ("Sie sollen Ihre Email erg\344nzen");
	     document.forms[0].emailempfanger.focus();
	     return false;
  	 } 

	if (emailvalidation(emailempfanger,"Ihre Email es ist falsch")==false) 
	{document.forms[0].emailempfanger.focus(); return false;}



   
   if ( document.forms[0].captcha.value == "" ) {
         alert (" Sie sollen captcha erg\344nzen.");
          document.forms[0].captcha.focus();
         return false;
   }
   
   return true;
}



function validateCustomComment() {

   // alert ("validateCustomComment");

   var comments =document.forms[0].comments.value;
   
   if ( comments == "" ) {
     alert ("Sie sollen das Kommentar erg\344nzen");
     return false;
   }
   
   return true;
}

function setSearchbedeutungboxsubmittedValue(value) {
   // alert("setSearchbedeutungboxsubmittedValue1 value: " + value);
   document.forms[0].searchbedeutungboxsubmitted.value = value;
}


function submitSearchBedeutungForm() {
   // alert("submitSearchBedeutungForm2");
   var strAction =document.forms[0].searchbedeutungboxsubmitted.value;
   
   if ( strAction == "0" ) {
     alert ("Sie sollen ein Name w\344hlen");
     return false;
   }
   
   strAction = "name/" + strAction.toLowerCase() + ".html";
   // alert("strAction: " + strAction);
   document.forms[0].action=strAction;
   document.forms[0].submit();
}

function submitHerkunftSpracheForm(prefixdir) {
  
   // alert("submitHerkunftSpracheForm prefixdir: " + prefixdir);
  
   if ( prefixdir == "0" || prefixdir =="undefined" || prefixdir=="") {
     prefixdir = "";
   }

   if ( prefixdir == 1 ) {
     prefixdir = "sprache/";
   }
   var strAction = prefixdir + document.forms[0].searchbedeutungboxsubmitted.value;
   // alert("submitHerkunftSpracheForm strAction: " + strAction);
   
   if ( strAction == "0" ) {
     alert ("Sie sollen eine Sprache w\344hlen");
     return false;
   }
   strAction = strAction.toLowerCase() + ".html";
  // alert("strAction: " + strAction);
   document.forms[0].action=strAction;
   document.forms[0].submit();
}

function submitThemaForm(prefixdir) {
   
   // alert("submitThemaForm prefixdir: " + prefixdir);
  
   if ( prefixdir == "0" || prefixdir =="undefined" || prefixdir=="") {
     prefixdir = "";
   }

   if ( prefixdir == 1 ) {
     prefixdir = "themengebiet/";
   }
   
   // alert ("prefixdir new: " + prefixdir);

   var strAction = document.forms[0].searchbedeutungboxsubmitted.value;
   if ( strAction == "0" ) {
     alert ("Sie sollen ein Thema w\344hlen");
     return false;
   }
   
   var strAction = prefixdir + document.forms[0].searchbedeutungboxsubmitted.value;
   strAction = strAction.toLowerCase() + ".html";
 
   // alert("strAction: " + strAction);
   document.forms[0].action=strAction;
   document.forms[0].submit();
}



function validateDetailsForm() {
   // alert ("validateDetailsForm2");
   
   var searchboxsubmitted = document.detailsform.searchboxsubmitted.value;
   if ( searchboxsubmitted == 1 ) {
     return true;
   }
   
   if ( document.detailsform.name.value == "" ) {
         alert (" Sie sollen name erg\344nzen.");
         document.detailsform.name.focus();
         return false;
   }

   if ( document.detailsform.comments.value == "" ) {
         alert (" Sie sollen comments erg\344nzen.");
         document.detailsform.comments.focus();
         return false;
   }

   if ( document.detailsform.captcha.value == "" ) {
         alert (" Sie sollen captcha erg\344nzen.");
         document.detailsform.captcha.focus();
         return false;
   }

   return true;
}



function updaterating(qtysterne) {
   // alert ("updaterating35");
   // var div = document.getElementById('votes');
   // div.innerHTML="<p>Votes: 35</p>";

   document.detailsform.op.value="updaterating";
   document.detailsform.qtysterne.value=qtysterne;

   // alert ("updaterating35");
   document.detailsform.submit();



}




function handlemousestar(flagfrom, position, qtysterne) {
  // alert("handlemousestar flagfrom: " + flagfrom + " position: " + position + " qtysterne: " + qtysterne);
  if ( flagfrom == 0 ) {
    // document.getElementById(imagename).src=imagefrom;

	for ( i = 1; i <= Math.floor(qtysterne); i ++ ) {
	   imagename = "star" + i;
	   document.getElementById(imagename).src="../images/star.gif";
	}

	// Check if half start will repainted
	if ( position > qtysterne  &&  qtysterne!= Math.floor(qtysterne) ) {

		imagename = "star" + Math.ceil(qtysterne);
		// alert ("with half imagename: " + imagename);
		document.getElementById(imagename).src="../images/star_half.gif";
	}


	// Check if gray starts will also mouse over

	for ( i = (Math.ceil(qtysterne) + 1); i <= position; i ++ ) {
	   //if ( i == Math.ceil(qtysterne) && qtysterne!= Math.floor(qtysterne) ) {
	   //  // skip, it is half star
	   //  continue;
	   // }
	   imagename = "star" + i;
	   // alert ( "imagename: " + imagename );
	   document.getElementById(imagename).src= "../images/star_disabled.gif";
	}


  }
  else {
	// document.getElementById(imagename).src="images/star_over.gif";
	// alert ("p2");
	// alert ( "floor(qtysterne): " + Math.floor(qtysterne) );

	// alert ( "ceil(qtysterne): " + Math.ceil(qtysterne) );

	for ( i = 1; i <= position; i ++ ) {
	   imagename = "star" + i;
	   document.getElementById(imagename).src="../images/star_over.gif";
	}




  }

}

