﻿/**
* Copyright (c) 2010 BEIJING QIANYITONG ADVERTISING DESIGN CO.,LTD ( http://www.qytdesign.com/)
* All rights reserved.
* Open source under the BSD License. 
*/
$(document).ready(function() {
    $('.callRight').corner("8px");
    //$('#head$ButtonSearch').keydown(function() { KeyDown($('#head_ButtonSearch')); });
    $('.menuLink a').click(function() {
        //$('.menuLink a').css("color", "white");
        $(this).css('color', 'yellow');
    });
    $('.menuOne').each(function() {
        if (!$(this).children().is('a')) {
            $(this).css("background", " url('../images/linkAllow.gif') #5d910e no-repeat right bottom");
        }
        if ($(this).parent().hasClass('menuTwo')) {
            var le = $(this).css("width");
            $(this).css("width", parseInt(le) - 13 + "px");
            var obj = $(this).siblings('.menuTwo').find('a');
            var lec = obj.css("width"); ;
            obj.css("width", parseInt(lec) - 13 + "px");
        }
    });
    $('.menuOne').click(
        function() {
            if ($(this).children().is('a'))
                return;

            if ($(this).hasClass('ClickOn')) {
                $(this).removeClass('ClickOn');
                $(this).css({ background: "url('../images/linkAllow.gif') #5d910e no-repeat right top" }).next(".menuTwo").hide(200);
                return;
            }
            $(this).siblings('.menuOne').removeClass('ClickOn');
            $(this).addClass('ClickOn');

            $(this).css({ background: "url('../images/linkAllow.gif') #5d910e no-repeat right bottom" }).next(".menuTwo").slideDown('fast').siblings(".menuTwo").hide(200);
            $(this).siblings('.menuOne').each(function() {
                if (!$(this).children().is('a')) {
                    $(this).css("background", " url('../images/linkAllow.gif') #5d910e no-repeat right top");
                }
            });
        }
       );
    slide(".menuTwo", 25, 15, 100, .8);

    //    $('#qsabout').trigger('click');
    //    $('#qyabout').trigger('click');
});

function slide(navigation_id, pad_out, pad_in, time, multiplier) {
    // creates the target paths
    var list_elements = navigation_id + " .menuLink";
    var link_elements = list_elements + " a";

    // initiates the timer used for the sliding animation
    var timer = 0;

    // creates the slide animation for all list elements 
    $(list_elements).each(function(i) {
        // margin left = - ([width of element] + [total vertical padding of element])
        $(this).css("margin-left", "0px");
        // updates timer
        timer = (timer * multiplier + time);
        $(this).animate({ marginLeft: "0" }, timer);
        $(this).animate({ marginLeft: "15px" }, timer);
        $(this).animate({ marginLeft: "0" }, timer);
    });

    // creates the hover-slide effect for all link elements 		
    $(link_elements).each(function(i) {
        $(this).hover(
		function() {
		    $(this).animate({ paddingLeft: pad_out }, 150);
		},
		function() {
		    $(this).animate({ paddingLeft: pad_in }, 150);
		});
    });
}

