
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()	
	}else{
		clearTimeout(tim)
		mOut()
	}
}

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
}

//#############################################################################


	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 getCounterTS() {
	var firstVisit = getCookie('firstVisit');
	//alert(firstVisit);
	if (!firstVisit) {
		firstVisit = (new Date()).getTime();
		var expire = new Date();
		expire.setTime(firstVisit + 1000*60*60*24*365);
//		setCookie('firstVisit', firstVisit, 65536);
		setCookie('firstVisit', firstVisit, expire);
		
		checkFlash();
		OpenFlash(375,500);
	}
	var now = (new Date()).getTime();
	
	return Math.round((now - firstVisit)/1000); 
	//alert(now);
	//alert(Math.round((now - firstVisit)/1000));
}

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))
}

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', '');
	}
}

