
ie=document.all?1:0
n=document.layers?1:0
ns6=document.getElementById&&!document.all?1:0

//visible part of layer
lshow=15

//how many pixels should it move every step? 
var move=10;

//speed
menuSpeed=40

var ltop;
var tim=0;

function makeMenu(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
    if (n) this.css=eval(nest+'document.'+obj)
    else if (ns6) this.css=document.getElementById(obj).style
    else if (ie) this.css=eval(obj+'.style')						
	this.state=1
	this.go=0
        if (n) this.width=this.css.document.width
        else if (ns6) this.width=document.getElementById(obj).offsetWidth
        else if (ie) this.width=eval(obj+'.offsetWidth')
	this.left=b_getleft
    this.obj = obj + "Object"; 	eval(this.obj + "=this")	
}

function b_getleft(){
        if (n||ns6){ gleft=parseInt(this.css.left)}
        else if (ie){ gleft=eval(this.css.pixelLeft)}
	return gleft;
}

function moveMenu(){
	if(!oMenu.state){
		clearTimeout(tim)
		mIn()	
		changeImages('counter', '/img/general/counter.gif');
	}else{
		clearTimeout(tim)
		mOut()
		changeImages('counter', '/img/general/counter_b.gif');
	}
}

function mIn(){
	if(oMenu.left()>-oMenu.width+lshow){
		oMenu.go=1
		oMenu.css.left=oMenu.left()-move
		tim=setTimeout("mIn()",menuSpeed)
	}else{
		oMenu.go=0
		oMenu.state=1
	}	
}

function mOut(){
	if(oMenu.left()<0){
		oMenu.go=1
		oMenu.css.left=oMenu.left()+move
		tim=setTimeout("mOut()",menuSpeed)
	}else{
		oMenu.go=0
		oMenu.state=0
	}	
}

function menuInit(){
	oMenu=new makeMenu('divMenu')
        if (n||ns6) scrolled="window.pageYOffset"
        else if (ie) scrolled="document.body.scrollTop"
	oMenu.css.left=-oMenu.width+lshow
        if (n||ns6) ltop=oMenu.css.top
        else if (ie) ltop=oMenu.css.pixelTop
}

//window.onload=menuInit;


//#############################################################################

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;

//#############################################################################

	var agent = navigator.userAgent;
	var cont_f0;
	var cont_f1;
	var cont_f2;
	var browser='';
	var flashyes = 0;
	var browser_version = parseFloat(navigator.appVersion);

function checkBrowser(){
	var userAgent = navigator.userAgent;
	var pos = userAgent.indexOf("Opera");
	var pos1 = userAgent.indexOf("MSIE");
	if (pos != -1){browser='Opera';}
	else{
	if (pos1 != -1) {browser='IE';}
	else browser='Netscape';
	}
}

function testinput(re, re1, str){ 
	if (str.search(re) != -1)   cont_f1 = 1; else cont_f1 = 0; 
	if (str.search(re1) != -1)   cont_f2 = 1;   else {cont_f2 = 0;}
	cont_f0 = (cont_f1&cont_f2);
}
  
function checkFlash (){
// Looking for plug-in for Netscape
if (browser=='Netscape' || browser=='Opera'){
for (var i = 1;i <= navigator.plugins.length-1; i++){
	testinput('6', 'Flash', navigator.plugins[i].description);
	if (cont_f0==1) 
		if (cont_f0==1) flashyes = 1;
		
	}
}
// Looking for plug-in for Explorer
if (browser=='IE'){
	if (navigator.userAgent.indexOf("MSIE 5.01")!= -1) {flashyes=0;}
	else if ( checkFlashInExplorer () ) flashyes = 1; else flashyes =0;
}
}

function getCounterTS() {
	var firstVisit = getCookie('firstVisit');
	if (!firstVisit) {
		firstVisit = (new Date()).getTime();
		var expire = new Date();
		expire.setTime(firstVisit + 1000*60*60*24*365);
		setCookie('firstVisit', firstVisit, expire);
	}
	var now = (new Date()).getTime();
	return Math.round((now - firstVisit)/1000); 
	//alert(now);
	//alert(Math.round((now - firstVisit)/1000));
}
		
function loadFlash () {
var counterTS = getCounterTS();
var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i]; 
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}
if ( MM_FlashCanPlay ) {
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="190" HEIGHT="92" id="chernigivske">');
	document.write('<PARAM NAME=movie VALUE="/a1.swf?showBox=10000&hold=4000&timeout=1000&fall=5&repeats=1&ts='+counterTS+'"><PARAM NAME="cap" VALUE="false"><PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor" VALUE="#FFFFFF"><PARAM NAME="menu" VALUE="false">');
	document.write('<EMBED src="/a1.swf?showBox=10000&hold=4000&timeout=1000&fall=5&repeats=1&ts='+counterTS+'"');
	document.write(' quality=high  WIDTH="190" HEIGHT="92" NAME="chernigivske" ALIGN="" menu="false" wmode="transparent"');
	document.write('  TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
	document.write('</EMBED></OBJECT><br>');
}else{
	document.write('<img src="/img/counter.gif" width="190" height="92" alt="" border="0">');
}
}

function trimstring(str)
{

	var i=0;
	while((str.charAt(0)==' ')||(str.charAt(0)=='\n')||(str.charAt(0)=='\t'))
	{
		str = str.substring(1, str.length);
	}
	return str;
}


function setCookie(name, value, expire) {   
	document.cookie = name + "=" + escape(value) 
	+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

function getCookie(Name) {   
	var search = Name + "="   
	if (document.cookie.length > 0) { 
		// if there are any cookies      
		offset = document.cookie.indexOf(search)       
		if (offset != -1) { // if cookie exists          
			offset += search.length          // set index of beginning of value         
			end = document.cookie.indexOf(";", offset)  // set index of end of cookie value         	
			if (end == -1) end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))      
		}    
	}
}

/**
Use it BEFORE html of main frame loaded
*/
function frameRedirect(framesetURL, targetFrameName) {
//	alert('frameRedirect');
	if (top.frames.length == 0) {
		// if no frames
//		alert('NO frames, setting cook');
		setCookie('sp_frameRedirectLocation', document.location); // store URL in cookie
		document.location = framesetURL;	// redirect to frameset
		return;
	}
	else {
		// if has frame, check 
		var redirectURL = getCookie('sp_frameRedirectLocation');
//		alert('Has frames, redirectURL=' + redirectURL)
		if (redirectURL && redirectURL.length > 0) {
			top.frames[targetFrameName].document.location = redirectURL;
		}
		setCookie('sp_frameRedirectLocation', '');
	}
}

