﻿function gotoRef(myURL){
    var linkref = myURL;
    if(confirm("Are you sure?")) {
        window.location.href=linkref;
    }
}

$(document).ready(function(){
    
    $("#thumbslide img").css({opacity: 0.8});
    $(".pslideinfo").css({opacity: 0.8});   
    $("#newspopup").css({opacity: 0.8});
    $("#aboutmenu").css({opacity: 0.8});
    $("#projectmenu").css({opacity: 0.8});
    $("#dropdownmenu").css({opacity: 0.8});
    $("#projectsubmenu").css({opacity: 0.8});
    $("#projectpopup").css({opacity: 0.8});
    $("#thumbslideprev").css({opacity: 0.6});
    $("#thumbslidenext").css({opacity: 0.6});
    
    
    
    
    $("#newsslide").cycle({ 
        fx:     "scrollUp", 
        speed:  "fast", 
        timeout: 6000,
        delay: -2000, 
        next:   "#nextnews", 
        prev:   "#prevnews" 
    });
    
    $("#slideshow").hover(function(){
	    $(".slideshowbutton").show();
    },function(){
	    $(".slideshowbutton").hide();
    });   
    
    
    $("#projectpopup").hover(function(){
	    $("#projectsubmenu").show();
    },function(){
	    $("#projectsubmenu").hide();
    });  
    
    $("#newsbar").hover(function(){
	    $(".newsbarbutton").show();
    },function(){
	    $(".newsbarbutton").hide();
    });
    
    $(".newsslidetitle").click(function(){
	    var skinfo = $(this).attr("kinfo");
	    $("#newspopup .newspopupcontent").html(skinfo);
	    $("#newspopup").show();
	    return false;
    });
    
    $(".newspopupclose").click(function(){
	    $("#newspopup").hide();
    });
    
    $(".btn-projects").click(function(){	        
        $("#projectmenu").slideToggle("slow");        
        $(this).toggleClass("active");  
        $("#aboutmenu").hide();       
        return false;
    });
    
    $(".btn-about").click(function(){		        
        $("#aboutmenu").slideToggle("slow");
        $(this).toggleClass("active"); 
        $("#projectmenu").hide();
        return false;
    });
    
    
    $("#thumbslideprev").hover(function(){            
        var position = $("#thumbslide").position(); 
        var ilength = $("#thumbslide img").length; 
        var iwidth = $("#thumbslide").width(); 
        var ileft = ilength * (-56);
            ileft = ileft + 270;
        $("#thumbslide").animate({left:ileft},ilength*200,function(){});
    },function(){       
       $("#thumbslide").stop();   
    });  
    
    $("#thumbslidenext").hover(function(){          
        var position = $("#thumbslide").position();
        var ilength = $("#thumbslide img").length;    
        var ileft = ilength * (-288);
	    $("#thumbslide").animate({left:"0"},ilength*200,function(){});
    },function(){       
      $("#thumbslide").stop();  
    }); 
    
        
    $("#thumbslide img").hover(function(){  
	    $(this).animate({opacity: 1.0, top:"-5", left:"-5", height:"60", width:"85"},100,function(){});
    },function(){        
	    $(this).animate({opacity: 0.8, top:"0", left:"0", height:"50", width:"75"},100,function(){});
    });  
    
    $("#thumbslide img").click(function(){  
        var skinfo = $(this).attr("kinfo");
	    $("#projectpopup .projectpopupcontent").html(skinfo);
         $("#projectpopup").show();
    });
    
    $(".projectpopupclose").click(function(){
	    $("#projectpopup").hide();
    });
    
   
    
    $("#infobox").mousemove(function(e){  
        
        var position = $("#infolists").position();
        var iheight = $("#infolists").height();
        var icondition = 380 - iheight - 15;
        $("#infolists").stop();
        
        if (e.pageY<200)
        {
            $("#infolists").animate({top: "0"},800, "linear", function(){});
            //$("#pagetitle").html(e.pageY + "  " + position.top + " " + iheight + " " + icondition);  
        }
            
        if (iheight>380)
        {               
            if(e.pageY>500)
            {
               $("#infolists").animate({top: icondition},800, "linear", function(){}); 
               //$("#pagetitle").html(e.pageY + "  " + position.top + " " + iheight + " " + icondition);  
            }
        }
        
     });
     
     $("#thumbslideshow").mousemove(function(e){  
        
        var tposition = $("#thumbslideshow").position();
        var position = $("#thumbslide").position();
        var iwidth = $("#thumbslide").width();
        var ilength = $("#thumbslide img").length;    
        
        var icondition = 410 - (ilength*81) - 81;
        $("#thumbslide").stop();
        
        if(e.pageX<tposition.left+100)
        {
            //$("#pagetitle").html(e.pageX + "  " + tposition.left + " " + iwidth + " " + icondition);
            $("#thumbslide").animate({left: "0"},ilength*300, "linear", function(){});
        }
        
        if (iwidth>280) 
        {
            if(e.pageX>tposition.left+350)
            {
                //$("#pagetitle").html(e.pageX + "  " + tposition.left + " " + iwidth + " " + icondition);
                $("#thumbslide").animate({left: icondition},ilength*300, "linear", function(){});   
            }
        }
        
     });
    
    
   	
	$(".navigationlink").click(function(){
	    var sTitle = $(this).attr("title");
	    $("#detail").html(sTitle);
	    return false;
    });
    
    
    
    
    
    
    
    
});
