function $() 
	{   
		if (arguments.length>1) 
			{
				return false;
			}
		if (arguments.length<1) 
			{
				return false;
			}
		var element = arguments[0];
		if (typeof element == 'string') 
			{
				if (document.getElementById) 
					{
						element = document.getElementById(element);           
					}
				else if (document.all) 
					{
						element = document.all[element];
					}
			}
		return element;
	}


function setFocus(elem)
	{
	    try {
		document.getElementById(elem).focus();
		} 
		catch(ex){
		}
	}

function changeLanguage( lang )
{
      if($("ctrlHeader_hLang"))
      {
        if($("ctrlHeader_hLang") !=lang)
        {
            document.getElementById("ctrlHeader_hLang").value = lang;
            document.getElementById("ctrlHeader_hAction").value = "ChangeLanguage";
            document.getElementById("frmMain").submit();
         }
     }
}

function toggleMenuSelection(subl)
	{
		var i=1;
		if (document.getElementById(subl).className=='lisub dB') 
			{
				document.getElementById(subl).className='lisub dN';
			}
		else if (document.getElementById(subl).className!='lisub dB')
				{
					while (document.getElementById("subl"+i)!=null) 
					{ 					   
					    document.getElementById('subl'+i).className='lisub dN';
						i++;
					}
					document.getElementById(subl).className='lisub dB';		
				}
	}
/*
function doSearch()
{
	/*if($("txCautare") && $("txCautare").value.replace(/[\s]+$/g,"") != "" )
        searchText = $("txCautare").value.replace(/[\s]+$/g,"");
    else*/
/*        searchText = $("txSearch").value.replace(/[\s]+$/g,"");
    if(searchText != "")
       document.location = "cautare.aspx?search="+searchText;
}

function doSearchPage()
{
	//if($("txCautare") && $("txCautare").value.replace(/[\s]+$/g,"") != "" )
        searchText = $("txCautare").value.replace(/[\s]+$/g,"");
   /* else
        searchText = $("Header_txCautare").value.replace(/[\s]+$/g,"");*/
/*  if(searchText != "")
        document.location = "cautare.aspx?search="+searchText;
}*/


function doSearch()
{
    var keyword = $("txSearch").value;
    if(keyword!="" > 0)
    {
        document.location.href = "/search.aspx?caut="+keyword;
    }
    return false;
}

function searchKey(e)
{
    var keynum;
    //try {console.log('a');}catch(ex){}
    if(window.event) // IE
        keynum = e.keyCode
    else if(e.which) // Netscape/Firefox/Opera
        keynum = e.which
    if (keynum ==13)
    { 
        doSearch();
        return false;
    }
    else
        return true;
}


function searchPage_clearText() {
    if ($("txCautare").value=="cerca" ) {
        $("txCautare").value = "";
        searchPage_wasCleared = true;
    }
}

function searchPage_showText() {
    if (searchPage_wasCleared && trim($("txCautare").value).length == 0) {
        $("txCautare").value = "cerca";
        searchPage_wasCleared = false;
    }
}


function ChangeFont(font,id) {
    document.getElementById(id).value = font;
    document.getElementById('frmMain').submit();
}



jQuery(function($) {
    
    //Toggle checkboxes
    $('#ckAlte').toggleElement('#txAlte');
    $('#ckAlte2').toggleElement('#txAlte2');
    
    //EmptyOnFocus
    $('#search').emptyOnFocus();
    
    // IE6 fixes
    if ($.browser.msie) { //IF IE
        
        if ($.browser.version <= 6 ) { //IF IE6
            //Forms
            $('input:text, input:password').addClass('inputText')
                .add('textarea')
                    .focus(function(){$(this).addClass('focus');})
                    .blur(function(){$(this).removeClass('focus');});
            
            
            $('#homeBoxes li').hover(
                function(){ $(this).addClass('hover'); },
                function(){ $(this).removeClass('hover'); }
            );
        }
    }
    
    //Set external Links
    $('a[rel=external]').attr('target','_blank');
    
    //Navigation select (with cookie)
    var itemActive = false;
    var items = $('#nav a');
    items.each(function(i){
        if ($(this).is('.selected')) itemActive = true;
        
        //Setting the cookie on the links
        $(this).click(function(){
            $.cookie('nav',i);
        });
    });
    
    if (!itemActive) {
        var cookieActive = $.cookie('nav');
        items.eq(eval(cookieActive)).addClass('selected');
    }
    
    
   
    
});


function SendSubscriber()
{
    var txEmail = document.getElementById("txEmail").value;  
    var error = "";
        
    if (isNotEmpty(txEmail))
    {
        if (isNotEmpty(txEmail) && !isEmail(txEmail))
        {
            error += getJSPH("Contact_EmailValid");
        }        
    }
    else
    {
        error += getJSPH("Contact_EmailValid");
    }
        
    if (error.length > 0) 
    {
        error = getJSPH("Contact_RemediatiProblemele") + error;
        alert(error);
    }
    else
    {
        document.location.href='/confirmareInscriere.aspx?sEmail='+txEmail;
    }
}


function isNotEmpty(val)
{
  return ((trim(val)).length>0);
}

function isEmail(val)
{
    if (!isNotEmpty(val)) {
        return true;
    }
	else {
	    var m = val.match(/\w+[.]?\w*@\w+[.]\w+/g);
	    return ((m!=null)&&(m.length>0));
	}
}

function isValidPhoneChar(c)
{
	if((c == "0")||(c == "1")||(c == "2")||(c == "3")||(c == "4")) return true;
	if((c == "5")||(c == "6")||(c == "7")||(c == "8")||(c == "9")) return true;
	if((c == '/')||(c == '-')||(c == '+')) return true;
	if((c == '(')||(c == ')')||(c == ' ')) return true;
	return false;
}

function isPhoneValid(value)
{
	var i=0;
	var s = new String();
	var c='';
	s = value.toString()
	for(i=0;i<s.length;i++)
	{
		c = s.substring(i,i+1);
		if(!isValidPhoneChar(c))
		{
			return false;
		}
	}
	return true;
}

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}
jQuery(function($) {
	$('ul.items').carouFredSel({
		auto    : {
	        items           : 1,
	        duration        : 3000,
	        easing          : "linear",
	        pauseDuration   : 0,
	        pauseOnHover    : true
	    },
		width:960,
		visibleItems		: 8,
		direction			: "left"				
	});
});
jQuery(function($) { 

    
	$(document).ready(function()
	{
		var quide = $('.guide');
		var guideLi = quide.find('li.selected');
		
		if (guideLi.length >= 1) {
			guideLi.parents().addClass('selected');
		} 
		


        // initialize scrollable
        //$(".scrollable").scrollable();
        //$(".scrollable").scrollable({circular: true}).autoscroll({ autoplay: true });


		
	});
	
	jQuery(".quote.guide ul").treeview({collapsed: true});
	jQuery(".quote.guide ul li:first div.hitarea").trigger("click");
	
});
