﻿$(document).ready(function() {
    //  $('.search_wtr').watermark({ watermarkText: 'Search', watermarkCssClass: 'search_wtr' });
    set_hide_show();
    set_div_corners();
    set_accordion_menu();
    set_facebox();
    set_search();
    $('#menu_news_text').show();
    $('#menu_news_text').cycle({
        fx: 'fade',
        speed: 1000,
        timeout: 10000, cleartypeNoBg: true
    });
    $('#menu_news_text_default').show();
    $('#menu_news_text_default').cycle({
        fx: 'fade',
        speed: 1000,
        timeout: 10000, cleartypeNoBg: true
    });
    $('.clients_logo').show();
    $('.clients_logo').cycle({
        fx: 'fade',
        speed: 1000,
        timeout: 10000, cleartypeNoBg: true
    });
    //    $('.module_height').equalHeights();
});
function set_search() {
    $("#btnSearch").click(function() {
        var _q = "http://www.google.com/search?q=" + $("#txtSearch").val();
        $("#txtSearch").val("");
        window.open(_q);
        return false;
    });    
}
function set_facebox() {
    $('a[rel*=facebox]').facebox();
}
function set_div_corners() {
    $('.module_default').corner();
    $('#footer_module').corner();
    $('#search').corner({
        tl: { radius: 6 },
        tr: { radius: 6 },
        bl: { radius: 6 },
        br: { radius: 6 }
    });
    $('#menu_news').corner();
    $('#menu_side_bg_blue').corner();
    $('#menu_side').corner({
        tl: { radius: 6 },
        tr: { radius: 6 },
        bl: { radius: 6 },
        br: { radius: 6}
    });
    $('#img_pharmaceutical').corner({
        tl: { radius: 6 },
        tr: { radius: 6 },
        bl: { radius: 6 },
        br: { radius: 6 }
    });
    $('#engineering_menu_side').corner({
        tl: { radius: 6 },
        tr: { radius: 6 },
        bl: { radius: 6 },
        br: { radius: 6 }
    });
    $('#services_menu_side').corner({
        tl: { radius: 6 },
        tr: { radius: 6 },
        bl: { radius: 6 },
        br: { radius: 6 }
    });
    $('#software_menu_side').corner({
        tl: { radius: 6 },
        tr: { radius: 6 },
        bl: { radius: 6 },
        br: { radius: 6 }
    });
    $('#menu_top').corner({
        tl: { radius: 6 },
        tr: { radius: 6 },
        bl: { radius: 6 },
        br: { radius: 6 }
    }); 
    $('.module_smll_header').corner({ bl: false, br: false });
    $('.module_smll_default').corner({ tl: false, tr: false });
    $('#module_default_today').corner();
    $('.module_links').corner();
    $('#module_andrew_small').corner({ tl: false, tr: false, bl: false });
}
function set_accordion_menu() {
    if ($.cookie('menustate') && $.cookie('menustate') != "#") {
        var _idState = $.cookie('menustate');
        $(_idState).next('.menu_side_content').slideToggle('fast').siblings('.menu_side_content').slideUp('fast');
    }
    $('.menu_side_button').click(function() {
        var _id = '#' + $(this).attr("id");
//        if (_id == $.cookie('menustate')) {
//            _id = '#';
//        }
        $.cookie('menustate', _id, { path: '/', expires: 2 });
//        if ($.cookie('menustate') != '#') {
//            $(_id).next('.menu_side_content').slideToggle('fast').siblings('.menu_side_content').slideUp('fast');
//        }
    });
    $('.menu_sub_click').click(function() {
        $(this).next('.menu_side_content_sub').slideToggle('fast').siblings('.menu_side_content_sub').slideUp('fast');    
    }); 
}
function set_hide_show() {
    $('.sh_text').click(function() {
        var _value = $(this).html();
        if (_value == "read more") {
            $(this).next().slideDown("slow");
            $(this).html("close");
        }
        else {
            $(this).next().slideUp("slow");
            $(this).html("read more");
        }
    });
}