$(document).ready(function(){
    $(".cboxWinIframe").colorbox({innerWidth:530, innerHeight:550, iframe:true});
    $(".cboxWin").colorbox({inline:true});
});


/* <!------------------------------ Hide and show Divs */

/* 
Example of use in <body>:
	<script language="JavaScript">
	//Array with group of ids
	var ids_group1 = new Array('id1','id2');
	</script>
	<a href="javascript:switchid('id1',ids_group1);">visa 1</a>, 
	<a href="javascript:switchid('id2',ids_group1);">visa 2</a>, 
	
	<div id="id1" style="display:block;">visar nummer ett</div>
	<div id="id2" style="display:none;">visar nummer tv</div>
*/


function switchid(id, ar){//id=element to show. ar=array containing elemts to hide
	hideallids(ar);
	showdiv(id);
}

function hideallids(ar){
	var ids = ar;
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

/* End hide and show Divs -----------------------//> */

function scrollDiv(currentDivId) {
	var scrolledX, scrolledY;
	if( self.pageYOffset ) {
		scrolledX = self.pageXOffset;
		scrolledY = self.pageYOffset;
	} else if( document.documentElement && document.documentElement.scrollTop ) {
		scrolledX = document.documentElement.scrollLeft;
		scrolledY = document.documentElement.scrollTop;
	} else if( document.body ) {
		scrolledX = document.body.scrollLeft;
		scrolledY = document.body.scrollTop;
	}
	
	var centerX, centerY;
	if( self.innerHeight ) {
		centerX = self.innerWidth;
		centerY = self.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
		centerX = document.documentElement.clientWidth;
		centerY = document.documentElement.clientHeight;
	} else if( document.body ) {
		centerX = document.body.clientWidth;
		centerY = document.body.clientHeight;
	}
	
	var divWidth = parseInt(document.getElementById(currentDivId).style.width.replace(/px/, ""));
	var divHeight = parseInt(document.getElementById(currentDivId).style.height.replace(/px/, ""));
	
	var containerWidth = 624;
	
	//var topOffset = scrolledY + (centerY - divHeight) / 2;	
	//var leftOffset = scrolledX + (centerX - divWidth) / 2;
	
	var topOffset = scrolledY + 5;	
	var leftOffset = scrolledX + (containerWidth - divWidth) / 2;
	
	document.getElementById(currentDivId).style.top = topOffset + "px";
	document.getElementById(currentDivId).style.left = leftOffset + "px";
}

function openPopup(currentDivId) {
	scrollDiv(currentDivId);
	document.getElementById(currentDivId).style.display = "block";
	//document.body.onscroll = scrollDiv(currentDivId);
	//window.onscroll = scrollDiv(currentDivId);
}
