// browser check
function Is() { //browser leválogatás
  agent = navigator.userAgent.toLowerCase();
  this.agent = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
  this.ns4 = (this.ns && (this.major <= 4) && (this.minor < 5));
  this.ns6 = (this.ns && (this.major >= 5));
  this.ie = (agent.indexOf("msie") != -1);
  this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") == -1));
  this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5") != -1));
  this.ie6 = (this.ie && (this.major == 4) && (agent.indexOf("msie 6") != -1));
  this.iframe = (this.ie || this.ns6) ;
}
var is = new Is();
    
function waiting(waittime) {
	for (wait_var = 0; wait_var <=waittime; wait_var++);
}

function layer_move(x, y) {
	nev = this.name;
	this.left = x; this.top = y;
	if (is.ie4 || is.ie5) { 
		document.all[nev].style.left = x;
		document.all[nev].style.top = y;	
	}else if(is.ns6){
		cucc = document.getElementById(nev);
		x = cucc.getAttribute("style.left");
		y = cucc.getAttribute("style.top");
	}else{
		document.layers[nev].left = x;
		document.layers[nev].top = y;
	}
}

function layer_move_value(x, y) {
	where_x = this.left + x;
	where_y = this.top + y;
	nev = this.name;
	this.left = where_x; this.top = where_y;
	if (is.ie) { 
		document.all[nev].style.left = where_x;
		document.all[nev].style.top = where_y;
	}else if(is.ns6){
		cucc = document.getElementById(nev);
		cucc.style.left=where_x;
		cucc.style.top=where_y;

/*		document.getElementById(nev).left = where_x;
		document.getElementById(nev).top = where_y;
		innerWidth = where_x;
		innerHeight = where_y;*/
	}else{
		document.layers[nev].left = where_x;
		document.layers[nev].top = where_y;		
	}
	
}


function layer_fading(step, intervalid) {
	opacity = this.opacity;
	nev = this.name;
	if (this.opacity >=0 ) {
		this.opacity = this.opacity - step;
		if (is.ie) { 
			document.all[nev].style.filter = "alpha(opacity=" + this.opacity + ")";
		}else if(is.ns6){
			document.getElementById(nev).filter = "alpha(opacity=" + this.opacity + ")";
		}else if(is.ns4){
			document.layers[nev].filter = "alpha(opacity=" + this.opacity + ")";	
		}
	} else {
		clearInterval(intervalid);
	}
}

function layer_fadeout() {
	nev = this.name;
	this.visibility = "hidden";
	if (is.ie4 || is.ie5){
	 document.all[this.name].style.visibility = "hidden";
	 }else if(is.ns6){
	 	document.getElementById(this.name).visibility = "hidden";
	 }else if(is.ns4){
	 	document.layers[this.name].visibility = "hidden";
	}
}


function layer_show() {
	nev = this.name;
	this.visibility = "visible";
	this.opacity = 100;
	if (is.ie4 || is.ie5 ) { 
		document.all[this.name].style.visibility = "visible";
		document.all[nev].style.filter = "alpha(opacity=100)";
	}else if(is.ns6){
		document.getElementById(this.name).visibility = "visible";
	}else{
		document.layers[this.name].visibility = "visible";
	}
}

function layer_main() {
	this.moveTo(this.originalleft, this.originaltop);
	this.show();
}

function layer_write() {
	sor = "<DIV ID=\"" + this.name + "\" NAME=\"" + this.name + "\" STYLE=\"position: " + this.position + "; visibility: " + this.visibility + "; left: " + this.left + "; top: " + this.top + "; \">" + this.content + "</DIV>";
	document.write(sor);
	return "";
}

function layer_object(name) {
	this.name = name;
	this.visibility = "visible";
	this.position = "";
	this.content = "";
	this.top = 0;
	this.left = 0;
	this.originaltop = 0;
	this.originalleft = 0;
	this.opacity = 100;
	this.constructor = layer_object;
	this.hide = layer_fadeout;
	this.show = layer_show;
	this.kirak = layer_write;
	this.moveTo = layer_move;
	this.moveBy = layer_move_value;
	this.shadeOut = layer_fading;
	this.reset = layer_main;
}

var timerid;
var restarttimerid;
delay = 50;

path_index = 0;
path_pos = 0;

function walk_path() {
	if (path_index <= path_count) {		
		if (path_pos <= path_length[path_index] ) {
			dx = path_stepx[path_index];
			dy = path_stepy[path_index];
			plate.moveBy(dx, dy);
			path_pos = path_pos + dx + dy;
		} else {
			path_index++;
			path_pos = 0;
		}
	} else {
		clearInterval(timerid);
		if (is.ie) 
		{
			shadeinterval = setInterval("plate.shadeOut(10, shadeinterval)", 10);
			restarttimerid = setTimeout("restart_walk()", 5000);
		}else if(is.ns){
			plate.hide();
			restarttimerid = setTimeout("restart_walk()", 5000);
		}
	}
}


function restart_walk() {	
	plate.reset();
	path_index = 0;
	path_pos = 0;
	timerid = setInterval(walk_path, delay);
	clearTimeout(restarttimerid);
}


// =====-----------------------------------------------------------------------------------------------=====//
path_count = 0;
var path_length = new Array(path_count);
var path_stepx = new Array(path_count);
var path_stepy = new Array(path_count);

path_length[0] = 960; //page width
if(is.ns6)path_stepx[0] = 5;else path_stepx[0] = 3;
path_stepy[0] = 0;

path_length[1] = 1800;
path_stepx[1] = 0;
path_stepy[1] = 3;

start_left = 10; //x-distance
start_top = 100; //y-distance

//*** itt a kep neve
plate_picture = "maszo.gif";

//*** itt ird at, hova mutasson, ha rakattintanak
plate_link = "http://www.macska.hu/forum.php";

plate = new layer_object("plate");
plate.originalleft = start_left;
plate.originaltop = start_top;
plate.left = start_left;
plate.top = start_top;
plate.position = "absolute";

//if (is.ie || is.ns6) {document.write("<DIV ID=\"plate\" STYLE=\"position: absolute; visibility: visible; left: " + start_left + "; top: " + start_top + "; filter: Alpha(opacity=100); -moz-opacity: 100%;\"><A HREF=\"" + plate_link + "\"><IMG SRC=\"http://www.macska.hu/img/" + plate_picture + "\" BORDER=0 ALT=\"\" onload=\"timerid = setInterval(walk_path, delay); this.onload='';\"></A></DIV>");}
//else{ document.write("<LAYER NAME=\"plate\" LEFT=\"" + start_left + "\" TOP=\"" + start_top + "\" VISIBILITY=\"show\"><A HREF=\"" + plate_link + "\"><IMG SRC=\"http://www.macska.hu/img/" + plate_picture + "\" BORDER=0 ALT=\"\" onload=\"timerid = setInterval(walk_path, delay); this.onload='';\"></LAYER>");}

