/*
Created By: Peter Rode (rode.peter@infolink.co.hu)
Website: http://www.infolink.co.hu/
Date: 2009.09.12

*/

$(document).ready(function(){

	$('a.nyroModal').nyroModal({bgColor: '#000000', resizable: false, autoSizable: true, padding: 1, forcetype: true, debug: false });

	$.nyroModalSettings(
	{
		processHandler: function(settings)
		{
			var from = settings.from;

			if (from && from.href && from.href.indexOf('.swf') > -1)
			{
				w = 430;
				h = 495;

				if(from.href.indexOf('retus_01.swf') > -1)
				{
					w = 430;
					h = 495;
				}
				else if(from.href.indexOf('retus_02.swf') > -1)
				{
					w = 430;
					h = 495;
				}
				else if(from.href.indexOf('retus_03.swf') > -1)
				{
					w = 554;
					h = 450;
				}

				$.nyroModalSettings(
				{
					type: 'swf',
					width: w,
					height: h
				});
      			}
		}
	});


	$("[id^='lm']").hover (
		function()
		{
			//this.src="images/"+this.id+"_on.gif";
			$("#mainNav").css("background", "url(images/"+this.id+"_roll.gif) top right no-repeat");

			//$("#mainNav").css("border", "1px solid #ff00ff");
		},
 		function()
		{
			//this.src="images/"+this.id+".gif";
			$("#mainNav").css("background", "url(images/lm_back.gif) top right no-repeat");
		}
	);


	$('#myselectbox').selectbox({debug: false});

	
	$("[id^='tm']").hover (
		function()
		{
			if(this.id.indexOf("_") > 0)
			{
				aa = this.id.split("_")[0];

			}
			else
			{
				aa = this.id;
			}

			$("[id^='"+aa+"']").each(function()
			{
				this.src="images/"+this.id+"_on.gif";
			});
		},
 		function()
		{
			if(this.id.indexOf("_") > 0)
			{
				aa = this.id.split("_")[0];
			}
			else
			{
				aa = this.id;
			}

			if ($("[id^='"+aa+"']").attr("rel") != "selected")
			{
				$("[id^='"+aa+"']").each(function()
				{
					this.src="images/"+this.id+".gif";
				});
			}
		}
	);


	$("[id^='tm']").click(
		function()
		{
			if(this.id.indexOf("_") > 0)
			{
				aa = this.id.split("_")[0];

			}
			else
			{
				aa = this.id;
			}

                	$("[id^='tm']").attr("rel", "");


			$("[id^='tm']").each(function()
			{
				this.src="images/"+this.id+".gif";
			});


			$("[id^='"+aa+"']").attr("rel", "selected");


			$("[id^='"+aa+"']").each(function()
			{
				this.src="images/"+this.id+"_on.gif";
			});
		}
	);


	$("[id^='szm']").hover (
		function()
		{
			if(this.id.indexOf("_") > 0)
			{
				aa = this.id.split("_")[0];

			}
			else
			{
				aa = this.id;
			}

			$("[id^='"+aa+"']").each(function()
			{
				this.src="images/"+this.id+"_on.gif";
			});
		},
 		function()
		{
			if(this.id.indexOf("_") > 0)
			{
				aa = this.id.split("_")[0];
			}
			else
			{
				aa = this.id;
			}

			if ($("[id^='"+aa+"']").attr("rel") != "selected")
			{
				$("[id^='"+aa+"']").each(function()
				{
					this.src="images/"+this.id+".gif";
				});
			}
		}
	);


	$("[id^='szm']").click(
		function()
		{
			if(this.id.indexOf("_") > 0)
			{
				aa = this.id.split("_")[0];

			}
			else
			{
				aa = this.id;
			}

                	$("[id^='szm']").attr("rel", "");


			$("[id^='szm']").each(function()
			{
				this.src="images/"+this.id+".gif";
			});


			$("[id^='"+aa+"']").attr("rel", "selected");


			$("[id^='"+aa+"']").each(function()
			{
				this.src="images/"+this.id+"_on.gif";
			});
		}
	);


	$.preloadImages("images/lm_back.gif", "images/logo-szines.gif");

	$.preloadImages("images/lm01_roll.gif", "images/lm02_roll.gif", "images/lm03_roll.gif", "images/lm04_roll.gif");

	$.preloadImages("img/ajaxLoader.gif", "img/prev.gif", "img/next.gif", "img/close.gif");

	$.preloadImages("images/lm01.gif", "images/lm02.gif", "images/lm03.gif", "images/lm04.gif");


	$.preloadImages("images/szm01.gif", "images/szm01_on.gif", "images/szm02.gif", "images/szm02_on.gif", "images/szm03.gif", "images/szm03_on.gif", "images/szm04.gif", "images/szm04_on.gif", "images/szm05.gif", "images/szm05_on.gif", "images/szm06.gif", "images/szm06_on.gif", "images/szm07.gif", "images/szm07_on.gif", "images/szm08.gif", "images/szm08_on.gif", "images/szm09.gif", "images/szm09_1.gif", "images/szm09_1_on.gif", "images/szm09_on.gif", "images/tm01.gif", "images/tm01_on.gif", "images/tm02.gif", "images/tm02_on.gif", "images/tm03.gif", "images/tm03_1.gif", "images/tm03_1_on.gif", "images/tm03_on.gif", "images/tm04.gif", "images/tm04_1.gif", "images/tm04_1_on.gif", "images/tm04_on.gif");


	//fullScreen();

});


function mysel(a)
{
	$("#myselectbox option[value='"+a+"']").attr('selected', 'selected');

	$('#myselectbox').selectbox({debug: true});

	alert(a);

}

function ell()
{
	var nev = $("input#nev").val().substring(0, 100);  
	var cegnev = $("input#cegnev").val().substring(0,100);  
	var email = $("input#email").val().substring(0,100);
	var tel = $("input#tel").val().substring(0,100);  
	var sel = $("select#myselectbox").val().substring(0,100);  
	var uzenet = $("textarea#uzenet").val().substring(0,1000);  
	
	var dataString = 'nev='+ nev + '&cegnev=' + cegnev + '&email=' + email + '&tel=' + tel + '&sel=' + sel + '&uzenet=' + uzenet; 

	$.ajax
	({  
		type: "POST",  
		url: "kontaktform.php",  
		data: dataString,
		success: function(msg)
			{
				if(msg=="OK")
				{
					$.nyroModalManual({url: 'kontaktform-ok.php?nev='+nev, minWidth: 100, minHeight: 100 });
				}
				else
				{
					$.nyroModalManual({url: 'kontaktform-error.php?nev='+nev, minWidth: 100, minHeight: 100 });
				}				
			}
  	});  

	return false;

}

function fullScreen()
{
	this.moveTo(0, 0);
	this.resizeTo(screen.availWidth,screen.availHeight)
	// this.outerWidth = screen.availWidth;
	// this.outerHeight = screen.availHeight;
}

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
/*    jQuery("<img>").attr("src", arguments[i]);*/

	img = new Image();
	img.src = arguments[i];

  }
}
