function copyArray(arr){
	var a = [];
	for(var i=0; i < arr.length; i++) a[i] = arr[i];
	return a;
}
function createDelegate(t, m){
	var target = t;
	var method = m;
	var type = typeof(method);
	var args = copyArray(arguments);
	args = args.slice(2);
	return function(){
		var arr = copyArray(args);
		for(var i=0; i < arguments.length; i++) arr.push(arguments[i]);
		switch(typeof(method)){
			case "string":
				if(target != null){
					return target[method].apply(target, arr);
				} else {
					return eval(method).apply(null, arr);
				}
				break;
			case "function":
				return method.apply(target, arr);
				break;
			default:
				alert("unexpexted method type: "+typeof(method));
		};
	};
};

// element
function getElement(id){
	//return isIE() ? window[id] : document[id];
	return document.getElementById(id);
}
function element(layer){
	return typeof(layer) == "string" ? document.getElementById(layer) : layer;
}
function MM_findObj(n, d) { //v4.01
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length){
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n]) && d.all) x=d.all[n];
	for(i=0; !x && i<d.forms.length; i++) x = d.forms[i][n];
	for(i=0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n);
	return x;
}

// browser
function isOpera(){
	return navigator.userAgent.indexOf("Opera") != -1;
}
function isIE(){
	return navigator.userAgent.indexOf("MSIE") != -1;
}
function isIE6(){
	return navigator.appVersion.match(/MSIE 6/i);
}
function isIE7(){
	return navigator.userAgent.match(/MSIE 7/i);
}
function isMoz(){
	return navigator.userAgent.match(/gecko/i);
}

// page offset
function getXOffset(){
	return window.pageXOffset ? window.pageXOffset : (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft
}
function getYOffset(){
	return window.pageYOffset ? window.pageYOffset : (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop
}
// inner dimentions
function getInnerWidth(){
	return window.innerWidth ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
}
function getInnerHeight(){
	return window.innerHeight ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
}


function setStyleTo(id, styles){
	var el = element(id);
	for(var i=0; i < styles.length; i++){
		 el.style[styles[i][0]] = styles[i][1];
	}
}
function setStyles(id, styles){
// 	alert("ID: "+id);
// 	return false;
	var  el = element(id);
	for(var i=0; i < styles.length; i++){
		 el.style[styles[i][0]] = styles[i][1];
	}
}
function setStyle(id, style, value){
	element(id).style[style] = value;
}
function getStyle(id, style){
	return element(id).style[style];
}
function styleToNum(val){
	val=String(val);
	var c,str = "",len=val.length;
	for(var i=0; i<len; i++){
		//c = val.slice(i, i+1);
		if(isNaN(str+(c=val.slice(i, i+1)))) break;
		str+=c;
	}
	if(!str.length) str = 0;
	return str;
}

//* ELEMENTS SHOW/HIDE
function showElements(){
	for(var i=0; i < arguments.length; i++){
		if(element(arguments[i])){
			element(arguments[i]).style.display = "block";
		}
	}
}
function hideElements(){
	for(var i=0; i < arguments.length; i++){
		//alert("hideElements="+arguments[i]);
		if(element(arguments[i])){
			element(arguments[i]).style.display = "none";
		}	
	}
}
function switchElements(){
	for(var i=0; i < arguments.length; i++){
        element(arguments[i]).style.display = isVisible(arguments[i]) ? "none" : "block";
	}
}
function isVisible(id){
	var el = element(id);
	return el ? !(element(id).style.display == "none") : false;
}

function setHtmlTo(id, str){
	var el = element(id);
	if(el) el.innerHTML = str;
}

// DIFFERENT CLASS STYLES BY ELEMENT FUNCTION START 
function stripe(id, tags, evenClass, oddClass, oddIsFirst){	
	var even = !oddIsFirst;
	var mainObj;
	if(!(mainObj = element(id))) return;	
	if(!evenClass) evenClass = 'even';
	if(!oddClass) oddClass = 'odd';	
	var elements = [];	
	var findElementsIn = function(obj, tags, depth, $elements){
		if(!depth) depth = 0;
		var elmnts = obj.getElementsByTagName(tags[depth]);
		if(tags[depth+1])
			for(var i=0; i < elmnts.length; i++) findElementsIn(elmnts[i], tags, depth+1, elements);
		else
			for(var i=0; i < elmnts.length; i++) elements.push(elmnts[i]);
	}	
	findElementsIn(mainObj, tags, 0, elements);	
	for(var i=0; i < elements.length; i++) elements[i].className = (even = !even) ? evenClass : oddClass;
}

		
// focus and blur
function setTextOnFocus(objName, def_text, toPass){
	var obj = element(objName);
	if(obj && obj.value == def_text){
		obj.value = "";
		if(toPass){
			obj.type = "password";
		}
	}
}
function setTextOnBlur(objName, def_text){
	var obj = element(objName);
	if(obj && !obj.value.length){
		obj.value = def_text;
		obj.type="text";
	}
}

/*---------------
	Cookies
---------------*/
function setCookie(cookieName, cookieValue, nDays) {
	var today = new Date();
	var expire = new Date();
	if(!nDays==null) nDays=1;
	expire.setTime(today.getTime()+3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString();
};
function readCookie(cookieName){
	var theCookie = ''+document.cookie;
	var ind=theCookie.indexOf(cookieName);
	if (ind==-1 || cookieName=="") return '';
	var ind1 = theCookie.indexOf(';',ind);
	if (ind1==-1) ind1 = theCookie.length;
	return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
};

function getQueryParamValue(param){
	var q = document.location.search || document.location.href.hash;
	if(q){
		var startIndex = q.indexOf(param +"=");
		var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
		if (q.length > 1 && startIndex > -1) {
			return q.substring(q.indexOf("=", startIndex)+1, endIndex);
		}
	}
	return "";
}

http://buildingoftheyear.bg/js/flashobject.js

FlashObject = function(elementId, swf, id, w, h, ver, c, quality, altImage, skipURL, dontShowTip, altContent){

	this.element = document.getElementById(elementId);

	this.removeBackgroundImage();

	if(!dontShowTip) this.changeContent("<span class='"+elementId+"'>In order to see this content you will have to install <a href='http://www.macromedia.com/shockwave/download/triggerpages_mmcom/flash.html' target='_blank'>Flash Player "+ver+"</a>.</span>");

	

	this.params = new Object();

	this.variables = new Object();

	this.attributes = new Array();

	

	if(swf) this.setAttribute('swf', swf);

	if(id) this.setAttribute('id', id);

	if(w) this.setAttribute('width', w);

	if(h) this.setAttribute('height', h);

	if(ver) this.setAttribute('version', new PlayerVersion(ver.toString().split(".")));

	if(c) this.addParam('bgcolor', c);

	this.addParam('quality', quality ? quality : 'high');

	//this.addParam('menu', 'false');

	if(altImage) this.altImage = altImage;

	this.altContent = altContent;

	

	installedVer = FlashObjectUtil.getPlayerVersion();
	this.isValidVersion = installedVer.versionIsValid(this.getAttribute('version'));
	if(!this.isValidVersion && skipURL){
		window.location = skipURL;
	}

}

FlashObject.prototype.setAttribute = function(name, value){

	this.attributes[name] = value;

}

FlashObject.prototype.getAttribute = function(name){

	return this.attributes[name];

}

FlashObject.prototype.getAttributes = function(){

	return this.attributes;

}

FlashObject.prototype.addParam = function(name, value){

	this.params[name] = value;

}

FlashObject.prototype.getParams = function(){

	return this.params;

}

FlashObject.prototype.getParam = function(name){

	return this.params[name];

}

FlashObject.prototype.addVariable = function(name, value){

	this.variables[name] = value;

}

FlashObject.prototype.getVariable = function(name){

	return this.variables[name];

}

FlashObject.prototype.getVariables = function(){

	return this.variables;

}

FlashObject.prototype.getParamTags = function(){

   var paramTags = ""; var key; var params = this.getParams();

   for(key in params) paramTags += '<param name="'+key+'" value="'+params[key]+'" />';

   return paramTags;

}

FlashObject.prototype.getVariablePairs = function(){

	var variablePairs = new Array();

	var key;

	var variables = this.getVariables();

	for(key in variables){

		variablePairs.push(key+"="+variables[key]);

	}

	return variablePairs;

}

FlashObject.prototype.getHTML = function() {

    var flashHTML = "";

    if(navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length){ // netscape plugin architecture

        flashHTML += '<embed type="application/x-shockwave-flash" src="'+this.getAttribute('swf')+'" width="'+this.getAttribute('width') +'" height="'+this.getAttribute('height')+'" id="'+this.getAttribute('id')+'" name="'+this.getAttribute('id')+'"';

		var params = this.getParams();

        for(var key in params) flashHTML += ' '+key+'="'+params[key]+'"';

		pairs = this.getVariablePairs().join("&");

        if (pairs.length > 0){ flashHTML += ' flashvars="'+pairs+'"'; }

        flashHTML += '></embed>';

    } else { // PC IE

        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" data="'+this.getAttribute('swf')+'"width="'+this.getAttribute('width')+'" height="'+this.getAttribute('height')+'" id="'+this.getAttribute('id')+'">';

        flashHTML += '<param name="movie" value="'+this.getAttribute('swf')+'" />';

		var tags = this.getParamTags();

        if(tags.length > 0) flashHTML += tags;

		var pairs = this.getVariablePairs().join("&");

        if(pairs.length > 0) flashHTML += '<param name="flashvars" value="'+pairs+'" />';

        flashHTML += '</object>';

    }

    return flashHTML;

}

/*FlashObject.prototype.getAltImage = function(){

	return '<div style="background:url('+this.altImage+') no-repeat;width:100%;height:100%;" ></div>';

}*/

FlashObject.prototype.removeBackgroundImage = function(){

	this.setBackgroundImage("");

}

FlashObject.prototype.setBackgroundImage = function(link, repeat, color){

	if(link != null) this.element.style.backgroundImage = link;

	if(repeat != null) this.element.style.backgroundRepeat = repeat;

	if(color != null) this.element.style.backgroundColor = color;

}

FlashObject.prototype.write = function(){

	if(document.getElementById){

		if(this.isValidVersion){

			this.changeContent(this.getHTML());

		} else if(this.altImage){

			this.changeContent('');

			this.setBackgroundImage(this.altImage);

			//this.element.innerHTML = this.getAltImage();

		} else if(this.altContent){

			this.setBackgroundImage();

			this.changeContent(this.altContent);

		}

	}

}

FlashObject.prototype.changeContent = function(str){

	//alert('changeContent str='+str);

	this.element.innerHTML = str;

}



// FlashObjectUtil

FlashObjectUtil = new Object();

FlashObjectUtil.getPlayerVersion = function(){

	var version = new PlayerVersion(0,0,0);

	if(navigator.plugins && navigator.mimeTypes.length){

		var plugin = navigator.plugins["Shockwave Flash"];

		if(plugin && plugin.description) {

			version = new PlayerVersion(plugin.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));

		}

	} else if (window.ActiveXObject){

		try {

			var ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");

			version = new PlayerVersion(ax.GetVariable("$version").split(" ")[1].split(","));

	   } catch (e) {}

	}

	return version;

}

// PlayerVersion

PlayerVersion = function(arrVersion){

	this.major = parseInt(arrVersion[0]) || 0;

	this.minor = parseInt(arrVersion[1]) || 0;

	this.rev = parseInt(arrVersion[2]) || 0;

}

PlayerVersion.prototype.versionIsValid = function(fv){

	if(this.major < fv.major){

		return false

	} else if(this.major == fv.major){

		if(this.minor < fv.minor){

			return false

		} else if(this.minor == fv.minor){

			if(this.rev < fv.rev){

				return false

			}

		}

	}	

	return true;

}

//  get value of query string param

getQueryParamValue = function(param){

	var q = document.location.search || document.location.href.hash;

	if(q){

		var startIndex = q.indexOf(param +"=");

		var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;

		if (q.length > 1 && startIndex > -1) {

			return q.substring(q.indexOf("=", startIndex)+1, endIndex);

		}

	}

	return "";

}



// add Array.push if needed (ie5)

if (Array.prototype.push == null){

	Array.prototype.push = function(item){

		this[this.length] = item;

		return this.length;

	}

}
