/********************************
* WASABI LIBIRY JS              *
* ----------------------------- *
* CR: DKone 19.06.2009 20:13:30 *
********************************/



/*********************
*  WASABI_LIB CLASS  *
*********************/
var wasabi_lib=Class.create({

	/****************************
	*  CONTENT-ELEMENT METHODS  *
	****************************/
	clearText:function(input) {//Login-Box + search: delete content of inputfield if onClick-event
		if(input.defaultValue==input.value) {
			input.value='';
			input.style.color="";
		}
	},
	restoreText:function(input) {
		if (input.value=='') {
			input.value=input.defaultValue;
			input.style.color='gray';
		}
	},



	/*******************
	*  COOKIE METHODS  *
	*******************/
	createCookie:function(name,value,days) {
		if(days) {
			var date=new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires='; expires='+date.toGMTString();
		}
		else expires='';
		document.cookie=name+'='+value+expires+'; path=/';
	},
	readCookie:function(name) {
		var nameEQ=name+'=';
		var ca=document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c=ca[i];
			while(c.charAt(0)==' ') c=c.substring(1,c.length);
			if (c.indexOf(nameEQ)==0) return c.substring(nameEQ.length,c.length);
		}
		return false;
	},
	deleteCookie:function(name) {
		document.cookie=name+'=;  expires=Thu, 01-Jan-70 00:00:01 GMT; path=/';
	},



	/*****************
	*  MISC METHODS  *
	*****************/
	noBlur:function(element) {
		if(element.blur){element.blur();}//useful in A-elements like: onfocus="noBlur(this);" or with keyboardNavigation:onmouseup="noBlur(this);
	},
	getRandomString:function(length) {//make a random string
		var chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
		var str='';
		for(x=0;x<length;x++) {
			i=Math.floor(Math.random() * 62);
			str+=chars.charAt(i);
		}
		return str;
	},
	pageScroll:function() {/* scroll page to top */
		var y=0;
		if(window.pageYOffset) {
			y=window.pageYOffset;
		} else if(document.body && document.body.scrollTop) {
			y=document.body.scrollTop;
		}
		if(y > 0) {
			window.scrollBy(0,-60);
			setTimeout('pageScroll()',10);
		}
	},
	preloadImage:function(imgList,path) {
		if(!path) {path='';}
		if(!Object.isArray(imgList)) {imgList=[imgList];}
		imgList.each(function(item){
			var temp=new Image();
			temp.src=path+item;
		});
	},
	getURIparam:function(param) {
		URI=window.location.href.toQueryParams();
		return $H(URI).get(param);
	},
	hideElementIfEmptyValue:function(value,element) {//if valueString is blank/notBlank, make element invisible/visible
		if(value.blank()) {
			element.setStyle({visibility:'hidden'});
		} else {
			element.setStyle({visibility:'visible'});
		}
	},
	makeHiddenTextfield:function(name,value) {
		return '<input name="'+name+'" type="hidden" value="'+value+'" />';
	},
	JSeffect:function(effect,element,options) {
		//alert('wasabi.lib.JSeffect(): '+effect+element+options);
		if(!wasabi.JSeffect) {
			if(effect=='BlindDown' || effect=='SlideDown' || effect=='Appear' || effect=='Grow') {effect='show';}
			if(effect=='BlindUp' || effect=='SlideUp' || effect=='Fade' || effect=='Shrink') {effect='hide';}
		}
		switch(effect) {
			case 'show':
				element.show();
				break;
			case 'hide':
				element.hide();
				break;
			case 'BlindDown':
				Effect.BlindDown(element,options);
				break;
			case 'BlindUp':
				Effect.BlindUp(element,options);
				break;
			case 'SlideDown':
				Effect.SlideDown(element,options);
				break;
			case 'SlideUp':
				Effect.SlideUp(element,options);
				break;
			case 'Appear':
				Effect.Appear(element,options);
				break;
			case 'Fade':
				Effect.Fade(element,options);
				break;
			case 'Grow':
				Effect.Grow(element,options);
				break;
			case 'Shrink':
				Effect.Shrink(element,options);
				break;
			case 'Shake':
				Effect.Shake(element,options);
				break;
			case 'Pulsate':
				Effect.Pulsate(element,options);
				break;
		}
		if((effect=='show' || effect=='hide') && options.afterFinish) {options.afterFinish();}
	}
});



/**********************
*  WASABI_LIB OBJECT  *
**********************/
wasabi.lib=new wasabi_lib();

