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 focusOn(elem)
//	{
//		elem.style.border = "1px #CC0000 solid";
//		//elem.style.backgroundColor = "#666";
//	}

//function focusOff(elem)
//	{
//		elem.style.border = "1px #D3D3D3 solid";
//		//elem.style.backgroundColor = "#161616";
//	}

function setFocus(elem)
	{
	    try {
		document.getElementById(elem).focus();
		} 
		catch(ex){
		}
	}

//<![CDATA[
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;
//]]>

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();
         }
     }
     if($("ctrlHeaderHome_hLang"))
     {
        if($("ctrlHeaderHome_hLang") !=lang)
        {
            document.getElementById("ctrlHeaderHome_hLang").value = lang;
            document.getElementById("ctrlHeaderHome_hAction").value = "ChangeLanguage";
            document.getElementById("frmMain").submit();
         }
     }

}

function toggleElement(handle,content,additionalContent){
    if (additionalContent) { 
        if (handle.is(':checked')) {
            additionalContent.fadeOut('fast',
                function(){
                    content.fadeIn('fast');
                }
            );   
        } else {
            content.fadeOut('fast',
                function(){
                    additionalContent.fadeIn('fast');
                }
            ); 
        }
    
    } else {
        if (handle.is(':checked')) {
            content.fadeIn('fast');
        } else {
            content.fadeOut('fast');
        }
    }
}

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 search_clearText() {
    if ($("txSearch").value=="cerca" ) {
        $("txSearch").value = "";
        search_wasCleared = true;
    }
}

function search_showText() {
    if (search_wasCleared && trim($("txSearch").value).length == 0) {
        $("txSearch").value = "cerca";
        search_wasCleared = false;
    }
}

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 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;
}

function ChangeFont(font,id) {
    document.getElementById(id).value = font;
    document.getElementById('frmMain').submit();
}



function AddFlashPlayer(){
	if (document.getElementById('player1') || document.getElementById('player2')) {
		PlayHeaderFlash();
	}
	if (document.getElementById('Animation')) {
		PlayHomeFlash();
	}	
}



//jQuery.noConflict();

jQuery(function($) { 
	
	
	/*
	 * IE fix
	 */
	//Filter IE
	if ($.browser.msie) {
		$('#nav>li>ul>li:last-child').addClass('last-child');
		
		$('#nav>li:first-child').addClass('first-child');
		$('#nav>li:last-child').addClass('last-child');
		
		//AboutNav separators
		aboutNavLi = $('#aboutNav>li').not(':first-child');
		aboutNavLi.prepend(' | ');
		
		$('input:text, input:password, textarea')
		    .focus(function(){ $(this).addClass('focus'); })
		    .blur(function(){ $(this).removeClass('focus'); });
		
		//Filter IE6
		if ($.browser.version == 6) {
			
		}
	}
	
		
	/*
	 * Navigation Animation
	 */
	var nav = $('#nav');
	var active = nav.find('.active');
	
	//Setting active classes
	active.parents('li').addClass('active');
	
	//Hiding non active elements
	nav.find('li').not('.active').find('>ul').hide();
	
	//Setting a click event on level 1 & 2 links
	//which will return false as only lvl 3 links are real
	var a = nav.find('>li>a');
	a.click(function(){
		var li = $(this).parent();
		
		if (li.is('.active')) {
		    $('ul',li).slideUp('fast');
		    li.removeClass('active');
		} else {
		
		    //Hiding other branches
		    var siblings = li.siblings();
		    siblings.find('>ul').slideUp('fast');
    		
		    //Removing the 'active' class from the other branches
		    siblings.removeClass('active');
    		
		    //Showing this particular branch
		    li.find('>ul').slideDown('fast');
    		
		    //Setting the 'active' class
		    li.addClass('active');
		}
		
		//Returning false as this link has only animation purposes
		var children = li.find('a');
		if (children.length != 1) {
		    return false;
		}
	});
	
	
	
});
