        var colors = ['#FFCA4D', '#FE0026', '#0099A1'];
        var imgpath = ['images/ircellPic.jpg','images/taliaPic.jpg','images/mciPic.jpg'];
        var cardtype = ['gi1','gi2','gi5','gi10','gi20','gt2','gt5','gt10','gt20','gt40','gh2','gh5','gh10','gh20'];
        var cardVisibility = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0]];
        var btns = ['btnirancell', 'btntaliya', 'btnhamrah1'];
        var btnhoverimg = ['images/hirancell.gif', 'images/htaliya.gif', 'images/hhamrah1.gif'];
        var btnimg = ['images/hirancell.gif', 'images/taliya.gif', 'images/hamrah1.gif'];
        var preloadImgs = ['img/ax-taliya.jpg', 'img/ax-hamrah.jpg', 'images/irancell.gif',
                            'images/htaliya.gif', 'images/hhamrah1.gif', 'images/hpardkht-button.jpg', 'images/wait.gif', 'images/card-hamrah-2-small.gif',
                            'images/card-hamrah-5-small.gif', 'images/card-hamrah-10-small.gif', 'images/card-hamrah-20-small.gif',
                            'images/card-taliya-10-small.gif', 'images/card-taliya-20-small.gif', 'images/card-taliya-40-small.gif'];
        var pics = new Array();
        function preload() {
            if (document.images) {
                for (i = 0; i < preloadImgs.length; i++) {
                    pics[i] = new Image(); pics[i].src = preloadImgs[i];
                } 
            }
            hesab();
        }
        function setFrame(id) {
            var oldid = document.getElementById('activePage').getAttribute('value');
            if (id == oldid) return;
            for (i = 0; i < cardtype.length; i++) document.forms['form1'].Card[i].checked = false;
            document.getElementById('LblMablagh').innerHTML = '';
            document.getElementById('LblKarmozd').innerHTML='';
            document.getElementById('LblMabKol').innerHTML = '';
            document.getElementById('mainframe').style.borderColor = colors[id];
            var imgKharidar = document.getElementById('imgKharidar');
            $(imgKharidar).fadeOut(200, function() { $(this).attr('src', imgpath[id]).fadeIn(200)});
            //imgKharidar.src = imgpath[id];
            //$(imgKharidar).fadeIn(200);
            for (i = 0; i < cardtype.length; i++) if (cardVisibility[id][i] == 1) document.getElementById(cardtype[i]).style.display = ''; else document.getElementById(cardtype[i]).style.display = 'none';
            document.getElementById('activePage').setAttribute('value', id);
            setnormal(oldid);
        }
        function sethover(id) {
            if (id != document.getElementById('activePage').getAttribute('value')) {
                document.getElementById(btns[id]).src = btnhoverimg[id];
            } 
        }
        function setnormal(id) {
            if (id != document.getElementById('activePage').getAttribute('value')) {
                document.getElementById(btns[id]).src = btnimg[id];
            } 
        }
        function validate() {
            cardselected = false;
            
            if (document.getElementById('TxtEmail').value == '')
            { 
            	alert('لطفا براي دريافت كد شارژ آدرس ايميل خود را وارد كنيد'); 
            	return false; 
            }
            	
            if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('TxtEmail').value)))
            	{ alert('لطفا آدرس ايميل را صحيح وارد كنيد'); return false; }
            
            
            if ((!document.getElementById('TxtMobile').value == ''))
                if (!(/\d{10}/.test(document.getElementById('TxtMobile').value)))
            	{ 
            	alert('لطفا شماره موبايل را صحيح وارد كنيد');
            	return false;
            	}
            
            for (i = 0; i < cardtype.length; i++) if (document.forms['form1'].Card[i].checked) cardselected = true;
            if (!cardselected) { alert('كارت شارژ مورد نظرتان را انتخاب كنيد'); return false; }
            gateselected = false;
            if (sbhf.value == "-1")
            { alert('ابتدا روش پرداخت مورد نظرتان را انتخاب کنید'); return false; }
            
            showwait();
        }
        function pageWidth() { return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null; }
        function pageHeight() { return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null; }
        function posLeft() { return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0; } function posTop() { return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0; } function posRight() { return posLeft() + pageWidth(); } function posBottom() { return posTop() + pageHeight(); }
        function showwait() {
            trback = document.getElementById('poptransback');
            trback.style.display = 'block';
            trback.style.width = pageWidth();
            trback.style.height = pageHeight();
            trback.style.left = posLeft();
            trback.style.top = posTop();
            document.getElementById('popback').style.display = 'block';
            setTimeout('document.images["waitimg"].src = "images/wait.gif"', 15000);
            document.getElementById('form1').action = "default.aspx"
        }
        var selectedCardMablagh;
        function hesab() {
            var cardId = -1;
            for (i = 0; i < cardtype.length; i++) if (document.forms['form1'].Card[i].checked) { cardId = i; break; }
            if (cardId == -1) return;
            var karmozd=0;
            //alert(cardId);
            if (cardId == 1) karmozd=0;
            else if ( cardId == 10 ) karmozd=0;
            selectedCardMablagh = cardValues[cardId]; //var karmozd=mablagh*0.02;
            document.getElementById('LblMablagh').innerHTML = selectedCardMablagh;
            document.getElementById('LblKarmozd').innerHTML=karmozd;
            document.getElementById('LblMabKol').innerHTML = selectedCardMablagh +karmozd;
        }
        var selectedBankDiv = null;
        $(document).ready(function() {
            var bankdivs = $("#bankha>div>div");
            bankdivs.each(function() {
                var $this = $(this);
                var w = $this.width(), h = $this.height();
                $this.data('hoverpulse.size', { w: parseInt(w), h: parseInt(h) });
            });
            bankdivs.hover(
            // hover over
		function() {
		    var $this = $(this);
		    $this.parent().css('z-index', 100);

		    var size = $this.data('hoverpulse.size');
		    var w = size.w, h = size.h;
		    $this.stop().animate({
		        height: (h + 30) + 'px'
		    }, 200);
		    $(".bankid", this).css('display', 'block');
		},
            // hover out
		function() {
		    var $this = $(this);
		    var size = $this.data('hoverpulse.size');
		    var w = size.w, h = size.h;

		    $this.stop().animate({
		        height: (h + 'px')
		    }, 200, function() {
		        $this.parent().css('z-index', 1);
		    });
		    $(".bankid", this).css('display', 'none');
		});
        });
        var preferredGateway = [0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0];
        var availableGateways = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2];
        //var availableGateways = [3, 3, 3, 3, 3, 2, 2, 2, 11, 1, 1];
        var gatewayNames = ['سامان', 'پارسیان', 'ملی', 'پاسارگاد', 'ملت'];
        var selectedBankElement;

        function bankClick(srcElement, bankId) {
            sgcmb.options.length = 0;
            var pasargadValid = false;
            if (selectedCardMablagh) {
                if (selectedCardMablagh >= 100000)
                    pasargadValid = true;
            }
            for (gi = 0; gi < 5; gi++) {
                if ((gi == 3) && (!pasargadValid))
                    continue;

                if ((availableGateways[bankId] & (1 << gi)) > 0) {
                    var y = document.createElement('option');
                    y.text = gatewayNames[gi];
                    y.value = gi;
                    try { sgcmb.add(y, null); } catch (ex) { sgcmb.add(y); }
                }
            }
            if ((bankId == 8) && (!pasargadValid))
                sgcmb.selectedIndex = 0;
            else
                sgcmb.selectedIndex = preferredGateway[bankId];
            sbhf.setAttribute("value", bankId);
            if (selectedBankElement)
                selectedBankElement.className = "wrapper2";
            srcElement.className = "wrapper2 selected";
            selectedBankElement = srcElement;
        }