/*******************************************************************/
/*                                                                 */
/*                                                                 */
/*    JAVASCRIPT DOCUMENT DEVELOPED BY IVAN ALEKSIC				   */
/*    IMPLEMENTEK INTERNET CONSULTING GROUP	- BELGRADE - SERBIA	   */
/*    IVAN@IMPLEMENTEK.COM - WWW.IMPLEMENTEK.COM				   */
/*                                                                 */
/*    Copyright Bard na nGleann Teoranta - IRELAND - EUROPE		   */
/*                                                                 */
/*    Revision 1.0 - September 8. 2008. - Ivan					   */
/*    Revision 1.1 - September 9. 2008. - Ivan					   */
/*    Revision 1.2 - September 10. 2008. - Ivan					   */
/*    Revision 1.3 - September 18. 2008. - Ivan					   */
/*                                                                 */
/*                                                                 */
/*******************************************************************/


// Smooth scroller
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;
		}
	}
};

// Category Navigation
var myDummyVarOne = "";
function doCategory(obj) {
	if(document.getElementById(obj).style.display == 'none') {
		$(obj).blindDown({ duration: 0.7 });
	} else {
		$(obj).blindUp({ duration: 0.3 });
	}

	if(myDummyVarOne != "" && myDummyVarOne != obj) {
		$(myDummyVarOne).blindUp({ duration: 0.3 });
	}

	myDummyVarOne = obj;
}

// Subcategory Navigation
var myDummyVarTwo = "";
function doSubcategory(obj) {
	if(document.getElementById(obj).style.display == 'none') {
		$(obj).blindDown({ duration: 0.7 });
		//document.getElementById(obj).style.display = 'block';
	} else {
		$(obj).blindUp({ duration: 0.3 });
		//document.getElementById(obj).style.display = 'none';
	}

	if(myDummyVarTwo != "" && myDummyVarTwo != obj) {
		$(myDummyVarTwo).blindUp({ duration: 0.3 });
		//document.getElementById(myDummyVarTwo).style.display = 'none';
	}

	myDummyVarTwo = obj;
}

// Subsubcategory Navigation
var myDummyVarThree = "";
function doSubsubcategory(obj) {
	if(document.getElementById(obj).style.display == 'none') {
		$(obj).blindDown({ duration: 0.7 });
		//document.getElementById(obj).style.display = 'block';
	} else {
		$(obj).blindUp({ duration: 0.3 });
		//document.getElementById(obj).style.display = 'none';
	}

	if(myDummyVarThree != "" && myDummyVarThree != obj) {
		$(myDummyVarThree).blindUp({ duration: 0.3 });
		//document.getElementById(myDummyVarThree).style.display = 'none';
	}

	myDummyVarThree = obj;
}

// Payment Method
function openCards(obj) {
	$(obj).blindDown({ duration: 0.7 });
}
function closeCards(obj) {
	$(obj).blindUp({ duration: 0.3 });
}
