﻿// Watermark effect on input.text fields

Event.observe(window, 'load', function(e){$$('input.text').each(startWatermark)});

function hideWatermark(e)
{
	if (e.element().title == e.element().value) e.element().value = '';
}

function showWatermark(e)
{
	if (e.element().value == '') e.element().value = e.element().title;
}

function startWatermark(e)
{
	if (e.value == '') e.value = e.title;
	$(e).observe('focus', hideWatermark);
	$(e).observe('blur', showWatermark);
}

/* Cookies functions */
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function existCookie(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 1;
	}
	return 0;
}

/* Bind down/up */

function swapBind(elementId)
{
	var el = document.getElementById(elementId);
	if (el.style.display != 'none')
	{
	    Effect.BlindUp(elementId, { duration: 0.5, queue: { position: 'end', scope: 'qf', limit: 1} })
	}
	else
	{
	    Effect.BlindDown(elementId, { duration: 0.5, queue: { position: 'end', scope: 'qf', limit: 1 }, afterFinish: function() {
	        $(elementId).style.display = "block";
	        //alert('a');
	    }
	    })
	    
	    
	    
	    //el.style.overflow = 'hidden';
	}
}

/* Forum scripts */
function swapForumVisible(forumId)
{
	var el = $('forum_' + forumId);
	if (el.style.display != 'none')
	{
		Effect.BlindUp(el, {duration: 0.5, queue: {position:'end', scope: 'qf', limit:1} })
		$('forum_hide_button_' + forumId).className = 'right plus';
		createCookie("HideForum" + forumId, "1", 3600);
	}
	else
	{
		Effect.BlindDown(el, {duration: 0.5, queue: {position:'end', scope: 'qf', limit:1} })
		$('forum_hide_button_' + forumId).className = 'right';
		createCookie("HideForum" + forumId, "", -1);
	}
}

function swapForumVisibleFast(forumId)
{
	var el = $('forum_' + forumId);
	if (el.style.display != 'none')
	{
		el.style.display = 'none';
		$('forum_hide_button_' + forumId).className = 'right plus';
		createCookie("HideForum" + forumId, "1", 3600);
	}
	else
	{
		el.style.display = '';
		$('forum_hide_button_' + forumId).className = 'right';
		createCookie("HideForum" + forumId, "", -1);
	}
}

/* Box pager */
var box_timers = new Array();

function box_show_next(id)
{
	var allNodes = document.getElementsByName('box_' + id + '_link');
	var next = box_hide_all(id) + 1;
	if (next >= allNodes.length) next = 0;
	
	box_show_proper(id, next);
}

function box_show_prev(id)
{
	var allNodes = document.getElementsByName('box_' + id + '_link');
	var next = box_hide_all(id) - 1;
	if (next < 0) next = allNodes.length - 1;
	
	box_show_proper(id, next);
}

function box_show_page(id, page)
{
	box_hide_all(id);
	box_show_proper(id, page);
}

function box_hide_all(id)
{
	var allNodes = document.getElementsByName('box_' + id + '_link');
	
	var current = 0;
	
	for(i = 0; i < allNodes.length; i++) {
		if (allNodes[i].className == 'selected') current = i;
		allNodes[i].className = '';
		$('box_'+id+'_content_'+i).style.display = 'none';
	}
	
	return current;	
}

function box_show_proper(id, page)
{	
	clearTimeout(box_timers['\''+id+'\'']);
	var allNodes = document.getElementsByName('box_' + id + '_link');
	allNodes[page].className = 'selected';
	$('box_'+id+'_content_'+page).style.display = '';
	box_timers['\''+id+'\''] = setTimeout('box_show_next(\''+id+'\')',8000);
}

function swapMessage(elementId)
{
	var el = document.getElementById(elementId);
	//alert(el);
	if (el.style.display != 'none')
	{
		Effect.BlindUp(elementId, {duration: 0.5, queue: {position:'end', scope: 'qf', limit:1} })
		//$$('body')[0].setAttribute('onclick', '');
	}
	else
	{
		Effect.BlindDown(elementId, {duration: 0.5, queue: {position:'end', scope: 'qf', limit:1} })
		//$$('body')[0].setAttribute('onclick', 'swapQuickFaq("quick_faq"); return false;');
	}
}

function swapMessageOpen(elementId)
{
	var elements;
	elements = $('register').getElementsByClassName('f_description2');
	
	for(i=0;i<elements.length;i++) 
	{
		if(elements[i].style.display != 'none') {
			elements[i].hide();
			//Effect.BlindUp(elements[i], {duration: 0.5, queue: {position:'end', scope: 'qf', limit:1} })
		}
	}
	
	Effect.BlindDown($(elementId), {duration: 0.5, queue: {position:'end', scope: 'qf', limit:1} })
	//$$('body')[0].setAttribute('onclick', 'swapQuickFaq("quick_faq"); return false;');
}

function swapMessageClose()
{
	var elements;
	elements = $('register').getElementsByClassName('f_description2');
	
	for(i=0;i<elements.length;i++) 
	{
		if(elements[i].style.display != 'none') {
			Effect.BlindUp(elements[i], {duration: 0.5, queue: {position:'end', scope: 'qf', limit:1} })
		}
	}
}

function resizeAAA()
{
 $('aaa').select('a').each(function(link){
     link.style.textDecoration = '';
 }); 
 document.getElementById(this.id).style.textDecoration = 'underline';
 document.getElementById('resize_content').className = this.id;
}