var xy; 

function getWH()
{
	var myWidth = 0, myHeight = 0;
 if( typeof( window.innerWidth ) == 'number' )
	 {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
	 }
else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		 }
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
			{
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
			}
	WH=new Array();
	WH[0]=myWidth;
	WH[1]=myHeight;
	return WH;
}


function ge(elem)
{
	return document.getElementById(elem);
}

function ucFirst(str) {
   return str.substr(0,1).toUpperCase() + str.substr(1,str.length);
}

function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function trim(str) {
	return ltrim(rtrim(str));
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}

function cover(sh,w,h)
{
	if (sh==1)
	{
		xy = YAHOO.util.Dom.getXY('b_overlay');
		if (h>xy[1])
			xy[1]=h;
		document.getElementById('b_overlay').className='b_overlay2';
		document.getElementById('b_overlay').style.top="0px";
		document.getElementById('b_overlay').style.left="0px";
		document.getElementById('b_overlay').style.width=w+"px";
		document.getElementById('b_overlay').style.height=xy[1]+"px";
	}
	else
	{
		document.getElementById('b_overlay').className='b_overlay1';
		document.getElementById('b_overlay').style.top=xy[1]+"px";
		document.getElementById('b_overlay').style.left=0;
		document.getElementById('b_overlay').style.width=0;
		document.getElementById('b_overlay').style.height=0;
	}
}

//transfer form----------------------
function addValue(id)
	{
		if (document.getElementById("filename_"+id).value!='')
		{
			objid=new Number(id);
			if (document.getElementById("filename_"+(objid+1))==undefined)
			{
				nrord=objid+1;
				br=document.createElement("br");
				document.getElementById("inputs").appendChild(br);

				newinput=document.createElement("input");
				newinput.id="filename_"+(nrord);
				newinput.type='file';
				newinput.name="f[]";
				newinput.className="field_upload";
				newinput.onchange=function(){addValue(nrord)};
				document.getElementById("inputs").appendChild(newinput);
			}
		}
    }
    
function clearDiv()
{
	document.getElementById("transf").innerHTML="";
}

var xmlHttp;
var isok;
function StartUpload()
{
	var frm=document.forms['uplform'];
	var UID=frm.elements["UPLOAD_IDENTIFIER"].value;

	wh=getWH();
	//alert(document.getElementById('transf').style.width);
	x=wh[0]/2-(document.getElementById('transf').style.width)/2;
	y=wh[1]/2-450/2;

	cover(1,wh[0],wh[1]);
	window.location.hash='#top';
	document.getElementById('transf').style.left=x+'px';
	document.getElementById('transf').style.top=y+'px';
	document.getElementById('transf').style.display='block';
	pageTracker._trackPageview("/upload_started");
	ajax();
}

function redirect()
{
	window.location.reload();
}

function retry(param)
{
	document.getElementById("transf").style.display='none';
	cover(0,0,0);
}    

var level=1;
function totransferornottotransfer(ch)
{
	if (ch.checked==true)
	{
	ch.form.emails.disabled=true;
	ch.form.emails.style.backgroundColor="#F2F2F2";
	ch.form.hismessage.disabled=true;
	ch.form.hismessage.style.backgroundColor="#F2F2F2";
	if (ch.form.pwd.disabled==true) level=0;
	else
		{
		ch.form.pwd.disabled=true;
		ch.form.pwd.style.backgroundColor="#F2F2F2";
		}
	ge('contacts').style.backgroundColor='#F2F2F2';
	}
	else
	{
	ch.form.emails.disabled=false;
	ch.form.emails.style.backgroundColor="#FFFFFF";
	ch.form.hismessage.disabled=false;
	ch.form.hismessage.style.backgroundColor="#FFFFFF";
	if (level!=0)
	{
		ch.form.pwd.disabled=false;
		ch.form.pwd.style.backgroundColor="#FFFFFF";
	}
	ge('contacts').style.backgroundColor='#FFFFFF';
	}
}

//address book-------------------------------
checked=0;
addresses=new Array();



function in_contacts(val)
{
	big=ge('contacts');
	litt=big.getElementsByTagName('div');
	for(q=0;q<litt.length;q++)
		if (litt[q].id==val)
			return true;
	return false;		
}

function fillTo(contacts)
{
	contacts=contacts.split(";");
	for(i=0;i<contacts.length;i++)
		if (contacts[i]!='')
			if (!in_contacts(contacts[i]))
			{
				c=document.createElement("div");
				c.id=contacts[i];
				c.style.borderBottom="1px solid #CCCCCC";
				c.style.textAlign="right";
				c.innerHTML="<span style='float:left;'>"+contacts[i]+"</span><a style='color:red;font-weight:bold;font-size:12px;' href='javascript:void(0)' onclick=\"ge('contacts').removeChild(ge('"+contacts[i]+"'))\"'>x</a><input type='hidden' name='emails2[]' value='"+contacts[i]+"'><br/>";
				ge('contacts').appendChild(c);
			}
}

//history-------------------------------------
function history(sh)
{
	 if (sh==1)
	 {
		wh=getWH();
		x=wh[0]/2-500/2;
		y=wh[1]/2-450/2;

		cover(1,wh[0],wh[1]);
		window.location.hash='#top';
		document.getElementById('history').style.left=x+'px';
		document.getElementById('history').style.top=y+'px';
		document.getElementById('history').style.display='block';
		alert(document.domain);

	 }
	 else
	{
		document.getElementById('history').style.display='none';
		/*document.getElementById('main').className='main1';*/
		cover(0,0,0);
	}
}

function debug(sh,mesaj)
{
	 	
	 if (sh==1)
	 {
		wh=getWH();
		x=wh[0]/2-500/2;
		y=wh[1]/2-450/2;

		cover(1,wh[0],wh[1]);
		window.location.hash='#top';
		document.getElementById('transf').style.left=x+'px';
		document.getElementById('transf').style.top=y+'px';
		document.getElementById('transf').style.display='block';
		document.getElementById('transf').innerHTML=mesaj;
	 }
	 else
	{
		document.getElementById('transf').innerHTML='';
		document.getElementById('transf').style.display='none';
		cover(0,0,0);
	}
}



function call(param)
{
	setTimeout("init("+param+")",1300);
}

function ajax()
{
	isok=0;
	call(0);
}


/*------------------------------------------------------------*/
function createOverlay(width, height, url, post)
{
   if(!document.getElementById('overlay_wrapper'))
   	{
		wh=getWH();
		cover(1,wh[0],wh[1]);
	   	var ov = document.createElement('DIV');
	   	ov.className = 'overlay_wrapper';
	   	ov.id = 'overlay_wrapper';
	   	ov.style.width = width + 'px';
	   	
	   	ov.style.height = height + 'px';
	   	ov.innerHTML = 'Loading...';
		ov.style.left = ((parseInt(wh[0])-width)/2) + 'px';
		ov.style.top = ((parseInt(wh[1])-height)/2) + 'px';
		document.body.appendChild(ov);
		if (post=='')
	   		requestData(url, 'overlay_wrapper');
	   	else
	   		sendRequest(url,post,'overlay');	
	   		return false;
	   	window.location.hash='top';
   }
   else
   {
	   	if (post=='')
	   		requestData(url, 'overlay_wrapper');
	   	else
	   		sendRequest(url,post,'overlay');
	   	window.location.hash='top';
   }
   return false;
}

function closeOverlayer(div_id)
{
	if(document.getElementById(div_id))
		document.getElementById(div_id).parentNode.removeChild(document.getElementById(div_id));
	cover(0,0,0);	
}



function sendRequest(url,post,handle) {

    var oXmlHttp = GetXmlHttpObject();
    oXmlHttp.open("post", url, true);
    oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    if (handle!='nada')
    oXmlHttp.onreadystatechange=function() 
    	{
    		//alert(handle);
    		if (oXmlHttp.readyState==4 || oXmlHttp.readyState=="complete")
			{
				if (oXmlHttp.status == 200) {
					switch (handle)
					{
					case 'nada':
						{
							//alert(oXmlHttp.responseText);
							break;
						}
					case 'ajaxeditcateg':
						{
							window.location='/AddressBook/contacts/'+category;
							break;
						}
					case 'overlay':
						{					
							document.getElementById('overlay_wrapper').innerHTML = oXmlHttp.responseText;
							if (oXmlHttp.responseText.slice(0,13)=="<!--editor-->")
							{
								id=3;
								if(document.getElementById("p"+id))document.getElementById("editor").innerHTML=document.getElementById("p"+id).innerHTML;
								var myEditor = new YAHOO.widget.Editor('editor', {
								    height: '300px',
								    width: '400px',
								    dompath: false,
								    animate: true,
								    toolbar: {
								        titlebar: 'Text Editor',
								        buttons: [
								            { group: 'textstyle', label: 'Font Style',
								                buttons: [
								                    { type: 'push', label: 'Bold', value: 'bold' },
								                    { type: 'push', label: 'Italic', value: 'italic' },
								                    { type: 'push', label: 'Underline', value: 'underline' },
								                    { type: 'separator' },
								                    { type: 'select', label: 'Arial', value: 'fontname', disabled: true,
								                        menu: [
								                            { text: 'Arial', checked: true },
								                            { text: 'Arial Black' },
								                            { text: 'Comic Sans MS' },
								                            { text: 'Courier New' },
								                            { text: 'Lucida Console' },
								                            { text: 'Tahoma' },
								                            { text: 'Times New Roman' },
								                            { text: 'Trebuchet MS' },
								                            { text: 'Verdana' }
								                        ]
								                    },
								                    { type: 'spin', label: '13', value: 'fontsize', range: [ 9, 75 ], disabled: true },
								                    { type: 'separator' },
								                    { type: 'color', label: 'Font Color', value: 'forecolor', disabled: true },
								                    { type: 'color', label: 'Background Color', value: 'backcolor', disabled: true }
								                ]
								            }
								        ]
								    }
								});
								myEditor.render();
							}
							break;
						}
					case 'emailcheckdomain':
						{
							if (oXmlHttp.responseText.length>0)
								ok=confirm(oXmlHttp.responseText);
							else
								ok=1;	
							if (ok)
								{
								StartUpload();
								document.forms['uplform'].elements['upload'].disabled=true;
								document.forms['uplform'].submit();
								//return true;
								}
							break;	
							/*else
								return false;*/
						}
					}
				}else {
	        		//not ok
	                alert("An error occurred: "+ oXmlHttp.statusText);
	            }
				
			}
    	};
    oXmlHttp.send(post);
}

function putSugest(text)
{
	document.getElementById("putsugestdiv").innerHTML=text;
}

function requestData(url, div_id)
{
	xmlHttp2 = GetXmlHttpObject();
	xmlHttp2.open("get", url, true);
	xmlHttp2.onreadystatechange = function(){
		if(xmlHttp2.readyState == 4){
			if(xmlHttp2.responseText=="notfound")
			{
				closeOverlayer('overlay_wrapper');
				StartUpload();
				document.forms['uplform'].elements['upload'].disabled=true;
				document.forms['uplform'].submit();
				return false;
			}
			else document.getElementById(div_id).innerHTML = xmlHttp2.responseText;
			/*alert(xmlHttp.responseText)*/
		}
	}
	xmlHttp2.send(null);

}

function addValue(id)
	{
		if (document.getElementById("filename_"+id).value!='')
		{
			objid=new Number(id);
			if (document.getElementById("filename_"+(objid+1))==undefined)
			{
				nrord=objid+1;
				br=document.createElement("br");
				document.getElementById("inputs").appendChild(br);

				newinput=document.createElement("input");
				newinput.id="filename_"+(nrord);
				newinput.type='file';
				newinput.name="f[]";
				newinput.className="field_upload";
				newinput.onchange=function(){addValue(nrord)};
				document.getElementById("inputs").appendChild(newinput);

	//			newdiv=document.createElement("div");
	//			newdiv.id="fileprogress_"+(nrord);
	//			document.getElementById("status").appendChild(newdiv);
			}
		}
    }

function check_email(e) 
{
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
for(i=0; i < e.length ;i++)
	{
	if(ok.indexOf(e.charAt(i))<0)
		{ 
		return (false);
		}	
	} 
if (document.images) 
	{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(e)) 
		{
		return false;		
		} 	
	}
return true;
}

function check(form)
{	
	if (form.emails.value=='')
	{
		alert("Invalid email detected!");
		return false;
	}

	var browserName=navigator.appName;

	if (browserName=="Netscape")
	 	emails=form.emails.value.split("\n");
	else
	 	if (browserName=="Microsoft Internet Explorer")
	  		emails=form.emails.value.split("\r\n");
	 	else
	    	emails=form.emails.value.split("\n");
	url2='';
    cnt=0;
	new_emails='';
	lista=new Array();
	lista["yahoo.com"]=new Array('yaahoo.com','hahoo.com','yahoo.con','yahho.com','uahoo.com','yahoo.co','yaho.com','ahoo.com','yahou.com','iahoo.com','yahoo.ro','yahoo.cm','yah.com','yhaoo.com','yahooo.com','yahoooo.com','zahoo.com','yahoo.om','jahoo.com','yahuu.com','yagoo.com','yahwoo.com','tahoo.com','yaho.com','yaoo.com');
	lista["yahoo.co.uk"]=new Array('yahoo.uk.com','yahoo.uk');
	lista["hotmail.com"]=new Array('hotmai.com');
	lista["gmail.com"]=new Array('gamil.com','gmial.com','gmail.ro','gnail.com','gmeil.com','gmail.co','gmai.com','gmail.coom','gmaol.com','gmeail.com','gmaul.com');
	indici_lista=new Array("yahoo.com","yahoo.co.uk","gmail.com","hotmail.com");
	for(i in emails)
		if (emails[i]!='')
			{
			cnt++;
			url2=url2+"&email"+cnt+"="+emails[i];
			em=emails[i];
			em=trim(em);
			ok=check_email(em);
			if(ok==false)
				{
				alert("Invalid email detected: "+em);
				form.emails.focus(); 
				return false;
				}
			else
				{
				if((em.indexOf('.')==3)&&(em.substr(0,3)=='www'))
						em=em.substr(4);
				pos=em.indexOf('@');
				id=em.substr(0,pos);
				domeniu=em.substr(pos+1);
				//mail_track
				pageTracker._trackEvent('mail', 'sent', domeniu);
				for(i=0;i<indici_lista.length;i++)
					for(j=0;j<lista[indici_lista[i]].length;j++)
						{
						if(domeniu==lista[indici_lista[i]][j])
							{
							em=id+'@'+indici_lista[i];
 							document.getElementById('abookimg').src='http://md5.transfer.ro/0.gif?correct='+domeniu;
					                pageTracker._trackPageview("/mail_corrected");

							}
						}
				if (browserName=="Netscape")
					new_emails+=em+"\n";
				else
					if (browserName=="Microsoft Internet Explorer")
						new_emails+=em+"\r\n";
					else
						new_emails=em+"\n";
				}
			}
			
	myurl="/emailcheck.php?";
    myurl=myurl+"n="+cnt+url2;
	form.emails.value=new_emails;

	if (form.filename_0.value=='')
	{
		alert("Please specify a file to upload."); 
		return false;
	}
	
	createOverlay(500, 300, myurl,'');
	return false;
	
	//return true;
	StartUpload();
	document.forms['uplform'].elements['upload'].disabled=true;
	return true;
}

function cover(sh,w,h)
{
	if (sh==1)
	{
		xy = YAHOO.util.Dom.getXY('b_overlay');
		if (h>xy[1])
			xy[1]=h;
		document.getElementById('b_overlay').className='b_overlay2';
		document.getElementById('b_overlay').style.top="0px";
		document.getElementById('b_overlay').style.left="0px";
		document.getElementById('b_overlay').style.width=w+"px";
		document.getElementById('b_overlay').style.height=xy[1]+"px";
	}
	else
	{
		document.getElementById('b_overlay').className='b_overlay1';
		document.getElementById('b_overlay').style.top=xy[1]+"px";
		document.getElementById('b_overlay').style.left=0;
		document.getElementById('b_overlay').style.width=0;
		document.getElementById('b_overlay').style.height=0;
	}
} 
//---------------------------------------------------------
function stateChanged()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
		upl_div=document.getElementById('progressbar');
		if ((upl_div.innerHTML.indexOf('mail')>-1)||(upl_div.innerHTML.indexOf('Please')>-1))
			{
			//document.forms['uplform'].elements['upload'].disabled=false;
			//document.getElementById("transf").style.display='none';
			}
		else 
			{
			if (xmlHttp.responseText=='e')
				{
				if (isok==0)
					if ((upl_div.innerHTML.indexOf('mail')>-1)||(upl_div.innerHTML.indexOf('Please')>-1))
					{
						//document.getElementById("transf").style.display='none';
						//document.forms['uplform'].elements['upload'].disabled=false;
					}
					else
						call(1);
				else
					call(0);
				}
			else
				{
				if ((xmlHttp.responseText.indexOf('ERROR')>-1)||(xmlHttp.responseText.indexOf('Eroare')>-1))
					if ((upl_div.innerHTML.indexOf('mail')>-1)||(upl_div.innerHTML.indexOf('Please')>-1))
						{
						//call(0);
						//document.getElementById("transf").style.display='none';
						//document.forms['uplform'].elements['upload'].disabled=false;
						}
					else
						{
						document.getElementById("progressbar").innerHTML=xmlHttp.responseText;
						document.forms['uplform'].elements['upload'].disabled=false;
						document.getElementById('TargetFrame').src='about:blank';
						}
				else
					{
					document.getElementById("progressbar").innerHTML=xmlHttp.responseText;
					//alert("ceva");
					isok=1;
					call(0);
					}
				}
			}
		}
}

function GetXmlHttpObject()
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
	{
	objXMLHttp=new XMLHttpRequest();
	}
else if (window.ActiveXObject)
	{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
return objXMLHttp;
}

function call(param)
{
	setTimeout("init("+param+")",1000);
}

//--------------------------------------------------------------------

function clearDiv()
{
	document.getElementById("progressbar").innerHTML="";
}

function getStyle(el,styleProp)
{
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}


function StartUpload()
{
	 	
	 var frm=document.uplform;
	 var UID=frm.elements["UPLOAD_IDENTIFIER"].value;
	 //frm.submit();

	//---document.getElementById("transf").style.display="block";
	var myWidth = 0, myHeight = 0;
	 if( typeof( window.innerWidth ) == 'number' )
		 {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		 }
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
			{
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
			 }
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
				{
				//IE 4 compatible
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
				}
	//alert(document.getElementById('transf').style.width);
	x=myWidth/2-transf_width/2;
	y=myHeight/2-450/2;

	document.getElementById('main').className='main2';
	window.location.hash='#top';
	document.getElementById('transf').style.display='block';
	document.getElementById('transf').style.width=transf_width+'px';
	document.getElementById('transf').style.left=x+'px';
	document.getElementById('transf').style.top=y+'px';
        pageTracker._trackPageview("/upload_started");

}

function showPbForm()
	{
		document.getElementById("pbfrm").style.display="block";
	}

function redirect()
{
	window.location='/';
}

function pro(f)
{
	ok=check_email(f.email.value);
	if(ok==false)
		{
		alert("Adresa de email invalida!");
		return false;
		}
	if (f.raport.value=='')	
		{
		alert("Va rugam descrieti problema!");
		return false;
		}
	return true;	
}

function retry(param)
{
	document.getElementById("transf").style.display='none';
	document.getElementById('main').className='main1';
}


//address book-------------------------------
checked=0;
addresses=new Array();

function abook(sh)
{
	 	
	 if (sh==1)
	 {
		var myWidth = 0, myHeight = 0;
		 if( typeof( window.innerWidth ) == 'number' )
			 {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
			 }
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
				{
				//IE 6+ in 'standards compliant mode'
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
				 }
			else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
					{
					//IE 4 compatible
					myWidth = document.body.clientWidth;
					myHeight = document.body.clientHeight;
					}
		
		x=myWidth/2-500/2;
		y=myHeight/2-450/2;

		document.getElementById('main').className='main2';
		window.location.hash='#top';
		document.getElementById('abook').style.left=x+'px';
		document.getElementById('abook').style.top=y+'px';
		document.getElementById('abook').style.display='block';

		if (document.getElementsByName('address[]'))
		{
		elem= document.getElementsByName('address[]');
		for(i=0;i<elem.length;i++)
			document.getElementById(elem[i].id).checked=false;
		}
		addresses=new Array();
	 }
	 else
	{
		document.getElementById('abook').style.display='none';
		document.getElementById('main').className='main1';
	}
}

function vab(ch)
{
	if (ch.checked==true)
	{
		checked++;
		document.getElementById('abookimg').src='http://md5.transfer.ro/0.gif?abook=1';
                pageTracker._trackPageview("/abook_used");

		if (checked<=5)
			addresses.push(ch.value);
		else
			{
			alert('Ati selectat deja 5 adrese!');
			checked--;
			ch.checked=false;
			return;
			}
	}
	else
	{
		checked--;
		for (i=0;i<addresses.length;i++)
			if (addresses[i]==ch.value)
				{
				for (j=i;j<addresses.length-1;j++)
					addresses[j]=addresses[j+1];
				addresses.pop()
				break;
				}
	}
}


function sab()
{
	checked=0;
	text=document.getElementById('emails').value;
	document.getElementById('emails').value='';
	text=trim(text);
	if (text.length>1)
		text+='\r\n';
	for(i=0;i<addresses.length;i++)
		text+=addresses[i]+'\n';
	document.getElementById('emails').value=text;
	abook(0);
}

//history-------------------------------------
function history(sh)
{
	 	
	 if (sh==1)
	 {
		var myWidth = 0, myHeight = 0;
		 if( typeof( window.innerWidth ) == 'number' )
			 {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
			 }
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
				{
				//IE 6+ in 'standards compliant mode'
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
				 }
			else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
					{
					//IE 4 compatible
					myWidth = document.body.clientWidth;
					myHeight = document.body.clientHeight;
					}
		
		x=myWidth/2-500/2;
		y=myHeight/2-450/2;

		document.getElementById('main').className='main2';
		window.location.hash='#top';
		document.getElementById('history').style.left=x+'px';
		document.getElementById('history').style.top=y+'px';
		document.getElementById('history').style.display='block';
	 }
	 else
	{
		document.getElementById('history').style.display='none';
		document.getElementById('main').className='main1';
	}
}

function debug(sh,mesaj)
{
	 	
	 if (sh==1)
	 {
		var myWidth = 0, myHeight = 0;
		 if( typeof( window.innerWidth ) == 'number' )
			 {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
			 }
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
				{
				//IE 6+ in 'standards compliant mode'
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
				 }
			else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
					{
					//IE 4 compatible
					myWidth = document.body.clientWidth;
					myHeight = document.body.clientHeight;
					}
		
		x=myWidth/2-600/2;
		y=myHeight/2-450/2;

		document.getElementById('main').className='main2';
		window.location.hash='#top';
		document.getElementById('transf').style.left=x+'px';
		document.getElementById('transf').style.top=y+'px';
		document.getElementById('transf').style.display='block';
		document.getElementById('transf').innerHTML=mesaj;
	 }
	 else
	{
		document.getElementById('transf').innerHTML='';
		document.getElementById('transf').style.display='none';
		document.getElementById('main').className='main1';
	}
}


function ajaxReq(file)
{
    var xmlHttp;
    try
    {
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        try
        {
            xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e)
            {
                alert('Your browser does not support AJAX!');
                return false;
            }
        }
    }
   
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            //document.getElementById( divName ).innerHTML = xmlHttp.responseText
        }
    }

    xmlHttp.open('POST',file,true);
    xmlHttp.send(null);
}

function getEmails()
{
	var emails = new Array();
	emailsTextArea = document.getElementById('emails').value;
	emails = emailsTextArea.split("\n");
	var emailsString = '';
	
	for(var i = 0; i < emails.length; i++)
	{
		emailsString += emails[i] + ';';
	}
	
	return emailsString;
}

function deleteFromABook(id, cookie)
{
	var confirmare = confirm('Doresti sa stergi e-mail-ul din address book?');
	if(confirmare)
	{
		ajaxReq('http://ab.transfer.ro/delete.php?id=' + id + '&cookie=' + cookie);
		var hide = document.getElementById('link' + id);
		hide.style.display = 'none';
	}
}

