/// <reference path="scripts/jquery-1.6.2-vsdoc.js" />
var captionLength = 0;
var caption = "";
var newsi = 0;
var i=1;
var handle;
var max = 651 ;
var min = 0;

$(document).ready(function () {
    if ($(".btn_area").height() < ($(document).height() - $(".tp_area").height())) {
        $(".btn_area").height(($(document).height() - $(".tp_area").height()) + "px");
    } else {
        $(".btn_area").height("auto");
    }
    var w = ($(document).width() / 2) - 199;
    var h = ($(document).height() / 2) - 125;
    //$('body').css("background-image", "url('images/CSLogo.png')");
    //$('body').css("background-repeat", "no-repeat");
    $('body').css({ backgroundPosition: w + "px " + h + "px" });
    $(".tp_area").delay(4000).show("slide", { direction: "up", easing: "easeOutBounce" }, 2000);
    $(".btn_area").delay(4000).show("slide", { direction: "down", easing: "easeOutBounce" }, 2000);
    /* MENU */
    var $page = jQuery.url.attr("file");
    //alert($page);
    if (($page != "Default.aspx") && ($page != null)) {
        $("#home").hover(function () { anmt_nav_hover($("#home")); }, function () { anmt_nav_out($("#home")); });
    }
    if (($page != "Products.aspx") && ($page != "ProductsView.aspx")) {
        $("#prdct").hover(function () { anmt_nav_hover($("#prdct")); }, function () { anmt_nav_out($("#prdct")); });
    }
    if ($page != "Support.aspx") {
        $("#spprt").hover(function () { anmt_nav_hover($("#spprt")); }, function () { anmt_nav_out($("#spprt")); });
    }
    if ($page != "Aboutus.aspx") {
        $("#abtus").hover(function () { anmt_nav_hover($("#abtus")); }, function () { anmt_nav_out($("#abtus")); });
    }
    if ($page != "Contactus.aspx") {
        $("#cntctus").hover(function () { anmt_nav_hover($("#cntctus")); }, function () { anmt_nav_out($("#cntctus")); });
    }
    function anmt_nav_hover(mnu_item) {
        mnu_item
					.stop(true, true).animate({
					    backgroundPosition: "(0px 0px)",
					    height: "65px"
					},
						  {
						      duration: 200
						  }
					)
					.animate({
					    backgroundPosition: "(0px -5px)",
					    height: "60px"
					},
						  {
						      duration: 200
						  }
					)
    }
    function anmt_nav_out(mnu_item) {
        mnu_item
					.stop().animate({
					    backgroundPosition: "(0px -10px)",
					    height: "55px"
					},
						  {
						      duration: 100
						  }
					)
    }
    /* END OF MENU 	*/
    /* SLIDE */

    handle = setInterval(function () {
        i++;
        slider();
    }, 10000);

    $("#nav_btn1").click(function () {
        clearInterval(handle);
        handle = setInterval(function () {
            i++;
            slider();
        }, 10000);
        i = 1;
        slider();
    });
    $("#nav_btn2").click(function () {
        clearInterval(handle);
        handle = setInterval(function () {
            i++;
            slider();
        }, 10000);
        i = 2;
        slider();
    });
    $("#nav_btn3").click(function () {
        clearInterval(handle);
        handle = setInterval(function () {
            i++;
            slider();
        }, 10000);
        i = 3;
        slider();
    });


    /* NEWS TICKER */


    setInterval("cursorAnimation()", 600);
    var news = $("#news li").get();
    caption = news[newsi++].innerHTML;
    type();
    setInterval(function () {
        if (newsi + 1 > news.length) {
            newsi = 0;
        }
        caption = news[newsi++].innerHTML;
        type();
    }, 8000);

    /* END OF NEWS TICKER */

    /* END OF SLIDE */
    /* Product LOGO */

    $("#nav_left").click(function () {
        if (parseInt($("#logo div div").css("left")) < max) {
            $("#logo div div").stop(true, true).animate({ left: "+=163" }, 1000, "easeInOutExpo");
        }
    });
    $("#nav_right").click(function () {
        if (parseInt($("#logo div div").css("left")) > min) {
            $("#logo div div").stop(true, true).animate({ left: "-=163" }, 1000, "easeInOutExpo");
        }
    });

    /*   END OF Product LOGO */

    /* Tab */
    $('#tabs').tabs();
    /* End OF Tab */


    /* Screen Shot */
    $(".navshot a").click(function () {
        var slct = $("img", this).attr("src");
        var	slct_i = $(this).attr("rel");
        $(".shotdis img").fadeOut(500, function () {
            $(".shotdis img").attr("src", slct);
            $(".shotdis a").attr("href", slct_i);
            $(".shotdis img").fadeIn(500);
        });
    });
    //if ($page == "ProductsView.aspx") {
        $("a#lightbox").fancybox();
    //}
    /* END OF Screen Shot */

});

/* SLIDE */	
	function slider(){
		if(i==1){				
			$(".motto2").stop(true, true).animate({top: '-500'},1000,"easeInOutExpo");
			$(".motto3").stop(true, true).animate({top: '-500'},1000,"easeInOutExpo");
			$(".motto1").stop(true, true).animate({top: '70'},2200,"easeInOutExpo");
			
			$(".slide_container").stop(true, true).animate({right: '0'},2000,"easeInOutExpo");

			$("#nav_btn1").css("background-position","0px 0px");
			$("#nav_btn2").css("background-position","0px -24px");
			$("#nav_btn3").css("background-position","0px -24px");

		}else if(i==2){	
			$(".motto1").stop(true, true).animate({top: '-500'},1000,"easeInOutExpo");
			$(".motto3").stop(true, true).animate({top: '-500'},1000,"easeInOutExpo");
			$(".motto2").stop(true, true).animate({top: '70'},2200,"easeInOutExpo");
			
			$(".slide_container").stop(true, true).animate({right: '-932'},2000,"easeInOutExpo");

			$("#nav_btn2").css("background-position","0px 0px");
			$("#nav_btn1").css("background-position","0px -24px");
			$("#nav_btn3").css("background-position","0px -24px");

		}else if(i==3){
			$(".motto1").stop(true, true).animate({top: '-500'},1000,"easeInOutExpo");
			$(".motto2").stop(true, true).animate({top: '-500'},1000,"easeInOutExpo");
			$(".motto3").stop(true, true).animate({top: '70'},2200,"easeInOutExpo");

			$(".slide_container").stop(true, true).animate({right: '-1864'},2000,"easeInOutExpo");
			
			$("#nav_btn3").css("background-position","0px 0px");
			$("#nav_btn1").css("background-position","0px -24px");
			$("#nav_btn2").css("background-position","0px -24px");

			i=0;
		}
	}
	/* NEWS TICKER */
	
		function type() 
		{
			$('p.caption').html(caption.substr(0, captionLength++));
			if(captionLength < caption.length+1)
			{
				setTimeout("type()", 50);
			}
			else {
				captionLength = 0;
				caption = "";
			}	
		}
		
		function cursorAnimation() 
		{
		  $("p.cursor").animate(
		  {
		    opacity: 0
		  }, "fast", "swing").animate(
		  {
		    opacity: 1
		  }, "fast", "swing");
		}
	/* END OF NEWS TICKER */
/* END OF SLIDE */	
