/* this script is bilalis made (c) 2007 (www.bilalis.com) */

function bll_linkAtSign(user, domain) {
	location.href = 'mai' + 'lto' + ':' + user + '@' + domain;
}
function bll_showAtSign(user, domain) {
	document.write(user + '@' + domain);
}

function bll_getStyle(obj, style) {
	if ( document.defaultView && document.defaultView.getComputedStyle ) {
		var v = document.defaultView.getComputedStyle(obj, null)[style];
	} else if ( obj.currentStyle ) {
		var v = obj.currentStyle[style];
	}
	return v;
}

function bll_addLoadEvent(func) {
	var oldonload = window.onload;
	if ( typeof window.onload != 'function' ) {
		window.onload = func;
	} else {
		window.onload = function() {
			if ( oldonload ) oldonload();
			if ( func ) func();
		}
	}
}

function bll_position(obj, objParent) {
	var objX, objY, pageX, pageY, viewPortWidth, viewPortHeight, pageWidth, pageHeight;
	objX = objY = pageX = pageY = viewPortWidth = viewPortHeight = null;
	if ( typeof obj == 'object' ) {
		if ( obj.offsetParent ) {
			do {
				objX += obj.offsetLeft;
				objY += obj.offsetTop;
			} while ( obj = obj.offsetParent );
		}
	}
	if ( typeof objParent == 'object' ) {
		if ( objParent.offsetParent ) {
			var objParentX = objParent.offsetLeft;
			var objParentY = objParent.offsetTop;
			while ( objParent = objParent.offsetParent ) {
				objParentX += objParent.offsetLeft;
				objParentY += objParent.offsetTop;
			}
			objX -= objParentX;
			objY -= objParentY;
		}
	}
	
	if ( document.documentElement ) {
		viewPortWidth = document.documentElement.clientWidth;
		viewPortHeight = document.documentElement.clientHeight;
		pageX = document.documentElement.scrollLeft;
		pageY = document.documentElement.scrollTop;
		if ( document.documentElement.scrollHeight > document.documentElement.offsetHeight ) {
			pageWidth = document.documentElement.scrollWidth;
			pageHeight = document.documentElement.scrollHeight;
		} else {
			pageWidth = document.documentElement.offsetWidth;
			pageHeight = document.documentElement.offsetHeight;
		}
	} else if ( document.body ) {
		viewPortWidth = document.body.clientWidth;
		viewPortHeight = document.body.clientHeight;
		pageX = document.body.scrollLeft;
		pageY = document.body.scrollTop;
		if ( document.body.scrollHeight > document.body.offsetHeight ) {
			pageWidth = document.body.scrollWidth;
			pageHeight = document.body.scrollHeight;
		} else {
			pageWidth = document.body.offsetWidth;
			pageHeight = document.body.offsetHeight;
		}
	}
	return [objX, objY, pageX, pageY, viewPortWidth, viewPortHeight, pageWidth, pageHeight];
}

function bll_write(writeStr) {
	document.write(writeStr);
}

function bll_getNextElementSibling(node) {
	var sib = node;
	if ( sib.nodeType == 3 ) sib = sib.parentNode;
	sib = sib.nextSibling;
	while (	sib.nodeType != 1 ) sib = sib.nextSibling;
	return sib;
}

function bll_getPreviousElementSibling(node) {
	var sib = node;
	if ( sib.nodeType == 3 ) sib = sib.parentNode;
	sib = sib.previousSibling;
	while (	sib.nodeType != 1 ) sib = sib.previousSibling;
	return sib;
}

function bll_getElementsByClassName(obj, strTagName, classNames) {
	if ( !obj.getElementsByTagName ) return;
	var arrElements = ( strTagName == '*' && obj.all ) ? obj.all : obj.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if ( typeof classNames == 'object' ) {
		for ( var i = 0; i < classNames.length; i++ ) {
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + classNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	} else {
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + classNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for ( var j = 0; j < arrElements.length; j++ ) {
		oElement = arrElements[j];
		bMatchesAll = true;
		for ( var k = 0; k < arrRegExpClassNames.length; k++ ) {
			if ( !arrRegExpClassNames[k].test(oElement.className) ) {
				bMatchesAll = false;
				break;
			}
		}
		if ( bMatchesAll ) {
			arrReturnElements.push(oElement);
		}
	}
	return ( arrReturnElements );
}

function bll_scrollToFixed(obj, offsetY) {
	if ( typeof stf == 'undefined' ) stf = new Array;
	if ( typeof obj == 'object' ) {
		obj.initialY = bll_position(obj)[1];
		obj.initialStylePosition = bll_getStyle(obj, 'position');
		switch ( typeof offsetY ) {
			case 'number':
				obj.plusY = offsetY;
				break;
			case 'boolean':
				obj.plusY = obj.initialY;
				break;
			default:
				obj.plusY = 0;
		}
		stf[stf.count] = setInterval(function() {
			var position = bll_position(obj);
			if ( position[3] + obj.plusY > obj.initialY ) {
				switch ( typeof obj.supportFixed ) {
					case 'boolean':
						if ( !obj.supportFixed ) {
							obj.style.top = (position[3] + obj.plusY) + 'px';
						} else {
							obj.style.top = obj.plusY + 'px';
							obj.style.position = 'fixed';
						}
						break;
					default:
						obj.style.top = obj.plusY + 'px';
						obj.style.position = 'fixed';
						obj.supportFixed = ( obj.offsetTop != obj.plusY ? false : true );
						if ( !obj.supportFixed ) {
							obj.style.top = (position[3] + obj.plusY) + 'px';
							obj.style.position = obj.initialStylePosition;
						}
				}
			} else if ( position[1] != obj.initialY ) {
				if ( typeof obj.supportFixed == 'boolean' ) {
					if ( !obj.supportFixed ) {
						obj.style.top = obj.initialY + 'px';
					} else {
						obj.style.top = obj.initialY + 'px';
						obj.style.position = obj.initialStylePosition;
					}
				}
			}
		}, 100);
	}
}

/*-*-* class named "hover" holds the "cursor: pointer" rule and copy of :hover rules *-*-*-*-*-*-*/
function bll_cloneLinkToPreviousSiblingImagePairsByParent(parentTagName, parentClassName, onmouseoverImgClassName, onmouseoverAClassName) {
	var links, theImg, theLink;
	var parents = bll_getElementsByClassName(document, parentTagName, parentClassName);
	for ( var i = 0, iMax = parents.length; i < iMax; i++ ) {
		if ( links = parents[i].getElementsByTagName('a') ) {
			for ( var j = 0, jMax = links.length; j < jMax; j++ ) {
				theLink = links[j];
				theImg  = bll_getPreviousElementSibling(theLink);
				if ( theImg.nodeName.toLowerCase() == 'img' ) {
					theImg.theHref	   = theLink.href;
					theImg.oc		   = theImg.className;
					theLink.oc		   = theLink.className;
					theImg.onmouseover = function() {
						var theLink = bll_getNextElementSibling(this);
						if ( onmouseoverImgClassName != undefined && onmouseoverImgClassName != '' ) {
							this.className = onmouseoverImgClassName;
						} else {
							this.className = ( this.oc != '' ) ? this.oc + ' hover' : 'hover';
						}
						if ( onmouseoverAClassName != undefined && onmouseoverAClassName != '' ) {
							theLink.className = onmouseoverAClassName;
						} else {
							theLink.className = ( theLink.oc != '' ) ? theLink.oc + ' hover' : 'hover';
						}
					}
					theLink.onmouseover = function() {
						var theImg = bll_getPreviousElementSibling(this);
						if ( onmouseoverImgClassName != undefined && onmouseoverImgClassName != '' ) {
							theImg.className = onmouseoverImgClassName;
						} else {
							theImg.className = ( theImg.oc != '' ) ? theImg.oc + ' hover' : 'hover';
						}
						if ( onmouseoverAClassName != undefined && onmouseoverAClassName != '' ) {
							this.className = onmouseoverAClassName;
						} else {
							this.className = ( this.oc != '' ) ? this.oc + ' hover' : 'hover';
						}
					}
					theImg.onmouseout = function() {
						var theLink = bll_getNextElementSibling(this);
						this.className = this.oc;
						theLink.className = theLink.oc;
					}
					theLink.onmouseout = function() {
						var theImg = bll_getPreviousElementSibling(this);
						this.className = this.oc;
						theImg.className = theImg.oc;
					}
					theImg.onclick = function() {
						location.href = this.theHref;
						return false;
					}
				}
			}
		}
	}
}
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

function bll_toggleSmallToLargeImage(className, loadingImageSrc, objParent) {
	var albums, photos, source;
	if ( albums = bll_getElementsByClassName(document, 'div', className) ) {
		for ( var i = 0, iMax = albums.length; i < iMax; i++ ) {
			photos = albums[i].getElementsByTagName('img');
			for ( var j = 0, jMax = photos.length; j < jMax; j++ ) {
				photos[j].style.cursor = 'pointer';
				photos[j].onclick = function() {
					var position = ( typeof objParent == 'object' ? bll_position(this, objParent) : bll_position(this) );
					this.blur();
					var loadSign = new Image();
					if ( this.src.search(/_s\.jpg$/) != -1 ) {
						loadSign.src = loadingImageSrc;
						loadSign.style.position = 'absolute';
						loadSign.style.border = 'none';
						this.parentNode.insertBefore(loadSign, this);
						loadSign.style.top  = (position[1] + (parseInt((this.height - loadSign.height) / 2) - parseInt(bll_getStyle(this, 'marginTop'))))  + 'px';
						loadSign.style.left = (position[0] + (parseInt((this.width - loadSign.width) / 2)   - parseInt(bll_getStyle(this, 'marginLeft')))) + 'px';
						this.src = this.src.replace(/_s\.jpg$/, '_l.jpg');
						this.onload = function() {
							this.parentNode.removeChild(this.previousSibling);
						}
						this.removeAttribute('width');
						this.removeAttribute('height');
					} else if ( this.src.search(/_l\.jpg$/) != -1 ) {
						this.src = this.src.replace(/_l\.jpg$/, '_s.jpg');
						this.onload = null;
						this.removeAttribute('width');
						this.removeAttribute('height');
					}
					loadSign = null;
					nextSize = null;
					return false;
				}
			}
		}
	}
}

bll_addLoadEvent(function(){bll_scrollToFixed(document.getElementById('page_menu'));bll_scrollToFixed(document.getElementById('back_to_top'))});
