$(function () {
    $("a[rel='_blank']").attr("target", "_blank");
});

/*$(function () {
    $("input, select, textarea").each(function () {
        $(this).attr("name", $(this).attr("id"));
    });
    $("input:radio").each(function(){
        $(this).attr("name", $(this).attr("alt"));
        $(this).removeAttr("alt");
    });
});*/

jQuery.fn.urlParam = function (name) {
    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
    if (results) {
        return results[1] || 0;
    }
};

jQuery.fn.fadeToggle = function (speed, easing, callback) {
    return this.animate({
        opacity: 'toggle'
    }, speed, easing, callback);
};

(function ($) {
    $.fn.fadeInPlus = function (speed, callback) {
        $(this).fadeIn(speed, function () {
            if (jQuery.browser.msie) $(this).get(0).style.removeAttribute('filter');
            if (callback != undefined) callback();
        });
    };
    $.fn.fadeOutPlus = function (speed, callback) {
        $(this).fadeOut(speed, function () {
            if (jQuery.browser.msie) $(this).get(0).style.removeAttribute('filter');
            if (callback != undefined) callback();
        });
    };
})(jQuery);

function in_array(thaArray, element) {
    var res = false;
    for (var e = 0; e < thaArray.length; e++) {
        if (thaArray[e] == element) {
            res = true;
            break;
        }
    }
    return res;
}

var isIE6 = !$.support.opacity && !window.XMLHttpRequest;

function checkEmail(email){
    var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(email)) {
        return false;
    }
    return true;
}

// jQuery URL Encode / Decode

$.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;while(x<c.length){var m=r.exec(c.substr(x));if(m!=null&&m.length>1&&m[1]!=''){o+=m[1];x+=m[1].length}else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);o+='%'+(h.length<2?'0':'')+h.toUpperCase()}x++}}return o},URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/;while((m=r.exec(o))!=null&&m.length>1&&m[1]!=''){b=parseInt(m[1].substr(1),16);t=String.fromCharCode(b);o=o.replace(m[1],t)}return o}});
