// Clayzy01.css, Hans E Andersson, 2010-03-25
var ie4_check = (document.all && !document.getElementById) ?     true : false;
var ie5_check = (document.all && document.getElementById)  ?     true : false;
var pTime;
//var imgArray;
//var currentIndex;

function closeCurWin(w) {
	var win = document.getElementById(w);
	win.style.display = 'none';
	if (document.getElementById('deskTopIconContainer')) {
		document.getElementById('deskTopIconContainer').style.overflow = 'auto';
		document.getElementById('deskTopIconContainer').style.bottom = '22px';
	}
	if (document.getElementById('deskTopIconFillContainer')) {
		document.getElementById('deskTopIconFillContainer').style.overflow = 'auto';
		document.getElementById('deskTopIconFillContainer').style.bottom = '22px';
	}
}

function closePop() {
	clearInterval(pTime);
	document.getElementById('blackBox').style.display = 'none';
}

function checkPos(src, dest) {
	
	clearInterval(pTime);
	
	var res = document.getElementById("td"+src);
	var box = document.getElementById(dest);
	
	if (box.style.display == 'block') {
		box.style.display = 'none';
	} else {
	//var x = getOffset( documen.getElementById(src) ).left;
	var txol = document.getElementById("headerTable").offsetLeft;
	var txsl = document.getElementById("headerTable").scrollLeft;
	
	var x = res.offsetLeft - res.scrollLeft;
	//alert("td"+src+ " är "+ res.offsetLeft +" offsetLeft och " + res.scrollLeft + "scrollLeft och tabellen är offsetLeft:"+txol+", scrollLeft:"+txsl);
	var y = res.offsetTop - res.scrollTop;
	
	box.innerHTML = document.getElementById("t"+src).innerHTML;
	
	if ((152 + x) >  window.innerWidth) {
		box.style.left = (window.innerWidth - 152) + 'px';
	} else {
		//box.style.left = x + 'px';
		//box.style.left = x + txol + 230 + 13 + 'px';
		box.style.left = x + txol + 231 + 'px';
	}
	// Om den är botten origenterad
	//box.style.bottom = y + 22 + 'px';
	box.style.display = 'block';
	// autohide funktion
	//pTime = setTimeout('startTimer(\''+dest+'\','+x+')', 6000);
	}
}

function startTimer(dest,num) {
	//alert('times up! ' +dest+ ' nummer:' + num);
	var box = document.getElementById(dest);
	box.style.display = 'none';
	clearInterval(pTime);
}

function getOffset( el ) {
    var _x = 0;
    var _y = 0;
    while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
        _x += el.offsetLeft - el.scrollLeft;
        _y += el.offsetTop - el.scrollTop;
        el = el.parentNode;
    }
    return { top: _y, left: _x };
}

function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	//alert("Cookie name " +name+ " deleted!");
}
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

