jQuery.noConflict();
(function($) { 
	$(function() {
		// pngfix
		if($.browser.msie && $.browser.version.substring(0,1) == '6') {
			$('#header #logo a').pngfix();
			$('#RPGlobalHeader').pngfix();
			$('#RPGlobalHeader #RPGlobalLogo').pngfix();
			$('#RPGlobalHeader #RPGlobalLogo a').pngfix();
			$('p.icon img').pngfix();
			$('p.icon_hp img').pngfix();
			$('div.promo_icons ul li img').pngfix();
			$('#RPGlobalHeader div#first').pngfix();
			$('#RPGlobalHeader #RPGlobalLogo div#second').pngfix();
			$('ul.boxLinks li').pngfix();
		}
		
		
		
		/* highlights mouse over */
		$("#highlights p").each( function(i,el) {
			//alert('ggg');
			$(this).hover( function() { $(this).addClass('h-big'); }, function() { $(this).removeClass('h-big'); }  );								  
		});
		
		/* clear bottom border */
		
		$("#transport").css({'border':'none'});	
		$("#horeca").css({'border':'none'});	
		$("#calitate").css({'border':'none'});
		
		/* eof clear bottom border  */
		
	
		/* icons ticker */
		
		/*$("#iconticker").newsticker(); */
		
		var headline_count;
		var headline_interval;
		var old_headline = 0;
		var current_headline = 0;
		headline_count = $("li.headline").size();
		$("li.headline:eq(" + current_headline + ")").css('top', '5px');
		headline_interval = setInterval(headline_rotate,5000);
		$('#iconticker').hover(function() {
		clearInterval(headline_interval);
		  }, function() {
		headline_interval = setInterval(headline_rotate,5000);
		headline_rotate();
		});
		
		function headline_rotate() {
		 current_headline = (old_headline + 1) % headline_count;
		  $("li.headline:eq(" + old_headline + ")")
		 .animate({top: -65},"slow", function() {
		   $(this).css('top', '60px');
		 });
		  $("li.headline:eq(" + current_headline + ")")
		 .animate({top: 5},"slow");
		  old_headline = current_headline;
		}
				
		
		/* end icons ticker */

		//hover fix
		if($.browser.msie && $.browser.version.substring(0,1) == '6') {

			//hightlights
			/*
			$('#header #highlights p').each(function(i, el) {
				$(this).mouseover(function(e){
					$(el).addClass('hover');
				}).mouseout(function(e) {
					$(el).removeClass('hover');
				});
			});
			*/

			//box
			$('#content #secondary div.box').each(function(i, el) {
				$(this).mouseover(function(e) {
					$(el).addClass('hover');
				}).mouseout(function(e) { 
					$(el).removeClass('hover');
				});
			});
			//label text
			$('form ul.checkboxes li label').each(function(i, el) {
				$(this).mouseover(function(e){
					$(el).addClass('hover');
				}).mouseout(function(e) {
					$(el).removeClass('hover');
				});
			});
			//submit button
			$('form div.actions input.button').each(function(i, el) {
				$(this).mouseover(function(e){
					$(el).addClass('hover');
				}).mouseout(function(e) {
					$(el).removeClass('hover');
				});
			});

		}
		//end hover fix

		//form verification
/*		$('#form_errors_name,#form_errors_tel,#form_errors_email,#form_errors_city,span#form_errors_county').hide();
		errors = false;
		$('#registerForm').submit(function() {
			if ($('#personalName').val()=='') {
				$('span#form_errors_name').text('Completeaza numele!').fadeIn();
				$('#personalName').focus().blur(function() {
						if ($('#personalName').val() != '') {
							$('span#form_errors_name').text('Completeaza numele!').hide();
						}
				});
				errors = true;
			}
			var name=$('#personalName').val();	
			if ( !name.match(/^[a-zA-Z0-9]+([\.\_\-]?[a-zA-Z0-9]+)*$/) ) {
				$('span#form_errors_name').text('Numele contine spatii si/sau caractere nepermise!').fadeIn();
				$('#personalName').focus().blur(function() {
						if ( name.match(/^[a-zA-Z0-9]+([\.\_\-]?[a-zA-Z0-9]+)*$/) ) {
							$('span#form_errors_name').text('Numele contine spatii si/sau caractere nepermise!').hide();
						}
				});
				errors = true;
			}

			if ($('#personalTel').val()=='') {
				$('span#form_errors_tel').text('Completeaza numarul de telefon!').fadeIn();
				$('#personalTel').focus().blur(function() {
						if ($('#personalTel').val() != '') {
							$('span#form_errors_tel').text('Completeaza numarul de telefon!').hide();
						}
				});
				errors = true;
			}
			
			var tel=$('#personalTel').val();
			if (isNaN(tel)) {
				$('span#form_errors_tel').text('Numarul de telefon nu este valid!').fadeIn();
				$('#personalTel').focus().blur(function() {
						if ( !isNaN(tel) ) {
							$('span#form_errors_tel').text('Numarul de telefon nu este valid!').hide();
						}
				});
				errors = true;
			}


			if ($('#personalEmail').val()=='') {
				$('span#form_errors_email').text('Completeaza adresa de e-mail!').fadeIn();
				$('#personalEmail').focus().blur(function() {
						if ($('#personalEmail').val() != '') {
							$('span#form_errors_email').text('Completeaza adresa de e-mail!').hide();
						}
				});
				errors = true;
			}

			var email=$('#personalEmail').val();
			if ( !email.match(/^[a-zA-Z0-9]+([\.\_\-]?[a-zA-Z0-9]+)*[@][a-zA-Z0-9]+([\.\-]?[a-zA-Z0-9]+)*[\.][a-zA-Z]{2,4}$/gi) ) {
				$('span#form_errors_email').text('Adresa de e-mail nu este valida!').fadeIn();
				$('#personalEmail').focus().blur(function() {
						if ( email.match(/^[a-zA-Z0-9]+([\.\_\-]?[a-zA-Z0-9]+)*[@][a-zA-Z0-9]+([\.\-]?[a-zA-Z0-9]+)*[\.][a-zA-Z]{2,4}$/gi) ) {
							$('span#form_errors_email').text('Adresa de e-mail nu este valida!').hide();
						}
				});
				errors = true;
			}

			if ($('#personalCity').val()=='') {
				$('span#form_errors_city').text('Completeaza localitatea!').fadeIn();
				$('#personalCity').focus().blur(function() {
						if ($('#personalCity').val()!='') {
							$('span#form_errors_city').text('Completeaza localitatea!').hide();
						}
				});
				errors = true;
			}
			var county=$('#personalCounty');
			if (county.val()=='') {
				$('span#form_errors_county').text('Alege judetul!').fadeIn();
				$('#personalCounty').focus().blur(function() {
						if (county.val()!='') {
							$('span#form_errors_county').text('Alege judetul!').hide();
						}
				});
				errors = true;
			}

			if (errors) {
				return false;
			}

			return true;
			
		});*/
		
		/*
		//var alreadyHave=document.getElementById('optionsAlreadyHave');
		if ( $("#optionsAlreadyHave:checked") == true ) {
			$("#optionsHaveWhat").show();
		} else {
			$("#optionsHaveWhat").hide();
		}
		*/
		


		//end form verification
		var parent = null;
		$('#slidemenu > .promo').each(function() {
			$(this).find('.boxTitle h2 a').click(function() {
				showItem($(this).parent().parent().parent().parent().children('div.boxContent'), 0);
				return false;
			});
			$(this).find('.boxLinks li a').each(function (i, el) {
				$(this).click(function () {
					showItem($(this).parent().parent().parent().parent().children('div.boxContent'), i+1);
					return false;
				});
			});
		});
		var showItem = function(parent, idx) {
			parent.find('div').each(function (i, el) {
				$(this).hide();
				if(i == idx) {
					$(this).show();
				}
			});
		};

		// the tabs
//		$('#primaryNavigation li a').each(function (i, el) {
		$('#homepage #page #main #header #navigation #primaryNavigation li a').each(function (i, el) {
			$(this).mouseover(function (e) {
				$('li.selected', $(this).parent().parent()).removeClass('selected');
				$(this).parent().addClass('selected');
				myMenu.show(i);
			});
		});

		//terms formular
		$("#personalCity").focus(function() {
			if (this.value == 'oras...') {
				this.value = '';
			}
		}).blur(function() {
			if (this.value == '') {
				this.value = 'oras...';
			}
		});

		//terms thickbox
		 $('#terms_loading').jqm({ajax: '/termeni-si-conditii/', trigger: 'a.terms'});
	});
})(jQuery);
	
	
	
