Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
	   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   		element = $(element);
    	element.style.height = h +"px";
	},
	setHeightP: function(element,p) {
   		element = $(element);
    	element.style.height = p +"%";
	},
	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

// -----------------------------------------------------------------------------------
//
// 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){	yScroll = document.documentElement.scrollTop;}   // Explorer 6 Strict
	else if (document.body) { yScroll = document.body.scrollTop; } // all other Explorers
	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;}
	 // all but Explorer Mac
	else if (document.body.scrollHeight > document.body.offsetHeight){	xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; 	}
	// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	else { 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;
}

	function createThumbNail(id, modelName) {					
  		var t="";
  		var mo="''";
  		var imgsrc = "/images/models/cards/" + id  + ".jpg";
  		t+= '<div class="thumbBg">';
  		t+='<div class="imageTag">';
   		t+='<a href="#" onclick="idoleSite.loadCard(' + id + ')">';
     	t+='<img src="' + imgsrc + '">';
     	t+='</a>';
		t+='<div class="nameTag">';
		t+= modelName;
    	t+='</div>';
     	t+='</div>';
     	t+='</div>';
		return t;
	};			

	function checkUncheckAll(theElement) {
        var theForm = theElement.form, z = 0;
	    for(z=0; z<theForm.length;z++){
            if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	            theForm[z].checked = theElement.checked;
	        }
        }
    }

	function getContent(xmlNode, tag){		
	    var xml_contents = xmlNode.getElementsByTagName(tag);    
		var contents = [];	
	    for (var i=0; i < xml_contents.length; i++) {    
		  var xml_content = xml_contents[i];		 		 
	      contents.push(xml_content.childNodes[0].nodeValue);
	    }
	    return contents;
	};
	
	
		var timeDiff  =  {
	    	setStartTime: function (){
	        	d = new Date();
	        	time  = d.getTime();
	    	},
	
	    	getDiff: function () {
	        	d = new Date();
	        	return (d.getTime()-time);
	    	}
		}

//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}


