
function enhanceCheckboxes() {

// finds every checkbox on the page
// and converts it to a graphical version

  // find all input controls:
  var els=document.getElementsByTagName("input");

  // for each input element...
  for(var i=0; i < els.length; i++) {


    if (els[i].type=='checkbox') { // its a checkbox

      // hide the original checkbox control:
      els[i].style.display='none';

      // create the graphical alternative:
      var img = document.createElement("img");

      // initial state of graphical checkbox
      // is the same as the original checkbox:

      if (els[i].checked) {

        //img.src="/CheckboxChecked.gif.gif";
        img.src="/images/checkbox_checked.gif";
        img.title="Checked";
      }
      else {

        //img.src="/CheckboxUnchecked.gif";
        img.src="/images/checkbox.gif";
        img.title="Unchecked";
      }

      // assign our onclick event
      img.onclick= toggleCheckbox;

      // insert the new, clickable image into the DOM
      // infront of the original checkbox:

      els[i].parentNode.insertBefore(img, els[i]);

    }

  }


}


function toggleCheckbox() {

// graphical checkbox onclick event handler

  // toggle the checkbox state:

  if (this.title == "Checked") {

    // toggle the image and title:

    //this.src="/CheckboxUnchecked.gif";
    this.src="/images/checkbox.gif";
    this.title="Unchecked";

    // update the hidden real checkbox to match the state of the graphical
    // version:
    this.nextSibling.checked=false;

  }
  else {

    // toggle the image and title:

    //this.src="/CheckboxChecked.gif";
    this.src="/images/checkbox_checked.gif";
    this.title="Checked";

    // update the hidden real checkbox to match the state of the graphical
    // version:
    this.nextSibling.checked=true;

  }

}
function EnhanceRadio() {

  // add popup links to all lookup fields

  var els=document.getElementsByTagName("input");

  for(var i=0; (el=els[i]); i++) {

    if (el.type == "radio") {

      el.style.display='none';

      var img=document.createElement("img");
      if (el.checked) {

        img= new Image(18,18);
        img.src="/images/radiobutton_checked.gif";
        img.title="Checked";
       // img.width="18";
        //img.height="18":
      }
      else {

       img= new Image(18,18);
        img.src="/images/radiobutton.gif";
        img.title="Unchecked";
        //img.width="17";
        //img.height="17":
      }
      //img.setAttribute("src", "/RadioboxUnchecked.gif");
     // img.setAttribute("src", "/images/radiobutton.gif");
     // img.setAttribute("alt", "Unchecked");
      img.onclick= toggleRadio;
      el.onchange=toggleRadio;

      el.parentNode.insertBefore(img, el);

    }

  }

}

function toggleRadio() {

// graphical checkbox onclick event handler

  // toggle the checkbox state:

  this.nextSibling.checked=true;

  els=this.parentNode.parentNode.getElementsByTagName("input");

  for(var i=0; (el=els[i]); i++) {

    if (el.type == "radio") {

      if(el.checked) {

        //el.previousSibling.setAttribute("src", "/RadioboxChecked.gif");
        el.previousSibling.setAttribute("src", "/images/radiobutton_checked.gif");

      }
      else {
        //el.previousSibling.setAttribute("src", "/RadioboxUnchecked.gif");
        el.previousSibling.setAttribute("src", "/images/radiobutton.gif");
      }

    }

  }

}
var win=null;

function NewWindow(mypage,myname,w,h,pos,infocus){

if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}

if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}

else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}

settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";

win=window.open(mypage,myname,settings);

win.focus();}

function relTags() {

	if (document.getElementsByTagName) {

		var anchors = document.getElementsByTagName( "a" );

		for (var loop = 0; loop < anchors.length; loop++) {

			var anchor = anchors[loop];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
				anchor.target = "_blank";
			}
		}
	}
}

window.onload = function() {

	relTags();

  //enhanceCheckboxes();
  //EnhanceRadio();
  //parseStylesheets();
}

var currentSheet, doc = window.document;
function parseStylesheets() {
	var sheets = doc.styleSheets, l = sheets.length;
	for(var i=0; i<l; i++)
		parseStylesheet(sheets[i]);
}
	function parseStylesheet(sheet) {
		var l, rules, imports;
		if(sheet.imports) {
			imports = sheet.imports, l = imports.length;
			for(var i=0; i<l; i++)
				parseStylesheet(sheet.imports[i]);
		}

		rules = (currentSheet = sheet).rules, l = rules.length;
		for(var j=0; j<l; j++) parseCSSRule(rules[j]);
	}

	function parseCSSRule(rule) {
		var select = rule.selectorText, style = rule.style.cssText;
		if(!((/\b(([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):hover/i).test(select) || (/\b((([^ ]+)?)|(([^#.][^ ]+)+)):unknown/i).test(select))) return;

		var newSelect = select.replace(/(\.([a-z0-9_-]+):hover)|(:hover)/g, '.$2onHover');
		var hasClass = (/(\.([a-z0-9_-]+):hover)/g).exec(select);
		var className = (hasClass? hasClass[2]:'') + 'onHover';
		var affected = select.replace(/:hover.*$/g, '');
		var elements = getElementsBySelect(affected);

		currentSheet.addRule(newSelect, style);
		for(var i=0; i<elements.length; i++)
			new HoverElement(elements[i], className);

		var newSelect = select.replace(/(\.([a-z0-9_-]+):unknown)|(:unknown)/g, '.$2onFocus');
		var hasClass = (/(\.([a-z0-9_-]+):unknown)/g).exec(select);
		var className = (hasClass? hasClass[2]:'') + 'onFocus';
		var affected = select.replace(/:unknown.*$/g, '');
		var elements = getElementsBySelect(affected);

		currentSheet.addRule(newSelect, style);
		for(var i=0; i<elements.length; i++)
			new FocusElement(elements[i], className);
	}

function HoverElement(node, className) {
	if(!node.hovers) node.hovers = {};
	if(node.hovers[className]) return;
	node.hovers[className] = true;
	node.attachEvent('onmouseover',
		function() { node.className += ' ' + className; });
	node.attachEvent('onmouseout',
		function() { node.className =
			node.className.replace((new RegExp('\\s+'+className)),''); });
}

function FocusElement(node, className) {
	if(!node.focuses) node.focuses = {};
	if(node.focuses[className]) return;
	node.focuses[className] = true;
	node.attachEvent('onfocus',
		function() { node.className += ' ' + className; });
	node.attachEvent('onblur',
		function() { node.className =
			node.className.replace((new RegExp('\\s+'+className)),''); });
}

function getElementsBySelect(rule) {
	var parts, nodes = [doc];
	parts = rule.split(' ');
	for(var i=0; i<parts.length; i++) {
		nodes = getSelectedNodes(parts[i], nodes);
	}	return nodes;
}
	function getSelectedNodes(select, elements) {
		var result, node, nodes = [];
		var classname = (/\.([a-z0-9_-]+)/).exec(select);
		var identify = (/\#([a-z0-9_-]+)/).exec(select);
		var tagName = (/^[a-z0-9]+/i).exec(select.toUpperCase()) || '*';
		for(var i=0; i<elements.length; i++) {
			result = elements[i].getElementsByTagName(tagName);
			for(var j=0; j<result.length; j++) {
				node = result[j];
				if((identify && node.id != identify[1]) || (classname && !(new RegExp('\\b' +
					classname[1] + '\\b').exec(node.className)))) continue;
				nodes[nodes.length] = node;
			}
		}	return nodes;
	}


function changeStyle(x, y){
	for(var p =1; p<=y; p++) {
			var test = document.getElementById('id'+p);
			test.style.backgroundImage = "url(/images/site/arrow_off.png)";
			var test1 = document.getElementById('link'+p);
			test1.style.color = "#CCCCCC";
	}
	var test = document.getElementById('id'+x);
	test.style.backgroundImage = "url(/images/site/arrow_on.png)";
	var test1 = document.getElementById('link'+x);
	test1.style.color = "#acc348";
}

/****************************************************
*  IMAGE POPUP ADVANCED                             *
*****************************************************/
function showImage(photo,width,height,caption) {
var wrapWidth = width + 50;
var wrapHeight= height + 50;

//get browser height/width and scroll positions
var scroll_array= getScrollXY();
var size_array=alertSize();

myleft=(screen.width)?(size_array[0]-wrapWidth)/2:100;
mytop=(screen.height)?(size_array[1]-wrapHeight)/2:100;
myleft+=scroll_array[0];
mytop+=scroll_array[1];
//document.write(myleft+ ''+mytop);
var i = document.getElementById('imageBlock');
i.style.left=myleft+"px";
i.style.top=mytop+"px";
photo.onload=i.style.display="none";
i.innerHTML = "<div id=\"wrapper\" style=\"width:" + wrapWidth + "px;height:" + wrapHeight + "px;z-index:100;\"><div class=\"closemer\" style=\"height:25px !important;\"><a href=\"javascript:loaderClose();\" style=\"color:#750109; font-size:12px; float:right; font-family: Arial, sans-serif; text-transform:uppercase; margin:5px 10px; \" title=\"close here\">x</a></div><div class=\"largeImage\"><a href=\"javascript:loaderClose();\" class=\"imageClose\"><img src=\"http://www.mamaya.eu/images/uploaded/" + photo + "\" width=\"" + width +"\" height=\"" + height +"\" alt=\"close\" title=\"click to close\" id=\"largeImage\" /></a><div style=\" font-family: verdana; font-size:10px; color: #3f3f3f; \">"+ caption +"</div></div></div>";
//i.innerHTML = "<img src=\"http://test.909.be/images/uploaded/" + photo + "\" width=\"" + width +"\" height=\"" + height +"\" alt=\"$photo\" id=\"largeImage\" /></a>";
i.style.display='block';
i.style.opacity="1.0";


}

function loaderClose() {
var loader = document.getElementById('loader');
//loader.innerHTML = "";
//loader.style.display='none';
var p = document.getElementById('imageBlock');
p.style.display='none';
p.style.opacity="0";
}

/****************************************************
*  WARNING POPUP ADVANCED                           *
*****************************************************/
///get scrollposoition
function showWarning(text) {

//document.write(myleft+ ''+mytop);
var i = document.getElementById('warningBlock');
i.style.left="300px";
i.style.top="150px";
text.onload=i.style.display="none";
i.innerHTML = "<div id=\"wrapper2\" style=\z-index:100;\"><div class=\"closemer\" style=\"height:25px !important;\"><a href=\"javascript:warningClose();\" style=\"color:#ffffff; font-size:12px; float:right; font-family: Times New Roman, sans-serif; text-transform:uppercase; margin:5px 10px; \" title=\"close here\">x</a></div><div class=\"largeImage\"><a href=\"javascript:loaderClose();\" class=\"imageClose2\">"+ text +"</a></div></div>";
//i.innerHTML = "<img src=\"http://test.909.be/images/uploaded/" + photo + "\" width=\"" + width +"\" height=\"" + height +"\" alt=\"$photo\" id=\"largeImage\" /></a>";
i.style.display='block';
i.style.opacity="1.0";

}

function warningClose() {
var loader = document.getElementById('loaderke');
//loader.innerHTML = "";
//loader.style.display='none';
var p = document.getElementById('warningBlock');
p.style.display='none';
p.style.opacity="0";

}
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

///getsize of window

function alertSize() {
  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;
  }
 return[ myWidth , myHeight];

}

function changeColor(x){
	//prompt(x);
	var i = document.getElementById(x);
	prompt(i);
	i.style.color="#0000FF";	
}
  

