// JavaScript Document
function MM_goToURL() {
  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 ignoreEvent(e) {
	if (!e || !e.stopPropagation)
		window.event.cancelBubble = true;
	else
		e.stopPropagation();
}

function CheckDelFormAndSubmit() {
if(confirm("Are you sure you want to delete the selected records ? \n Warning: This operation is irreversible !!!"))
 document.frmDelete.submit();
}

function CheckCopyFormAndSubmit(id) {
	var ii = "";
	if (id > 0) ii = "?bid=" + id;
	document.frmDelete.action = "php/act_copy_messages.php" + ii;
	document.frmDelete.submit();
}

function RecallFormAndSubmit(id) {
	var re = "";
	if (id != undefined) {
		re = "?dirid=" +id;
	}
		else re = "?dirid=0";
	document.frmDelete.action = "php/act_recall_message.php" + re;
	document.frmDelete.submit();
}

function submitForm(id){
	document.temp_list.target="_self";
	if (id == 1) document.temp_list.action="http://www.emaileditor.nl/admin/campaign_create.php";
	if (id == 2) document.temp_list.action="http://www.emaileditor.nl/admin/campaign_modify.php";
	document.temp_list.submit();
}
function DelThis(delid) {
if(confirm("Are you sure you want to delete these records ? \n Warning: This operation is irreversible !!!")) {
		document.getElementById('loading').style.display  = 'block';
		MM_goToURL('parent', 'php/act_delete_activelists.php?id='+delid) 
	}
}

function CheckName() {
	if (document.filters.name.value == "") {
			alert("Missing Filter Name!");
			return false;
	}
	document.filters.submit();

}

function CheckCombos() {
	document.getElementById('loading').style.display  = 'block'; 
	document.temp_list.submit();
}



function checkItem(txF, dvName_) {	
	ret = 1;
	style_ = 'stFormCellText';
	item_ = document.getElementById(dvName_);
	if(txF.value == '') {
		style_ = "stFormCellTextError";		
		ret = 0;
	}
	item_.className = style_;
	return ret;
}

function setDVstyle(dv, st){
	item_ = document.getElementById(dv);
	item_.className = st;
}


function hideDiv(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showDiv(id) {		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}


function toggle_visibility(id) {
	var e = document.getElementById(id);
	if(e.style.display == 'none')
		e.style.display = 'block';
	else
		e.style.display = 'none';
}


function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)

	 if (str.indexOf(at)==-1) return false
	 if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false
 	 if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || ldot+1==lstr) return false
	 if (str.indexOf(at,(lat+1))!=-1) return false
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false
	 if (str.indexOf(dot,(lat+2))==-1) return false		
	 if (str.indexOf(" ")!=-1) return false
	
	return true					
}

function isNumeric(sText) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++)  { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1)
		return false;
   }
	return true;
}


var dtCh= "-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strYear=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strDay=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1) return false;
	if (strMonth.length<1 || month<1 || month>12) return false;
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]) return false;
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear) return false;
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false) return false;
return true;
}


function gotoTabel(month,day){
	document.getElementById('mailstat').src="mailingstatistics_tabel.php?date1=2007-" + month + "-" + day +" 00:00:00&date2=2007-" + month + "-" + day + " 23:59:59";
}

function gotoTabelMonth(month, lday){
	document.getElementById('mailstat').src="mailingstatistics_tabel.php?date1=2007-" + month + "-01 00:00:00&date2=2007-" + month + "-" + lday + " 23:59:59";
}

function gotoStatistics(id){
	document.getElementById('statistics').src="mailingstatistics_show.php?id=" + id;
}

function divshow(){
	toggle_visibility('inpUnsubscr');
	toggle_visibility('unurl');
}

function divshow2(){
	toggle_visibility('personalization');
}

function formeditor(){
	if (document.form_manager.list.value != '') {
		document.form_manager.action = "formmanager.php?lid=" + document.form_manager.list.value;
		document.form_manager.submit();
	}
	else {
		document.form_manager.action = "formmanager.php";
		document.form_manager.submit();
	}	 
}

function LoadPopup(doc, w, h) {
	if (!w) w=580;
	if (!h) h=600;
	win = window.open(doc, "BC", 'status=no,toolbar=0,scrollbars=1,menubar=0,titlebar=0,resizable=0,width='+w+',height='+h);
	win.moveTo(screen.width/2-w/2, screen.height/2-h/2);
	win.focus();
}

function delFile(filename, mesid, id, type){
	if (type == 1)	document.message.action="php/act_delete_file.php?fn=" + filename + "&message_id=" + mesid + "&id=" +id;
		else document.message.action="php/act_delete_file2.php?fn=" + filename + "&message_id=" + mesid + "&id=" +id;
	document.message.submit();
}

function download(){
	document.frmDelete.action="saveactivelist.php";
	document.frmDelete.submit();
}

function del_img(id, uid){
	document.tfriend.action="php/act_del_tfriend.php?act="+id +"&uid=" + uid;
	document.tfriend.submit();
}

function changeLink(){
	document.getElementById('link').innerHTML =  "http://www.emaileditor.nl/order.php?id=" + document.message.actioncode.value;
}

function changeLink2(){
	document.getElementById('link').innerHTML =  "http://www.emaileditor.nl/order.php?id=" + document.message.actioncode.value + "&email=[0]&cnum=[2]";
}

function addProd(){
	var num = parseInt(document.getElementById('nr').value) + 1;
	document.getElementById('nr').value = num;
	var name = "price_" + num;
	var name2 = name + "_1";
	var name3 =  "nr_price_" + num;
	var x=document.getElementById('myTable').insertRow(8+7*(num-1));
	var y=x.insertCell(0);
	var z=x.insertCell(1);
	x.vAlign="top";
	if (num == 1) y.innerHTML="<div class=\"stFormCellText\" id='inpProduct'>Product " + num + ": </div>";
		else y.innerHTML="<div class=\"stFormCellText\">Product " + num + ": </div>";
	z.innerHTML="<textarea rows=\"3\" cols=\"54\" name=\"prod_" + num + "\" class=\"stInput\"></textarea>";
	tinyMCE.execCommand('mceAddControl', false, 'prod_'+num);
	var x=document.getElementById('myTable').insertRow(9+7*(num-1));
	var y=x.insertCell(0);
	var z=x.insertCell(1);
	y.innerHTML="<div class='stFormCellText'>Image for Product " + num + ":</div>";
	z.innerHTML="<input type='file' name='img_" + num + "' class='stInput' />";
	var x=document.getElementById('myTable').insertRow(10+7*(num-1));
	var y=x.insertCell(0);
	var z=x.insertCell(1);
	y.innerHTML="<div class='stFormCellText'>Link for image " + num + ":</div>";
	z.innerHTML="<input type='file' name='linkimg_" + num + "' class='stInput' value='http://' />";
	var x=document.getElementById('myTable').insertRow(11+7*(num-1));
	var y=x.insertCell(0);
	var z=x.insertCell(1);
	x.vAlign="top";
	y.innerHTML="<div class='stFormCellText'>Text Image Top " + num + ":</div>";
	z.innerHTML="<textarea rows='3' cols='54' name='img_top_text_" + num + "' class='stInput'></textarea>";
	tinyMCE.execCommand('mceAddControl', false, 'img_top_text_'+num);
	var x=document.getElementById('myTable').insertRow(12+7*(num-1));
	var y=x.insertCell(0);
	var z=x.insertCell(1);
	x.vAlign="top";
	y.innerHTML="<div class=\"stFormCellText\">Text Image Bottom " + num + ": </div>";
	z.innerHTML="<textarea rows='3' cols='54' name='img_bottom_text_" + num + "' class='stInput'></textarea>";
	tinyMCE.execCommand('mceAddControl', false, 'img_bottom_text_'+num);
	var x=document.getElementById('myTable').insertRow(13+7*(num-1));
	var y=x.insertCell(0);
	var z=x.insertCell(1);
	y.innerHTML="<div class=\"stFormCellText\">Select Type " + num + ":</div>";
	z.innerHTML="<select name='ctype_" + num + "'><option value='0'>Square-box where a number can be inserted</option><option value='1'>Square-box which only can be selected - default on</option><option value='2'>Square-box which only can be selected - default off</option></select>";
	var x=document.getElementById('myTable').insertRow(14+7*(num-1));
	var y=x.insertCell(0);
	var z=x.insertCell(1);
	x.vAlign="top";
	y.innerHTML="<div class=\"stFormCellText\">Extra Information " + num + ": </div>";
	z.innerHTML="<textarea rows=\"3\" cols=\"54\" name=\"extra_" + num + "\" class=\"stInput\"></textarea>";
	tinyMCE.execCommand('mceAddControl', false, 'extra_'+num);
	var x=document.getElementById('myTable').insertRow(15+7*(num-1));
	var y=x.insertCell(0);
	var z=x.insertCell(1);
	x.vAlign="top";
	y.innerHTML="<div class=\"stFormCellText\">Price for Product " + num + ": </div>";
	z.innerHTML="<div id=\"" + name + "\"><input type=\"text\" name=\"" + name2 + "\" id=\"" + name2 + "\" class=\"stInput\" style=\"width:400px\" value=\"&euro;\" /></div><div class=\"stFormCellText\"><a href=\"javascript:addPrice(" + num + ");\" class=\"toplink\">Add Price</a></div><input type=\"hidden\" id=\"" + name3 + "\" value=\"1\" name=\"" + name3 + "\" />";
}

function addPrice(id){
	var name = "price_" + id;
	var name2 = "nr_price_" +id;
	var num = parseInt(document.getElementById(name2).value) + 1;
	document.getElementById(name2).value = num;
	var name3 = name + "_" + num;
	var a = new Array();
	for (i=1; i<num;i++) {
		names = "price_" + id + "_" + i;
		a[i] = document.getElementById(names).value;
	}
	document.getElementById(name).innerHTML = document.getElementById(name).innerHTML + "<div style='height:5px'></div><input type=\"text\" name=\"" + name3 + "\" id=\"" + name3 + "\" class=\"stInput\" style=\"width:400px\" value=\"&euro;\"/>";
	for (i=1;i<num;i++){
		names = "price_" + id + "_" + i;
		document.getElementById(names).value = a[i];
	}
}

function del_img_oo(id, uid){
	document.too.action="php/act_del_too.php?act="+id +"&uid=" + uid;
	document.too.submit();
}

function changeDesc(){
	if (document.campaign.message.value != "") {
		var a = document.campaign.description_values.value.split(',');
		for (i=0; i<a.length; i++){
			if (a[i] == document.campaign.message.value) document.campaign.description.value = a[i+1];
		}
	}
	else
		document.campaign.description.value = "";
}

function CheckPOAndSubmit() {
		 document.frmDelete.action = "php/act_publish_online.php";
		 document.frmDelete.submit();
}

function bounce_stat(){
	document.getElementById('loading').style.display='block';
	document.getElementById('message').style.display='none';
	document.account.submit();
}

function add_file(){
	var i = 1;
	document.getElementById('error').innerHTML = "";
	if ((document.account.name.value.indexOf("?") != -1) || (document.account.name.value.indexOf("%") != -1) || (document.account.name.value.indexOf("/") != -1) || (document.account.name.value.indexOf("\\") != -1) || (document.account.name.value.indexOf("*") != -1) || (document.account.name.value.indexOf(":") != -1) || (document.account.name.value.indexOf("|") != -1) || (document.account.name.value.indexOf("<") != -1) || (document.account.name.value.indexOf(">") != -1) || (document.account.name.value.indexOf(";") != -1) || (document.account.name.value.indexOf(",") != -1) || (document.account.name.value.indexOf("\"") != -1)) {
		document.getElementById('error').innerHTML='Do not use in the name: ?, %, /, \\, *, :, |, ", <, >, ;, ,';
		i=0;
	}
	if (document.account.csv.value == "") {
		setDVstyle('inpCsv','stFormCellTextError');
		i=0;
	}
	
	if (i == 1) {
		document.getElementById('loading').style.display='block';
		document.getElementById('message').style.display='none';
		document.account.submit();
	}
}

function redirect_to_del(){
	document.del.submit();
}

function to_files(){
	if (document.campaign.sdufile.value != 0) {
		document.campaign.action="sdu_list_select.php";
		document.campaign.submit();
	}
}

function to_files_mod(){
	if (document.campaign.sdufile.value != 0) {
		document.campaign.action="sdu_list_select.php?mod=1";
		document.campaign.submit();
	}
}

function changeYears(){
	var y;
	y=parseInt(document.stats.years.value)+2007;
	document.stats.action = "sendings.php?year=" + y + "&account=" + document.stats.cmbReseller.value;
	document.stats.submit();
}

function changeSMS(){
	var y;
	y=parseInt(document.stats.years.value)+2009;
	document.stats.action = "smssendings.php?year=" + y + "&account=" + document.stats.cmbReseller.value + "&type=" + document.stats.send_type.value;
	document.stats.submit();
}

function changeYearsSurvey(){
	var y;
	y=parseInt(document.stats.years.value)+2007;
	document.stats.action = "surveysendings.php?year=" + y + "&account=" + document.stats.cmbReseller.value;
	document.stats.submit();
}

function question_types(){
	var t = document.survey.types.value;
	if (t == 2) {
		showDiv('nq');
		hideDiv('mr');hideDiv('mradd');
		hideDiv('sr');hideDiv('sradd');
		hideDiv('ls');hideDiv('lsadd');
		hideDiv('lsr');hideDiv('lsradd');
	}
	if (t == 3) {
		showDiv('sr');showDiv('sradd');
		hideDiv('mr');hideDiv('mradd');
		hideDiv('ls');hideDiv('lsadd');
		hideDiv('lsr');hideDiv('lsradd');
		hideDiv('nq');
	}
	if (t == 4) {
		showDiv('mr');showDiv('mradd');
		hideDiv('sr');hideDiv('sradd');
		hideDiv('ls');hideDiv('lsadd');
		hideDiv('lsr');hideDiv('lsradd');
		hideDiv('nq');
	}
	if (t == 5) {
		showDiv('ls');showDiv('lsadd');
		showDiv('lsr');showDiv('lsradd');
		hideDiv('sr');hideDiv('sradd');
		hideDiv('mr');hideDiv('mradd');
		hideDiv('nq');
	}
	if (t == 1) {
		hideDiv('sr');hideDiv('sradd');
		hideDiv('mr');hideDiv('mradd');
		hideDiv('ls');hideDiv('lsadd');
		hideDiv('lsr');hideDiv('lsradd');
		hideDiv('nq');
	}
}

function add_resp(){
	var n = document.survey.srnr.value;
	var an = Array();
	var v;
	for (i=1;i<n;i++){
		v = 'resp_s'+i;
		an[i] = document.getElementById(v).value;
	}

	if (n.length == 1)
		document.getElementById('sr').innerHTML = document.getElementById('sr').innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_s" + n + "' class='stInput' style='width:250px' id='resp_s" + n + "'/></div>";
		else
			document.getElementById('sr').innerHTML = document.getElementById('sr').innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_s" + n + "' class='stInput' style='width:250px' id='resp_s" + n + "' /></div>";
	for (i=1;i<n;i++){
		v = 'resp_s'+i;
		document.getElementById(v).value = an[i];
	}
	document.survey.srnr.value = parseInt(n)+1;
}

function add_resp_m(id){
	var n = document.survey.mrnr.value;
	var an = Array();
	var v;
	for (i=1;i<n;i++){
		v = 'resp_m'+i;
		an[i] = document.getElementById(v).value;
	}

	if (n.length == 1)
		document.getElementById('mr').innerHTML = document.getElementById('mr').innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_m" + n + "' class='stInput' style='width:250px' id='resp_m" + n + "' /></div>";
		else
			document.getElementById('mr').innerHTML = document.getElementById('mr').innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_m" + n + "' class='stInput' style='width:250px' id='resp_m" + n + "' /></div>";
	for (i=1;i<n;i++){
		v = 'resp_m'+i;
		document.getElementById(v).value = an[i];
	}		
	document.survey.mrnr.value = parseInt(n)+1;
}

function add_resp_lsr(id){
	var n = document.survey.lsrnr.value;
	var an = Array();
	var v;
	for (i=1;i<n;i++){
		v = 'resp_lsr'+i;
		an[i] = document.getElementById(v).value;
	}

	if (n.length == 1)
		document.getElementById('lsr').innerHTML = document.getElementById('lsr').innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_lsr" + n + "' class='stInput' style='width:250px' id='resp_lsr" + n + "' /></div>";
		else
			document.getElementById('lsr').innerHTML = document.getElementById('lsr').innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_lsr" + n + "' class='stInput' style='width:250px' id='resp_lsr" + n + "' /></div>";
	for (i=1;i<n;i++){
		v = 'resp_lsr'+i;
		document.getElementById(v).value = an[i];
	}		
	document.survey.lsrnr.value = parseInt(n)+1;
}

function add_resp_ls(id){
	var n = document.survey.lsnr.value;
	var an = Array();
	var v;
	for (i=1;i<n;i++){
		v = 'resp_ls'+i;
		an[i] = document.getElementById(v).value;
	}

	if (n.length == 1)
		document.getElementById('ls').innerHTML = document.getElementById('ls').innerHTML + "<div style='margin-top:7px'>Variable" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_ls" + n + "' class='stInput' style='width:250px' id='resp_ls" + n + "' /></div>";
		else
			document.getElementById('ls').innerHTML = document.getElementById('ls').innerHTML + "<div style='margin-top:7px'>Variable" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_ls" + n + "' class='stInput' style='width:250px' id='resp_ls" + n + "' /></div>";
	for (i=1;i<n;i++){
		v = 'resp_ls'+i;
		document.getElementById(v).value = an[i];
	}		
	document.survey.lsnr.value = parseInt(n)+1;
}



function DeleteQuestion(id, sid){
	if ((id != "") && (sid != "")){
		document.survey.action ="php/act_question_delete.php?id=" + id + "&sid=" + sid;
		document.survey.submit();
	}
}

function DeleteQuestionOne(id, sid){
	if ((id != "") && (sid != "")){
		document.survey.action ="php/act_question_delete_one.php?id=" + id + "&sid=" + sid;
		document.survey.submit();
	}
}

function question_mod_types(id, typ){
	var t = document.getElementById(typ).value;
	if (t == 3) {
		showDiv('sr'+id);showDiv('sradd'+id);
		hideDiv('mr'+id);hideDiv('mradd'+id);
		hideDiv('ls'+id);hideDiv('lsadd'+id);
		hideDiv('lsr'+id);hideDiv('lsradd'+id);
		hideDiv('nq'+id);
	}
	if (t == 4) {
		showDiv('mr'+id);showDiv('mradd'+id)
		hideDiv('sr'+id);hideDiv('sradd'+id);
		hideDiv('ls'+id);hideDiv('lsadd'+id);
		hideDiv('lsr'+id);hideDiv('lsradd'+id);
		hideDiv('nq'+id);
	}
	if (t == 1) {
		hideDiv('sr'+id);hideDiv('sradd'+id);
		hideDiv('mr'+id);hideDiv('mradd'+id);
		hideDiv('ls'+id);hideDiv('lsadd'+id);
		hideDiv('lsr'+id);hideDiv('lsradd'+id);
		hideDiv('nq'+id);
	}
	if (t == 2) {
		showDiv('nq'+id);
		hideDiv('mr'+id);hideDiv('mradd'+id);
		hideDiv('sr'+id);hideDiv('sradd'+id);
		hideDiv('ls'+id);hideDiv('lsadd'+id);
		hideDiv('lsr'+id);hideDiv('lsradd'+id);
	}
	if (t == 5) {
		showDiv('ls'+id);showDiv('lsadd'+id);
		showDiv('lsr'+id);showDiv('lsradd'+id);
		hideDiv('sr'+id);hideDiv('sradd'+id);
		hideDiv('mr'+id);hideDiv('mradd'+id);
		hideDiv('nq'+id);
	}
}

function mod_resp_m(id, k){
	var n = document.getElementById(id).value;
	var an = Array();
	var v;
	for (i=1;i<n;i++){
		v = 'resp_m'+k+'_'+i;
		an[i] = document.getElementById(v).value;
	}

	if (n.length == 1)
		document.getElementById('mr'+k).innerHTML = document.getElementById('mr'+k).innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_m" + k + "_" + n + "' class='stInput' style='width:250px' id='resp_m" + k + "_" + n + "' /></div>";
		else
			document.getElementById('mr'+k).innerHTML = document.getElementById('mr'+k).innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;<input type='text' name='resp_m" + k + "_" + n + "' class='stInput' style='width:250px' id='resp_m" + k + "_" + n + "' /></div>";
	for (i=1;i<n;i++){
		v = 'resp_m'+k+'_'+i;
		document.getElementById(v).value = an[i];
	}		
	document.getElementById(id).value = parseInt(n)+1;
}

function mod_resp(id,k){
	var n = document.getElementById(id).value;
	var an = Array();
	var v;
	for (i=1;i<n;i++){
		v = 'resp_s'+k+'_'+i;
		an[i] = document.getElementById(v).value;
	}

	if (n.length == 1)
		document.getElementById('sr'+k).innerHTML = document.getElementById('sr'+k).innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_s" + k + "_" + n + "' class='stInput' style='width:250px' id='resp_s" + k + "_" + n + "'/></div>";
		else
			document.getElementById('sr'+k).innerHTML = document.getElementById('sr'+k).innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;<input type='text' name='resp_s" + k + "_" + n + "' class='stInput' style='width:250px' id='resp_s" + k + "_" + n + "' /></div>";
	for (i=1;i<n;i++){
		v = 'resp_s'+k+'_'+i;
		document.getElementById(v).value = an[i];
	}
	document.getElementById(id).value = parseInt(n)+1;
}

function mod_resp_ls(id,k){
	var n = document.getElementById(id).value;
	var an = Array();
	var v;
	for (i=1;i<n;i++){
		v = 'resp_ls' + k + '_' + i;
		an[i] = document.getElementById(v).value;
	}

	if (n.length == 1)
		document.getElementById('ls'+k).innerHTML = document.getElementById('ls'+k).innerHTML + "<div style='margin-top:7px'>Variable" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_ls" + k + "_" + n + "' class='stInput' style='width:250px' id='resp_ls" + k + "_" + n + "' /></div>";
		else
			document.getElementById('ls'+k).innerHTML = document.getElementById('ls'+k).innerHTML + "<div style='margin-top:7px'>Variable" + n + ":&nbsp;&nbsp;&nbsp;<input type='text' name='resp_ls" + k + "_" + n + "' class='stInput' style='width:250px' id='resp_ls" + k + "_" + n + "' /></div>";
	for (i=1;i<n;i++){
		v = 'resp_ls'+ k + '_' + i;
		document.getElementById(v).value = an[i];
	}		
	document.getElementById(id).value = parseInt(n)+1;
}

function mod_resp_lsr(id,k){
	var n = document.getElementById(id).value;
	var an = Array();
	var v;
	for (i=1;i<n;i++){
		v = 'resp_lsr' + k + '_' + i;
		an[i] = document.getElementById(v).value;
	}

	if (n.length == 1)
		document.getElementById('lsr'+k).innerHTML = document.getElementById('lsr'+k).innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='resp_lsr" + k + "_" + n + "' class='stInput' style='width:250px' id='resp_lsr" + k + "_" + n + "' /></div>";
		else
			document.getElementById('lsr'+k).innerHTML = document.getElementById('lsr'+k).innerHTML + "<div style='margin-top:7px'>Response" + n + ":&nbsp;&nbsp;&nbsp;<input type='text' name='resp_lsr"+ k + "_" +n + "' class='stInput' style='width:250px' id='resp_lsr"+ k + "_" + n + "' /></div>";
	for (i=1;i<n;i++){
		v = 'resp_lsr' + k + '_' + i;
		document.getElementById(v).value = an[i];
	}		
	document.getElementById(id).value = parseInt(n)+1;
}

function gotoUploadCSV(id){
	document.invitation.action="https://www.emaileditor.nl/admin/survey_fromcsv.php?mod=" +id;
	document.invitation.submit();	
}

function changeInv(id){
	if (id == '2'){
		document.getElementById('but2').style.display = 'none';
		document.getElementById('but2_2').style.display = 'block';
		document.getElementById('but1').style.display = 'none';
		document.getElementById('but1_2').style.display = 'block';
		document.getElementById('inv_plain').style.display = 'none';
		document.getElementById('inv_html').style.display = 'block';
		document.getElementById('inv_html_2').style.display = 'none';
		document.getElementById('ler').style.display = 'none';
	}
	if (id == '1'){
		document.getElementById('but2_2').style.display = 'none';
		document.getElementById('but2').style.display = 'block';
		document.getElementById('but1_2').style.display = 'none';
		document.getElementById('but1').style.display = 'block';
		document.getElementById('inv_plain').style.display = 'block';
		document.getElementById('inv_html').style.display = 'none';	
		document.getElementById('inv_html_2').style.display = 'block';	
		document.getElementById('ler').style.display = 'none';
	}
}

function changeDirectorys(){
	if (document.getElementById('dirs').value == -1){
		window.location="http://www.emaileditor.nl/admin/message_directorys.php";
	}
		else {
			window.location="http://www.emaileditor.nl/admin/messagecenter.php?dirid=" + document.getElementById('dirs').value;
		}
}
function changeDirectorysA(){
	if (document.getElementById('dirs').value == -1){
		window.location="http://www.emaileditor.nl/admin/message_directorys.php";
	}
		else {
			window.location="http://www.emaileditor.nl/admin/messages_archive.php?dirid=" + document.getElementById('dirs').value;
		}
}

function CheckDelDir() {
if(confirm("Are you sure you want to delete selected records ? \n WARNING: THIS OPERATION IS IRREVERSIBLE !!!")) {
 	document.frmDelete.submit();
	}
}

function changeDir(mid){
	document.message.action="php/act_changeDir.php?mid=" + mid + "&did=" + document.message.dirs.value;
	document.message.submit();
}

function addDir(mid){
	document.message.action="php/act_changeDir.php?mid=" + mid + "&did=" + document.message.dirs.value + "&add=1";
	document.message.submit();
}

function toShow(id){
	document.temp_list.target="_blank";
	document.temp_list.action="show_emails.php?type=" + id;
	document.temp_list.submit();
}

function change_sorting_order(ord, last_order, irany, id, pg){
	if (ord == last_order) {
		if (irany == 0) irany =1;
			else irany = 0;
		window.location="http://www.emaileditor.nl/admin/activelists_view.php?id=" + id + "&order=" + ord + "&irany=" + irany + "&pg=" + pg + "&search=" + document.getElementById('inpUserName').value;
;
		}
		else
			window.location="http://www.emaileditor.nl/admin/activelists_view.php?id=" + id + "&order=" + ord + "&irany=0&pg=" +pg + "&search=" + document.getElementById('inpUserName').value;

}

function checkGoToStep3(frm){
	if (frm.book.value == -1) {
		frm.action ="orderform_modify_step3.php?id=" + frm.formID.value;
		frm.submit();
	}
		else {
			frm.action ="php/act_orderform_modify_step2to3.php?add";
			frm.submit();	
		}
}

function checkAddGoToStep3(frm){
	if (frm.book.value == -1) {
		frm.action ="orderform_add_step3.php?id=" + frm.formID.value;
		frm.submit();
	}
		else {
			frm.action ="php/act_orderform_add_step2to3.php";
			frm.submit();	
		}
}

function checkAddOrderFormStep2to3(frm){
	if (frm.book.value == -1) {
		frm.action ="orderform_modify_step3.php?id=" + frm.formID.value;
		frm.submit();
	}
		else {
			frm.action ="php/act_orderform_modify_step2to3.php";
			frm.submit();	
		}
}

function setEditor(){
	if (document.getElementById('type').value == 2) {
		document.getElementById('new').style.display = "block";
		document.getElementById('old').style.display = "none";
	}
		else{
			document.getElementById('old').style.display = "block";
			document.getElementById('new').style.display = "none";	
		}
}

function del_img_ch(id, uid){
	document.tfriend.action="php/act_del_changeadr.php?act="+id +"&uid=" + uid;
	document.tfriend.submit();
}

function change_other(type, wh){
	var nume = "";
	if (type == 1) nume ="n";
	nume = nume + "click_" + wh;
	if (document.getElementById(nume).disabled == false) document.getElementById(nume).disabled = true;
		else document.getElementById(nume).disabled = false;
	count_adr();
}

function change_sorting_orderBlacklist(ord, last_order, irany, id, pg){
	if (ord == last_order) {
		if (irany == 0) irany =1;
			else irany = 0;
		window.location="http://www.emaileditor.nl/admin/blacklist.php?order=" + ord + "&irany=" + irany + "&pg=" +pg + "&inpCName=" + document.getElementById('inpCName').value + "&inpCEmail=" + document.getElementById('inpCEmail').value;
		}
		else
			window.location="http://www.emaileditor.nl/admin/blacklist.php?order=" + ord + "&irany=0&pg=" +pg + "&inpCName=" + document.getElementById('inpCName').value + "&inpCEmail=" + document.getElementById('inpCEmail').value;
}