// (c) Alex Bokov 2008


function chim(name,image)
{
	if (navigator.appName == 'Microsoft Internet Explorer' ) { document.images[name].filters['blendTrans'].apply(); }
	document.images[name].src = image;
	if (navigator.appName == 'Microsoft Internet Explorer' ) { document.images[name].filters['blendTrans'].play();  }
}
function loadhtml(html)	{ window.location.href = html; }

//
// -- load & show icons array on mainpage

var	imname	= new Array();
	imname[ 1] = "i11"; imname[ 2] = "i12"; imname[ 3] = "i13"; imname[ 4] = "i14"; imname[ 5] = "i15";
	imname[ 6] = 'i21'; imname[ 7] = 'i22'; imname[ 8] = 'i23'; imname[ 9] = 'i24';
	imname[10] = 'i31'; imname[11] = 'i32'; imname[12] = 'i33'; imname[13] = 'i34'; imname[14] = 'i35';
	imname_count = 14;
var	TimeOut;
var	j;
var	dTime	= 20;	/* delay in milliseconds */
function show_init() { busy = 1; j = 0; TimeOut = window.setTimeout("show_next();",dTime); }
function show_next() 
{ 
	clearTimeout(TimeOut); 
	j++; changeOpac( 50, imname[j] ); 
	if ( j < imname_count ) 
		{ TimeOut = window.setTimeout("show_next();", dTime); } 
	else	{ TimeOut = window.setTimeout("show_next2();", dTime); j = 0; } 
}
function show_next2() 
{ 
	clearTimeout(TimeOut); 
	j++; changeOpac( 100, imname[j] ); 
	if ( j < imname_count ) 
		{ TimeOut = window.setTimeout("show_next2();", dTime); } 
	else	{ busy = 0 }
}


//
// -- load & show right menu
 

//function appear( name )
//{
//	var	millisec = 100;
//	var	speed = Math.round(millisec / 100);
//
//	// setTimeout(name.id+".height = 14;",(timer * speed));
//	name.height = 14;
//	for (i = 0; i <= 50; i++) { setTimeout("changeOpac(" + i + ",'" + name.id + "')",(timer * speed)); timer++; }
//}
//function disappear( name )	{ changeOpac( 0, name.id ); name.height = 0; name.light = 50; }
//function count( name )
//{
//	if ( name.substr( 0, 4 ) == 'abou' ) { 
//		document.getElementById('abou_end').height = 186; 
//		document.getElementById('proj_end').height = 186; 
//		for ( i = 0; i < menu2nd_count; i++ ) { 
//			if ( document.getElementById(menu2nd[i]).height > 0 ) document.getElementById(name.substr( 0, 4 )+'_end').height = document.getElementById(name.substr( 0, 4 )+'_end').height - document.getElementById(menu2nd[i]).height; 
//		}
//		for ( i = 0; i < menu3rd_count; i++ ) { 
//			if ( document.getElementById(menu3rd[i]).height > 0 ) document.getElementById(name.substr( 0, 4 )+'_end').height = document.getElementById(name.substr( 0, 4 )+'_end').height - document.getElementById(menu3rd[i]).height; 
//		}
//	} 
//	if ( name.substr( 0, 4 ) == 'proj' ) { 
//		document.getElementById('abou_end').height = 14; 
//		document.getElementById('proj_end').height = 414; 
//		for ( i = 0; i < menu2nd_count; i++ ) { 
//			if ( document.getElementById(menu2nd[i]).height > 0 ) document.getElementById(name.substr( 0, 4 )+'_end').height = document.getElementById(name.substr( 0, 4 )+'_end').height - document.getElementById(menu2nd[i]).height; 
//		}
//		for ( i = 0; i < menu3rd_count; i++ ) { 
//			if ( document.getElementById(menu3rd[i]).height > 0 ) document.getElementById(name.substr( 0, 4 )+'_end').height = document.getElementById(name.substr( 0, 4 )+'_end').height - document.getElementById(menu3rd[i]).height; 
//		}
//	} 
//	if ( name.substr( 0, 4 ) == 'cont' ) { document.getElementById('abou_end').height = 186; document.getElementById('proj_end').height = 186; } 
//}


function setCookie (name, value, days, path, domain, secure) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";

      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=/" : "") +		// ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=mossinepartners.com" : "") +
        ((secure) ? "; secure" : "");
}
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}



// ---- (c) not Alex Bokov ;-)
// Cross-browser BlendTrans Filter JavaScript, Fade in/out
// http://brainerror.net/scripts/javascript/blendtrans/
// blendtrans.js
// slightly modified by Alex Bokov - for this site only

var	busy;	//	= 0;
function opacity(id, opacStart, opacEnd, millisec) {

//	if ( busy == 0 ) {
		//speed for each frame
		var speed = Math.round(millisec / 100);
		var timer = 0;

		//determine the direction for the blending, if start and end are the same nothing happens
		if(opacStart > opacEnd) {
			for(i = opacStart; i >= opacEnd; i--) {
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
			}
		} else if(opacStart < opacEnd) {
			for(i = opacStart; i <= opacEnd; i++)
				{
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
			}
		}
//	}
}
//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;

	if ( document.getElementById(imageid).src.substr(document.getElementById(imageid).src.length-imagefile.length, imagefile.length ) != imagefile )	/* don't replace if same already */ 
	{
		//set the current image as background
		document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
		//make image transparent
		changeOpac(0, imageid);
	
		//make new image
		document.getElementById(imageid).src = imagefile;

		//fade in image
		for(i = 0; i <= 100; i++) {
			setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
			timer++;
		}
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}


