//Common
function showHide(tmp_id) {
	var obj = $(tmp_id);
	
	obj.style.display = (obj.style.display == 'none') ? '' : 'none';
}

//Featured
var featured_i = 0;
var featured_count;
function initFeatured(tmp_count) {
	featured_count = tmp_count;
	
	setInterval("animateFeatured();", 3000);
}

function animateFeatured() {
	var old_i;

	old_i = featured_i;
	featured_i++;
	
	if (featured_i >= featured_count) {
		featured_i = 0;
	}
	
	Tween.addTween($('featured_content'), 1, { _x: -248, transition: "expoOut", onComplete: function () {
		if (old_i > -1) {
			var img = $('featured_td' + String(old_i));
			img.parentNode.removeChild(img);
			$('featured_tr').appendChild(img);
		}
	
		$('featured_content').style.left = "0px";
	}});
}
	

function overFeatured(tmp_id) {
	Tween.addTween($(tmp_id), 0.4, { _alpha: 100, transition: "quartOut" });
}

function outFeatured(tmp_id) {
	Tween.addTween($(tmp_id), 0.4, { _alpha: 0, transition: "quartOut" });
}

//Search
function videosSearch() {
	var search = $('videos_search_input').value;
	
	if (search == "" || search.length < 3) {
		alert("Please insert at least 3 letters");
	}
	
	document.location = videos_search_link.replace("#QUERY#", search);
}

//Password digits
function initDigits(tmp_id_base, tmp_count) {
	var input;
	for (i = 1; i <= tmp_count; i++) {
		input = $(String(tmp_id_base) + String(i));
		input.maxLength = 1;
		input.digitIdBase = String(tmp_id_base);
		input.digitCount = tmp_count;
		input.digitIndex = i;
		
		if (OS.isIOS) {
			input.onkeydown = function (e) {
				var code = "";
				for (var i = 1; i <= 5; i++) {
					code += String($(this.digitIdBase + String(i)).value);
				}
				
				if (e.keyCode == 8) {
					code = code.substr(0, code.length - 1);
					r = false;
				} else if (e.keyCode == 13) {
					if (this.digitIdBase == 'password1_digits') {
				   		enterPasswordDownloads();
				   	} else if (this.digitIdBase == 'password2_digits') {
				   		enterPasswordEmbed();
				   	} else {
				   		enterProtectedVideo(this.digitIdBase.split('_digits').join(''));
				   	}
				} else {
					code += String.fromCharCode(e.keyCode);
				}
				
				for (i = 1; i <= 5; i++) {
					$(this.digitIdBase + String(i)).value = code.charAt(i - 1);
				}
				
				if (this.digitIdBase == 'password1_digits') {
				   CSS.removeClass($('downloads_password_box'), 'incorrect');
				} else if (this.digitIdBase == 'password2_digits') {
				   CSS.removeClass($('embed_password_box'), 'incorrect');
				} else {
				   CSS.removeClass($(this.digitIdBase.split('_digits').join('') + '_protected'), 'incorrect');
				}
				
				return false;
			}
		} else {
		
			Event.add(input, (OS.isIOS) ? 'keydown' : 'keyup', function(e) {
				e = e || event;
				
				if (this.value.length == 1) {
				   if (this.digitIndex < this.digitCount) {
				   	$(this.digitIdBase + String(this.digitIndex + 1)).focus();
				   }
				} else {
				   if (e.keyCode == 8) {
				   	if (this.digitIndex > 1) {
				   		$(this.digitIdBase + String(this.digitIndex - 1)).focus();
				   	}
				   }
				}
				 
				if (e.keyCode == 13) {
				   if (this.digitIdBase == 'password1_digits') {
				   	enterPasswordDownloads();
				   } else if (this.digitIdBase == 'password2_digits') {
				   	enterPasswordEmbed();
				   } else {
				   	enterProtectedVideo(this.digitIdBase.split('_digits').join(''));
				   }
				}
				 
				if (this.digitIdBase == 'password1_digits') {
				   CSS.removeClass($('downloads_password_box'), 'incorrect');
				} else if (this.digitIdBase == 'password2_digits') {
				   CSS.removeClass($('embed_password_box'), 'incorrect');
				} else {
				   CSS.removeClass($(this.digitIdBase.split('_digits').join('') + '_protected'), 'incorrect');
				}
			});
		}
	}
}

//Downloads
function loadDownloads() {
	if (!(user_id > 0)) {
		alert("To download files, you first need to Log In or Register.");
		return;
	}

	if (downloads_password == '(PROTECTED)') {
		$('downloads_filters').style.display = 'none';
		Tween.addTween($('downloads_password_box'), 0.4, { _y: 0, transition: "quartOut", onComplete: function () {
			$('password1_digits1').focus();
		}});
		Tween.addTween($('downloads_password_box_wrapper'), 0.4, { _height: 69, _marginTop: 17, transition: "quartOut" });
		
		return;
	}
	
//	window.open ("http://nuview.tv/html5/site/content/pages/download.php?id=" + video_id,"donwload","menubar=0,resizable=0,width=100,height=100"); 

	var ajax = new Ajax();
	ajax.onLoad = function () {
		$('downloads_container').innerHTML = this.html;
		$('downloads_loading').style.display = 'none';
		
		if (this.html == '') {
			return;
		}
		
		$('downloads_filters').style.display = '';
		
		//if (true) {
		/*var group;
		var img;
		for (i = 1; i <= 3; i++) {
		    group = $('downloads_group' + String(i));
		    if (!group) {
		    	img = $('downloads_filter' + String(i) + '_img');
		    	CSS.addClass(span, 'hidden');
		    	span.onclick = function () {};
		    	
		    	if (downloads_selected_filter == i) {
		    		downloads_selected_filter = 0;
		    	}
		    }
		}*/

		if (downloads_selected_filter > -1) {
		    filterDownloads(downloads_selected_filter);
		}
		//}
	}
	
	$('downloads_loading').style.display = '';
	ajax.get(ajax_root + "routine/ajaxDownloads/" + video_id + "/" + downloads_password + "/");
}

function filterDownloads(filter_type) {
	
	if (!(user_id > 0)) {
		alert("To download files, you first need to Log In or Register.");
		return;
	}

	if (downloads_password == '(PROTECTED)') {
		$('downloads_filters').style.display = 'none';
		Tween.addTween($('downloads_password_box'), 0.4, { _y: 0, transition: "quartOut", onComplete: function () {
			$('password1_digits1').focus();
		}});
		Tween.addTween($('downloads_password_box_wrapper'), 0.4, { _height: 69, _marginTop: 17, transition: "quartOut" });
		return;
	}
	

	var ajax = new Ajax();
	ajax.onLoad = function () {
		$('downloads_container').innerHTML = this.html;
		$('downloads_loading').style.display = 'none';
		
		if (this.html == '') {
			return;
		}
		
		$('downloads_filters').style.display = '';

		if (downloads_selected_filter > -1) {
		    filterDownloads(downloads_selected_filter);
		}
	}
	
	$('downloads_loading').style.display = '';
	ajax.get(ajax_root + "routine/ajaxDownloads/" + video_id + "/" + filter_type + "/");
}

/*
function filterDownloads(tmp_group_index) {
	var group, img;
	
	if ($('downloads_container').innerHTML == '') {
		downloads_selected_filter = tmp_group_index;
		loadDownloads();
		return;
	}
	
	for (i = 0; i <= 3; i++) {
	    group = $('downloads_group' + String(i));
	    if ((i == 0) || (group)) {
	    	if (group) {
		    	if (tmp_group_index == 0 || tmp_group_index == i) {
		    		group.style.display = '';
	    		} else {
	    			group.style.display = 'none';
	    		}
	    	}
	    	
	    	img = $('downloads_filter' + String(i) + '_img');
	    	if (tmp_group_index == i) {
	    		img.src = img.src.split('-sel.png').join('.png').split('.png').join('-sel.png');
	    	} else {
	    		img.src = img.src.split('-sel.png').join('.png');
	    	}
	    	
	    }
	}
}
*/

function cancelPasswordDownloads() {
	downloads_password = '(PROTECTED)';
	
	//$('downloads_filters').style.display = '';
	//$('downloads_password_box').style.display = 'none';
	CSS.removeClass($('downloads_password_box'), 'incorrect');
	$('downloads_password_description').innerHTML = 'A code is required to acess these downloads.';
	
	for (i = 1; i <= 5; i++) {
		$('password1_digits' + String(i)).value = '';
		//$('password1_digits' + String(i)).blur();
	}
	
	Tween.addTween($('downloads_password_box'), 0.4, { _y: -69, transition: "quartOut", onComplete: function () {
		$('downloads_filters').style.display = '';
	}});
	Tween.addTween($('downloads_password_box_wrapper'), 0.4, { _height: 0, _marginTop: 0, transition: "quartOut" });
}

function enterPasswordDownloads() {
	var password = '';
	for (i = 1; i <= 5; i++) {
		password += $('password1_digits' + String(i)).value;
	}
	
	var ajax = new Ajax();
	ajax.onLoad = function () {
		$('downloads_password_loading').style.display = 'none';
		if (this.html == "[INVALID]") {
			CSS.addClass($('downloads_password_box'), 'incorrect');
			$('downloads_password_description').innerHTML = 'Incorrect passcode. Please try again.';
		} else {
			//alert($('downloads_password_box'));
			
			Tween.addTween($('downloads_password_box'), 0.4, { _y: -69, transition: "quartOut"});
			Tween.addTween($('downloads_password_box_wrapper'), 0.4, { _height: 0, _marginTop: 0, transition: "quartOut" });
			
			CSS.removeClass($('downloads_password_box'), 'incorrect');
			downloads_password = this.html;
			loadDownloads();
		}
	}
	$('downloads_password_loading').style.display = '';
	ajax.get(ajax_root + 'routine/ajaxValidateVideoPassword/' + video_id + '/' + password + '/');
}

//Embed
function loadEmbed(tmp_auto) {
	if (embed_password == '(PROTECTED)') {
		$('embed_filters').style.display = 'none';
		Tween.addTween($('embed_password_box'), 0.4, { _y: 0, transition: "quartOut", onComplete: function () {
			$('password2_digits1').focus();
		}});
		Tween.addTween($('embed_password_box_wrapper'), 0.4, { _height: 69, _marginTop: 17, transition: "quartOut" });
		
		return;
	}

	var auto = tmp_auto;
	var ajax = new Ajax();
	ajax.onLoad = function () {
		$('embed_container').innerHTML = this.html;
		$('embed_loading').style.display = 'none';
		
		if (this.html == '') {
			return;
		}
		
		if (true) {
			if (embed_autoopen) {
				openEmbed(tmp_auto);
			} else {
				$('embed_filters').style.display = '';
			}
		}
	}
	
	$('embed_loading').style.display = '';
	ajax.get(ajax_root + "routine/ajaxEmbed/" + video_id + "/" + embed_password + "/");
}

function openEmbed(tmp_auto) {
	if ($('embed_container').innerHTML == '') {
		embed_autoopen = true;
		loadEmbed(true);
		return;
	}
	
	var onc = null;
	if (embed_first_time) {
		embed_first_time = false;
		onc = function () {
			selectSizeEmbed(1);
			selectAll($('embed_code'));
		}
	}
	
	$('embed_container').style.display = '';
	
	if (!embed_open) {
		Tween.addTween($('embed_container'), 0.4, { _y: 0, transition: "quartOut" });
		Tween.addTween($('embed_container_wrapper'), 0.4, { _height: 185, transition: "quartOut", onComplete: onc });
	} else {
		Tween.addTween($('embed_container'), 0.4, { _y: -167, transition: "quartOut" });
		Tween.addTween($('embed_container_wrapper'), 0.4, { _height: 0, transition: "quartOut" });
	}
	embed_open = !embed_open;
}

function cancelPasswordEmbed() {
	embed_password = '(PROTECTED)';
	
	//$('embed_filters').style.display = '';
	//$('embed_password_box').style.display = 'none';
	CSS.removeClass($('embed_password_box'), 'incorrect');
	$('embed_password_description').innerHTML = 'A code is required to embed this video.';
	
	for (i = 1; i <= 5; i++) {
		$('password2_digits' + String(i)).value = '';
	}
	
	Tween.addTween($('embed_password_box'), 0.4, { _y: -69, transition: "quartOut", onComplete: function () {
		$('embed_filters').style.display = '';
	}});
	Tween.addTween($('embed_password_box_wrapper'), 0.4, { _height: 0, _marginTop: 0, transition: "quartOut" });
}

function enterPasswordEmbed() {
	var password = '';
	for (i = 1; i <= 5; i++) {
		password += $('password2_digits' + String(i)).value;
	}
	
	var ajax = new Ajax();
	ajax.onLoad = function () {
		$('embed_password_loading').style.display = 'none';
		if (this.html == "[INVALID]") {
			CSS.addClass($('embed_password_box'), 'incorrect');
			$('embed_password_description').innerHTML = 'Incorrect passcode. Please try again.';
		} else {
			//$('embed_password_box').style.display = 'none';
			
			Tween.addTween($('embed_password_box'), 0.4, { _y: -69, transition: "quartOut", onComplete: function () {
				$('embed_filters').style.display = '';
			}});
			Tween.addTween($('embed_password_box_wrapper'), 0.4, { _height: 0, _marginTop: 0, transition: "quartOut" });
			
			CSS.removeClass($('embed_password_box'), 'incorrect');
			embed_password = this.html;
			loadEmbed();
		}
	}
	$('embed_password_loading').style.display = '';
	ajax.get(ajax_root + 'routine/ajaxValidateVideoPassword/' + video_id + '/' + password + '/');
}

function selectSizeEmbed(tmp_index) {
	var sizes = [[560, 340], [640, 385], [846, 486]];
	
	$('embed_code').value = $('embed_basecode').value.split("#WIDTH#").join(sizes[tmp_index - 1][0]).split("#HEIGHT#").join(sizes[tmp_index - 1][1]);
	
	if (!$('embed_radio' + tmp_index).checked) {
		$('embed_radio' + tmp_index).checked = true;
	}
}

function selectAll(tmp_input) {
	tmp_input.select();
}

//Login
var user_id = 0;
var auto_login = false;
function enterLogin() {
	//$('Username**2_TXT1').blur();
	//$('Password**2_TXT1').blur();
	
	if (f.send('frm_login', true)) {
		$('login_submit').blur();
	
		var ajax = new Ajax();
		ajax.onLoad = function () {
			$('login_loading').style.display = 'none';
			
			var arr = this.html.split('|#|');
			
			//alert(parseInt(arr[0]) + " - " + arr[0]);
			
			if (parseInt(arr[0]) == 1) {
				user_id = parseInt(arr[1]);
				
				$('login_user').innerHTML = String(arr[2]);
				//$('login_last_login').innerHTML = String(arr[3]);
				
				$('login_form').style.display = 'none';
				$('login_logged').style.display = '';
				
				$('register_header').style.display = 'none';
				$('lkForgotten').style.display = 'none';
				CSS.addClass($('login_header'), 'login-logged');
				
				if (!auto_login) {
					toggleRegister(false);
				}
			} else {
				$('login_incorrect').style.display = '';
			}
			
			this.runJS(this.html);
		}
		
		$('login_loading').style.display = '';
		ajax.sendForm('frm_login');
	}
}

function closeIncorrectLogin() {
	$('login_incorrect').style.display = 'none';
}

function enterLogout() {
	var ajax = new Ajax();
	ajax.onLoad = function () {
		user_id = 0;
		
		$('login_loading').style.display = 'none';
		CSS.removeClass($('login_loading'), 'login-logged');
		
		$('login_form').style.display = '';
		$('login_logged').style.display = 'none';
		
		$('register_header').style.display = '';
		$('lkForgotten').style.display = '';
		CSS.removeClass($('login_header'), 'login-logged');
	}
	
	CSS.addClass($('login_loading'), 'login-logged');
	$('login_loading').style.display = '';
	ajax.get(ajax_root + "routine/ajaxLogout/");
}

//Protected Video
var input_name;
function loadProtectedVideo(tmp_prefix, tmp_small) {
	//$(tmp_prefix + '_protected').style.display = '';
	$(tmp_prefix + '_preview_play').style.display = 'none';
	//$(tmp_prefix + '_padlock').style.display = 'none';
	
	if (tmp_small) {
		Tween.addTween($(tmp_prefix + '_protected'), 0.4, { _y: 0, transition: "quartOut", onComplete: function () {
			$(tmp_prefix + '_digits1').focus();
		}});
	} else {
		Tween.addTween($(tmp_prefix + '_protected'), 0.4, { _alpha: 100, transition: 'quadOut', onComplete: function () {
			$(tmp_prefix + '_digits1').focus();
		}});
	}
}

function cancelProtectedVideo(tmp_prefix, tmp_small) {
	//$(tmp_prefix + '_protected').style.display = 'none';
	$(tmp_prefix + '_preview_play').style.display = '';
	//$(tmp_prefix + '_padlock').style.display = '';
	
	CSS.removeClass($(tmp_prefix + '_protected'), 'incorrect');
	$(tmp_prefix + '_protected_description').innerHTML = 'A code is required to view this video.';
	
	for (i = 1; i <= 5; i++) {
		$(tmp_prefix + '_digits' + String(i)).value = '';
		$(tmp_prefix + '_digits' + String(i)).blur();
	}
	
	if (tmp_small) {
		Tween.addTween($(tmp_prefix + '_protected'), 0.4, { _y: 178, transition: "quartOut" });
	} else {
		Tween.addTween($(tmp_prefix + '_protected'), 0.4, { _alpha: 0, transition: 'quadOut' });
	}
}

function enterProtectedVideo(tmp_prefix, tmp_small) {
	var video_id = $(tmp_prefix + '_input_video_id').value;
	var width = $(tmp_prefix + '_input_width').value;
	var height = $(tmp_prefix + '_input_height').value;
	var index = $(tmp_prefix + '_input_index').value;
	
	var password = '';
	for (i = 1; i <= 5; i++) {
		password += $(tmp_prefix + '_digits' + String(i)).value;
	}
	
	var ajax = new Ajax();
	var prefix = tmp_prefix;
	var small = tmp_small;
	ajax.onLoad = function () {
		$(tmp_prefix + '_protected_loading').style.display = 'none';
		
		if (this.html.indexOf("[INVALID]") == 0) {
			CSS.addClass($(tmp_prefix + '_protected'), 'incorrect');
			$(tmp_prefix + '_protected_description').innerHTML = 'Incorrect passcode. Please try again.';
		} else {
			if (small) {
				Tween.addTween($(tmp_prefix + '_protected'), 0.4, { _y: 178, transition: "quartOut", onComplete: function () {
					$(prefix + '_protected').style.display = 'none';
				}});
			} else {
				Tween.addTween($(tmp_prefix + '_protected'), 0.4, { _alpha: 0, transition: "quartOut", onComplete: function () {
					$(prefix + '_protected').style.display = 'none';
				}});
			}
			
			CSS.removeClass($(tmp_prefix + '_protected'), 'incorrect');
			$(tmp_prefix + '_preview').style.display = 'none';
			
			$(tmp_prefix + '_container').style.display = '';
			$(tmp_prefix + '_container').innerHTML = this.html;
			
			this.runJS(this.html);
		}
	}
	$(tmp_prefix + '_protected_loading').style.display = '';
	ajax.get(ajax_root + 'routine/ajaxVideo/' + video_id + '/' + password + '/' + width + '/' + height + '/' + index + '/');
}

//Register
function toggleRegister(tmp_visible) {
	var height_to;
	var y_to;

	if (tmp_visible) {
		//$('register_box').style.display = '';
		CSS.addClass($('register_header'), 'register-selected');
		
		height_to = 442;
		y_to = -4;
		
		/*if ($('register_container').innerHTML == "") {
			var ajax = new Ajax();
			ajax.onLoad = function () {
				$('register_loading').style.display = 'none';
				$('register_container').innerHTML = this.html;
				this.runJS(this.html);
			}
			$('register_loading').style.display = '';
			ajax.get(ajax_root + "routine/ajaxRegisterHtml/");
		}*/
		
	} else {
		//$('register_box').style.display = 'none';
		CSS.removeClass($('register_header'), 'register-selected');
		
		height_to = 0;
		y_to = -4 - 442;
	}
	
	Tween.addTween($('register_box_content'), 0.8, { _y: y_to, transition: "quartOut" });
	Tween.addTween($('register_box'), 0.8, { _height: height_to, transition: "quartOut" });
}

var _verify_email = false;
var _verify_username = false;
function enterRegister(tmp_from_step) {
	if (tmp_from_step == 1) {
		if (f.send('frm_register', true)) {
			
//			verifyEmail($('E-mail Address_EML1').value);
//			verifyUsername($('Username_TXT1_3').value);
			
			//alert('email: '+_verify_email+' -- username:'+_verify_username);
			if ($('E-mail Address_EML1').value == $('Re-type E-mail Address_EML1').value) {
				
				if(_verify_email) {
					
					if(_verify_username) {						

						if (encriptString($('Security_TXT1').value.toUpperCase()) == $('register_captcha_code').innerHTML) {	
							$('register_step1').style.display = 'none';
							$('register_step2').style.display = '';
						} else {
							alert("Your security confirmation is incorrect.");
							$('Security_TXT1').focus();
							f.lastFocusedElement = $('Security_TXT1');
						}
						
					} else {
						alert("The Username already exists.");
					}
					
				} else {
					alert("The E-mail already exists.");
				}
								
			} else {
				alert("The E-mail confirmation is invalid.");
			}
		}
	} else {
		if ($('register_accept_terms').checked) {
			var ajax = new Ajax();
			ajax.onLoad = function () {
				$('register_loading').style.display = 'none';
				$('register_step3').style.display = '';
				
				//$('Username**2_TXT1').value = $('Username_TXT1_3').value;
				//$('Password**2_TXT1').value = $('Password_PW11_6').value;
				
				//auto_login = true;
				//enterLogin();
			}
			
			$('register_step2').style.display = 'none';
			$('register_loading').style.display = '';
			ajax.sendForm('frm_register');
		} else {
			alert("You must agree to the terms and conditions.");
		}
	}
}

function verifyEmail(email) {

	var ajax = new Ajax();	
	ajax.onLoad = function () {		
		
		var arr = this.html.split('|#|');

		if (parseInt(arr[0]) == 1) {
			_verify_email = false;
		} else if (parseInt(arr[0]) == 0) {
			_verify_email = true;
		} else {
			_verify_email = false;
		}

	}
	
	ajax.get(ajax_root + "routine/ajaxVerifyEmail/" + email);
}

function verifyUsername(username) {

	var ajax = new Ajax();
	ajax.onLoad = function () {
		
		var arr = this.html.split('|#|');
		if (parseInt(arr[0]) == 1) {
			_verify_username = false;
		} else if (parseInt(arr[0]) == 0) {
			_verify_username = true;
		} else {
			_verify_username = false;
		}
		
	}
	
	ajax.get(ajax_root + "routine/ajaxVerifyUsername/" + username);
}

function backToFormRegister() {
	$('register_step1').style.display = '';
	$('register_step2').style.display = 'none';
}

function encriptString(tmp_string) {
	var arr = ['4', '5', 'J', 'A', 'Q', 'c', 'n', 'x', 'P', 'Y', 'd', 'b', 'g', 'i', 'j', 'y', 'a', '9'];
	var t = arr.length - 1;
	var r = "";
	var l = tmp_string.length;
	var c1, c2;	
	
	for (i = 0; i < l; i++) {
		c1 = 0;
		c2 = tmp_string.charCodeAt(i);
			
		while (c2 > t) {
			c2 -= t;
			c1++;
		}
			
		if ((i % 2) == 0) { r += String(arr[c1]) + String(arr[c2]); }
		else { r += String(arr[t - c1]) + String(arr[t - c2]); }
	}
		
	return r;
}

//Contact
function enterContact() {
	if (f.send('frm_contact', true)) {
		var ajax = new Ajax();
		ajax.onLoad = function () {
			$('contact_loading').style.display = 'none';
			$('contact_ok').style.display = '';
		}
		
		$('contact_loading').style.display = '';
		$('contact_form').style.display = 'none';
		ajax.sendForm('frm_contact');
	}
}

//Info
var info_visible = true;
function toogleInfo(tmp_no_animation) {
	var y_to;
	var height_to;
	var oncomplete = null;
	
	if (info_visible) {
		/*oncomplete = function () {
			$('info_box').style.display = 'none';
		}*/
		
		y_to = 8;
		height_to = 0;
		
		CSS.removeClass($('info_box_bt'), "info-bt-open");
	} else {
		//$('info_box').style.display = '';
		y_to = 46;
		height_to = 28;
		
		CSS.addClass($('info_box_bt'), "info-bt-open");
	}
	
	if (tmp_no_animation == true) {
		$('info_box_content').style.top = String(y_to) + "px";
		$('info_box').style.height = String(height_to) + "px";
		
		/*if (oncomplete != null) {
			oncomplete.apply();
		}*/
	} else {
		Tween.addTween($('info_box'), 0.8, { _height: height_to, transition: "quartOut" });
		Tween.addTween($('info_box_content'), 0.8, { _y: y_to, transition: "quartOut"/*, onComplete: oncomplete */});
	}
	
	info_visible = !info_visible;
}

//Share
function toogleShare(tmp_visible) {
	if (tmp_visible) {
		$('share_box').style.visibility = 'visible';
	} else {
		$('share_box').style.visibility = 'hidden';
	}
}

//Pre load images
function preloadImages() {
	for (i = 0; i < preload_images.length; i++) {
		var img = document.createElement('img');
		img.src = preload_images[i];
	}
}

var preload_images = [];
//preload_images.push("site/img/structure/register-bg.png");
//preload_images.push("site/img/structure/");
preloadImages();

/********   forgotten password  **********/
function openBoxForgotten() {

	if(document.getElementById('box-forgotten').className == "close") {
		document.getElementById('box-forgotten').className = 'open';
	} else {
		document.getElementById('box-forgotten').className = 'close';
	}
	
}

function enterForgotten() {
	
	if (f.send('frm_pswd_forgot', true)) {
	
		var ajax = new Ajax();
		ajax.onLoad = function () {
			
			var arr = this.html.split('|#|');
			document.getElementById('frm_pswd_forgot').innerHTML = '';
			if (parseInt(arr[0]) == 1) {
				document.getElementById('box-forgotten-content').innerHTML = '<p class="text">Your Password has been sent to you.</p>';
			} else {
				document.getElementById('box-forgotten-content').innerHTML = '<p class="text">This username not in our database.</p>';
			}
			
			this.runJS(this.html);
		}
		
		ajax.sendForm('frm_pswd_forgot');
	}
	
}

