<!--
function getXMLHTTPRequest()
{
    var xRequest=null;
    if (window.XMLHttpRequest)
    {
        xRequest=new XMLHttpRequest();
    }
    else if (typeof ActiveXObject != "undefined")
    {
        xRequest=new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xRequest;
}

// exemplu : var raspuns =sendRequest("test2.php","call="+intrebare+"&gg="+gg,"POST");
function sendRequest(url,params,HttpMethod)
{
	//alert('OK2'+HttpMethod+url+false);
	if (!HttpMethod)
    {
        HttpMethod="POST";
    }
    var req=getXMLHTTPRequest();
    if (req)
    {
        
    	
        req.open(HttpMethod,url,false);
       
    	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
         
        req.send(params);
    }
    
   
    return req.responseText;
}
function URLEncode(str)
{
    // The Javascript escape and unescape functions do not correspond
    // with what browsers actually do...
    var SAFECHARS = "0123456789" + // Numeric
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
	"abcdefghijklmnopqrstuvwxyz" + "-_.!~*'()"; // RFC2396 Mark characters
    var HEX = "0123456789ABCDEF";
    var plaintext = str.toString();
//    alert(plaintext);
//    alert(plaintext.charAt(0));
    
    var encoded = "";
    for (var i = 0; i < plaintext.length; i++ )
    {
        var ch = plaintext.charAt(i);
        if (ch == " ")
        {
            encoded += "+"; // x-www-urlencoded, rather than %20
        }
        else
	    if (SAFECHARS.indexOf(ch) != -1)
    	    {
        	encoded += ch;
    	    }
    	    else
            {
        	var charCode = ch.charCodeAt(0);
                if (charCode > 255)
                {
                    //alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" +
                    //"(URL encoding only supports 8-bit characters.)\n" +
                    //"A space (+) will be substituted." );
                    encoded += "+";
                }
                else
	        {
	    	//    if(i==0 || i==2)
	    	//	alert(i+"%"+HEX.charAt((charCode >> 4) & 0xF)+HEX.charAt(charCode & 0xF));
    	            encoded += "%";
                    encoded += HEX.charAt((charCode >> 4) & 0xF);
                    encoded += HEX.charAt(charCode & 0xF);
                }
            }
    }
//    alert(encoded);
    // for
    return encoded;
}

function showInfoFrame(url, div_id) {
    document.getElementById('benchmark_report').src=url;
    return false;
}
function showInfo(url, div_id) {
    
	document.getElementById(div_id).innerHTML = '<div align="center" style="font-family:Verdana;font-size:11px;">Loading, please wait ...<br /><br /><img src="https://www.whiteimage.eu/clients/wlm/images/preloader.gif" /></div>'
    var xmlhttpRequestObj;
	
    if (xmlhttpRequestObj = create_xmlhttpRequestObj()) {
	xmlhttpRequestObj.onreadystatechange = processRequestChange;
	xmlhttpRequestObj.open("GET", url, true);
	//xmlhttpRequestObj.setRequestHeader("Content-Type", 'text/xml; charset="ISO-8859-2"');
	//xmlhttpRequestObj.setRequestHeader("Accept-Charset", "iso-8859-2");
	xmlhttpRequestObj.send(null);
    } else {
	//alert('Nu pot crea xmlhttpRequestObj');
    }
	
    function processRequestChange() {
	if (xmlhttpRequestObj.readyState == 4) {
	    if (xmlhttpRequestObj.status == 200) {
		var string             = xmlhttpRequestObj.responseText;
		var responsecont       = document.createElement('div');
		responsecont.innerHTML = string;
		var mstrresponse       = responsecont.innerHTML;
		var homecont           = document.getElementById(div_id);
		homecont.innerHTML     = mstrresponse;
	    } else {
		//alert('Nu e ok');
	    }
	}
    }
	
    function create_xmlhttpRequestObj() {
	//alert('OK');
    	if (window.ActiveXObject) 
    	{
	    	return new ActiveXObject("Microsoft.XMLHTTP");
		} 
		else if (window.XMLHttpRequest) 
		{
	    	return new XMLHttpRequest();
		}
	
	return null;
    }
	
}

function is_empty(str) {
    return str.search('^[ \t\r\n]*$')>-1 ? true : false;
}

function is_uint(str) {
    if (is_empty(str)) {
	return false;
    }
    return str.search('^[.0-9]*$')>-1 ? true : false;
}

function is_email(str) {
    if (str.search("^([a-zA-Z0-9_]|\\-|\\.)+@(([a-zA-Z0-9_]|\\-)+\\.)+[a-zA-Z]{2,4}\$") > -1) {
	return true;
    }	
    return false;
}
function changeDisplay(m)
{
 	
	document.getElementById('linieButon').style.display='block';
 	if(m==0) 
 	{
 		document.getElementById('a1').style.display='block';
 		document.getElementById('a2').style.display='none';
 		document.getElementById('tipFiltru').value=m;
 	}	
	else
	{
		document.getElementById('a1').style.display='none';
 		document.getElementById('a2').style.display='block';
 		document.getElementById('tipFiltru').value=m;
	}
}
function changeDisplayMessage(m,n)
{
 	
	
	var  lanseaza=document.getElementById(m).value;
 	
	if(is_uint(lanseaza) && lanseaza>0)
 	{
 		if(n!='nrzile' && n!='nrzile1')
		document.getElementById(n).value=0;
		else
		document.getElementById(n).selectedIndex=0;
 		
 		
 	}	
	else
	{
		if(m!='nrzile' && m!='nrzile1')
		document.getElementById(m).value=0;
		else
		document.getElementById(m).selectedIndex=1;
	}
}
// de la silviu citire
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
//folosita in tplcampaign.tpl pentru 
function returnPath()
{
	//alert('OKA');
	//alert("ok"+document.getElementById('cmpgid').value);

	var raspuns=sendRequest("index.php?m=campaigns&s=tplcampaign&o=changeTestRP","cmpgid="+document.getElementById('cmpgid').value+"&testRP="+document.getElementById('rp').checked,"POST");	
//alert(raspuns);

}

function returnPath1(campania)
{
	//alert(campania+document.getElementById('rp_'+campania).checked);
	var raspuns=sendRequest("index.php?m=campaigns&s=tplcampaign&o=changeTestRP","cmpgid="+campania+"&testRP="+document.getElementById('rp_'+campania).checked,"POST");	
	//alert(raspuns);
}

// pt noul modul de liste.. pt schimbat taburi
function menulistchange(item)
{
	//item = Number(item);
	var itemOld = document.getElementById('menulisttab').value;
	if(item != itemOld )
	{
		//facem tabulare
		/*document.getElementById('menulist_'+itemOld).className='menulistoff';
		document.getElementById('menulist_'+item).className='menuliston';
		document.getElementById('bodylist_'+itemOld).style.display='none';
		document.getElementById('bodylist_'+item).style.display='';*/
		
		document.getElementById('menulisttab').value=item;
		location.href='index.php?m=listsnew&t='+document.getElementById('menulisttab').value;
	}
}

function changeDiacritics()
{
	//alert('OKA');
	//alert("ok"+document.getElementById('cmpgid').value);
	if(document.getElementById('diacritics').checked)
	{
		document.getElementById('diacritic').innerHTML='';
	}
	else
	{
		document.getElementById('diacritic').innerHTML='Right now you will use HTML code for diacritics';
	}
	var raspuns=sendRequest("index.php?m=campaigns&s=tplcampaign&o=replaceDiacritics","cmpgid="+document.getElementById('cmpgid').value+"&diacritics="+document.getElementById('diacritics').checked,"POST");	
//alert(raspuns);
}
function changeDiacritics()
{
	//alert('OKA');
	//alert("ok"+document.getElementById('cmpgid').value);
	if(document.getElementById('diacritics').checked)
	{
		document.getElementById('diacritic').innerHTML='';
	}
	else
	{
		document.getElementById('diacritic').innerHTML='Right now you will use HTML code for diacritics';
	}
	var raspuns=sendRequest("index.php?m=campaigns&s=tplcampaign&o=replaceDiacritics","cmpgid="+document.getElementById('cmpgid').value+"&diacritics="+document.getElementById('diacritics').checked,"POST");	
//alert(raspuns);
}
function changeDiacriticsForMessage()
{
	if(document.getElementById('diacritics').checked)
	{
		document.getElementById('diacritic').innerHTML='';
	}
	else
	{
		document.getElementById('diacritic').innerHTML = 'Right now you will replace diacritics with HTML code only in autoresponders';
	}
	var raspuns=sendRequest("index.php?m=listsnew&s=editlist&o=replaceDiacritics","listid="+document.getElementById('list_id').value+"&diacritics="+document.getElementById('diacritics').checked,"POST");	
}

function changeHistoryForMessage()
{
	if(document.getElementById('history').checked)
	{
		document.getElementById('history').innerHTML='<b>This list will record history  events.Uncheck if you want to cancel </b>';
	}
	else
	{
		document.getElementById('history').innerHTML='<b>This list will not record history  events.Check if you want to record all history events </b>';
	}
	var raspuns=sendRequest("index.php?m=listsnew&s=editlist&o=replaceHistory","listid="+document.getElementById('list_id').value+"&history="+document.getElementById('history').checked,"POST");	
}

var displaySwitch = {
	clickId: '#switchArchiveDispayId',
	targetId: '#tcaId',
	run: function () {
		if($(displaySwitch.targetId).css('display') == 'none') {
			$(displaySwitch.targetId).slideDown();
			$(displaySwitch.clickId).html('Collapse -');
		} else {
			$(displaySwitch.targetId).slideUp();
			$(displaySwitch.clickId).html('Expand +');
		}
	}
};
$(document).ready(function() {
  	$('.export_csv_with_sep').click (function () {
		var separator = prompt("Enter the separator for your export", ",");
		document.location.href=this.href+'&separator='+separator;
		return false;
	});
});


//-->
