function DoQuery(query, url){
  Check = confirm(query);
	if (Check == false){
		//nix machen
  }else{
		window.location.href =url;
  }
}

function SetPic(Id,Url){
 document.getElementById(Id).src = Url;
}
//Var, welche für jede Id die aktuelle Nr speichert
var IdNrs = new Array();

function SetNextJpg(Id,Name,MaxNr){
//Parameter:
//  Id: Id des Elements, dessen Bild geändert werden soll
//  Name: Namensteil für Datei; [Datei] = [Name] + [Id] + ".jpg"
//        z.B.: wenn [Name]="meinBild", [Datei]= "meinBild1.jpg"
//  MaxNr: die höchste zu vergebende BildNr
//         es wird nicht geprüft, ob eine entsprechende Datei vorhanden ist
//         die Dateien sollten von 1 bis [MaxNr] nummeriert sein
//Anmerkung: Das Bild, dass 'hartkodiert' angegeben wird, sollte das
//           das mit der Nr=1 angegeben werden; es wird davon ausgegangen,
//           dass min. 2 Bilder vorhanden sind!

 if(IdNrs[Id]){
  //Für das Element wurde bereits eine Nr gespeichert
  if(IdNrs[Id]<MaxNr){
   //Nr darf noch erhöht werden
   IdNrs[Id]++;
  }
  else{
   //Wieder am Anfang beginnen
   IdNrs[Id]=1;
  }
 }
 else{
  //Für das Element wurde noch keine Nr gespeichert
  //Mit dem 2. beginnen, da das erste bereits 'hartkodiert' angegeben wurde
  IdNrs[Id]=2;
 }
 document.getElementById(Id).src = Name + IdNrs[Id] + ".jpg";
}

function OpenWindow(url, target, style)
{
 F = window.open(url,target,style);
}

function SetClass(obj, name)
{
  obj.className=name;
}

function SetClassById(Id, name)
{
  e=document.getElementById(Id);
  e.className=name;

}

function SwapClass(obj, name1, name2)
{
 if(obj.className==name1) {obj.className=name2;} else{ obj.className=name1;}
}


function ImgDivAction(divId, divClass, imgId, width, height, name, maxAnz){
 if (divId>''){
  e=document.getElementById(divId);
  SetClass(e,divClass);
 }
 if((width!=0)&&(height!=0)){
  SetSize(imgId,width,height);
 }
 if (name>''){SetNextJpg(imgId,name,maxAnz);}
}

function SetDisplayVisibility(id,dis,vis){
 e=document.getElementById(id);
 if (e) {
  //ANMERKUNG: e.style.setAttribute() geht nicht im Mozilla
  e.style.visibility = vis;
  e.style.display = dis;
 }
}

function HideElement(e){
 if (e) {
  //ANMERKUNG: e.style.setAttribute() geht nicht im Mozilla
  e.style.visibility = "hidden";
  e.style.display = "none";
  //e.style[0]="visibility:hidden";
 }
}

function ShowElement(e){
 if (e) {
  //ANMERKUNG: e.style.setAttribute() geht nicht im Mozilla
  e.style.visibility = "visible";
  e.style.display = "block";
  //e.style[0]="visibility:visible";
 }
}


function ShowById(id){
 e=document.getElementById(id);
 ShowElement(e);
}

function HideById(id){
 e=document.getElementById(id);
 HideElement(e);
}

function BlendInById(id){
 e=document.getElementById(id);
 if (e) {
  //ANMERKUNG: e.style.setAttribute() geht nicht im Mozilla
  e.style.visibility = "visible";
  //e.style[0]="visibility:visible";
 }
}
function BlendOutById(id){
 e=document.getElementById(id);
 if (e) {
  //ANMERKUNG: e.style.setAttribute() geht nicht im Mozilla
  e.style.visibility = "hidden";
  //e.style[0]="visibility:visible";
 }
}

function SetVisibility(id,visible){
 if (visible) {
//  alert("Showing: " + e.id);
	ShowById(id);

 } else {
//  alert("Hiding: " + e.id);
  HideById(id);
 }
}

function SwapVisibility(id){

 e=document.getElementById(id);
 if (e.style.visibility != "hidden") {
   //alert("Hiding: " + e.id);
   HideById(id);
 } else {
   //alert("Showing: " + e.id);
   ShowById(id);
 }
}

function SwapVisibleByIdMatch(startId, mString){
e=document.getElementById(startId);
if(e){
	SwapVisibleByIdMatchRecurse(e,mString);
}
}
function SwapVisibleByIdMatchRecurse(e,mString){
  //alert("ID:" + e.id);
  var k = e.firstChild;
  while (k!=null) {
    SwapVisibleByIdMatchRecurse(k,mString);
    k=k.nextSibling;
  }

	if (e.id){
   if(e.id.indexOf(mString)>=0){SwapVisibility(e.id);}
  }

}


function SetVisibleByIdMatch(startId, mString,doShow){
e=document.getElementById(startId);
if(e){
	SetVisibleByIdMatchRecurse(e,mString,doShow);
}
}

function SetVisibleByIdMatchRecurse(e,mString,doShow){
  //alert("ID:" + e.id);
  var k = e.firstChild;
  while (k!=null) {
    SetVisibleByIdMatchRecurse(k,mString,doShow);
    k=k.nextSibling;
  }

	if (e.id){
   if(e.id.indexOf(mString)>=0){SetVisibility(e.id,doShow);}
  }

}


function SetClassByIdMatch(startId, mString,className){
e=document.getElementById(startId);
if(e){
	SetClassByIdMatchRecurse(e,mString,className);
}
}

function SetClassByIdMatchRecurse(e,mString,className){
  //alert("ID:" + e.id);
  var k = e.firstChild;
  while (k!=null) {
    SetClassByIdMatchRecurse(k,mString,className);
    k=k.nextSibling;
  }

	if (e.id){
   if(e.id.indexOf(mString)>=0){SetClass(e,className);}
  }

}

function SetPosition(id, top, left){
 e=document.getElementById(id);
 e.style.setAttribute("top",top);
 e.style.setAttribute("left",left);
}

function SetSize(id, width, height){
 e=document.getElementById(id);
 //ANmerkung: e.style.setAttribute("width",width) funktioniert unter FireFox nicht
 if(e){
		if(width>"") {e.style.width = width;}
    if(height>"") {e.style.height= height;}
 }
}

function SwapDivById(showId, hideId){
 document.getElementById(showId).style.visibility="visible";
 document.getElementById(hideId).style.visibility="hidden";

}


function SetBackgroundImage(id, file){
 e=document.getElementById(id);
 //ANmerkung: e.style.setAttribute("width",width) funktioniert unter FireFox nicht
 if(e){
	//e.setAttribute("background-image","url('"+file+"')");
  e.style.backgroundImage="url('"+file+"')";
  //alert(file);
 }
}


var scrollElementInterval;
var scrollElementParent;
var scrollElement;

function ScrollElementStart(eParent,id){
	if(eParent.offsetHeight <= document.getElementById(id).offsetHeight){
	  scrollElement=document.getElementById(id);
    scrollElement.style.top=0;
	  scrollElementParent=eParent;
	  scrollElementInterval = setInterval("DoScrollElement()",20);
  }
}
function ScrollElementStop(){
	window.clearInterval(scrollElementInterval);
}

function DoScrollElement(){
  if(scrollElement.style.top){
  	t=parseInt(scrollElement.style.top);
  };
  t=t-1;

  if(t<-1 * scrollElement.offsetHeight){
  	t=scrollElementParent.offsetHeight;
  }
  scrollElement.style.top=t;
}

function ohneCSS() {
  document.getElementsByTagName("style")[0].disabled = true;
}




function Fensterweite()
{
 if (window.innerWidth) return window.innerWidth;
 else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
 else return 0;
}

function Fensterhoehe()
{
 if (window.innerHeight) return window.innerHeight;
 else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 else return 0;
}


function xxshowSize(){
// alert(Fensterweite()+':'+Fensterhoehe());
 var hK="";
 e=document.getElementById("tdLeftFrame");

for(var i = 10; i < e.attributes.length; i++)
{
 hK=hK+e.attributes[i]+"; ";
}

 alert(e.id+": "+hK);

// hK=e.getAttribute("width");
// alert(document.getElementsByTagName("body")[0].getAttribute("bgcolor"));

// alert(e.id+": "+hk);
}

function setSpecialSizes(){
	setContentSize();
  setMenuWidth();
}

function setContentSize(){
//Wird am Ende der Html-Datei aufgerufen mittels eingebundenem JS-Code
//Wird außerdem bei body.onResize aufgerufen; das funktioniert aber
//nur im IE...
//DRAWBACK: MUSS MANUELL ANGEPASST WERDEN!
 h=Fensterhoehe()-145;
 SetSize("Content","100%",h);
 if(h>0){
	 SetSize("artikelBestsellerList",112,h-280);
 }else{
   SetSize("artikelBestsellerList",112,1);
 }
}
function setMenuWidth(){
//DRAWBACK: MUSS MANUELL ANGEPASST WERDEN!
  e=document.getElementById("menuUl");
  if(e){
	  var k = e.firstChild;
	  var x=0;
	  while (k!=null) {
	    x=x+k.offsetWidth+5;
	//    alert(x);
	    k=k.nextSibling;
	  }
	  if (x>Fensterweite()){
	    SetSize("menuDiv",x+"px",""); //height nicht angeben, weil bereits im css gesetzt
	//    alert(x);
	  }else{
	    SetSize("menuDiv","100%",""); //height nicht angeben, weil bereits im css gesetzt
	//    alert("100%");
	  }
  }
}



/*
function getSelection(id){
	el=document.getElementById(id);
  alert(el.id);
	if ( el.selectionStart == undefined ){
		var r = document.selection.createRange();
		return new Array( r.start, r.end );
	}else{
  	return new Array( el.selectionStart, el.selectionEnd );
	}
}
*/

function selektierterText () {
  if (window.getSelection) {
    alert(window.getSelection());
  } else if (document.getSelection) {
    alert(document.getSelection());
  } else if (document.selection) {
    alert(document.selection.createRange().text);
  }
}
