var 
BMF_progImg,
BMF_imgClose1,
BMF_imgClose2,
BMF_scriptAddr,
//BMF_waitMess,
BMF_waitMessFillCombo,
BMF_waitMessDoOperation,
BMF_waitMessGetForm;
var isfirefox=document.getElementById && !document.all;
var BMF_connectionMethod='POST';
var BMF_isfskeyOn=true;
var sx=0,sy=0;
var dat=new Date();


var 
BMFmsgBox_alpha=90,
BMFmsgBox_initx,
BMFmsgBox_inity,
BMFmsgBox_lastsx=0,
BMFmsgBox_lastsy=0,
BMFmsgBox_lastsybeforechange=0,
BMFmsgbox_animateTimer,
BMFmsgbox_animateTimer2,
BMFmsgBox_vibration=0,
BMFmsgBox_lastPosYinit,
BMFmsgbox_animateState=1,
BMFmsgBox_TargetY,
BMFmsgbox_ismoving=0,
BMFmsgBox_t0=0,
BMFmsgBox_isMouseDown=0,
BMFmsgBox_lastPosX=null,
BMFmsgBox_lastPosY=null,
BMFsmallprog='';


//(3)////////////////////////////////////////////////////////////////////////////////
function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}
function getDocWidth() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
}
//(3)////////////////////////////////////////////////////////////////////////////////
function BMFinitJS(prgImg,msgboxCloseImg1,msgboxCloseImg2,scriptAddress,waitMessage,smallprog){
BMF_progImg=prgImg;
BMF_imgClose1=msgboxCloseImg1;
BMF_imgClose2=msgboxCloseImg2;
BMF_scriptAddr=scriptAddress;

var iImg =new Image();
iImg.src=BMF_progImg;
var iImg2 =new Image();
iImg2.src=BMF_imgClose1;
var iImg3 =new Image();
iImg3.src=BMF_imgClose2;
var iImg4 =new Image();
iImg4.src=smallprog ;
BMFsmallprog=smallprog;

if (BMF_scriptAddr!='')
    if (BMF_scriptAddr.charAt[BMF_scriptAddr.length -1]!='/')
        BMF_scriptAddr=BMF_scriptAddr+'/';
//BMF_waitMess=waitMessage;
BMF_waitMessFillCombo=waitMessage;
BMF_waitMessDoOperation=waitMessage;
BMF_waitMessGetForm=waitMessage;
}
//(3)////////////////////////////////////////////////////////////////////////////////
function BM_changeDisplay(objID,nextOp){
if (GEBI(objID).style.display=='none'){
    BM_showObj(objID);
    }else{
        BM_hideObj(objID);
        }
if (nextOp)
    eval(nextOp);
}
//(3)////////////////////////////////////////////////////////////////////////////////
function BM_showObj(objID,nextOp){
GEBI(objID).style.display='inline';
if (nextOp)
    eval(nextOp);
}
//(1)////////////////////////////////////////////////////////////////////////////////
function BM_hideObj(objID,nextOp){
GEBI(objID).style.display='none';
if (nextOp)
    eval(nextOp);
}
//(1)////////////////////////////////////////////////////////////////////////////////
function GEBI(s){
var r=window.parent.document.getElementById(s);
if (r){
    return r;
    }
else{
    try{
    if (document.getElementById(s))
        return document.getElementById(s)
    if (window.frames[0])
        return window.frames[0].document.getElementById(s);
        }catch(e){}
    }
}
//(1)////////////////////////////////////////////////////////////////////////////////
function GEBIPlace(s){
if (document.getElementById(s)){
    return 0;
    }
else{
try{
    if (window.parent){
        if (window.parent.document.getElementById(s))
            return 1;
        }
    if (window.frames[0]){
        if (window.frames[0].document.getElementById(s))
            return -1;
        }
        }catch(e){}
    }
return 0;
}
window.onscroll=function (){
var obj=GEBI('BMFmsgboxPlace');
getScrollXY();

if (!obj)
    return;
    if (obj.style.display!='inline')
        return;
        window.clearTimeout(BMFmsgbox_animateTimer);
        BMFmsgbox_animateTimer=window.setTimeout('BMFmsgBox_lastsybeforechange=sy;BMFmsgBox_TargetY=BMFmsgBox_lastPosY+(sy-BMFmsgBox_lastsy);BMFmsgBox_lastPosYinit=BMFmsgBox_lastPosY;BMFmsgBox_vibration=0;BMFmsgBox_t0=0;BMFmsgbox_animate((BMFmsgBox_TargetY-BMFmsgBox_lastPosY)/Math.abs(BMFmsgBox_TargetY-BMFmsgBox_lastPosY));',500);
};

//(2)////////////////////////////////////////////////////////////////////////////////

function BMFmsgbox_animate(d){
BMFmsgbox_ismoving=1;
window.clearTimeout(BMFmsgbox_animateTimer2);
var obj=GEBI('BMFmsgboxPlace');
if (BMFmsgBox_vibration){
            BMFmsgBox_lastPosY=BMFmsgBox_TargetY+60*d*Math.exp(-0.005*BMFmsgBox_t0)*Math.sin(.02500*BMFmsgBox_t0);
            if (BMFmsgBox_t0>2000)
                {
                BMFmsgbox_ismoving=0;
                BMFmsgBox_lastPosY=BMFmsgBox_TargetY;
                BMFmsgBox_vibration=0;
                BMFmsgBox_t0=0;
                return 0;
                }
            }
            else{
               BMFmsgBox_lastPosY=((BMFmsgBox_TargetY-BMFmsgBox_lastPosYinit)/0.05) * Math.pow(BMFmsgBox_t0/1000,2)+BMFmsgBox_lastPosYinit;
                if ((BMFmsgBox_lastPosY>=BMFmsgBox_TargetY && d>0) || (BMFmsgBox_lastPosY<=BMFmsgBox_TargetY && d<0)){
                    BMFmsgBox_vibration=1;
                    BMFmsgBox_t0=0;
                    }
            }
            BMFmsgBox_t0+=10; 
            BMFmsgBox_lastsy=BMFmsgBox_lastsybeforechange+d*(BMFmsgBox_TargetY-BMFmsgBox_lastPosY);
            obj.style.top=BMFmsgBox_lastPosY+'px';
    BMFmsgbox_animateTimer2=window.setTimeout('BMFmsgbox_animate('+d+');',10);
 return 0;
}
//(2)////////////////////////////////////////////////////////////////////////////////
function getScrollXY() {

  if( typeof( window.pageYOffset ) == 'number' ) {
    sy= window.pageYOffset;
    sx= window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    sy= document.body.scrollTop;
    sx= document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    sy = document.documentElement.scrollTop;
    sx= document.documentElement.scrollLeft;
  }
  return 0;
}
//(2)////////////////////////////////////////////////////////////////////////////////
function BMFmsgBox_move(evt){
if (BMFmsgbox_ismoving)
    return 0;
if (BMFmsgBox_isMouseDown==1){
var tempX,tempY;
if (isfirefox) {
    tempX = (evt.clientX+sx) - BMFmsgBox_initx;
    tempY = (evt.clientY+sy) - BMFmsgBox_inity;
    }
    else{
        tempX = event.x+sx - BMFmsgBox_initx;
        tempY = event.y+sy - BMFmsgBox_inity;
        }
    obj=GEBI('BMFmsgboxPlace');
    BMFmsgBox_lastPosX=tempX;
    BMFmsgBox_lastPosY=tempY;
    obj.style.left=tempX+'px';
    obj.style.top =tempY+'px';
    BMFmsgBox_lastsx=sx;
    BMFmsgBox_lastsy=sy;
    }
}
function BMFmsgBox_setinitvals(evt){
obj=GEBI('BMFmsgboxPlace');
BMFmsgBox_initx=evt.clientX+sx -Number(String(obj.style.left).substring(0,String(obj.style.left).length-2));
BMFmsgBox_inity=evt.clientY+sy -Number(String(obj.style.top).substring(0,String(obj.style.top).length-2));
}
function BMFmsgbox(header,message,boxWidth,boxHeight,nextOp){

if (runInParentWindow==true){
runInParentWindow=false;
window.parent.BMFmsgbox.apply(this,arguments);
return 0;
}

document.onselectstart =new Function ("return false");
document.body.onmousemove=function (evt){
    var e = window.event ? window.event : evt;
    BMFmsgBox_move(e);
};
document.body.onclick=function (){BMFmsgBox_isMouseDown=0;};
var obj1=GEBI('BMFBackgroundDisabledPlace');
if (obj1==null){
    obj1 =document.createElement('div');
    obj1.id='BMFBackgroundDisabledPlace';
    obj1.innerHTML='<div style="width:100%;height:100%;filter:alpha(opacity='+BMFmsgBox_alpha+');-moz-opacity:'+(BMFmsgBox_alpha/100)+';-khtml-opacity: '+(BMFmsgBox_alpha/100)+';opacity: '+(BMFmsgBox_alpha/100)+';background-Color:gray;"></div>';
    document.body.insertBefore(obj1, null);
    
    }
var obj=GEBI('BMFmsgboxPlace');
if (obj==null){
    obj =document.createElement('div');
    obj.id='BMFmsgboxPlace';
    document.body.insertBefore(obj, null);
    }
 var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  } 

  obj1.style.position='absolute';
  obj1.style.width=getDocWidth()+'px';
  obj1.style.height=getDocHeight()+'px';
  obj1.style.left='0px';
  obj1.style.top= '0px';
  obj1.style.display='inline';
  obj1.style.zIndex=Number.MAX_VALUE-1 ;
  
  
var BMFmsgBox_width,BMFmsgBox_height;
BMFmsgBox_width=(boxWidth)?boxWidth:400;
BMFmsgBox_height=(boxHeight)?boxHeight:300;
obj.style.position='absolute';
obj.style.border='1px solid black';
obj.style.width=BMFmsgBox_width+'px';
obj.style.height=BMFmsgBox_height+'px';
obj.style.display='none';
if (BMFmsgBox_lastPosY<sy || BMFmsgBox_lastPosY>(sy+myHeight))
BMFmsgBox_lastPosY=(myHeight/2)-(BMFmsgBox_height/2)+sy;

BMFmsgBox_lastPosX=BMFmsgBox_lastPosX?(BMFmsgBox_lastPosX):(myWidth/2-(BMFmsgBox_width/2)+sx);
BMFmsgBox_lastPosY=BMFmsgBox_lastPosY?(BMFmsgBox_lastPosY):(myHeight/2-(BMFmsgBox_height/2)+sy);
obj.style.left=BMFmsgBox_lastPosX+'px';
obj.style.top= BMFmsgBox_lastPosY+'px';
BMFmsgBox_lastsx=sx;
BMFmsgBox_lastsy=sy;
obj.innerHTML='<table cellspacing="0" cellpadding="5" style="filter:alpha(opacity='+BMFmsgBox_alpha+');-moz-opacity:'+(BMFmsgBox_alpha/100)+';-khtml-opacity: '+(BMFmsgBox_alpha/100)+';opacity: '+(BMFmsgBox_alpha/100)+';background-Color:white;font-family:tahoma;font-size:8pt;direction:rtl;" width="100%" height="'+BMFmsgBox_height+'px" border ="0"><tr><td onmousedown="BMFmsgBox_isMouseDown=1;BMFmsgBox_setinitvals(event);" onmouseup="BMFmsgBox_isMouseDown=0;" height="20px" width="'+(BMFmsgBox_width-20)+'px" style="cursor:move;"><b>'+header+'</b></td><td width="20px" height="20px" ><img style="cursor:hand;" onmouseover="this.src=BMF_imgClose2" onmouseout="this.src=BMF_imgClose1" src="'+BMF_imgClose1+'" id="closeBMFmsgboxButton" onclick="BMFmsgBox_close();" /></td></tr><tr><td style="height:'+(BMFmsgBox_height-85)+'px" colspan="2" valign="top" align="top" style="background-Color:aliceblue;"><hr/>'+message+'</td></tr><tr><td colspan="2" style="font-size:7pt;" height="30px" align="center"><hr />powered by <b><a href="http://www.bornamehr.com">bornaMehrFan</a></b> | 2008 - 2010</td></tr></table>';
try{
obj.style.filter=getDXFilter(Math.floor(Math.random()*17));
obj.filters[0].Apply();
obj.style.display='inline';
obj.filters[0].play(0.5);
}catch(e){
    obj.style.display='inline';
}
obj.style.zIndex=Number.MAX_VALUE ;
if (nextOp)
    eval(nextOp);
GEBI('closeBMFmsgboxButton').focus();
return;
}

function BMFmsgBox_close(nextOp){
document.onselectstart =new Function ("");
document.body.onmousemove=new Function("");
document.body.onclick=new Function("");
var obj=GEBI('BMFmsgboxPlace');
var obj1=GEBI('BMFBackgroundDisabledPlace');
    if (obj!=null){
            obj.style.display='none';
    }
    if (obj1!=null){
            obj1.style.display='none';
    }
    if (nextOp)
        eval(nextOp);
}

//(3)////////////////////////////////////////////////////////////////////////////////
function BMFdhtmlLoadScript(url,nextOp)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e);
   if (nextOp)
    eval(nextOp);
}

function BMF_selectCombo(comboID,selectedValue){
var CCombo=GEBI(comboID);
for (var i=0;i<CCombo.options.length;i++) {
    if (CCombo.options[i].value == selectedValue)
        CCombo.options[i].selected = true;
    }

}
