﻿// Created By: Gourav Rampal
// Created On: 31st Oct 2011
// Desc: Function used to bind dynamic pages. & Site map page

$(document).ready(function () {
    //$(".jqgridTable").setGridWidth($(window).width() - 500, true);
    //$(".jqgridTable").setGridHeight($(window).height() - 800, true);

    /*on click of dynamic page links on footer*/
    $('.dynamic').click(function () {
        
        var _shortcode = $(this).attr('shortcode');
        $.post("Home/DynamicPage", { ShortCode: _shortcode }, function (data) { $('.middle_box').html(data); });
    });

    /*on click of Contact Us page links on footer*/
    $('#sitemap').click(function () {
        $.post("Home/SiteMap", {}, function (data) { $('.middle_box').html(data); });
    });


});

// Created By: Gourav Rampal
// Created On: 31st Oct 2011
// Desc: Function used to bind dynamic pages using custom function.
function Redirecttopage(pagecode) {
$.post("Home/DynamicPage", { ShortCode: pagecode }, function (data) { $('.middle_box').html(data); });
}




function UpdateStatus(id, status,controller,action) {
    try {       
        $.post('/' + controller + '/' + action, { ID: id, Active: status }, function (data) {
            $('.jqgridTable').trigger('reloadGrid');
        });
    }
    catch (ex) { alert(ex.message); }
};

// Created By: Gourav Rampal
// Created On: 24th Nov 2011
// Desc: Function for checking file upload extentions
function checkFileExtension(elem) {
    var filePath = elem;

    if (filePath.indexOf('.') == -1)
        return false;

    var validExtensions = new Array();
    var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();
    //Add valid extentions in this array
    validExtensions[0] = 'png';
    validExtensions[1] = 'jpg';
    validExtensions[2] = 'jpeg';

    for (var i = 0; i < validExtensions.length; i++) {
        if (ext == validExtensions[i])
            return true;
    }

    alert('The file extension ' + ext.toUpperCase() + ' is not allowed!');
    $('#flImage').val('');
    return false;
}

/*
* ---------------------------
* Created By: Gourav Rampal
* Created On: 18th Jan 2012
* functions for Prompt Notification
* ---------------------------
*/
function mycallbackfunc(v, m, f) {
    $.prompt('i clicked ' + v);
}

function mycallbackform(v, m, f) {
    if (v != undefined)
        $.prompt(v + ' ' + f.alertName);
}

function mysubmitfunc(v, m, f) {
    an = m.children('#alertName');
    if (f.alertName == "") {
        an.css("border", "solid #ff0000 1px");
        return false;
    }
    return true;
}

(function ($) {
    $.fn.extend({
        dropIn: function (speed, callback) {
            var $t = $(this);

            if ($t.css("display") == "none") {
                eltop = $t.css('top');
                elouterHeight = $t.outerHeight(true);

                $t.css({ top: -elouterHeight, display: 'block' }).animate({ top: eltop }, speed, 'swing', callback);
            }
        }
    });
})(jQuery);

var txt = 'Please enter your name:<br /><input type="text" id="alertName" name="alertName" value="name here" />';
var txt2 = 'Try submitting an empty field:<br /><input type="text" id="alertName" name="alertName" value="" />';

var brown_theme_text = '<h3>Example 13</h3><p>Save these settings?</p><img src="images/help.gif" alt="help" class="helpImg" />';

var statesdemo = {
    state0: {
        html: 'test 1.<br />test 1..<br />test 1...',
        buttons: { Cancel: false, Next: true },
        focus: 1,
        submit: function (v, m) {
            if (!v) return true;
            else $.prompt.goToState('state1'); //go forward
            return false;
        }
    },
    state1: {
        html: 'test 2',
        buttons: { Back: -1, Exit: 0 },
        focus: 1,
        submit: function (v, m) {
            if (v == 0) $.prompt.close()
            else if (v = -1) $.prompt.goToState('state0'); //go back
            return false;
        }
    }
};

