﻿var Marquee = function(j,s,w) {
   var self = this;
   var jTarget = j;
   var strText = s;
   var intWidth = w;
   var intPaddingLeft = 60;
   var jText,intTextWidth;
   var update = function() {
     intPaddingLeft -= 2;
     if (intPaddingLeft < -intTextWidth) {
         intPaddingLeft += intTextWidth;
     }
   jText.css({'left':intPaddingLeft + 'px'});
   };
   var setup = function() {
     jText = $('<div class="scrollingtext"></div>').text(strText);
     jTarget
       .append(jText)
       .append($('<div class="fader"></div>').html('&nbsp;'))
       .append($('<div class="fader left"></div>').html('&nbsp;'));
     intTextWidth = $(jTarget).find('.scrollingtext').width();
     jTarget.width(intWidth);
     jText.text(strText + " " + strText);
     update();
   };
   setup();
   setInterval(update,50);
   return self;
};

function changeLang(langId)
{
    var sPath = window.location.pathname;
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    if (langId==2)
    {
        document.location='Russian/'+sPage;
    }
    if (langId==3)
    {
        document.location='Portuguese/'+sPage;
    }
}

function validate()
{
            if (document.getElementById("first_name").value =="")
		    {
			    alert("(*) You must fill in all fields marked with ");
			    document.getElementById("first_name").focus();
		    }
		    else
		    {
		        if (document.getElementById("title").value =="")
		        {
			    alert("(*) You must fill in all fields marked with ");
			    document.getElementById("title").focus();
		        }
		        else
		        {
		            if (document.getElementById("company").value =="")
		            {
			        alert("(*) You must fill in all fields marked with ");
			        document.getElementById("company").focus();
		            }
		            else
		            {  
		                if (document.getElementById("email").value =="")
		                {
			            alert("(*) You must fill in all fields marked with ");
			            document.getElementById("email").focus();
		                }
		                else
		                {  
    		                if (document.getElementById("country").value =="")
		                    {
			                alert("(*) You must fill in all fields marked with ");
			                document.getElementById("country").focus();
		                    }
		                    else
		                    {  
		                     document.searchForm.submit();           
		                    }
		                }
		             }
		           }
		        }

}

$(document).ready(function() {    
    
        $(".header .menu A,.header .menu .Selected").hover( 
        function() { 
            $(".header .menu A,.header .menu .Selected").textShadow( );
        });
    

        $(".dropdown img.flag").addClass("flagvisibility");

        $(".dropdown dt a").click(function () {
            $(".dropdown dd ul").toggle();
        });

        $(".dropdown dd ul li a").click(function () {
            var text = $(this).html();
            $(".dropdown dt a span").html(text);
            $(".dropdown dd ul").hide();
            $("#result").html("Selected value is: " + getSelectedValue("sample"));
        });

        function getSelectedValue(id) {
            return $("#" + id).find("dt a span.value").html();
        }

        $(document).bind('click', function (e) {
            var $clicked = $(e.target);
            if (!$clicked.parents().hasClass("dropdown"))
                $(".dropdown dd ul").hide();
        });


        $("#flagSwitcher").click(function () {
            $(".dropdown img.flag").toggleClass("flagvisibility");
        });

});
     
