﻿
$(document).ready(function(){

	$("#pridat_clanek .linkinput INPUT").keyup(function() {
		
		/*
		load('ajax.html?script=produkt_jednotka&id='+$(this).attr('value'), function() {
			$(this).siblings('.jednotkabox').text('Kč/'+$(this).text());
		});
		*/
		
		//var regexp = /.+-(\d{10})\.html$/g;
		//vysledek = /.+-(\d{10})\.html$/g.exec( $(this).val() );
		/*
		if( vysledek && vysledek[1] )
			vypis = '[url='+vysledek[1]+']';
		else
			vypis = 'neplatne';
		*/
		
		$(this).load('ajax.php?urlid='+$(this).attr('value'), function() {
			//$(this).text('Kč/'+$(this).text());
			$('INPUT', $(this).parents('LABEL').siblings('.linkmaker') ).val($(this).text());
			//alert();
		});
		
	});


	$("#admin_hidder").click(function() {
		$('.admin').toggleClass("hide");
		//$('class=admin').toggleClass("hide");
		//$('[class*=admin]').toggleClass("hide");
		$(this).toggleClass("active");
	});

	$("#admin_hidder").hover( function() {
		$('.admin').toggleClass("o50");
	});
	
	

	//MESSAGE
	$(".my_message.tohide").delay(2000).animate({opacity: 'toggle', height: 'toggle'}, 2000);

	
	//MENU BUBBLE HIDER
	$("#navigation").mouseenter( function() {
		$("#bubble").fadeOut(500);
	}).mouseleave( function() {
		$("#bubble").fadeIn(1000);
	});
	
	//STYLE FORM
	//$("FORM .file INPUT").attr("size", 38);
	
	//IE PNG
	$("#blank, #navigation A, #navigation LI.active, #logo IMG, .green_box BIG, .cist_vice, .soubor DIV, #kontakt H3, #kontakt_form H3, #search *, .my_message *" ).toggleClass("png_bg");
	//$("#blank, #kontakt H3, #kontakt_form H3, #navigation A, #navigation LI.active, #logo IMG, #search *, .message_ko *, .message_ok *, .message_i *, .message_w *, .message_q *" ).toggleClass("png_bg");
	
	//FONT
	//$("h1, .h2, .h3, .h4, .h5, .h6, UL#navigation").addClass("typeface-js");
	
	
	$(".popup a").hover(
		function() {
			$(this).next("em").stop(true, true).animate({opacity: "show", top: "-60"}, "slow");
		},
		function() {
			$(this).next("em").animate({opacity: "hide", top: "-70"}, "fast");
		}
	);


	//Form focus
	$("input, textarea, select").focusin( function() {								//pristupujeme do inputu
		$(this).parents("span").toggleClass("focus");
	});
	$("input, textarea, select").focusout( function() {							//opoustime input
		$(this).parents("span").toggleClass("focus");
	});
	
	//TODO nedelat u readonly
	//Defaultni hodnoty inputů
	$(".inside INPUT, .inside TEXTAREA").focusin( function() {								//pristupujeme do inputu
		
		if( $(this).parents("form").attr("class") != 'white' ) {
			if( !$(this).attr("my_default") )									//pokud je pro tento input prazdna
				$(this).attr("my_default", $(this).attr("value") );			//ulozime hodnotu inputu
			if( $(this).attr("value") == $(this).attr("my_default") ) {			//pokud je stale default
				$(this).attr("value", "");										//vyprazdnime
				//if( $(this).attr("type") == 'text' && ( $(this).attr("name") == 'heslo' || $(this).attr("name") == 'pass' || $(this).attr("name") == 'passwd' || $(this).attr("name") == 'passwrd' || $(this).attr("name") == 'password') )
				//$(this).className = "focus";
			}
			//$(this).toggleClass("focus");
		}
	});
	$(".inside INPUT, .inside TEXTAREA").focusout( function() {							//opoustime input
		if( $(this).parents("form").attr("class") != 'white' ) {
			if( $(this).attr("value") == '' )	{								//pokud zustal prazdny
				$(this).attr("value", $(this).attr("my_default") );			//vratime do nej default
				//if( $(this).attr("type") == 'password')
					//$(this).attr("type", "text");
			}
			//$(this).toggleClass("focus");
		}
	});
	
	
	
	/*
	$(function(){
	  $("input").focusin(	function()	{
		
		if( $(this).attr("name") == 'heslo' ) {
		
			if( $(this).attr("type") == 'text') {
			
				$(this).after( $("<input name='heslo' type='password' \>") );
				$(this).remove();
				
			}
		}
		
		/*
		if( $("#show:checked").length > 0 ){
		  var pswd = $("#txtpassword").val();
		  $("#txtpassword").attr("id","txtpassword2");
		  $("#txtpassword2").after( $("<input id='txtpassword' type='text'>") );
		  $("#txtpassword2").remove();
		  $("#txtpassword").val( pswd );
		}
		else{
		  var pswd = $("#txtpassword").val();
		  $("#txtpassword").attr("id","txtpassword2");
		  $("#txtpassword2").after( $("<input id='txtpassword' type='password'>") );
		  $("#txtpassword2").remove();
		  $("#txtpassword").val( pswd );
		}
	  });
	});
	*/
    
});

