function showObject(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function changeProduct(sURL) {
	if (sURL=='n'){ return; } else { window.location = "http://www.nc-17.de" + sURL; return; }
}

function switcher (div) {
	if (document.getElementById(div).style.display == 'none') {
		document.getElementById(div).style.display = 'block';
	} else {
		document.getElementById(div).style.display = 'none';
	}
	return false;
}

function ahah(url, target) {
  document.getElementById(target).innerHTML = 'Lade Daten...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahahDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML = "Fehler:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

// changing the url of the hovered status-link on produtct page
function change_url_of_link(on_mouse_out) {
	// search for link element having onmouseout like "switcher('" + on_mouse_out + "');return false;"
	var div = document.getElementById("content_right");
	var anchors = div.getElementsByTagName('a');
	for(var i=0; i < anchors.length; i++) {
		var anchor = anchors[i];
		
		// fix for internet explorer
		var attr = anchor.getAttribute('onmouseout');
		if(attr != null) {
			var mouseoutaction = anchor.getAttribute('onmouseout').toString();
			if(mouseoutaction.substring(23, mouseoutaction.length - 2) == "switcher('" + on_mouse_out + "');return false;") {
				anchor.href = "/fileadmin/scripts/nc17.de/products/redirect_to_shop.php?p=" + on_mouse_out.substring(8);
				anchor.target = "_blank";
			}
		}

		// the other browsers		
		if(anchor.getAttribute('onmouseout','true') == "switcher('" + on_mouse_out + "');return false;") {
			anchor.href = "/fileadmin/scripts/nc17.de/products/redirect_to_shop.php?p=" + on_mouse_out.substring(8);
			anchor.target = "_blank";
		}
	}
	return true;
}

function load (name, div) {
	change_url_of_link(div);
	switcher(div);
	ahah(name,div);
	return false;
}

/* Stop the Enter-Button from strange behaviour */
function stopRKey(evt) {
   var evt = (evt) ? evt : ((event) ? event : null);
   var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
   if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = stopRKey; 
