<!--
var vidMenuCount = 0;
var vidCount = 0;

function leftVid()
{  
    if( vidMenuCount > 0 )
    {
        vidMenuCount = vidMenuCount - 1;
        checkArrows();
        changeVidPage(); 
    }
    return false;
}
function rightVid()
{
    if( vidMenuCount < vidCount )
    { 
        vidMenuCount = vidMenuCount + 1;
        checkArrows();
        changeVidPage();
    }
    return false;
}
function gotoPage(obj)
{
    var toPage = obj.id;
    vidMenuCount = toPage;
    checkArrows();
    changeVidPage();
   
}
function checkArrows()
{
    getTotalVids();
    if( vidMenuCount == 0 )
    {
        $("#leftArrow").css("background-image","url('/images/vidLeftx.jpg')");
    }
    else if( vidMenuCount == vidCount)
    {
        $("#rightArrow").css("background-image","url('/images/vidRightx.jpg')");
    }
    else
    {
        $("#leftArrow").css("background-image","url('/images/vidLeft.jpg')");  
        $("#rightArrow").css("background-image","url('/images/vidRight.jpg')");  
    }
}
function getTotalVids()
{
     $.get("http://"+window.location.host+"/grabMoreVids.php", { pos: 'get'}, 
        function(data){
            var x = Math.floor(data/12);    
            vidCount = x;
            var pages = '';
            var i = 0;
            for( i = 0; i <= vidCount; i++ )
            {
                if( i == vidMenuCount )
                {
                    pages += '<img src="/images/xpage.gif">';   
                    continue;
                }
                pages += '<img class="vidPageCircle" id="'+i+'" src="/images/page.gif" onClick="gotoPage(this)">';
            }
            $("#vidPage").html(pages);
        });
}
function changeVidPage()
{
    $("#x").html('<img src="/images/loading.gif" />');
    $("#showVids").fadeOut("fast",function()
    {
        $.get("http://"+window.location.host+"/grabMoreVids.php", { pos: vidMenuCount}, 
        function(data){
            $("#showVids").fadeIn().html(data);
            $("#x").empty();    
        });
    });
}

$(document).ready(function()
{    
    rememberLangauge('get'); 
    checkArrows();
    $("#email").focus(function(){
        if( $("#email").val() == "Email")
        {
            $(this).val('');
            $(this).siblings('#password').val('');
        }
    });
    
    $(".jobTitle").toggle(
    function(){
        $(this).siblings(".jobDescription").show();
        $(this).children("span").html("[-]");
    },
    function(){
        $(this).siblings(".jobDescription").hide();
        $(this).children("span").html("[+]");
    });
    
    //Change big image when user mouses over small thumbnail
    var originalSRC = $("#bigImage").attr("src");
    $(".tinyThumb").mouseenter(function(){
        
        var oldSRC = $(this).attr("src");
        var newSRC = "http://"+window.location.host+oldSRC.replace("tiny_thumbs/xtn_",""); 
//alert(newSRC);

        if (navigator.appName=="Microsoft Internet Explorer")
        {
            $("#bigImage").attr("src",newSRC);
        }
        else
        {
            $("#oiLoad").html('<img src="http://roylco.com/images/oiload.gif"/>');
            $("#bigImage").load(newSRC,function(e){
              $("#oiLoad").empty();
              $("#bigImage").attr("src",newSRC);
            });
        }
    });
    
    //Returns big image to main image for that product  
    $("#otherImages").mouseleave(function(){
         $("#bigImage").attr({"src":originalSRC});
    });
    
    //Toggle Instructions
    $("#viewInstructions, #videoInst").click(function(e){
        e.preventDefault();
        $("#videoInstructions").dialog().is(":visible")?$("#videoInstructions").dialog("close"):$("#videoInstructions").dialog("open");
    });
    
    $(function(){
         $('#videoInstructions').dialog({
	  	      width: 210,
	  	      autoOpen: false,
	  	      zIndex: 3999,
	  	      position: ['right','center']
	  	  });
     });
     
    //Submit select menus when user clicks an option
    $(".distChoice").change(function(){
        $(this).parent("form").submit();
    });
    $(".methodOrder").change(function(){
        $(this).parent("form").submit();
    });
    $(".selectNumber").change(function(){
        $(this).parent("form").submit();
    });
    
    //Make entire cartInfo div an anchor
    $("#cartInfo").click(function(){
         window.location = "/cart";
    });
    
     
	  //Show video player functionality
	  $("#videoButton").click(function(event){
	      event.preventDefault();
	      $("#video").dialog("open");
	  });
	  $("#cover").click(function(){
	      $("#video").dialog("close");
	  });
	  
	  //Settings for video & add to cart popups
	  $(function() {
	  	   $("div.dialog").dialog({ 
	  	      draggable: true,
	  	      open: function(){
	  	          updateCartInfo();
	  	      }       	  	          
	  	   });
	       $("#video").dialog({
	  	      close: function(){
	  	          hideVideo();
	  	      },
	  	      width: 452,
	  	      autoOpen: false,
	  	      zindex: 9999,
	  	      position: ['center','center']
	  	  });
	  });
	 
	var showFeedbackForm = function(){
	      $("#feedbackForm").dialog("open");
	};  
	  //Feedback form hiding/showing:
    $('#voiceOpinion').click(function(event){
	      showFeedbackForm();
	  });  $('#voiceTop').click(function(event){
	      showFeedbackForm();
	  });      
     $(function(){
         $('#feedbackForm').dialog({
	  	      width: 370,
	  	      autoOpen: false,
	  	      zIndex: 3999,
	  	      position: ['center','center']
	  	  });
     });
    
    
    //AJAX cart update for left column
    function updateCartInfo()
    {
         $.get("http://"+window.location.host+"/grabcartinfo.php", 
             function(data){
                 $("#cartInfo").html(data);
             });
    }

/*
    //Add style to select menus
    $("#chooseCountry").selectmenu();
    $("#chooseState").selectmenu({
         maxHeight: 450,
         menuWidth: 180
    });
    $("#chooseProv").selectmenu({
        width: 180,
        menuWidth: 150
    });    
    $("#orderMethod").selectmenu({
        width: 140,
        menuWidth: 105
    });
     $("#numberSelect").selectmenu({
        width: 60,
        menuWidth: 40
    });
    $("#chooseDist").selectmenu({
        width: 170,
        menuWidth: 145
    });
*/    
	//Ensures select menu events are triggered
    $("select").keyup(function(){
        $(this).change();
    });
    
    
    //Translation functions:
    $('#french').click(function(event){
        event.preventDefault();
        $('body').translate('fr');
        rememberLangauge('fr');
    });
    $('#spanish').click(function(event){
        event.preventDefault();
        $('body').translate('es');
        rememberLangauge('es');
    });
    $('#german').click(function(event){
        event.preventDefault();
        $('body').translate('de');
        rememberLangauge('de');
    });
    $('#italian').click(function(event){
        event.preventDefault();
        $('body').translate('it');
        rememberLangauge('it');
    });
    $('#polish').click(function(event){
        event.preventDefault();
        $('body').translate('pl');
        rememberLangauge('pl');
    });
    $('#greek').click(function(event){
        event.preventDefault();
        $('body').translate('el');
        rememberLangauge('nl');
    });
    $('#dutch').click(function(event){
        event.preventDefault();
        $('body').translate('nl');
        rememberLangauge('nl');
    });
    $('#english').click(function(event){
        event.preventDefault();
        rememberLangauge('clear');
    });
    
    function rememberLangauge(langauge)
    {
        if(langauge == 'get')
        {
            $.get("http://"+window.location.host+'/keepTranslation.php',{lang: "get" },function(data){
                if(data)
                {
                    $('body').translate(data);
                }
            });
        }
        else if(langauge == 'clear')
        {
            $.get("http://"+window.location.host+'/keepTranslation.php',{lang: "clear" },function(data){
                window.location.reload(true);
            });
        }
        else
        {
            $.get("http://"+window.location.host+'/keepTranslation.php',{lang: langauge });
        }
    }
    

    
    //This function prevents the mouseover popup images from
    //being clipped by the visible screen. If the popup is being
    //clipped it is moved so that it is visible.
    $(".thumb").mouseenter(function(){
        
        var r = Math.floor(Math.random()*255);
        var g = Math.floor(Math.random()*255);
        var b = Math.floor(Math.random()*255);
        
        //Give div a random background color
        $(this).siblings('.popup').css("background-color","rgb("+r+","+g+","+b+")"); 

        //Show the popup
        $(this).siblings('.popup').css("display","inline");

        //Calculate horizontal positioning
        var width = $(this).siblings('.popup').width()+12;
        var winx = $(window).width(); 
        var left = $(this).siblings('.popup').position().left;
        
        //Calculate vertical positioning
        var height = $(this).siblings('.popup').height()+12;
        var winy = $(window).height(); 
        var top = ( ($(this).siblings('.popup').offset().top) - ($(document).scrollTop()) );
        
        //Prevent horizontal clipping
        if( left + width + 15 > winx )
        {
            var change = 0 -(15 + 150 + width);
            $(this).siblings('.popup').css("margin-left",change+"px");    
        }
        
        //Prevent vertical bottom clipping
        if( (top + height) > winy )
        {
            var clipping = -30 - ( (top + height) - winy );
            $(this).siblings('.popup').css("margin-top",clipping+"px");
        }
        
        //Prevent vertical top clipping
        if( top < 0 )
        {
           $(this).siblings('.popup').css("margin-top",(20-top)+"px");
        }
        
    });
    //Hides the popup when user mouses out of thumbnail
    $(".thumb").mouseleave(function(){
        $(this).siblings('.popup').css("display","none");
        $(this).siblings('.popup').css("margin","0 0 0 15px");
    });
     
     
    //Populate the shipping info form with billing info values when the checkbox is clicked
    $("#same").click(function(){
        if($(this).is(':checked'))
        {
            $("#SfirstName").val( $("#firstName").val());
            $("#SlastName").val( $("#lastName").val());
            $("#Saddress").val( $("#address").val());
            $("#Scity").val( $("#city").val());
            $("#Sstateprov").val( $("#stateprov").val());
            $("#SUcountry").val( $("#Ucountry").val());
            $("#SpostZIP").val( $("#postZIP").val());
            $("#Semail").val( $("#email").val());
            $("#Sphone").val( $("#phone").val());
        }
        else
        {
            $("#SfirstName").val("");
            $("#SlastName").val("");
            $("#Saddress").val("");
            $("#Scity").val("");
            $("#Sstateprov").val("");
            $("#SUcountry").val("");
            $("#SpostZIP").val("");
            $("#Semail").val("");
            $("#Sphone").val("");
        }
    });
    
    //Make sure the user provides thier shipping information 
    $("#confirmOrder").submit(function(event){
        if( !confirm('You will now be taken to PayPal to make a secure payment.\n\n You do NOT need a registered PayPal account to make your payment.\n\n Click OK to continue to PayPal, or click Cancel to stay on this page. ') )
        {
            event.preventDefault();
        }
        else if( !$("#SfirstName").val() || !$("#SlastName").val() || !$("#Saddress").val() || !$("#Scity").val() || !$("#Sstateprov").val() || !$("#SUcountry").val() || !$("#SpostZIP").val() )
        {
            event.preventDefault(); 
            alert("You have not provided enough shipping information!");
        }  
    });
    
    $("#roylcoLinks a img").mouseenter(function(){
        $(this).fadeTo('0','0.5');
    });
    $("#roylcoLinks a img").mouseleave(function(){
        $(this).fadeTo('0','1');
    });
     
});

function hideVideo()
{
    document.getElementById("cover").style.display = "none";
    document.getElementById("video").innerHTML = '';
    return false;
}
function showVideo(url)
{
document.getElementById("video").innerHTML = "<object width='425' height='344' id='flvPlayer'>"+
  "<param name='allowFullScreen' value='true'>"+
  "<param name='movie' value='/player/player.swf?movie=/product_videos/"+url+"&btncolor=0x333333&accentcolor=0x9c0000&txtcolor=0xffffff&volume=50&autoplay=on&autoload=on'>"+
  "<embed src='/player/player.swf?movie=/product_videos/"+url+"&btncolor=0x333333&accentcolor=0x9c0000&txtcolor=0xffffff&volume=50&autoplay=on&autoload=on' width='425' height='344' allowFullScreen='true' type='application/x-shockwave-flash'>"+
 "</object>";

    document.getElementById("cover").style.display = "block";
    return false;
}


//-->

