﻿function GetCurrentUrl(url) {
    return url.substring(0, url.indexOf("?_sid=")) + "?_sid=" + Math.round(new Date().getTime() / 1000);
}

function _RedirectTo(url) {
    window.location = url;
}

function SiteMap() {
    $('#sub-footer').slideToggle(1000, function () { });
}

RegexString = function (val) {
    if (val.length >= 1) {
        return true;
    } else {
        return false;
    }
};

RegexNumeric = function (val) {
    var regex = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
    if (regex.test(val) || val == '-') {
        return true;
    }
    return false;
};

RegexInteger = function (val) {
    var regex = /(^-?\d\d*$)/;
    if (regex.test(val) || val == '-') {
        return true;
    }
    return false;
};

RegexLogin = function (val) {
    var regex = /^[a-z]([0-9a-z_])+$/i; ;
    if (regex.test(val)) {
        return true;
    }
    return false;
};

RegexEmail = function (val) {
    var regex = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
    //var regex = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{2,3})$)/i;
    if (regex.test(val) || val == '-') {
        return true;
    }
    return false;
};

RegexPhone = function (val) {
    var regex = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
    if (regex.test(val) || val == '-') {
        return true;
    }
    return false;
};

RegexIP = function (val) {
    var regex = /^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$/;
    if (regex.test(val)) {
        return true;
    }
    return false;
};


//function slideSwitch() {
//    var $active = $('#slideshow DIV.active');
//    var $activeNews = $('#slidenews DIV.active');
//    var $activeToggle = $('#slidetoggle a.act');

//    if ($active.length == 0) $active = $('#slideshow DIV:last');
//    if ($activeNews.length == 0) $activeNews = $('#slidenews DIV:last');
//    if ($activeToggle.length == 0) $activeToggle = $('#slidetoggle a:last');

//    // use this to pull the divs in the order they appear in the markup
//    var $next = $active.next().length ? $active.next() : $('#slideshow DIV:first');
//    var $nextNews = $activeNews.next().length ? $activeNews.next() : $('#slidenews DIV:first');
//    var $nextToggle = $activeToggle.next().length ? $activeToggle.next() : $('#slidetoggle a:first');

//    // uncomment below to pull the divs randomly
//    // var $sibs  = $active.siblings();
//    // var rndNum = Math.floor(Math.random() * $sibs.length );
//    // var $next  = $( $sibs[ rndNum ] );


//    $active.addClass('last-active');
//    $activeNews.addClass('last-active');
//    $activeToggle.addClass('last-active');

//    $next.css({ opacity: 0.0 }).addClass('active').animate({ opacity: 1.0 }, 1000, function () { $active.removeClass('active last-active'); });
//    $nextNews.css({ opacity: 0.0 }).addClass('active').animate({ opacity: 1.0 }, 1000, function () { $activeNews.removeClass('active last-active'); });
//    $nextToggle.css({ opacity: 0.0 }).addClass('act').animate({ opacity: 1.0 }, 500, function () { $activeToggle.removeClass('act last-active'); });
//}

//function SelectImage(id) {
//    $('#slideshow DIV.active').attr('class', '');
//    $('#slidenews DIV.active').attr('class', '');
//    $('#slidetoggle a.act').attr('class', '');

//    $('#image-block-' + id).attr('class', 'active');
//    $('#slide-news-' + id).attr('class', 'active');
//    $('#slide-state-' + id).attr('class', 'act');
//}

//$(function () {
//    setInterval("slideSwitch()", 3000);
//});
