// function lib
function setImg(src, path)
{
	src.src = path;
}

function setImgByName(imgname, path)
{
	document.images[imgname].src = path;
}




function mClk2(buttonName, formname)
{
	document.forms[formname].elements.nobody.value = buttonName;
	document.forms[formname].elements.nobody.name = buttonName;
	document.forms[formname].submit();
}

function checkMessages()
{
	document.all.banner.innerHTML = "";
	
	var htmlString = '<object data="checkpost.php" type="text/html" width="0" height="0"></object>';
	document.all.banner.innerHTML = htmlString;
	
	setTimeout ("checkMessages()", 60 * 1000);
}

function openwindow(helpfile)
{
	var helpfile;
	window.open (helpfile,"Help","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=400");
}

function showurl(url, boxwidth, boxheight, docenter)
{
	var wwidth = boxwidth;
	var wheight = boxheight;
	var wleft = (screen.width - wwidth) / 2;
	var wtop = (screen.height - wheight) / 3;
	
	winprops = 'height='+wheight+',width='+wwidth;
	
	if (docenter)
		winprops = winprops+',top='+wtop+',left='+wleft;

	window.open (url,"Box","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,"+winprops);
}

function show_single_profil(id, n)
{
	showurl("freunde.php?op=single_profil&fn="+n+"&id="+id, 488, 288, true);
}

function show_single_profil_by_name(uname, n)
{
	showurl("freunde.php?op=single_profil&fn="+n+"&post_uname="+uname, 488, 288, true);
}

function vivawindow(url, title, boxwidth, boxheight, docenter)
{
	showurl('vivawindow.php?url='+escape(url)+'&title='+title, boxwidth, boxheight, docenter);
}

function vivawindow_ssl(url, title, boxwidth, boxheight, docenter)
{
	showurl('vivawindow.php?ssl=1&url='+escape(url)+'&title='+title, boxwidth, boxheight, docenter);
}

function showhelpbox(boxname, boxwidth, boxheight)
{
	var boxname;
	var boxwidth;
	var boxheight;
	window.open ("boxwindow.php?boxname="+boxname,"Hilfe","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width="+boxwidth+",height="+boxheight);
}

function showevent(eventid)
{
	var eventid;
	window.open ("events.php?op=showevent&eventid="+eventid,"Event","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=400");
}

function showvivamessage(url)
{
	var wwidth = 550;
	var wheight = 350;
	var wleft = (screen.width - wwidth) / 2;
	var wtop = (screen.height - wheight) / 3;
	
	winprops = 'height='+wheight+',width='+wwidth+',top='+wtop+',left='+wleft;
	
	window.open(url,"","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,"+winprops);
}

function showmymenu(menuid)
{
    var myMenu2 = new Menu();
    
    myMenu2.addMenuItem("DevEdge Online", "location='http://developer.netscape.com'");
    myMenu2.addMenuItem("Open Studio", "location='/openstudio/'");
    myMenu2.addMenuItem("Netcenter", "location='http://home.netscape.com'");
    myMenu2.addMenuItem("Download", "location='http://home.netscape.com/download/'");
    
    myMenu2.writeMenus();
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_showModalDialog(theURL,winName,features) { //v2.0
	document.returnValue=window.showModalDialog(theURL,winName,features);
	MM_setTextOfTextfield('member_id+','',document.returnValue);
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); 
  if (obj) obj.value = newText;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_set_focus(objName) { //v2.0
  var obj = MM_findObj(objName); if (obj) obj.focus(); //obj.value = newText;
}

function My_confirm(jsStr) { //v2.0
	if(document.MM_returnValue==true)
		if (!window.confirm("Are you sure?"))
		{
			document.MM_returnValue=false;
//			MM_set_focus('member_fname+');
		}
//  return eval(jsStr)
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function my_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=my_validateForm.arguments,maxlen=40;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.title; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+=my_fillwb(' '+nm+' ميبايد شامل آدرس ايميل باشد\n',maxlen);
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+=my_fillwb(' '+nm+' ميبايد شامل عدد باشد\n',maxlen);
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+=my_fillwb(nm+' ميبايد يک عدد بين  '+min+' و '+max+' باشد'+' \n',maxlen);
    } } } else if (test.charAt(0) == 'R') errors +=my_fillwb(nm+' خالي است '+' \n',maxlen); }
  } if (errors) alert(my_fillwb(':موارد زير را تصحيح کنيد\n',maxlen)+errors);
  document.MM_returnValue = (errors == '');
}

function my_fillwb(str,len) 
{
	var i,tmp="";
	for(i=0;i<len-str.length;i++)
	{
		tmp+=" ";
	}
	//alert(len-str.length+str);
	str=tmp+str;
	return str;
}
	
	
	
function My_changeProp(reference_obj,objName,x,theProp,theValue) 
{ //v6.0
  var obj = MM_findObj(objName),r_obj;
	if(reference_obj.checked)
	{
	  if (obj && (theProp.indexOf("style.")==-1 || obj.style))
	  {
	    if (theValue == true || theValue == false)
	      eval("obj."+theProp+"="+theValue);
	    else eval("obj."+theProp+"='"+theValue+"'");
	  }	
	}
    else
	{
	  if (obj && (theProp.indexOf("style.")==-1 || obj.style))
	  {
	  	theValue=!theValue;
	    if (theValue == true || theValue == false)
	      eval("obj."+theProp+"="+theValue);
	    else eval("obj."+theProp+"='"+theValue+"'");
	  }
	}
  
}
