/**
 * Project: mezofi.com
 * Created: 2010-12-18
 *
 * Desc: Default Javascript functions.
 */

/**
 * Add url to bookmark list with jQuery.
 *
 * @return mixed
 */

function add_bookmark()
{
	$(document).ready(function()
	{
		if(window.opera)
		{
			if ($("a.jqbookmark").attr("rel") != "")
			{
				$("a.jqbookmark").attr("rel","sidebar");
			}
		}

		$("a.jqbookmark").click(function(event)
		{
			event.preventDefault();
			var url = this.href;
			var title = this.title;
			
			// Mozilla Firefox
			if (window.sidebar)							
			{
				window.sidebar.addPanel(title, url,"");
			} 
			
			// IE
			else if( window.external )					
			{
				window.external.AddFavorite( url, title);
			} 
			
			// Opera 7+
			else if(window.opera)						
			{
				return false;
			} 
			
			// Safari, Konq etc
			else										
			{
				 alert('Ez a funkciót nem támogatja az Ön böngészője.');
			}

		});
	});
}

/**
 * Set website as homepage.
 *
 * @return void
 */
function set_homepage()
{
	if (document.all)
	{
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage('http://www.mezofi.com');
	}
	else if (window.sidebar)
	{
		if(window.netscape)
		{
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}
			catch(e) {
				alert("Ezt a funkciót nem támogatja az Ön böngészője.");
			}
		}
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref('browser.startup.homepage','http://www.mezofi.com');
	}
}



/**
 * Start EasySlider slideshow.
 *
 * Start a jQuery easySlider 1.7 slideshow, if 
 * a DOM element exists with container_id.
 *
 * @var container_id string (ID of slider container.)
 * @return void
 */
function start_slideshow(container_id)
{
	if(document.getElementById(container_id))
	{
		$(document).ready(function()
		{
			$("#" + container_id).easySlider(
			{
				auto: true,
				continuous: true,
				controlsShow: false,
				speed: 2000,
				pause: 5000
			});
		});
	}
}

/**
 * Validate e-mail address.
 *
 * @var string
 * @return boolean
 */
function isvalidemail(email)
{
	if ( !( /^\w+([\.-]?\w+)*@\w+\w+([\.-]?\w+)*(\.\D{2,8})+$/.test(email) ) )
	{
		alert("Hibás e-mail cím.");
		return false;
	}
	return true;
}

/**
 * Init Javascript.
 *
 * @return void
 */
function initialize_javascript()
{
	// Start slideshow.
	start_slideshow("slider");
	start_slideshow("slider2");

	// Init add bookmark function.
	add_bookmark();
	
	// Contact form Javascript validation.
	if(document.getElementById('contactform'))
	{
		$(document).ready(function(){
			$("#contactform").validate();
		});
	}
}


function ajanlo() {
  window.open("ajanlo.php?action=ajanlom", "_new",
      "resizable=0,scrollbars=1,toolbar=0,location=0,menubar=0,status=0,width=600,height=350");
}

function onlyNumbers(mibe)
{
x=mibe.value
ki=""
for(i=0;i<x.length;i++)
{
   if (x.substr(i,1)>='0' && x.substr(i,1)<='9')
      ki+=x.substr(i,1)
     }
mibe.value=ki
}
