﻿ViewController = function() {

    //statics vars
    //var _var1 = null;

    //static functions
    return {

        IsValidEmail: function(email) {

            regex = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\.\\w+([-.]\\w+)*";

            if (email.search(regex) == -1) {
                return false;
            }

            return true;
        },

        Init: function() {

            //navigation
            $(".NavItem").click(function() {
                window.location = $(this).attr("linkurl");
            });

            $(".NavText").hover(
                function() {
                    $(this).addClass("NavHover");
                },
                function() {
                    $(this).removeClass("NavHover");
                }
            );

            //Contact
            $("#ContactUsButton").click(function() {
                window.location = $(this).attr("linkurl");
            });

            //ProductBox
            $(".ProductBoxWrapper").hover(
                function() {
                    $(this).find(".ProductBox").addClass("ProductBoxHover");
                    $(this).find(".ProductBoxViewDetails").show();
                },
                function() {
                    $(this).find(".ProductBox").removeClass("ProductBoxHover");
                    $(this).find(".ProductBoxViewDetails").hide();
                }
            );

            $(".ProductBoxWrapper").click(function() {
                window.location = $(this).attr("linkurl");
            });

            //ProductQuickSelector
            $("#ProductQuickSelector").change(function() {

                window.location = $(this).val();

            });

            //SoftwareServicesImageContainer
            $(".SoftwareServicesImageContainer").click(function() {

                var screenShotImageUrl = $(this).attr("screenshotimageurl");

                var html = "<div class=\"ScreenShotImageContainer\">" +
                           "    <img class=\"ScreenShotImage\" src=\"" + screenShotImageUrl + "\" alt=\"\"/>" +
                           "</div>";

                $.blockUI(
                        {
                            message: html,
                            css: {
                                padding: 0,
                                margin: 0,
                                width: '',
                                top: '10%',
                                left: '25%',
                                color: '#000000',
                                border: '0px',
                                cursor: 'pointer'
                            }
                        });

                $(".ScreenShotImageContainer").click(function() {
                    $.unblockUI();
                });

                $(".blockOverlay").click(function() {
                    $.unblockUI();
                });

            });
        }

    };

} ();

//onload
jQuery(function() { ViewController.Init(); });
