// ===================================================================
// Author: Kris Barnhoorn <kris@biassweb.be>
// WWW: http://www.biassweb.com/
// revised: 2003-12-08 14:50
//
// ===================================================================

function BW_checkboxImage() { //v0.1 needs MM_findObj(Object)
  var x,y,a=BW_checkboxImage.arguments;
  y=MM_findObj(a[3]);
  if ((x=MM_findObj(a[0]))!=null){
   		if(!y.checked){ 
			x.src=a[1];
			//document.forms[0].checkbox.checked=true;
			y.checked=true;
			
		}else{
			x.src=a[2];
			y.checked=false;
			
		}
	}
}

function BW_sure(){
  return confirm("Are you sure to remove?");
}
function BW_noSpam(user,domain){
 location.href="mailto:"+user+"@"+domain;
}

function BW_noSpam(user,domain,tld){

 location.href="mailto:"+user+"@"+domain+"."+tld;

}


function BW_findSelectItem(target,property,value){

	var found = false;
	for (var i = 0; i < target.options.length; i++) {
	if (target.options[i][property].toUpperCase().indexOf(value.toUpperCase()) == 0) {
		found=true; break;
		}
	}
	if (found) { target.selectedIndex = i; }
	else { target.selectedIndex = -1; }
	
}
function BW_switchDiv( obj,image,closeImg,openImg )
{

    if (obj.style['display'] != "block" )
    {
        obj.style['display'] = "block";
        if (image){
        	image.src = openImg;
        }
    }
    else
    {
        obj.style['display'] = "none";
        if(image){
        	image.src = closeImg;
        }
    }
}
function BW_switchDivState( obj,stateObj,image,closeImg,openImg )
{

    if (obj.style['display'] != "block" )
    {
        obj.style['display'] = "block";
        if (image){
        	image.src = openImg;
        }
		stateObj.value='true'
    }
    else
    {
        obj.style['display'] = "none";
        if(image){
        	image.src = closeImg;
        }
		stateObj.value='false'
    }
}

function BW_markAll(formId)
{
	var i=0; 
	while(formId.elements[i])
	{
		formId.elements[i].checked=1;
		i++;
	}
}

function BW_unmarkAll(formId)
{
	var j=0; 
	while(formId.elements[j])
	{
		formId.elements[j].checked=0; 
		j++;
	}
}

function BW_invertMarking(formId)
{
	var k=0; 
	while(formId.elements[k])
	{
		if(formId.elements[k].checked == 1) 
		{
			formId.elements[k].checked=0;
		} else {
		formId.elements[k].checked=1;
		} 
		k++;
	}
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------


//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
