$(document).ready(function(){

	function initCorners() {
	    var settings = {
	      tl: { radius: 10 },
	      tr: { radius: 10 },
	      bl: { radius: 10 },
	      br: { radius: 10 },
	      antiAlias: true
	    }

	    /*
	    Usage:

	    curvyCorners(settingsObj, selectorStr);
	    curvyCorners(settingsObj, Obj1[, Obj2[, Obj3[, . . . [, ObjN]]]]);

	    selectorStr ::= complexSelector [, complexSelector]...
	    complexSelector ::= singleSelector[ singleSelector]
	    singleSelector ::= idType | classType
	    idType ::= #id
	    classType ::= [tagName].className
	    tagName ::= div|p|form|blockquote|frameset // others may work
	    className : .name
	    selector examples:
	      #mydiv p.rounded
	      #mypara
	      .rounded
	    */
	    curvyCorners(settings, ".roundedCorners");
	  }

	initCorners();
	

	    
	
	
	
	var language="ro";
	
	// in cookie "displayloginbox" avem statusul
	var statusLoginBox=$.cookie('displayloginbox');
	if(statusLoginBox == 'hide' ) {
		 $("#login_top").hide();
		 $("#login_body").hide();
		 $("#login_body_color").hide();
		 $("#login_top_show").show();
	}
	else
	{

	}

	
	

	
	
	$("#showGalerie").click(function(event)
	{
		event.preventDefault();
		$("#concept_popup").css("display","none");
		
		if($("#galerie_popup").css("display")=="block")
		{
			$("#galerie_popup").css("display","none");
// 			$("#concept_popup").fadeOut("fast");alert($("#concept_popup").css("display"));
		}else{
			$("#galerie_popup").fadeIn("fast");	
		}
		return false;
	});
	
	$("#galerie_popup").mouseleave(function()
	{
		$(this).hide();
	});
	
	$("#concept_popup").mouseleave(function()
			{
				$(this).hide();
			});
	
	// menu from login
	$("#showAccount").click(function(event)
			{
		event.preventDefault();
		$(this).addClass("bara_contul_meu_button_selectat");
		$("#pop_up_pasapoarte_box").css("display","none");
		$("#pop_up_contul_meu_box").show();	
		return false;
			});
	
	
	$("#btnShowAccount").hover(function() { //Hover over event on list item
		$("#showAccount").addClass("bara_contul_meu_button_selectat");
		$("#pop_up_contul_meu_box").show(); //Show the subnav
	} , function() { //on hover out...
		$("#showAccount").removeClass("bara_contul_meu_button_selectat");
		$("#pop_up_contul_meu_box").hide();
	});

	$("#btnShowPasapoarte").hover(function() { //Hover over event on list item
		$("#showPasapoarte").addClass("bara_contul_meu_button_selectat");
		$("#pop_up_pasapoarte_box").show(); //Show the subnav
	} , function() { //on hover out...
		$("#showPasapoarte").removeClass("bara_contul_meu_button_selectat");
		$("#pop_up_pasapoarte_box").hide();
	});
	
	$("#btnSlideUpLogin").click(function(event){
		event.preventDefault();
		 $("#login_top").hide();
		 $("#login_body_color").slideToggle("slow",function(){
			$("#login_body").hide();
			$("#login_top_show").fadeIn();
		 });
		 $.cookie('displayloginbox', 'hide');		 
	});

	$("#btnSlideDownLogin").click(function(event){
		event.preventDefault();
		$("#login_top_show").hide();
		 
		 $("#login_body").show();
		 $("#login_body_color").slideToggle("slow",function(){
			 $("#login_top").fadeIn(); 
		 });
		 $.cookie('displayloginbox', 'show');
	});
	
	
	$("#btnShowConcept").hover(
	  function() { //Hover over event on list item
		if($("#showConcept").hasClass("butoane_arrow"))
		{
			selected=false;
			$("#showConcept").addClass("butoane_arrow_selected");
			$("#showConcept").removeClass("butoane_arrow");		
		}
		else
		{
			selected=true;
		}
		
		$("#concept_popup").show(); //Show the subnav
		
	} , function() { //on hover out...
		if(!selected)
		{
			$("#showConcept").addClass("butoane_arrow");
			$("#showConcept").removeClass("butoane_arrow_selected");
		}
		$("#concept_popup").hide(); //Show the subnav
	});
	
	
	function toggleLoading(left,top)
	{
	
		if(left!=false)
		{
		$("#loadingImg").css( { "left": left + "px", "top":top + "px" } );
		$("#loadingImg").show();
		}
		else
		{
		$("#loadingImg").hide();	
		}
	}
	
	
	// history for ajax callback
    $.tenis10var = {
        firstload : 0,
        other: "other"
    } 
	   
                
	   $.address.externalChange(function(link){
	       var baseurl=$.address.baseURL();
           
           var hash=$.address.hash();
           var container=false;
           //  alert(hash+','+$.tenis10var.firstload);
           // alert(baseurl);
           
           var strurl=baseurl+'/'+$.address.hash();
                var ajaxurl="";
        		strurl=strurl.split("/");
        		for(i=0;i<strurl.length;i++)
        		{
        			if( strurl[i]==language )
        			{
        				ajaxurl+=language+"/";
        				ajaxurl+='ajax/';
        			    isajax = true;
        			}else{
        				ajaxurl+=strurl[i]+'/';
        			}
        		}
           
           if($.tenis10var.firstload>1 || hash.length>1)
                {
        	   
        	   if(baseurl.indexOf("/ro/video")>0)
               {     
                     var container='video_listing_container';
                        
               }
               else if(baseurl.indexOf("/ro/stiri")>0)
               {     
                     var container='modul_stiri';
                        
               }
               else if(baseurl.indexOf("/ro/concept")>0)
               {     
                     var container='middle';
                        
               }
               else if(baseurl.indexOf("/ro/jucatori")>0)
               {     
                     var container='passports_listing_container';   
               }
               else if(baseurl.indexOf("/ro/cluburi")>0)
               {     
                     var container='clubs_listing_container';   
               }
               else if(baseurl.indexOf("/ro/home")>0)
               {     
                     if(hash == '')
                     {
                        document.location=baseurl;
                     }
                     else
                     {
                        if(hash.indexOf("/jucatori")>0)
                        {
                            var container='modul_pasapoarte';
                        }
                        else if(hash.indexOf("/competitii")>0)
                        {
                            var container='modul_competitii';
                        }
                        
                        
                     }
                        
               }
               else if(baseurl.indexOf("/ro/competitii")>0)
               {     
                     var container='competitions_listing_container';   
                     if(hash.indexOf("in-desfasurare/")==0)
                     {
                        var index =1;
                     }
                     else if(hash.indexOf("incheiate/")==0)
                     {
                        var index =2;
                     }
                     else if(hash.indexOf("viitoare/")==0)
                     {
                        var index =0;
                     }
                     else
                     {
                        var index =0;
                     }
                    var tabname="competitions_tabs";
                    var tabdiv=$("div.competitions_tabs");
                    			
        			var total=3; 
        		    
        		    for(i=0;i<total;i++)
        		    {
        		    	var tabid=$("div[class=competitions_tab]").find("li")[i];      		    	
        		    	if(i==index)
        		    	{		    			
        			    	 $(tabid).removeClass("inactiv");
        			    	 $(tabid).addClass("activ");
        		    	}
        		    	else
        		    	{
        		    		$(tabid).removeClass("activ");
        			    	$(tabid).addClass("inactiv");
        		    	}
        		    }
                     
               }
               else if(baseurl.indexOf("/ro/foto")>0)
               {     
                     var container='foto_listing_container';   
                     if(hash.indexOf("fotografii-turnee/")==0)
                     {
                        var index =2;
                     }
                     else if(hash.indexOf("fotografii-evenimente/")==0)
                     {
                        var index =3;
                     }
                     else if(hash.indexOf("toate-fotografiileviitoare/")==0)
                     {
                        var index =1;
                     }
                     else
                     {
                        var index =1;
                     }
                    
                    			
        			var total=4; 
        		   // alert(index);
        		    for(i=1;i<total;i++)
        		    {
        		    	  		    	
        		    	if(i==index)
        		    	{		    			
        			    	 $("#tab-"+i).removeClass("inactiv");
        			    	 $("#tab-"+i).addClass("activ");
        		    	}
        		    	else
        		    	{
        		    		$("#tab-"+i).removeClass("activ");
        			    	$("#tab-"+i).addClass("inactiv");
        		    	}
        		    }
                     
               }
               
               ajaxloading(container,ajaxurl);               
              
           }
	        $.tenis10var.firstload++;
	   })
       $.address.init(function(init)
       {
            $.tenis10var.firstload++;
       });
       
       
       function ajaxloading(container,ajaxurl)
       {
        $("#"+container).load(ajaxurl,function(){
		  
          toggleLoading(false,false);
						
		 // display pagination
					
		 if($("#"+container+"_paginare_hidden") != "" ){
						
		      $($("#"+container+"_paginare")).html($("#"+container+"_paginare_hidden").html());
		 }
					
		});
       }
    
	$("a[rel*=ajax]").live("click",function(event){
		event.preventDefault();		
		var baseurl=encodeURI($.address.baseURL());
        
        var isajax=false;
	//	$.history.load(this.href);
		
		
		//var strurl=$(this).attr("href");
        var strurl = $(this).attr('href')
		var ajaxurl="";
		strurl=strurl.split("/");
		for(i=0;i<strurl.length;i++)
		{
			if( strurl[i]==language )
			{
				ajaxurl+=language+"/";
				ajaxurl+='ajax/';
			    isajax = true;
			}else{
				ajaxurl+=strurl[i]+'/';
			}
		}
        
       //  alert(ajaxurl);
        
        
        if(isajax)
        {
           // alert(baseurl);
            temp=$(this).attr('href').split(baseurl+'/');
           //  alert(temp);
            $.address.hash(temp[1]);
            
        }
		var temp=$(this).attr("rel").split("|");
		
		var container=temp[1];
		// alert(container);
		if(container != "" || container !="undefined")
		{
						
			// toggleLoading($("#"+container).offset().left,$("#"+container).offset().top);
			toggleLoading(event.pageX - 20,event.pageY - 30);
			

				$("#"+container).load(ajaxurl,function(){
					
						
						
						toggleLoading(false,false);
						
						// $("#"+container).pngFix(); 
						if(temp[2]=="scroll"){
							$("#login").scrollTo();
						}
					 // display pagination
					
					 if($("#"+container+"_paginare_hidden") != "" ){
						
						 $($("#"+container+"_paginare")).html($("#"+container+"_paginare_hidden").html());
					 }
					
					 
				//	 $(".disponibilitate_competitie").everyTime(1000,'getlivedata',function()
						   //	 {
					//	 			alert($(this).load($(this).attr("rel")));
						   		//	$(this).load($(this).attr("rel"));		
						//   	 });
					 
					 
					 });
			

			/*
			$("#"+container).fadeTo("fast",0,function(){
				
				$("#"+container).load(ajaxurl,function(){
					
						toggleLoading(false,false);
						
						// $("#"+container).pngFix(); 
						if(temp[2]=="scroll"){
							$("#login").scrollTo();
						}
					 // display pagination
					
					 if($("#"+container+"_paginare_hidden") != "" ){
						
						 $($("#"+container+"_paginare")).html($("#"+container+"_paginare_hidden").html());
					 }
					 $("#"+container).fadeTo("fast",1);
					 
				//	 $(".disponibilitate_competitie").everyTime(1000,'getlivedata',function()
						   //	 {
					//	 			alert($(this).load($(this).attr("rel")));
						   		//	$(this).load($(this).attr("rel"));		
						//   	 });
					 
					 
					 });
			});
			*/
			
			 

			 
		}
		else
		{
		document.location=strurl;	
		}
		
	});

	$("a.help").live("click",function(event){
		event.preventDefault();
		var openurl=$(this).attr("href");
		$.fn.colorbox({
			href:openurl,
			opacity:0.5,
			overlayClose:false,
			close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
			});
	});   
	
	
	$('#judet').selectbox({
		inputClass: 'selectbox1'
	});
	

	
	
	$('a.tooltip').live('click',function(event){
		event.preventDefault();
		
	});
	
	$('a.tooltip-big').live("click",function(event){
		event.preventDefault();
		
		
	});
	

	$.fn.cluetip.defaults = {  // default options; override as needed
		   // width:            275,      // The width of the clueTip
		    height:           'auto',   // The height of the clueTip. more info below [1]
		    cluezIndex:       97,       // Sets the z-index style property of the clueTip
		    positionBy:       'auto',   // Sets the type of positioning. more info below [2]
		    topOffset:        15,       // Number of px to offset clueTip from top of invoking element. more info below [3]
		    leftOffset:       15,       // Number of px to offset clueTip from left of invoking element. more info below [4]
		    local:            false,    // Whether to use content from the same page for the clueTip's body
		                                // (treats the attribute used for accessing the tip as a jQuery selector,
		                                // but only selects the first element if the selector matches more than one). more info below [5]
		    hideLocal:        true,     // If local option is set to true, this determines whether local content
		                                //  to be shown in clueTip should be hidden at its original location
		    attribute:        'rel',    // the attribute to be used for fetching the clueTip's body content
		    titleAttribute:   'title',  // the attribute to be used for fetching the clueTip's title
		    splitTitle:       '',       // A character used to split the title attribute into the clueTip title and divs
		                                // within the clueTip body. more info below [6]
		    showTitle:        false,     // show title bar of the clueTip, even if title attribute not set
		    cluetipClass:     'jtip',// class added to outermost clueTip div in the form of 'cluetip-' + clueTipClass. more info below [7]
		    hoverClass:       '',       // class applied to the invoking element onmouseover and removed onmouseout
		    waitImage:        true,     // whether to show a "loading" img, which is set in jquery.cluetip.css
		    arrows:           true,    // if true, displays arrow on appropriate side of clueTip. more info below [8]
		    dropShadow:       true,     // set to false if you don't want the drop-shadow effect on the clueTip
		    dropShadowSteps:  6,        // adjusts the size of the drop shadow
		    sticky:           false,    // keep visible until manually closed
		    mouseOutClose:    false,    // close when clueTip is moused out
		    activation:       'hover',  // set to 'click' to force user to click to show clueTip
		    clickThrough:     false,    // if true, and activation is not 'click', then clicking on a clueTipped link will take user to 
		                                // the link's href, even if href and tipAttribute are equal
		    tracking:         false,    // if true, clueTip will track mouse movement (experimental)
		    delayedClose:     0,        // close clueTip on a timed delay (experimental)
		    closePosition:    'top',    // location of close text for sticky cluetips; can be 'top' or 'bottom' or 'title'
		    closeText:        'Close',  // text (or HTML) to to be clicked to close sticky clueTips
		    truncate:         0,        // number of characters to truncate clueTip's contents. if 0, no truncation occurs

		    // effect and speed for opening clueTips
		    fx: {             
		                      open:       'show', // can be 'show' or 'slideDown' or 'fadeIn'
		                      openSpeed:  ''
		    },
		                  
		    // settings for when hoverIntent plugin is used
		    hoverIntent: {    
		                      sensitivity:  3,
		                      interval:     50,
		                      timeout:      0
		    }, 
		    
		    // function to run just before clueTip is shown.            
		    onActivate:       function(e) {return true;},

		    // function to run just after clueTip is shown.
		    onShow:           function(ct, c){},
		    
		    // whether to cache results of ajax request to avoid unnecessary hits to server
		    ajaxCache:        true,     
		    
		    // process data retrieved via xhr before it's displayed
		    ajaxProcess:      function(data) {
		                        data = $(data).not('style, meta, link, script, title');
		                        return data;
		    },
		    
		    // can pass in standard $.ajax() parameters, not including error, complete, success, and url
		    ajaxSettings: {   
		                      dataType: 'html'
		    }
		  };
	
	$('.tooltip').cluetip({
	    activation:       'hover',
	    sticky: true,
	    mouseOutClose: true
	  });
	

	/*
	jQuery.bt.defaults.ajaxLoading = '<img src="ro/imagess/loading.gif" width="40" height="40" />';
	jQuery.bt.defaults.closeWhenOthersOpen = true;
	
	// tooltips
	$('.tooltip',$(this)).bt({
		 ajaxPath: ["$(this).attr('href')"],
		 centerPointY: .1,
		  positions: ['right', 'left'], 
		  padding: 20, 
		  width: 256, 
		  spikeGirth: 10, 
		  spikeLength: 40, 
		  cornerRadius: 10, 
		  fill: '#FFFFE1', 
		  strokeStyle: '#E3C823', 
		  shadow: true, 
		  shadowBlur: 12,
		  shadowOffsetX: 0,
		  shadowOffsetY: 5, 
		  hoverIntentOpts: {interval: 800, timeout: 3000}, 
		  cssStyles: {
		    fontSize: '12px',
		    fontFamily: 'arial,helvetica,sans-serif'
		  },
		 ajaxCache:false
	});
*/
	
	/*
	$('.tooltip-big',$(this)).bt({
		  trigger: 'click',
		  ajaxPath: ["$(this).attr('href')"],
		  trigger: 'click',
		  ajaxCache:false,
		  width: 500,
		  height:300,
		  strokeWidth: 0, 
		  spikeLength: 40,
		  spikeGirth: 10,
		  fill: '#FFFFE1',
		  strokeStyle: '#E3C823',
		  shadow:true,
		  shadowBlur: 12,
		  shadowOffsetX: 0,
		  shadowOffsetY: 5, 
		  padding: 20,
		  cssStyles: {
		    fontFamily: '"lucida grande",tahoma,verdana,arial,sans-serif', 
		    fontSize: '13px'
		  }
	});
	*/
	// here we check values for "Create new account steps"
	
	function checkformcontnou(what){
		
		valid=true;
		if(what=='1')
		{
		var checkstep1fields=new Array('lname','fname','birthdate','phone','email','email2','password','password2');
		var checkstep1types=new Array('string-3','string-3','date-/','numeric-7','email','like-email','string-6','like-password');
		var checkstep1errors=new Array('2','3','4','10','11','12','13','14');
		valid=validateForm(checkstep1fields,checkstep1types,checkstep1errors);
		}
		
		if(what=='2')
		{
		var checkstep2fields=new Array('address2','stateid2','cityid2','postalcode2','address3','stateid3','cityid3','postalcode3','accept');
		var checkstep2types=new Array('string-5','id-0','id-0','numeric-3','string-5','id-0','id-0','numeric-3','checked-');
		var checkstep2errors=new Array('16','17','18','19','16','17','18','19','20');
		valid=validateForm(checkstep2fields,checkstep2types,checkstep2errors);
		}
		
		if(what=='3')
		{
			// date facturare
			if($('#tipcont').attr('value')=='pj'){
				// persoana juridica
				var checkstep3fields=new Array('company','cui','nrj','banca','iban','stateid5','cityid5','address5');
				var checkstep3types=new Array('string-3','string-5','string-4','string-6','string-24','id-0','id-0','string-5');
				var checkstep3errors=new Array('21','22','23','24','25','17','18','16');
			}
			else
			{
				// persoana fizica
				var checkstep3fields=new Array('lname2','fname2','stateid4','cityid4','address4');
				var checkstep3types=new Array('string-3','string-3','id-0','id-0','string-5');
				var checkstep3errors=new Array('2','3','17','18','16');
			}
		
		valid=validateForm(checkstep3fields,checkstep3types,checkstep3errors);
		}
		
		if(what=='4')
		{
			// passport data
			// first check current passport
			// then check other passports, in case of error switch to that passport tab
			
			var arrvalues=new Array(0,1,2);
			var psp1fields=new Array('psp_lname1','psp_fname1','psp_birthdate1','psp_testkey1');
			var psp1types=new Array('string-3','string-3','datePassport-/','testkey-15');
			var psp1errors=new Array('2','3','17','16');
			
			var psp2fields=new Array('psp_lname2','psp_fname2','psp_birthdate2','psp_testkey2');
			var psp2types=new Array('string-3','string-3','datePassport-/','testkey-15');
			var psp2errors=new Array('2','3','17','16');
			
			var psp3fields=new Array('psp_lname3','psp_fname3','psp_birthdate3','psp_testkey3');
			var psp3types=new Array('string-3','string-3','datePassport-/','testkey-15');
			var psp3errors=new Array('2','3','17','16');
			
			var selected=$('#psp_selected').attr('value');
			
			
			
			if(selected != undefined)
			{
				
			if(selected<1){selected=1;}
			
			var nbpasapoarte=parseInt($('#nbpasapoarte').attr('value'));
			
			valid_selected=validateForm(eval("psp"+selected+"fields"),eval("psp"+selected+"types"),eval("psp"+selected+"errors"));
			
			
			
			if(valid_selected){
			
			for(i=1;i<nbpasapoarte+1;i++){
				if(i!=selected)
				{
					valid=validateForm(eval("psp"+i+"fields"),eval("psp"+i+"types"),eval("psp"+i+"errors"));
					if(!valid)
					{
					// we found an passport with incorrect data, goto that passport
						for(j=1;j<4;j++){
							$('#div-psp'+j).hide();
						}
						
						for(j=1;j<4;j++){
							if(j==i){
								$('#tab-psp'+i).addClass('activ');
								$('#tab-psp'+i).removeClass('inactiv');
								$('#div-psp'+i).show();	
							}else{
								$('#tab-psp'+j).removeClass('activ');
								$('#tab-psp'+j).addClass('inactiv');
							}
						}
					break;	
					}
				}
			  }
		    }
			else
			{
			valid=false;	
			}
		}
			
		}
		
		
		if(what=='a1')
		{
		var checkstep1fields=new Array('lname','fname','birthdate','phone');
		var checkstep1types=new Array('string-3','string-3','date-/','numeric-7');
		var checkstep1errors=new Array('2','3','4','10');
		valid=validateForm(checkstep1fields,checkstep1types,checkstep1errors);
		}
		
		if(what=='a2')
		{
		var checkstep2fields=new Array('address2','stateid2','cityid2','postalcode2','address3','stateid3','cityid3','postalcode3','accept');
		var checkstep2types=new Array('string-5','id-0','id-0','numeric-3','string-5','id-0','id-0','numeric-3','checked-');
		var checkstep2errors=new Array('16','17','18','19','16','17','18','19','20');
		valid=validateForm(checkstep2fields,checkstep2types,checkstep2errors);
		}
		
		
		return valid;
	}
	
	function validateForm(fields,types,errors)
	{
		var valid=true;
		var checkstep1fields=fields;
		var checkstep1types=types;
		var checkstep1errors=errors;
		
		
		var formObj=$("#frmcontnou");
		items = formObj.serializeArray();
		data={};
		
		$.each(items,function(i,item)
		   {
		       data[item['name']]=item['value'];
		   });
		
		$.each(checkstep1fields,function(i,field)
		{
			var typearr=checkstep1types[i].split('-');
			var type=typearr[0];
			var value=typearr[1];
			
			if(type=='string')
				{
				if(data[field].length<value)
					{
						$("#"+field+"error").load('ro/ajax/errormessages/'+checkstep1errors[i]+'/plain',function(){
								// $("#"+field+"error").show();
							});
						valid=false;
					}
					else
					{
						$("#"+field+"error").html('');
					}
				}
		
			 if(type=='email')
			 {
				if(!isValidEmailAddress($('#'+field).attr('value')))
				{
					$("#"+field+"error").load('ro/ajax/errormessages/'+checkstep1errors[i]+'/plain',function(){
						// $("#"+field+"error").show();
					});
					valid=false;
				}
				else
				{
					 $("#"+field+"error").html('');
				}
			 }
			 
			 if(type=='like')
			 {
				 if($('#'+field).attr('value')!=$('#'+value).attr('value'))
					{
					
						$("#"+field+"error").load('ro/ajax/errormessages/'+checkstep1errors[i]+'/plain',function(){
							// $("#"+field+"error").show();
						});
						valid=false;
					}
					else
					{
						$("#"+field+"error").html('');
					}
			 }
			 
			 if(type=='numeric')
			 {
				 
				var error=false;
				if(data[field].length<value)
				{
					error=true;
				}
				if(!isInteger(data[field]))
				{
					error=true;
				}
				if(error)
				{
					$("#"+field+"error").load('ro/ajax/errormessages/'+checkstep1errors[i]+'/plain',function(){
						// $("#"+field+"error").show();
					});
					valid=false;
				}else{
					$("#"+field+"error").html('');
				}
			 }
			 
			 if(type=='date')
			 {
				 error=isDate(data[field]);
				 if(error>0)
				 {
						$("#"+field+"error").load('ro/ajax/errormessages/'+error+'/plain',function(){
							// $("#"+field+"error").show();
						});
						valid=false;
					}else{
						$("#"+field+"error").html('');
					}
			 }
			 
			 if(type=='datePassport')
			 {
				 error=isDatePassport(data[field]);
				 if(error>0)
				 {
						$("#"+field+"error").load('ro/ajax/errormessages/'+error+'/plain',function(){
							// $("#"+field+"error").show();
						});
						valid=false;
					}else{
						$("#"+field+"error").html('');
					}
			 }
			 
			 
			 if(type=='id')
			 {
				 if(data[field]!=parseInt(data[field]) || data[field] <= (value))
				 {
						$("#"+field+"error").load('ro/ajax/errormessages/'+checkstep1errors[i]+'/plain',function(){
							// $("#"+field+"error").show();
						});
						valid=false;
					}else{
						$("#"+field+"error").html('');
					}
			 }
			 
			 if(type=="checked")
			 {
				if(data[field]!='on')
				{
					$("#"+field+"error").load('ro/ajax/errormessages/'+checkstep1errors[i]+'/plain',function(){
						// $("#"+field+"error").show();
					});
					valid=false;
				}else{
					$("#"+field+"error").html('');
				}
			 }
			 
			
		});
		
		return valid;
	}
	
	$(".contnou0").live("click",function(event){
		event.preventDefault();
		
			var openurl=$(this).attr("href");
			// $.fn.colorbox.close();
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});

	});
	
	$(".contnou1").live("click",function(event){
		event.preventDefault();
		if(checkformcontnou("1")){
			var openurl=$(this).attr("href");
			// $.fn.colorbox.close();
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});

			
		
		}
	});
	
	$("[rel=contnou-intro]").live("click",function(event){
				
			var openurl=$(this).attr("href");
			// $.fn.colorbox.close();
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});

			
		
		return false;
	});
	
	$(".account-cumparapasaport1").live("click",function(event){
		event.preventDefault();
		// if(checkformcontnou("a1")){
		
		// don`t check any more step1
		if(1){
			var openurl=$(this).attr("href");
			// $.fn.colorbox.close();
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});

			
		
		}
	});
	
	
	$(".contnou2").live("click",function(event){
		event.preventDefault();
		var rel=$(this).attr("rel");
		if(checkformcontnou("2") || rel=='prev'){
			var openurl=$(this).attr("href");
			// $.fn.colorbox.close();
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});		
		}
	});
	
	
	$(".account-cumparapasaport2").live("click",function(event){
		event.preventDefault();
		var rel=$(this).attr("rel");
		if(checkformcontnou("2") || rel=='prev'){
			var openurl=$(this).attr("href");
			// $.fn.colorbox.close();
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});		
		}
	});
	
	
	$(".contnou3").live("click",function(event){
		event.preventDefault();
		var rel=$(this).attr("rel");
		if(checkformcontnou("3") || rel=='prev'){
			var openurl=$(this).attr("href");
			// $.fn.colorbox.close();
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});		
		}
	});
	
	$(".account-cumparapasaport3").live("click",function(event){
		event.preventDefault();
		var rel=$(this).attr("rel");
		if(checkformcontnou("3") || rel=='prev'){
			var openurl=$(this).attr("href");
			// $.fn.colorbox.close();
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});		
		}
	});
	

	$(".contnou4").live("click",function(event){
		event.preventDefault();
		var rel=$(this).attr("rel");
		if(checkformcontnou("4") || rel=='prev'){
			var openurl=$(this).attr("href");
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});		
		}
	});
	

	$(".account-cumparapasaport4").live("click",function(event){
		event.preventDefault();
		var rel=$(this).attr("rel");
		if(checkformcontnou("4") || rel=='prev'){
			var openurl=$(this).attr("href");
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});		
		}
	});
	
	
	$(".contnou5").live("click",function(event){
		event.preventDefault();
		var rel=$(this).attr("rel");
		
			var openurl=$(this).attr("href");
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});		
		
		
	});
	
	$(".account-cumparapasaport5").live("click",function(event){
		event.preventDefault();
		var rel=$(this).attr("rel");
		
			var openurl=$(this).attr("href");
			
			// first post values to the session, then open next step
			
			$.post(openurl, $("#frmcontnou").serialize(), function(data) {
				$.fn.colorbox({
				html:data,
				opacity:0.5,
				overlayClose:false,
				close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				});
			});		
		
		
	});
	
	$("a.closebox").live("click",function(event)
			{
			event.preventDefault();
			$.fn.colorbox.close();
			}
	);
	
	
	
	
	function validateform(arrfields,arrtypes,arrerrors){
		
	}
	
	function isValidEmailAddress(emailAddress) {
			var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
			return pattern.test(emailAddress);
			}
	
	// Declaring valid date character, minimum year and maximum year
	var dtCh= "/";
	var minYear=1900;
	var maxYear=2010;
	
	function isInteger(s){
		var i;
	    for (i = 0; i < s.length; i++){   
	        // Check that current character is number.
	        var c = s.charAt(i);
	        if (((c < "0") || (c > "9"))) return false;
	    }
	    // All characters are numbers.
	    return true;
	}

	function stripCharsInBag(s, bag){
		var i;
	    var returnString = "";
	    // Search through string's characters one by one.
	    // If character is not in bag, append to returnString.
	    for (i = 0; i < s.length; i++){   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) returnString += c;
	    }
	    return returnString;
	}

	function daysInFebruary (year){
		// February has 29 days in any year evenly divisible by four,
	    // EXCEPT for centurial years which are not also divisible by 400.
	    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	function DaysArray(n) {
		for (var i = 1; i <= n; i++) {
			this[i] = 31
			if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
			if (i==2) {this[i] = 29}
	   } 
	   return this
	}

	function isDate(dtStr){
		var daysInMonth = DaysArray(12)
		var pos1=dtStr.indexOf(dtCh)
		var pos2=dtStr.indexOf(dtCh,pos1+1)
		var strDay=dtStr.substring(0,pos1)
		var strMonth=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
		strYr=strYear
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		month=parseInt(strMonth)
		day=parseInt(strDay)
		year=parseInt(strYr)
		if (pos1==-1 || pos2==-1){
			
			return 4;
		}
		if (strMonth.length<1 || month<1 || month>12){
			// alert("Please enter a valid month")
			return 5;
		}
		if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			// alert("Please enter a valid day")
			return 6;
		}
		if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
			// alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
			return 7;
		}
		if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
			// alert("Please enter a valid date")
			return 8;
		}
	return 0;
	}
	
	
	function isDatePassport(dtStr){
		var daysInMonth = DaysArray(12)
		var pos1=dtStr.indexOf(dtCh)
		var pos2=dtStr.indexOf(dtCh,pos1+1)
		var strDay=dtStr.substring(0,pos1)
		var strMonth=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
		var maximYear=2006;
		var minimYear=2000;
		
		strYr=strYear
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		month=parseInt(strMonth)
		day=parseInt(strDay)
		year=parseInt(strYr)
		if (pos1==-1 || pos2==-1){
			
			return 4;
		}
		if (strMonth.length<1 || month<1 || month>12){
			// alert("Please enter a valid month")
			return 5;
		}
		if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			// alert("Please enter a valid day")
			return 6;
		}
		if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
			// alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
			return 7;
		}
		if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
			// alert("Please enter a valid date")
			return 8;
		}
		
		
		if(year<minimYear || year>maximYear)
		{
			return 26;
		}
		
	return 0;
	}
	
	

	$('#birthdate').live('focus',function()
			{
			if($('#birthdate').attr('value')=='zz/ll/aaaa')
			{
			$('#birthdate').attr('value','');
			$('#birthdate').removeClass('lightgray');
			}
	});
	
	// for step 2, is "Same address" is checked, copy all data from up to bottom
	
	$('.checkbox').live('click',function(i) {
		var obj=$("#sameaddress1");
		if(obj.attr('checked'))
		{
			// elements to copy:
			// address2 	-> address3
			// stateid2 	-> stateid3
			// cityid2		-> cityid3
			// postalcode2 	-> postalcode3
		
		$("#stateid3_input").attr('value',$("#stateid2_input").attr('value'));
		$("#stateid3").attr('value',$("#stateid2").attr('value'));
		
		$('#cityid3').load('ro/ajax/geos/options/' + $('#stateid3').val() + '/1',function(){
			$("#cityid3").attr('value',$("#cityid2").attr('value'));
			$('#cityid3').selectbox.refresh('cityid3');
			$("#cityid3_input").attr('value',$("#cityid2_input").attr('value'));
		});
		
		
		
		
		$("#address3").attr('value',$("#address2").attr('value'));		
		$("#postalcode3").attr('value',$("#postalcode2").attr('value'));
		
		}
		 
		});
	// pas 3 -> taburi
	
	$('.pass3-tab').live('click',function(event){
		event.preventDefault();
		var what=$(this).attr('href');
		if(what=='pf'){
			$('#contnoupj').hide();
			$('#contnoupf').show();
			$('#tabpf').removeClass('inactiv');
			$('#tabpf').addClass('activ');
			
			$('#tabpj').removeClass('activ');
			
		}
		else
		{
			$('#contnoupf').hide();
			$('#contnoupj').show();
			$('#tabpj').addClass('activ');
			$('#tabpj').removeClass('inactiv');
			
			$('#tabpf').removeClass('activ');
		}
		
		$('#tipcont').attr('value',what);
		
	});
	
	// pas 4 -> taburi
	
	$('.pass4-tab').live('click',function(event){
		event.preventDefault();
		
		
		if(checkformcontnou(4)){
		 // get to next tab only if current tab is complete and correct !
			
		var selected=$(this).attr('href');		
		$('#psp_selected').attr('value',selected);
			
		for(i=1;i<4;i++){
			$('#div-psp'+i).hide();
		}
		
		for(i=1;i<4;i++){
			if(i==selected){
				$('#tab-psp'+selected).addClass('activ');
				$('#tab-psp'+selected).removeClass('inactiv');
				$('#div-psp'+selected).show();	
			}else{
				$('#tab-psp'+i).removeClass('activ');
				$('#tab-psp'+i).addClass('inactiv');
			}
		}
		
		}
				
	});
	
	
	$("a.foto-tab").click(
		function(event)
		{
			event.preventDefault();
			var rel=$(this).attr('rel');
			var tab=rel.split("|");
			$("#tab-1").removeClass("activ");
			$("#tab-2").removeClass("activ");
			$("#tab-3").removeClass("activ");
			$("#tab-1").addClass("inactiv");
			$("#tab-2").addClass("inactiv");
			$("#tab-3").addClass("inactiv");
			
			$("#tab-"+tab[2]).addClass("activ");
			$("#tab-"+tab[2]).removeClass("inactiv");
			
			
			
			
		});
	
	$("a.video-tab").click(
			function(event)
			{
				event.preventDefault();
				var rel=$(this).attr('rel');
				var tab=rel.split("|");
				$("#tab-1").removeClass("activ");
				$("#tab-2").removeClass("activ");
				$("#tab-3").removeClass("activ");
				$("#tab-1").addClass("inactiv");
				$("#tab-2").addClass("inactiv");
				$("#tab-3").addClass("inactiv");
				$("#tab-"+tab[2]).addClass("activ");
				$("#tab-"+tab[2]).removeClass("inactiv");
			});
	
	
	jQuery.fn.extend({
		  scrollTo : function(speed, easing) {
		    return this.each(function() {
		      var targetOffset = $(this).offset().top;
		      $('html,body').animate({scrollTop: targetOffset}, speed, easing);
		    });
		  }
		});

	// video
	$("a.videoplay").live("click",function(event)
			{
			event.preventDefault();
			var rel=$(this).attr('rel');
			var temp=rel.split("|");
			var id=temp[3];

			// deselect old play
			var oldid=$("#currentVideo").attr("value");
			
			if(oldid>0)
			{
				$("#containerVideo_"+oldid).attr("class","video_dinLista");
			}
			
			$("#currentVideo").attr("value",id);
			
			// sellect curent div
			$("#containerVideo_"+id).attr("class","video_dinLista_curent");
	
			});
	
	// right filter operations
	
	// on page display, function to show speciffic filter, based on cookie, is on template. see .tpl source
	
	// hide options
	$(".filtru_cat").live("click",function(event)
		{			
			$(this).next().slideToggle("fast",function(){
				$.cookie($(this).prev().attr('id'),$(this).css('display'));
			});
		});
	
	// toggle -> read more/less from options
	$("a.filter_more").live("click",function(event)
	{
		event.preventDefault(event);
		
		if($(this).parent().parent().children(".less:last").css('display')=='none')
		{
			$(this).parent().parent().children(".less").slideDown("400");
			$(this).html("Restrange &laquo;");
			$.cookie($(this).parent().parent().attr('id'),'show_all');
		}
		else
		{
			$(this).parent().parent().children(".less").slideUp("400");
			$(this).html("Toate &raquo;");
			$.cookie($(this).parent().parent().attr('id'),'show_first');
		}
	
		
		
	});
	

	// simple tabs
	// can show/hide elements with classname like tabname_tabnumber
	// can make ajax call in speciffic container
	
	$("div[rel*=tabs] ul li a").live("click",function(event)
			{
			event.preventDefault();
			// get the <th>
		     var li = $(this).parent();
		    // find the index, two options with jQuery 1.3.2
			
			
			var tabname=$(this).parent().parent().parent().attr('class');			
			var total=$(this).parent().parent().children().length;
			
		    var index =$('div[rel*=tabs] ul li').index(li);
		    
		    for(i=0;i<total;i++)
		    {
		    	var tabid=$(this).parent().parent().find("li")[i];
		    	
		    	if(i==index)
		    	{		    		
			    	 $("."+tabname+"_"+i).show();	
			    	 $(tabid).removeClass("inactiv");
			    	 $(tabid).addClass("activ");
		    	}
		    	else
		    	{
		    		$("."+tabname+"_"+i).hide();
		    		$(tabid).removeClass("activ");
			    	$(tabid).addClass("inactiv");
		    	}
		    }
		    
		    
		    // var index = $th.parent().children().index($th);

			});
	

	// popup with competition status
	// provides timer and live update of status.
	
	
	
	$('.disponibilitate_competitie').live('mousemove', function(event) {
		
		var container='divCompetitionDetails';
		var myDiv=$("#"+container);	
		var strurl='';
		strurl=$(this).attr("rel");
		myDiv.css({left:event.pageX+10, top:event.pageY+10});
		if( $(this).attr('id') != myDiv.data('rel') )
		{
			
		myDiv.html('');
		var ajaxurl="";
		strurl=strurl.split("/");
		for(i=0;i<strurl.length;i++)
		{
			if( strurl[i]==language )
			{
				ajaxurl+=language+"/";
				ajaxurl+='ajax/';
			}else{
				ajaxurl+=strurl[i]+'/';
			}
		}
		var temp=$(this).attr("rel").split("|");
		
		
		
		if(container != "" || container !="undefined")
		{
					
					if(myDiv.data('rel') != $(this).attr("id"))
					{
						$("#"+container).load(ajaxurl,function(data){
						//	toggleLoading(false,false);						
				       		// $("#"+container).fadeIn("50");
							
				       		
						 });
						
						jQuery.data(container,'loaded');
						$("#"+container).show();
			       		$(this).stopTime('getlivedata');
			       		$(this).everyTime(5000,'getlivedata',function()
			       				{
			       					processLiveData(container,ajaxurl);
			       				});
			       		
						myDiv.data('rel',$(this).attr("id"));
					}
					else
					{
						//	$("#"+container).show();
				       		
					}
			
		}
		
		
	//	alert(myDiv.data('rel')+","+$(this).attr("id"));
		
		$(this).bind('mouseleave',function(){
			$('#divCompetitionDetails').stopTime('getlivedata');
	   	 	// $('#divCompetitionDetails').fadeOut("fast");
			$('#divCompetitionDetails').hide();
	   	 	$('#divCompetitionDetails').data('rel','');
		});
		
		}
		
		
		});
	
	
	
	
	/*
	$(".disponibilitate_competitie").live("mousemove",function(event)
		{
	
		var container='divCompetitionDetails';
		var myDiv=$("#"+container);	
		var strurl='';
		strurl=$(this).attr("rel");
		myDiv.css({left:event.pageX+10, top:event.pageY+10});
		if( $(this).attr('id') != myDiv.data('rel') )
		{
			
		myDiv.html('');
		var ajaxurl="";
		strurl=strurl.split("/");
		for(i=0;i<strurl.length;i++)
		{
			if( strurl[i]==language )
			{
				ajaxurl+=language+"/";
				ajaxurl+='ajax/';
			}else{
				ajaxurl+=strurl[i]+'/';
			}
		}
		var temp=$(this).attr("rel").split("|");
		
		
		
		if(container != "" || container !="undefined")
		{
			
		//	toggleLoading($("#"+container).offset().left,$("#"+container).offset().top);
			
		//	$("#"+container).ajax({
		//	    type: "GET",
		//	    url: ajaxurl,
		//	    dataType: "xml",
		//	    success: function(xml){
		//				alert(xml)
			         //         $(xml).find("CD").each(function(){
			         //               $("#CD").append($(this).find("ARTIST").text() + "<br />");
			         //         });
		//	               }
		//	  });

			
			$("#"+container).load(ajaxurl,function(){
						toggleLoading(false,false);						
			       		// $("#"+container).fadeIn("50");
						$("#"+container).show();
			       		$(this).stopTime('getlivedata');
			       		$(this).everyTime(5000,'getlivedata',function()
			       				{
			       					processLiveData(container,ajaxurl);
			       				});
			       		
					 });
			
		}
		
		myDiv.data('rel',$(this).attr("id"));
		
		$(this).bind('mouseleave',function(){
			$('#divCompetitionDetails').stopTime('getlivedata');
	   	 	// $('#divCompetitionDetails').fadeOut("fast");
			$('#divCompetitionDetails').hide();
	   	 	$('#divCompetitionDetails').data('rel','');
		});
		
		}
		
		
		
	});
	
	*/
	
	$(".disponibilitate_competitie_right").live('click',function(){
		var rel=$(this).attr("rel");
		if(rel!='' || rel!='undefined')
		{
			document.location=rel;
		}
	});
	
	
	

	function processLiveData(container,ajaxurl)
	{
   			// load xml with competition data
   			$('#divCompetitionDetalisProcessData').load(ajaxurl+'js',function(xml)
   			{
   				// first, get new time to refresh
   				$(xml).find("NEXT-TIMER").each(function(){
   					var newinterval=parseInt($(this).text());
   					$("#"+container).stopTime('getlivedata');
   					$("#"+container).everyTime(newinterval,'getlivedata',function()
   					{
   						processLiveData(container,ajaxurl);
   					});
			        });
   				
   				$(xml).find("DIV-IDS").each(function(){
   						var dataid=$(this).attr('id');
   						var datacontent=$(this).text();
   						$("#"+dataid).html(datacontent);
			        });
   				
   			});
   				
	}
	
	
    $("#btnPopupLogin").live("click",function(event){
        event.preventDefault();
        var url=$(this).attr("href");
        $.post(url, $("#frmlogin").serialize(),function(data){
         //  location.reload();
        	$.fn.colorbox({
	    		html:data,
	    		opacity:0.5,
	    		overlayClose:false,
	    		close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
    		});        	
        });
    });
    
    $("#btnPopupForgotPass").live("click",function(event){
        event.preventDefault();
        var url=$(this).attr("href");
        $.post(url, $("#frmlogin").serialize(),function(data){
         //  location.reload();
        	$.fn.colorbox({
	    		html:data,
	    		opacity:0.5,
	    		overlayClose:false,
	    		close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
    		});        	
        });
    });
    
    $("#btnPopupAcceptTerms").live("click",function(event){
        event.preventDefault();
        var url=$(this).attr("href");
        $.post(url, $("#frmlogin").serialize(),function(data){
         //  location.reload();
        	$.fn.colorbox({
	    		html:data,
	    		opacity:0.5,
	    		overlayClose:false,
	    		close:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
    		});        	
        });
    });
    
    
    
    
    $("a.btnlogoff").live("click",function(event){
        event.preventDefault();
        var url=$(this).attr("href");
        $.post(url, {},function(data){
           location.reload();
        });
    })	
	
    $(".contul_meu_pasaport_inscriere").live("mouseover",function(){
        var temp=$(this).attr("id").split("_");
        
        var currentid=temp[1];
        
        $(".contul_meu_pasaport_body").each(function(){
           var temp=$(this).attr('id').split("_");
           if(temp[2] != currentid){
            $(this).slideUp();
           }else{
           
                $(this).slideDown();
                      }
           
        });
    })
    
    
    $(".concept_terenuri_redCourt").live("click",function(event){
    	event.preventDefault();
    	var disp=$("#conceptSlideshow").css('display');
    	
    	if(disp =='block')
    	{
    		if($("#terenrosu").css('display')=='none')
    		{
    			$("#terenorange").hide();
    			$("#terenrosu").show();	
    		}
    		else
    		{
    			$("#terenorange").hide();
    			$("#terenrosu").hide();
    		$("#conceptSlideshow").slideUp(function(){
    			
    		});	
    		}
    		
    	}
    	else
    	{
    		$("#conceptSlideshow").slideDown(function(){
    			$("#terenorange").hide();	
    			$("#terenrosu").show();	
    		});	
    		
    	}
    	
    	return false;
    });
    
    $(".concept_terenuri_orangeCourt").live("click",function(event){
    	event.preventDefault();
    	var disp=$("#conceptSlideshow").css('display');
    	if(disp =='block')
    	{
    		
    		if($("#terenorange").css('display')=='none')
    		{
    			$("#terenrosu").hide();
    			$("#terenorange").show();	
    		}
    		else
    		{
    			$("#terenorange").hide();
    			$("#terenrosu").hide();
    		$("#conceptSlideshow").slideUp(function(){
    			
    		});	
    		}
    	}
    	else
    	{
    		$("#conceptSlideshow").slideDown(function(){
    			$("#terenrosu").hide();	
    			$("#terenorange").show();	
    		});	
    		
    	}
    	
    	return false;
    });
	
});
	
