﻿function WebForm_DoPostBackWithOptions2(options) {
    var validationResult = true;
    if (options.validation) {
        if (typeof(Page_ClientValidate) == 'function') {
            validationResult = Page_ClientValidate(options.validationGroup);
        }
    }
    if (validationResult) {
        if ((typeof(options.actionUrl) != "undefined") && (options.actionUrl != null) && (options.actionUrl.length > 0)) {
            theForm.action = options.actionUrl;
        }
        if (options.trackFocus) {
            var lastFocus = theForm.elements["__LASTFOCUS"];
            if ((typeof(lastFocus) != "undefined") && (lastFocus != null)) {
                if (typeof(document.activeElement) == "undefined") {
                    lastFocus.value = options.eventTarget;
                }
                else {
                    var active = document.activeElement;
                    if ((typeof(active) != "undefined") && (active != null)) {
                        if ((typeof(active.id) != "undefined") && (active.id != null) && (active.id.length > 0)) {
                            lastFocus.value = active.id;
                        }
                        else if (typeof(active.name) != "undefined") {
                            lastFocus.value = active.name;
                        }
                    }
                }
            }
        }
    }
    return validationResult;
}
Message=function() {
    return {};
};
Message.IntervalID=new Object();
Message.setMessage=function(_parentElementId, _type, _text)
{
    Dark.Start();
    //
    var strColor  = new String('');
    var strColor2 = new String('');
    var strIcon   = new String('');
    switch (_type) {
        case 1: strColor = '#FFEEDB'; strColor2 = '#FF8170'; strIcon = '../../Style/Images/Alert/error.gif'; break;
        case 2: strColor = '#ECF6E5'; strColor2 = '#97CB75'; strIcon = '../../Style/Images/Alert/ok.gif'; break;
        case 3: strColor = '#D1EDFD'; strColor2 = '#4AAAE1'; strIcon = '../../Style/Images/Alert/info.gif'; break;
    };
    var oDiv = document.getElementById('div_alert5467001');
    if (!oDiv) {
        oDiv = document.createElement('DIV');
        oDiv.id = 'div_alert5467001';
        try
        {
            document.body.firstChild.appendChild(oDiv);
        }
        catch(_exAppend)
        {
            document.body.appendChild(oDiv);
        }
    };
    oDiv.className='px12 tahoma';
    oDiv.style.position='absolute';
    oDiv.style.display='block';
    oDiv.style.backgroundColor=strColor;
    oDiv.style.padding='50px';
    oDiv.style.filter='progid:DXImageTransform.Microsoft.Glow(color='+strColor2+',strength=3);';
    oDiv.style.zIndex='1001';
    oDiv.style.cursor='hand';
    oDiv.innerHTML="<center><img src=\""+strIcon+"\" align=\"absmiddle\"/>&nbsp;<span class=\"px13\">"+_text+"</span></center>";
    oDiv.onclick=function()
    {
        Message.EndMessage();
    };
    Message.IntervalID=window.setInterval("Message.EndMessage()",10000);
    var _width=parseInt(oDiv.offsetWidth);
    var _height=parseInt(oDiv.offsetHeight);
    oDiv.style.top=((window_height()-_height)/2)+'px';
    oDiv.style.left=((window_width()-_width)/2)+'px';
};
Message.EndMessage=function()
{
    document.getElementById('div_alert5467001').style.display='none';
    Dark.End();
    window.clearInterval(Message.IntervalID);
};

function is_ie() {
    if (navigator.appName.toLowerCase() == 'microsoft internet explorer')
        return true;
    else
        return false;
};
function full_window() {
    window.moveTo(0, 0);
    if (document.all) {
        top.window.resizeTo(screen.availWidth, screen.availHeight);
    }
    else if (document.layers || document.getElementById) {
        if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth) {
            top.window.outerHeight = screen.availHeight;
            top.window.outerWidth = screen.availWidth;
        };
    };
};
function window_width() {
    if (is_ie())
        return document.documentElement.clientWidth;
    else
        return Math.min(window.innerWidth, document.documentElement.clientWidth);
};
function window_height() {
    if (is_ie())
        return document.documentElement.clientHeight;
    else
        return Math.min(window.innerHeight, document.documentElement.clientHeight);
};
var Dark=
{
    Start:function()
    {
        var oframe=dg('fr_message5467001');
        if(oframe)
        {
            with(oframe.style)
            {
                left='0px';
                top=document.documentElement.scrollTop+'px';
                width=(window_width()+16)+'px';
                height=window_height()+'px';
            }
        }
        
        var oDiv=document.getElementById('div_dark8742');
        if (!oDiv)
        {
            oDiv=document.createElement('DIV');
            oDiv.id='div_dark8742';
            try
            {
                document.body.firstChild.appendChild(oDiv);
            }
            catch(_exAppend)
            {
                document.body.appendChild(oDiv);
            }
        };
        oDiv.style.position='absolute';
        oDiv.style.top=document.documentElement.scrollTop+'px';
        oDiv.style.left='0px';
        oDiv.style.width=(window_width()+16)+'px';
        oDiv.style.height=window_height()+'px';
        oDiv.style.display='block';
        oDiv.style.backgroundColor='#000';
        oDiv.style.backgroundImage='url(../../Style/Images/darkbg.jpg)';
        oDiv.style.backgroundPosition='left bottom';
        oDiv.style.zIndex=1000;
        if (is_ie())
            oDiv.style.filter='alpha(opacity=60);';
        else
            oDiv.style.opacity='0.6';

//        //
//        // disable all controls
//        var oArr1,oArr2,oArr3;
//        oArr1=document.getElementsByTagName('input');
//        oArr2=document.getElementsByTagName('select');
//        oArr3=document.getElementsByTagName('a');
//        this.DisabledObjects(oArr1,false);
//        this.DisabledObjects(oArr2,false);
//        this.DisabledObjects(oArr3,true);
//        
//        if(window.frames)
//        {
//            for(var i=0;i<=window.frames.length-1;i++)
//            {
//                oArr1=window.frames[i].document.getElementsByTagName('input');
//                oArr2=window.frames[i].document.getElementsByTagName('select');
//                oArr3=window.frames[i].document.getElementsByTagName('a');
//                this.DisabledObjects(oArr1,false);
//                this.DisabledObjects(oArr2,false);
//                this.DisabledObjects(oArr3,true);
//            }
//        };
    },
    End: function()
    {
        var oframe=dg('fr_message5467001');
        if(oframe)
        {
            oframe.style.width='0px';
            oframe.style.height='0px';
        }
        
        var oDiv=document.getElementById('div_dark8742');
        if (oDiv)
            oDiv.style.display = 'none';
        
//        //
//        // disable all controls
//        var oArr1,oArr2,oArr3;
//        oArr1=document.getElementsByTagName('INPUT');
//        oArr2=document.getElementsByTagName('SELECT');
//        oArr3=document.getElementsByTagName('A');
//        this.EnabledObjects(oArr1,false);
//        this.EnabledObjects(oArr2,false);
//        this.EnabledObjects(oArr3,true);

//        if(window.frames)
//        {
//            for(var i=0;i<=window.frames.length-1;i++)
//            {
//                oArr1=window.frames[i].document.getElementsByTagName('input');
//                oArr2=window.frames[i].document.getElementsByTagName('select');
//                oArr3=window.frames[i].document.getElementsByTagName('a');
//                this.EnabledObjects(oArr1,false);
//                this.EnabledObjects(oArr2,false);
//                this.EnabledObjects(oArr3,true);
//            }
//        };
    },
    
    DisabledObjects:function(oArray,isAnchor)
    {
        try
        {
            for(var i=0;i<=oArray.length-1;i++)
            {
                if(!oArray[i].getAttribute('Disabled_In_Dark'))
                {
                    if(isAnchor==true)
                    {
                        if(oArray[i].getAttribute('message_control')==null && oArray[i].getAttribute('disabled')!='true')
                        {
                            oArray[i].setAttribute('disabled','true');
                            oArray[i].setAttribute('disabled_by_msg','true');
                        };
                    }
                    else
                    {
                        if(oArray[i].getAttribute('message_control')==null && oArray[i].disabled!=true)
                        {
                            oArray[i].disabled=true;
                            oArray[i].setAttribute('disabled_by_msg','true');
                        };
                    };
                };
            };
        }
        catch(__ex)
        {
        };
    },
    EnabledObjects:function(oArray,isAnchor)
    {
        for(var i=0;i<=oArray.length-1;i++)
        {
            if(isAnchor==true)
            {
                if(oArray[i].getAttribute('disabled_by_msg')=='true')
                {
                    oArray[i].setAttribute('disabled','false');
                    oArray[i].setAttribute('disabled','');
                }
            }
            else
            {
                if(oArray[i].getAttribute('disabled_by_msg')=='true')
                    oArray[i].disabled=false;
            }
        };
    },
    
    
    
    Start2: function()
    {
        window.clearInterval(Message.IntervalID);
        var oframe=dg('fr_message5467001');
        if(oframe)
        {
            with(oframe.style)
            {
                left='0px';
                top='0px';
                width=window_width()+'px';
                height=window_height()+'px';
            }
        }
        
        var oDiv = document.getElementById('div_dark8742');
        if (!oDiv)
        {
            oDiv = document.createElement('DIV');
            oDiv.id = 'div_dark8742';
            try
            {
                document.body.firstChild.appendChild(oDiv);
            }
            catch(_exAppend)
            {
                document.body.appendChild(oDiv);
            }
        };
        oDiv.style.position = 'absolute';
        oDiv.style.top = '0px';
        oDiv.style.left = '0px';
        oDiv.style.width = window_width() + 'px';
        oDiv.style.height = window_height() + 'px';
        oDiv.style.display = 'block';
        oDiv.style.backgroundColor = '#000';
        oDiv.style.zIndex='1000';
        if (is_ie())
            oDiv.style.filter = 'alpha(opacity=40)';
        else
            oDiv.style.opacity = '0.4';
    },
    End2: function() {
        var oDiv = document.getElementById('div_dark8742');
        if (oDiv)
            oDiv.style.display = 'none';
        var oframe=dg('fr_message5467001');
        if(oframe)
        {
            oframe.style.width='0px';
            oframe.style.height='0px';
        }
    }
};
var Wait=
{
    Start:function()
    {
        var oDiv = document.getElementById('div_ldng');
//        if (!oDiv) {
//            oDiv = document.createElement('DIV');
//            oDiv.id = 'div_alert5467001';
//            try
//            {
//                document.body.firstChild.appendChild(oDiv);
//            }
//            catch(_exAppend)
//            {
//                document.body.appendChild(oDiv);
//            }
//        };
        oDiv.className='px12 tahoma';
        oDiv.style.position='absolute';
        oDiv.style.display='block';
        oDiv.style.backgroundColor='#fff';
        oDiv.style.filter='progid:DXImageTransform.Microsoft.Glow(color=#eeeeee,strength=3);';
        oDiv.style.zIndex='1001';
        oDiv.style.backgroundColor='#f0f0f0';
        oDiv.style.width='300px';
        oDiv.innerHTML='<center><br/><img src=\"../../Style/Images/loading.gif\" />&nbsp;کمی صبر کنيد. در حال بارگذاری...<br/><br/></center>';
        var _width=parseInt(oDiv.offsetWidth);
        oDiv.style.top='5px';
        oDiv.style.left=((window_width()-_width)/2)+'px';
    },
    End:function()
    {
        document.getElementById('div_ldng').style.display='none';
        //Dark.End();
    }
};

var MoslemBallon=
{
    Start:function(_p)
    {
        var oDiv=dg('div_ballon8742');
        if (!oDiv)
        {
            oDiv=document.createElement('DIV');
            oDiv.id='div_ballon8742';
            oDiv.className='px11 tahoma';
            try
            {
                document.body.firstChild.appendChild(oDiv);
            }
            catch(_exAppend)
            {
                document.body.appendChild(oDiv);
            }
        };
        oDiv.innerHTML=_p;
        with(oDiv.style)
        {
            position='absolute';
            top=(ey()+18)+'px';
            display='block';
            backgroundColor='#ffffc9';
            zIndex='1000';
            padding='5px';
            borderWidth='1px';
            borderColor='#cbcbcb';
            borderStyle='solid';
        }
        var oleft=(ex()-parseInt(oDiv.offsetWidth));
        oDiv.style.width='';
        if(parseInt(oDiv.offsetWidth)>300)
        {
            oDiv.style.width='300px';
            oleft=(ex()-300);
        }
//        else
//        {
//        }
        if(oleft<0)
            oleft=0;
        oDiv.style.left=oleft+'px';
    },
    End:function()
    {
        h('div_ballon8742',1);
    }
};

function doHistory(_i)
{
    var x = -1 * parseInt(_i);
    history.go(x);
}
var arrPops=new Array();
function OpenWin(_url,width,height)
{
    var myDate=new Date();
    var tk=myDate.getFullYear()+myDate.getMonth()+myDate.getDay()+myDate.getHours()+myDate.getMinutes()+myDate.getSeconds()+myDate.getMilliseconds();
    //if(_url.indexOf('?',0)!=-1)
    //    _url=_url+'&t='+tk;
    //else
    //    _url=_url+'/?t='+tk;
    
    if(width==null)
        width=screen.width;
    if(height==null)
        heigh=screen.height;
    
    if(arrPops.length>0)
    {
        try
        {
            var oldWin;
            for(var i=0;i<=arrPops.length-1;i++)
            {
                oldWin=arrPops.pop();
                if(oldWin)
                    oldWin.close();
            }
        }
        catch(_exerr)
        {
        }
        finally
        {
            arrPops=null;
            arrPops=new Array();
        };
    }
        
    var newWin=window.open(_url,tk+1,'top='+((screen.height-height)/2)+',left='+((screen.width-width)/2)+',scrollbars=no,location=no,status=yes,width='+width+',height='+height);
    newWin.focus();
    arrPops.push(newWin);
}
function OpenWin2(_url,width,height)
{
    var myDate=new Date();
    var tk=myDate.getFullYear()+myDate.getMonth()+myDate.getDay()+myDate.getHours()+myDate.getMinutes()+myDate.getSeconds()+myDate.getMilliseconds();
    //if(_url.indexOf('?',0)!=-1)
    //    _url=_url+'&t='+tk;
    //else
    //    _url=_url+'/?t='+tk;
    
    if(width==null)
        width=screen.width;
    if(height==null)
        heigh=screen.height;
    
    var newWin=window.open(_url,tk+1,'top='+((screen.height-height)/2)+',left='+((screen.width-width)/2)+',scrollbars=yes,location=no,status=yes,width='+width+',height='+height);
    newWin.focus();
}
function OpenWin3(_url,width,height)
{
    var myDate=new Date();
    var tk=myDate.getFullYear()+myDate.getMonth()+myDate.getDay()+myDate.getHours()+myDate.getMinutes()+myDate.getSeconds()+myDate.getMilliseconds();
    //if(_url.indexOf('?',0)!=-1)
    //    _url=_url+'&t='+tk;
    //else
    //    _url=_url+'/?t='+tk;
    
    if(width==null)
        width=screen.width;
    if(height==null)
        heigh=screen.height;
    return showModalDialog(_url,'','dialogWidth:'+width+'px;dialogHeight:'+height+'px;status:no;center:yes;dialogLeft='+((screen.width-width)/2)+';dialogTop='+((screen.height-height)/2)+';scroll:1;');
}
function OpenWin4(_url,width,height)
{
    var myDate=new Date();
    var tk=myDate.getFullYear()+myDate.getMonth()+myDate.getDay()+myDate.getHours()+myDate.getMinutes()+myDate.getSeconds()+myDate.getMilliseconds();
    //if(_url.indexOf('?',0)!=-1)
    //    _url=_url+'&t='+tk;
    //else
    //    _url=_url+'/?t='+tk;
    
    if(width==null)
        width=screen.width;
    if(height==null)
        heigh=screen.height;
    return showModalDialog(_url,'','dialogWidth:'+width+'px;dialogHeight:'+height+'px;status:no;center:yes;dialogLeft='+((screen.width-width)/2)+';dialogTop='+((screen.height-height)/2)+';scroll:0;');
}




//////////////////////////////////////////////////////////////////////////
//                             Style Manager                            //
//////////////////////////////////////////////////////////////////////////
var StyleManage=
{
    GetNewSkin:function(_p)
    {
        var styles = document.getElementsByTagName('link');
        if (styles && styles.length > 0) {
            for (var i = 0; i <= styles.length - 1; i++)
            {
                if(styles[i].getAttribute('title')!=null)
                {
                    if (styles[i].getAttribute('title').indexOf('dynamicStyle', 0) != -1)
                    {
                        if (styles[i].getAttribute('title').split(':')[1] == _p)
                        {
                            styles[i].setAttribute('rel', 'stylesheet');
                            styles[i].disabled=false;
                        }
                        else
                        {
                            styles[i].setAttribute('rel', 'alternate stylesheet');
                            styles[i].disabled=true;                            
                        };
                    };
                };
            };
        };
    },
    GetNewFontSize: function(_p)
    {
        var styles = document.getElementsByTagName('link');
        if (styles && styles.length > 0) {
            for (var i = 0; i <= styles.length - 1; i++)
            {
                if(styles[i].getAttribute('title')!=null)
                {
                    if (styles[i].getAttribute('title').indexOf('dynamicFontSize', 0) != -1)
                    {
                        if (styles[i].getAttribute('title').split(':')[1] == _p)
                        {
                            styles[i].setAttribute('rel', 'stylesheet');
                            styles[i].disabled=false;
                        }
                        else
                        {
                            styles[i].setAttribute('rel', 'alternate stylesheet');
                            styles[i].disabled=true;                            
                        };
                    };
                };
            };
        };
    },
    GetNewFontFace: function(_p)
    {
        var styles = document.getElementsByTagName('link');
        if (styles && styles.length > 0) {
            for (var i = 0; i <= styles.length - 1; i++)
            {
                if(styles[i].getAttribute('title')!=null)
                {
                    if (styles[i].getAttribute('title').indexOf('dynamicFontFace', 0) != -1)
                    {
                        if (styles[i].getAttribute('title').split(':')[1] == _p)
                        {
                            styles[i].setAttribute('rel', 'stylesheet');
                            styles[i].disabled=false;
                        }
                        else
                        {
                            styles[i].setAttribute('rel', 'alternate stylesheet');
                            styles[i].disabled=true;                            
                        };
                    };
                };
            };
        };
    }
};

var EventHandlers = new Array();
function WireUpEventHandler(Target, Event, Listener, EventUniqueName)
{
    var exists_event=false;
	if (EventHandlers.length>0)
	{
	    for(var i=0;i<=EventHandlers.length-1;i++)
	    {
	        if(EventHandlers[i]==EventUniqueName)
	        {
	            exists_event=true;
	        }
	    }
	}
	if(exists_event==true)
	{
	    return;
	}
	else
	{
	    EventHandlers.push(EventUniqueName);
	}
	
	
    if(Target.addEventListener)	   
		Target.addEventListener(Event,Listener,false);	    
    else if(Target.attachEvent)
		Target.attachEvent('on'+Event,Listener);
    else 
    {
		Event='on'+Event;
		Target.Event=Listener;	 
	}
}

var w=window,d=document;
function dg(_p)
{
    return d.getElementById(_p);
}
function e()
{
    return w.event;
}
function sc(_p)
{
    return w.screen;
}
function ex()
{
    return e().clientX;
}
function ey()
{
    return e().clientY;
}
function h(_p,_p2)
{
    try
    {
        if(_p2==1)
            dg(_p).style.display='none';
        else
            dg(_p).style.display='hidden';
    }
    catch(__ex)
    {
    };
}
function v(_p,_p2)
{
    try
    {
        if(_p2==1)
            dg(_p).style.display='block';
        else if(_p2==2)
            dg(_p).style.display='visible';
        else
            dg(_p).style.display='inline';
    }
    catch(__ex)
    {
    };
}
function setv(_p,_p2)
{
    dg(_p).value=_p2;
}
function getv(_p)
{
    return dg(_p).value;
}
function setf(_p)
{
    dg(_p).focus();
}
function oc(_p)
{
    dg(_p).onclick();
}
function seth(_p,_p2)
{
    dg(_p).style.height=_p2+'px';
}
var seth2_p,seth2_p2;
function seth2(_p,_p2)
{
    seth2_p=_p;
    seth2_p2=_p2;
    seth2_e();
    WireUpEventHandler(window,'resize',seth2_e);
    WireUpEventHandler(document.body,'resize',seth2_e);
}
function seth2_e()
{
    dg(seth2_p).style.height=(window_height()-seth2_p2)+'px';
}
function hs()
{
    //document.body.scroll='no';
    document.body.scroll = "no";
    document.documentElement.style.overflow = 'hidden';
}
function vs()
{
    document.body.scroll = "auto";
    document.documentElement.style.overflow = 'scroll';	 // firefox, chrome
}
function curLeft(obj)
{
	toreturn = 0;
	while(obj)
	{
		toreturn += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return toreturn;
}
