jQuery.noConflict();
jQuery(document).ready(function() {

	/*
	 * Old things
	 * 
	 */

	var linp = jQuery('.overLabel input');
	linp.each(function() {
		if (jQuery(this).val() != "")
			jQuery(this).next('label').hide();
	})

	linp.focus(function() {
		jQuery(this).next('label').hide();
	}).blur(function() {
		if (jQuery(this).val() == "")
			jQuery(this).next('label').show();
	});

	var tszolg = jQuery('#tvszolgaltato');
	var ttip = jQuery('#tvtipus');

	tszolg.change(function() {
		if (tszolg.val() != "Nincs TV előfizetésem" && tszolg.val() != "")
			ttip.attr('disabled', '');
		else
			ttip.attr('disabled', 'disabled');
	})

	tszolg.trigger('change');

	jQuery('.btnForward, .btnFinish').hover(function() {
		jQuery(this).addClass('hover');
	}, function() {
		jQuery(this).removeClass('hover');
	});

	/*
	 * Tab switch
	 * 
	 */

	var tab1 = jQuery("a.ttab1");
	var tab2 = jQuery("a.ttab2");

	var content1 = jQuery("div#cont1");
	var content2 = jQuery("div#cont2");

	tab1.click(function(e) {
		e.preventDefault();
		tab1.addClass("ttab1active");
		tab2.removeClass("ttab2active");
		content1.show();
		content2.hide();
	});

	tab2.click(function(e) {
		e.preventDefault();
		tab2.addClass("ttab2active");
		tab1.removeClass("ttab1active");
		content2.show();
		content1.hide();
	});

	/*
	 * Design btn - IE6 fix
	 * 
	 * 
	 * jQuery('.btnArrowed').hover(function() {
	 * jQuery(this).addClass('btnArrowedActive'); }, function() {
	 * jQuery(this).removeClass('btnArrowedActive'); });
	 * 
	 */

	/*
	 * Open modal layer
	 * 
	 */

	jQuery('.openModalLayer').click(function(e) {

		e.preventDefault();

		url = "#" + jQuery(this).attr("rel");

		jQuery(url).dialog("destroy");

		jQuery(url).dialog( {
			position : 'center',
			width : 890,
			zIndex : 5000,
			modal : true,
			closeOnEscape : true

		});
	});

	jQuery('.closeDialog').click(function(e) {
		e.preventDefault();
		jQuery(url).dialog("destroy");
	});

	/*
	 * Tabs init
	 * 
	 */

	if (jQuery("#bigTab").length > 0) {

		var tabDuration = 500;

		jQuery(".smallTab").tabs( {
			selected : -1,
			cache : true,
			fx : {
				opacity : 'toggle',
				duration : tabDuration
			},
			select : function() {
				var first = jQuery(this).find('.first');
				jQuery(first).fadeOut(tabDuration);
			}
		});

		jQuery("#bigTab").tabs( {
			fx : {
				opacity : 'toggle',
				duration : tabDuration
			}
		});

	}
		
		jQuery("div#iphone4sPromo ul.tabs-selector a").each(function(){
			jQuery(this).click(function(e){
				e.preventDefault();
				var clicked = jQuery(this);
				if (!jQuery("div#iphone4sPromo div.tabs").hasClass("animating") && !clicked.parent().hasClass("active")) {
					jQuery("div#iphone4sPromo div.tabs").addClass("animating");
					jQuery("div#iphone4sPromo ul.tabs-selector li.active").removeClass("active");
					clicked.parent().addClass("active");				
					jQuery("div#iphone4sPromo div.tabs div.active").fadeOut("fast",function(){
						jQuery(this).removeClass("active");
						jQuery("div#iphone4sPromo div.tabs div." + clicked.parent().attr("id")).fadeIn("fast",function(){
							jQuery(this).addClass("active");
							jQuery("div#iphone4sPromo div.tabs").removeClass("animating");
						});
					});
				}
			});
		});

})
