/**
 * Webshop (c) 2007 by Sahrmann-IT (Philipp Sahrmann) and Fixtreme (Uwe Faisst)
 *
 * adminError.class.php
 */

/**
 * Main functions
 *
 * @package     shop
 *
 * @author      Philipp Sahrmann
 * @author      Uwe Faisst
 * @since       08.08.2007
 *
 */
 

/**
	Event
 */
function AAddEvent(o, evType, fn) {
	eval("o."+evType+"=function(){"+fn+"(this);};");
}

/**
	class read
 */
function GGetElementsByClassName(tagname, classname) {
	var i, j, k=0;
	var result=new Array();
	var tag = document.getElementsByTagName(tagname);
	if(tag) {
		for(i=0;i<tag.length;i++) {
			temp = tag[i].className;
			if(temp && (classes = temp.split(" "))) {
				for(j=0;j<classes.length;j++) {
					if(classes[j] == classname) {
						result[k] = tag[i];
						k++;
					}
				}
			}else{
				if(temp == classname) {
					result[k] = tag[i];
					k++;
				}
			}
		}
	}
	return result;
}

/**
	search read
 */
function SearchAction() {
	var i;
	var elem = GGetElementsByClassName('select', 'find');
	if (elem) {
		for(i=0;i<elem.length;i++) {
			AAddEvent(elem[i], 'onchange', 'DoSearchAction');
		}
	}
}

/**
	search read
 */
function DoSearchAction(o) {
	window.location=(o.options[o.selectedIndex].value);
}

/**
	onload - javascript examine
 */
if(document.getElementById && document.createAttribute){
	window.onload=function(){
		SearchAction();
		InitAHref();
	}
}

/**
 * hide element, depending on checkbox status
 */
function checkhide(chkbox, hideelement)
{	
 	if (document.getElementById(chkbox).checked == true)
 	{
  		document.getElementById(hideelement).style.display = 'inline';
 	}
 	else if (document.getElementById(chkbox).checked != true)
	{
		document.getElementById(hideelement).style.display = 'none';
	}
}


 /**
  * hide frame of links in Mozilla Firefox
  */
function InitAHref()
{
   var ahref=document.getElementsByTagName('a');

   for(var i=0;i<ahref.length;i++){
      ahref[i].onmousedown = function()
      {
         this.onfocus = function()
         {
            this.blur();
         }
      }
      ahref[i].onmouseup = function()
      {
         this.onfocus = function(){}
      }
      ahref[i].onmouseout = ahref[i].onmouseup;
   }
   
   var ahref=document.getElementsByTagName('button');

   for(var i=0;i<ahref.length;i++){
      ahref[i].onmousedown = function()
      {
         this.onfocus = function()
         {
            this.blur();
         }
      }
      ahref[i].onmouseup = function()
      {
         this.onfocus = function(){}
      }
      ahref[i].onmouseout = ahref[i].onmouseup;
   }
}
 
 
/**
	Background picture flicker switch off (IE-Failure)
 */
try{
	document.execCommand("BackgroundImageCache", false, true);
}
catch(err) {}


/**
	Delete standardtext from element
*/
function focusreplace(e, standardtext) {
	if(e.value == standardtext) {
		e.value = '';
	} else if(e.value == '') {
		e.value = standardtext;
	}
}
