/**
	JAVSCRIPTS..

*/

/* EMAIL convert */
			function nai(n,d,c){
		    this.location.href = 'mailto:'+n+'@'+d+'.'+c; 
		 	}		



function emailcheck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){		   
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){		   
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){		    
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){		    
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){		    
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){		    
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){		    
		    return false;
		 }

 		 return true			;		
	}


/*   
	modalwindows

*/
	
	
			function modalDialog(showdiv) {			
			$("#"+showdiv).modal();							
		}
		function modalDialogWithText(mytext) {			
			$.modal('<div class="modalDialog">'+mytext+'</div>');	
		}
		function closeDialog() {
			$.modal.close();	
		}
		function switchlang(showdiv,tolang) {			
			$("#"+showdiv).modal();	
			//var turl = startpath+tolang;			
			//setTimeout("document.location.href = '"+turl+"';",600);									
		}
		
/* 
	Dropdown menu
*/
$(document).ready(function()
{
    $('#topnav').topnav();
});

var topnav={
    effect: 'fade',           /* default animation effect */
    duration: 400,         /* default duration */
    set: function (settings)
    {
       try
        {
            if (settings.animation == 'show') { this.effect='show'; }
            if (settings.animation == 'slide') { this.effect='slide'; }
            if (settings.animation == 'fade') { this.effect='fade'; }
        } catch (e) {}
        
        try
        {
            this.duration=settings.duration;
        } catch (e) {} 
    },
    fix_pos:function(elem)
    {
        if ($(elem).parent('ul').parent('li').length)
        {
            $(elem).children('ul').eq(0).css({marginTop:-$(elem).height(),marginLeft:$(elem).width()});
        } else
        {
            $(elem).children('ul').eq(0).css({'top':$(elem).offset().top+$(elem).height(),'left':$(elem).offset().left});
        }
    },
    show:function(elem)
    {
        if (this.effect=='fade') { $(elem).children('ul').eq(0).stop(1,1).fadeIn(this.duration); }
        else if (this.effect=='slide') {$(elem).children('ul').eq(0).stop(1,1).slideDown(this.duration); }
        else if (this.effect=='show') { $(elem).children('ul').eq(0).stop(1,1).show(this.duration); }
    },
    hide: function(elem)
    {
        $(elem).children('ul').eq(0).stop(1,1).fadeOut(100);
    }
}

jQuery.fn.topnav=function(settings)
{
    topnav.set(settings);
    
    $(this).find('li').each(function()
    {
            $(this).hover(
                function()
                {
                    topnav.fix_pos(this);
                    topnav.show(this);
                },
                function()
                {
                    topnav.hide(this);
                }
            );
    });
}
