/*function appendscript(filename)
{
	
	var jsel = document.createElement('SCRIPT');
	var dom = document.getElementsByTagName('head')[0];
    var now = new Date();
	var exitTime = now.getTime();
	jsel.type = 'text/javascript';
	jsel.src = filename;
	dom.appendChild(jsel);
	dom = null;
	jsel = null;
}*/

function checkIt(string) {
	var detect = navigator.userAgent.toLowerCase();
	place = detect.indexOf(string) + 1;
	thestring = string;
	//alert(place);
	return place;
	}

	// In IE, select elements hover on top of the lightbox


	hideSelects=function(visibility){
		//alert("hiddeing selects");
		selects = document.getElementsByTagName('select');
		for(i = 0; i < selects.length; i++) {
			selects[i].style.visibility = visibility;
		}
	}

//--
function loading()
{
		var LI=document.getElementById('loadingImage');
        var BG=document.getElementById('loadingBG');
        var WP=document.getElementById('WorkingPlace');
        var WA=document.getElementById('working-area');
		
		if(LI && BG  )
			{
           
				
                LI.style.width=WA.offsetWidth;
				
                BG.style.width=WA.offsetWidth;
				
				if(WA.offsetHeight<50)
					{
					LI.style.height="151px";
					 BG.style.height="151px";
					}
				else
					{
					LI.style.height=(WA.offsetHeight-50);
					BG.style.height=(WA.offsetHeight-50);
					}
                LI.style.left=(WA.offsetLeft);
                
				BG.style.left=(WA.offsetLeft) ;
                LI.style.top=(WA.offsetTop+10);
                BG.style.top=(WA.offsetTop+10);
                LI.style.display='block';
                BG.style.display='block';
				
                if (checkIt('msie')) // if IE
                    hideSelects('hidden');
                LI.innerHTML="<table border='0' width='100%' height='100%' align='center' ><tr valign='middle'><td height='100%' align='center' valign='top'><br><br><br><br><br><br><img valign='middle' src='images/loading1.gif'></td></tr></table>";
				
             
			}
	
}//function
//---------------Search Alphabitical
function LoadModule(module,submodule,location,params,form)
	{

		if(module=='Register' || module=='Contact_us'){
			
			var divName=submodule+"Div";
			var respondeDiv=document.getElementById(divName);
			//alert('update'+divName);
			if(respondeDiv)
			respondeDiv.innerHTML="<img valign='middle' src='images/ajax-loader(2).gif'>";
		}
		
        else if(location!='send_progress' && submodule != 'send_process_finish' && submodule != 'list_upload' && submodule !='list_copy_progress' ) loading();
			
		
		
		var url="LoadModule.php";
		var now = new Date();
		var exitTime = now.getTime();
		var data="module="+module+"&submodule="+submodule+"&someParameter="+exitTime;
		
		if(params)
			data+="&"+params;
		if(form)
			data+="&"+Form.serialize(document.getElementById(form));
		//alert('data===='+data);
		if(!location)
			location='working-area';
			//alert('location is'+location);
			//alert('url'+url);
     var myAjax = new Ajax.Updater(
			location,
			url,
			{
				method: 'post',
				parameters: data,
				onComplete: showResponse,
				onLoading :showWaiting,
				evalScripts:true,
				asynchronous:true
			} );
	function showResponse(originalRequest)
	{
		if(module=='Register'){
			var divName=submodule+"Div";
			if($(divName))
			$(divName).innerHTML="";
		}
		//alert("Response"+originalRequest.responseText);
		
        document.getElementById('loadingImage').style.display='none';
        document.getElementById('loadingBG').style.display='none';
        if (checkIt('msie')) // if IE
             hideSelects('visible');

		document.getElementById(location).innerHTML=originalRequest.responseText;

		//heights();
         //  	document.getElmentById(location).innerHTML="<table border='0' width='100%' height='380' align='center' ><tr valign='middle'><td height='380' align='center' valign='middle'><img valign='middle' src='images/working.gif'></td></tr></table>";

	}

function showWaiting()
	{
	}
	}
	//-------------ChangeLang
ChangeLang=function(epars)
{
		var now = new Date();
		var exitTime = now.getTime();


		var pars = 'someParameter='+exitTime+"&"+epars;
		//alert(pars);
		//var url="admin-page.php";
		var url="changeLang.php";
		var place="";
      var myAjax = new Ajax.Updater(
			place,
			url,
			{
				method: 'post',
				parameters: pars,
				onComplete: showadmin,
				onLoading :loginWaiting,
				evalScripts:true,
				asynchronous:true
			} );

function showadmin(originalRequest)
	{
		
		
	eval(originalRequest.responseText);

	}
		
	function loginWaiting()
		{
		
		}
	}
//-------------logout
loginNow=function(epars)
{
		var now = new Date();
		var exitTime = now.getTime();

		
		var pars = 'someParameter='+exitTime+"&"+epars;
		//alert(pars);
		//var url="admin-page.php";
		var url="loginto.php";
		var place="";
      var myAjax = new Ajax.Updater(
			place, 
			url, 
			{
				method: 'post', 
				parameters: pars,
				onComplete: showadmin,
				onLoading :loginWaiting,
				evalScripts:true,
				asynchronous:true
			} );

function showadmin(originalRequest)
	{
		
		
	eval(originalRequest.responseText);

	}
		
	function loginWaiting()
		{
		
		}
	}

	//-------------Parse e-mails file 
startParse=function(epars,file)
{
		var now = new Date();
		var exitTime = now.getTime();

		
		var pars = 'someParameter='+exitTime+"&readOffset="+epars+"&myFile="+file;
		var url="parse.php";
		var place="";
      var myAjax = new Ajax.Updater(
			place, 
			url, 
			{
				method: 'post', 
				parameters: pars,
				onComplete: showRsult,
				onLoading :showWaiting,
				evalScripts:true,
				asynchronous:true
			} );

function showRsult(originalRequest)
	{
		
		
	alert(originalRequest.responseText);
	if(originalRequest.responseText!=0)
		startParse(originalRequest.responseText)

	}
		
	function showWaiting()
		{
		
		}
	}

