// JavaScript Document
if ( typeof(AW) == 'undefined' ) AW = function() {};
if ( typeof(AW.config) == 'undefined' ) AW.config = function() {};
AW.get_path = function(x){return this.config.aw_path + x;}
AW.onLoad = new Array();
AW.startOnLoad = function(){for(oLF_i=0;oLF_i<this.onLoad.length;oLF_i++){eval(this.onLoad[oLF_i]);}}
AW.addOnLoad = function(){var args = this.addOnLoad.arguments;for(var i=0; i<args.length; i++){this.onLoad[this.onLoad.length]=args[i];}}

function PMA_markRowsInit()
{
 	if(document.getElementById('oddd'))
	{
		var rows = document.getElementById('oddd').getElementsByTagName('tr');
		for ( var i = 0; i < rows.length; i++ ) 
		{
			if ( 'odd' != rows[i].className) 
			{
				continue;
			}
		   
			if ( navigator.appName == 'Microsoft Internet Explorer' ) 
			{
				rows[i].onmouseover = function() 
				{
					this.className = 'hover';
				}
				rows[i].onmouseout = function() 
				{
					if(this.getElementsByTagName( 'input' )[0].checked)this.className = 'marked';
					else this.className = 'odd'
				}
			}
			rows[i].onmousedown = function() 
			{
				var checkbox;
	
				checkbox = this.getElementsByTagName( 'input' )[0];
				if ( checkbox && checkbox.type == 'checkbox' ) 
				{
					checkbox.checked;
					checkbox.checked = ! checkbox.checked;
					
					if(checkbox.checked==true) this.className = 'marked';
					else 
					{
						this.className = 'odd';
						rows[0].getElementsByTagName( 'input' )[0].checked=false;
					}
				} 
				else 
				{
					return;
				}
			}
	
			var checkbox = rows[i].getElementsByTagName('input')[0];
			if ( checkbox ) 
			{
				checkbox.onclick = function() 
				{
					this.checked = ! this.checked;
				}
			}
		}
	}
}
function select_all()
{
	var rows = document.getElementById('oddd').getElementsByTagName('tr');
	if(rows[0].getElementsByTagName( 'input' )[0].checked)
	{
		for(i=1;i<rows.length;i++)
		{
			if(rows[i].getElementsByTagName( 'input' )[0].checked==false)
			{
				rows[i].getElementsByTagName( 'input' )[0].checked=true;
				rows[i].className = 'marked';
			}
		}
	}
	else
	{
		for(i=1;i<rows.length;i++)
		{
			rows[i].getElementsByTagName( 'input' )[0].checked=false;
			rows[i].className = 'odd';
		}
	} 
}
function ltrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

//RTrim(string) : Returns a copy of a string without trailing spaces.
function rtrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}

// Trim(string) : Returns a copy of a string without leading or trailing spaces
function str_rep_arr(str,str_search,str_rpl)
{
	for(i=0;i<str_search.length;i++)
	{
		while(str.indexOf(str_search[i])!=-1)
		{
	 		str=str.replace(str_search[i],str_rpl[i]);
		}
	}
	return str;
}
function str_rep(str,str_search,str_rpl)
{
	while(str.indexOf(str_search)!=-1)
	{
		str=str.replace(str_search,str_rpl);
	}
    return str;
}
function trim(str)
{
   str=ltrim(str);
   str=rtrim(str);
   while(str.indexOf("  ")!=-1)
	{
	 str=str.replace("  "," ");
	}
   return str;
}
function insertMyImg(opener_id,x,y,z)
{
	document.getElementById('Layer_' + opener_id).innerHTML=x;
	document.getElementById(opener_id).value=y;
	document.getElementById(opener_id + '_id').value=z;
}
function illegalusername(chara)
{
	chara=chara.toLowerCase();
	for (i=0; i < chara.length; i++)
 	{
  		var E = chara.substring(i, i + 1);
  		if ((E < "0" || "9" < E ) && E !="_" && (E < "a" || "z" < E))
  		{
   			return false;
  		}
 	}
}
function isValidPassword(chara)
{
	chara=chara.toLowerCase();
	for (i=0; i < chara.length; i++)
 	{
  		var E = chara.substring(i, i + 1);
  		if ((E < "0" || "9" < E ) && (E < "a" || "z" < E) && E !="_" && E !="*" && E !="-" && E !="?" && E !="+")
  		{
   			return false;
  		}
 	}
}
function illegalaz(chara)
{
	durum=true;
	keyStr = MailVars.keyStr;
	for (i=0; i < chara.length; i++)
 	{
  		var e = chara.substring(i, i + 1);
		e = e.charCodeAt();
		bulundu=false;
		for (z=0; z < keyStr.length; z++)
		{
			var k = keyStr.substring(z, z + 1);
			k = k.charCodeAt();
			if(k==e){bulundu=true;break;}
		}
  		if(bulundu==false){durum=false;break;}
 	}
	return durum;
}
function illegalaz2(chara,at)
{
	durum=true;
	keyStr = MailVars.keyStr + at;
	for (i=0; i < chara.length; i++)
 	{
  		var e = chara.substring(i, i + 1);
		e = e.charCodeAt();
		bulundu=false;
		for (z=0; z < keyStr.length; z++)
		{
			var k = keyStr.substring(z, z + 1);
			k = k.charCodeAt();
			if(k==e){bulundu=true;break;}
		}
  		if(bulundu==false){durum=false;break;}
 	}
	return durum;
}
function onlyNumbers(c)
{
  	s = new String("0123456789");
   	for( j = 0; j<c.length; j++ )
   		if( s.indexOf(c.charAt(j)) == -1  ) 
	  	{
			return true;
      	}
	return false;
}

function num_chk( e )
{
	var k;
	k = e.keyCode;
	durum = false
	if(k>=48 && k<58)durum = true 
	return durum
}

function randomNumber(limit){
  return Math.floor(Math.random()*limit);
}
function insertHtml(oDiv,html,display) 
{
    if(document.getElementById(oDiv))
	{
		document.getElementById(oDiv).innerHTML = html;
		if(display==1)document.getElementById(oDiv).style.display="";
		else document.getElementById(oDiv).style.display="none";
	}
}
function cnfrm(x)
{
	//var sp = /MSIE ((5\.5)|[6789])/.test(navigator.userAgent);
	//if (sp) 
	//{
	//	var obj = new Object();
	//	obj.status = false;
	//	obj.msj = x;
	//	var params = 'dialogWidth:300px;dialogHeight:100px;help:no;'
	//	params += "scroll:no;"
	//	params += "status:no;"
	//	window.showModalDialog(AW.get_path("cnfrm.html?" + randomNumber(50000)), obj, params);
	//	return obj.status;
	//}
	//else 
	return confirm(x);
}
function openDialog(url, width, height) 
{
	var params = ''
	params = "left="+((screen.width/2)-(width/2))+","
	params += "top="+((screen.height/2)-(height/2));
	win=window.open(url,"asd","toolbar=0,directories=0,menubar=0,status=0,width="+width+",height="+height+",resizable=0,scrollbars=0,"+params);
	win.focus();
	return win
}
function isNull(value)
{
	value = trim(value);
	value = value.toLowerCase();
	if(value==null || value=='null' || value=='' || value=="" || value==" " || value==' ')return true;
	else return false;
}
function $(oId){return document.getElementById(oId);}
