/* ------------------- flash banner ------------------- */

// PARAMS
var params = {};
params.bgcolor = "#FFFFFF";
params.menu = "false";
params.scale = 'noScale';
params.wmode = "opaque";
params.allowfullscreen = "true";
params.allowScriptAccess = "always";

// ATTRIBUTES
var attributes = {};
attributes.id = 'flash';
attributes.name = 'flash'

// JAVASCRIPT VARS 
// cache buster
var cacheBuster = Date.parse(new Date());		    

// stage dimensions
var stageW = 608;
var stageH = 248; 

/** FLASH VARS **/
var flashvars = {};

// component dimensions inside the SWF file
flashvars.componentWidth = stageW;
flashvars.componentHeight = stageH;

// path to files (can be "")
flashvars.pathToFiles = "/image/banner/";

// path to content XML
flashvars.xmlPath = "banner.xml"

/** EMBED THE SWF**/        
swfobject.embedSWF('/image/banner/banner.swf', 'flash', stageW, stageH, '9.0.45', '/wp-content/themes/orion/images/flash/expressinstall.swf', flashvars, params, attributes);

/* ------------------- end of flash banner ------------------- */

function users_list(){
	alert('Trebuie sa va logati pentru a putea adauga produse in lista!');
};

function isEmail(string)
{
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	return true;
	else
	return false;
}

function focusInput(obj,text) {
	if (obj.value == text) {
		obj.value = '';
		//obj.className = "inputs_err";
	}
}

function blurInput(obj,text) {
	if (obj.value == '') {
		obj.value = text;
		//obj.className = "inputs_err inp_on";
	}
}

/* ----------------- distributors' page ----------------- */

function show_j(e){
	var id = e.options[e.selectedIndex].value;
	var url = location.href;
	var where = url.indexOf('?j=');
	if(where == -1){
		window.location.href = url + '?j=' + id;
	} else {
		if(id == 'a'){
			window.location.href = url.substr(0,where);
		} else {
			window.location.href = url.substr(0,where) + '?j=' + id;
		};
	};
};

/* ----------------- end of distributors' page ----------------- */

/* ----------------- newsletter ----------------- */

function inscrie(){
	if(document.getElementById('email').value == ''){
		alert('Va rugam introduceti o adresa de email valida!');
	} else {
		document.forms["inscriere"].submit();
	};
};

/* ----------------- end of newsletter ----------------- */

$(function(){
	jQuery('.newest ul').jcarousel();
	
	$("a.fancy").fancybox({
		'hideOnContentClick': true,
		'transitionIn'	:	'fadeIn',
		'transitionOut'	:	'fadeOut',
		'speedIn'		:	500, 
		'speedOut'		:	300
	});

	/* ----------------- login ----------------- */
	
	$('.not_logged_in .parola').after('<input type="password" value="" class="real_pass" name="pwd" id="user_pass" />');
	$('.not_logged_in .login_info input:first').attr('value','Username').attr('onfocus','focusInput(this, "Username");').attr('onblur','blurInput(this, "Username");').next().next().next().before('<input type="text" value="Parola" class="parola" />').prev().prev().remove();
	
	/* ----------------- login ----------------- */
	
	/* ----------------- fake pass ----------------- */
	
	$('.not_logged_in .parola').focus(function(){
		$(this).attr('style','display: none;');
		$('.not_logged_in .real_pass').attr('style','display: block;').focus();
	});
	
	$('.not_logged_in .real_pass').blur(function(){
		if($(this).val() == '') {
			$(this).attr('style','display: none;');
			$('.not_logged_in .parola').attr('style','display: block;');
		};
	});
	
	/* ----------------- end of fake pass ----------------- */
	
	/* ----------------- proiecte ----------------- */
	
	/*$('.proiect_other img').click(function(){
		var img_preview = $(this).parent().prev().children().first();
		var name = $(this).attr('src');
		var extension = name.slice(-4);
		name = name.replace('_thumb'+extension, extension);
		img_preview.attr('src',name).fadeIn(300);
	});*/
	
	var current = new Array();
	$('.holder').each(function(i){
		current[i] = $(this).children('.proiect_preview').children('a:first');
		$(this).children('.proiect_preview').children('a:not(:first)').hide();
		$(this).children('.go_right, .go_left').css('opacity','0.3');
		$(this).hover(function(){
			$(this).children('.go_left, .go_right').stop().fadeTo(200,1);
		},function(){
			$(this).children('.go_left, .go_right').stop().fadeTo(250,0.3);
		});
		
		$(this).children('.go_right').click(function(){
			if(current[i].next().html() != null){
				current[i].fadeOut();
				current[i] = current[i].next();
				current[i].fadeIn();
			};
		});
		
		$(this).children('.go_left').click(function(){
			if(current[i].prev().html() != null){
				current[i].fadeOut();
				current[i] = current[i].prev();
				current[i].fadeIn();
			};
		});
	});
	
	/* ----------------- end of proiecte ----------------- */
	
	/* ----------------- left menu ----------------- */

	var opened = [];
	var onClass = 'on';
	$('ul.left_menu').multiAccordion(opened,onClass);
	
	$('ul.left_menu li a').removeAttr('title');
	
	/* ----------------- end of left menu ----------------- */
	
});
