function checker(container, item, step) {
	try {
		counter = 1;
		items = document.getElementById(container).getElementsByTagName('div');
		for(i=0;i<items.length;i++){
			if(items[i].className == item) {
				if(counter == step) {
					items[i].style.marginRight = '0';
					counter = 1;
				}
				else
					counter++;
			}
		}
	}
	catch(e) {
	}
}
function setClass(target, targetClass) {
	obj = document.getElementById(target);
	obj.className = targetClass;
}
function openImage(imgId, imgSrc) {
	try {
		img = document.getElementById(imgId);
		img.src = imgSrc;
		img.onload = function() {
			img.style.display = 'block';
		}
	}
	catch(e){
	}
}
function closeImage(imgId) {
	img.src = '';
	img.style.display = 'none';
}


function portfolio_related(id){
	this.id=id;
	this.element=document.getElementById(this.id);
	this.childElements=new Array();
	
	// AF20080125: multiple childsets
	this.childSets=new Array();
	this.controller=null;
	this.childSetClass='';
	
	this.limit=false;
	
	this.setLimit=function(limit){
		if(!isNaN(limit))
			this.limit=limit;
		else
			this.limit=false;
	}
	
	this.setChildSetClass=function(className) {
		this.childSetClass=className;
	}
	
	this.createChildSet=function(){
		for(i=0;i<this.element.childNodes.length;i++){
			if(this.element.childNodes[i].nodeType==1 && this.element.childNodes[i].nodeName=="DIV"){
				this.childElements.push(this.element.childNodes[i].cloneNode(true));
			}
		}
	}
	this.getController=function() {
		if(!this.controller) {
			this.controller= API.frameControllers.New(this.id,'v2');
			this.controller.swap=5;
		}
		return this.controller;		
	}
	
	
	this.display=function(){
		this.createChildSet();
		if(this.limit!=false){
			controller=this.getController();
			this.element.innerHTML='';
			if(this.limit>this.childElements.length)
				this.limit=this.childElements.length;
			this.childElements.sort(function() {return 0.5 - Math.random()});
			
			// AF20080125: multiple childsets
			var total = 0;
			var runner = 0;
			var currentSet=null;
			while(total<this.childElements.length) {
				if(currentSet==null || runner>=this.limit) {					
					currentSet=document.createElement('div');
					currentSet.className=this.childSetClass;
					
					frame=controller.addFrame(); 
					frame.setContainer(currentSet); 
					frame.addEffect(new frameController_v2_fadeEffect(2,50));
					
					this.childSets.push(currentSet);
					this.element.appendChild(currentSet);
					runner=0;
				}
				currentSet.appendChild(this.childElements[total]);
				runner++;
				total++;
			}
			
			//for(i=0;i<this.limit;i++){
			//		this.element.appendChild(this.childElements[i]);
			//}
		}
		this.element.style.display='block';
		this.element.style.height="70px";
	
		if(controller) {			
			controller.Load();
		
		}
	}
}

function setFrameToolTipAlignment(id,frame) {
		element=document.getElementById(id);
		element.frame=frame;
		frame.container.style.display="none";
		element.onmouseover=frameToolTipAlignment;
}
function frameToolTipAlignment(e) {
			e=e || window.event;			
			if(this.frame.container.style.display=='none') {
				this.frame.container.style.top=(e.clientY+document.documentElement.scrollTop+10)+"px";
				this.frame.container.style.left=(e.clientX-(document.documentElement.offsetWidth/2)+400)+"px";
			}
			this.frame.Show();
		}
