/*************************************************************************/
/*                                                                 		 */
/*    JAVASCRIPT DOCUMENT DEVELOPED BY IVAN ALEKSIC				   		 */
/*    IMPLEMENTEK INTERNET CONSULTING GROUP	- BELGRADE - SERBIA		     */
/*    IVAN@IMPLEMENTEK.COM - WWW.IMPLEMENTEK.COM					     */
/*                                                                 		 */
/*    Copyright Student Instintute For International & Global Affairs    */
/*    BELGRADE - SERBIA - EUROPE									     */
/*                                                             	  	     */
/*    Revision 1.0 - November 25. 2008. - Ivan					  		 */
/*                                                             	  	     */
/*************************************************************************/

MMJSV = {
	init: function(fid, vld) {
		frm = document.getElementById(fid);
		frm.onsubmit = function() {
			ret = true;
			for (i in vld) {
				valid = true;
				el = document.getElementById(i);
				if (el.type == "submit") continue;
				fld = vld[i];
				el.onchange = function() {
					frm.onsubmit();
				}
				if (null != fld.validator) {
					valid = fld.validator.test(el.value);
				}
				if (valid) {
					if (null != fld.minLength) {
						valid = el.value.length >= fld.minLength;
					}
				}
				labels = document.getElementsByTagName('LABEL') || document.all;
				if (!valid) {
					el.className = vld[i].originalClass+"error";
					for (j in labels) {
						if (labels[j].htmlFor == i) {
							if (null == fld.noError) {
								fld.noError = labels[j].innerHTML;
							}
							labels[j].innerHTML = fld.error;
							break;
						}
					}
				} else {
					el.className = vld[i].originalClass;
					for (j in labels) {
						if (labels[j].htmlFor == i) {
							if (null != fld.noError) {
								labels[j].innerHTML = fld.noError;
							}
							break;
						}
					}
				}
				if (!valid) {
					ret = false;
				}
			}
			return ret;
		}
	},

	validators: {
		notEmpty: /.+/,
		email: /(.*?)@(.*?)\.(.*?)/i,
		number:	/^[0-9]+$/,
		year: /^[12][0-9]{3}$/,
		alphanum: /[^\\dA-Z]/i,
		blank: /[^\\s]/,
		human: { test: function(param) {	return param > 100;	} }
	}
}

var ScrollWin = {
	w3c : document.getElementById,
	iex : document.all,
	scrollLoop : false, 
	scrollInterval : null,
	currentBlock : null,
	getWindowHeight : function(){
		if(this.iex) return (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		else return window.innerHeight;
	},
	getScrollLeft : function(){
		if(this.iex) return (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		else return window.pageXOffset;
	},
	getScrollTop : function(){
		if(this.iex) return (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		else return window.pageYOffset;
	},
	getElementYpos : function(el){
		var y = 0;
		while(el.offsetParent){
			y += el.offsetTop
			el = el.offsetParent;
		}
		return y;
	},
	scroll : function(name){
		if(!this.w3c){
			location.href = "#"+name;
			return;
		}
		if(this.scrollLoop){
			clearInterval(this.scrollInterval);
			this.scrollLoop = false;
			this.scrollInterval = null;
		}
		if(this.currentBlock != null) this.currentBlock.className = this.offClassName;
		this.currentBlock = document.getElementById(name);
		this.currentBlock.className = this.onClassName;
		var doc = document.getElementById(this.containerName);
		var documentHeight = this.getElementYpos(doc) + doc.offsetHeight;
		var windowHeight = this.getWindowHeight();
		var ypos = this.getElementYpos(this.currentBlock);
		if(ypos > documentHeight - windowHeight) ypos = documentHeight - windowHeight;
		this.scrollTo(0,ypos);
	},
	scrollTo : function(x,y){
		if(this.scrollLoop){
			var left = this.getScrollLeft();
			var top = this.getScrollTop();
			if(Math.abs(left-x) <= 1 && Math.abs(top-y) <= 1){
				window.scrollTo(x,y);
				clearInterval(this.scrollInterval);
				this.scrollLoop = false;
				this.scrollInterval = null;
			}else{
				window.scrollTo(left+(x-left)/2, top+(y-top)/2);
			}
		}else{
			this.scrollInterval = setInterval("ScrollWin.scrollTo("+x+","+y+")",50);
			this.scrollLoop = true;
		}
	}
};

ScrollWin.containerName = "container"; 
ScrollWin.anchorName    = "anchor";    
ScrollWin.blockName     = "home";     
ScrollWin.onClassName   = "active";   
ScrollWin.offClassName  = "visited"; 

$(document).ready(function(){
	
	$('a img').hover(
		 function(){$(this).animate({opacity:0.7}, { duration: "fast" });}, 
		 function(){$(this).animate({opacity:1}, { duration: "fast" });});
	
	
});