
function changeToLf(s) {
	regBr = /<br>/
	regLf = '\n';
	br = 'yes';
	string = s;
	
	if (string != "") {
		do {
	
			if (string.search(regBr) == -1) {
				br = 'no';
			} else {
				string = string.replace(regBr,regLf)
			}
		
		} while (br == 'yes')
	}
	
	return s=string
}

function changeToBr(s) {
	regBr = /\n/
	regLf = '<br>';
	br = 'yes';
	string = s;
	
	if (string != "") {
		do {
	
			if (string.search(regBr) == -1) {
				br = 'no';
			} else {
				string = string.replace(regBr,regLf)
			}
		
		} while (br == 'yes')
	}
	
	return s=string
}

function changeToUn(s) {
	regBl = ' ';
	regUn = '_';
	Bl = 'yes';
	string = s;
	
	if (string != "") {
		do {
	
			if (string.search(regBl) == -1) {
				Bl = 'no';
			} else {
				string = string.replace(regBl,regUn)
			}
		
		} while (Bl == 'yes')
	}
	
	return s=string
}

function changeToRSQuote(s) {
	regBl ='&rsquo;';
	regUn = '"';
	Bl = 'yes';
	string = s;
	
	if (string != "") {
		do {
	
			if (string.search(regBl) == -1) {
				Bl = 'no';
			} else {
				string = string.replace(regBl,regUn)
			}
		
		} while (Bl == 'yes')
	}
	
	return s=string
}


function changeToBl(s) {
	regBl = ' ';
	regUn = '_';
	Un = 'yes';
	string = s;
	
	if (string != "") {
		do {
	
			if (string.search(regUn) == -1) {
				Un = 'no';
			} else {
				string = string.replace(regUn,regBl)
			}
		
		} while (Un == 'yes')
	}
	
	return s=string
}

// Form Method = GET, Input Type = Hidden. 
function post(link, names, values) {

	var i, l;
	var form, input;

	if (names.length!=values.length)
		alert("Programming error, length of post arrays not same.");
	else {
		l=names.length;
		form=document.createElement("form");
		form.action=link;
		form.method="get";
		for (i=0;i<l;i++) {	
			input=document.createElement("input");
			input.type="hidden";
			input.name=names[i];
			input.value=values[i];
			form.appendChild(input);
		}
		document.body.appendChild(form);
		form.submit();
	}
}

// Form Method = POST, Input Type = Hidden. 
function postHidden(link, names, values) {

	var i, l;
	var form, input;

	if (names.length!=values.length)
		alert("Programming error, length of post arrays not same.");
	else {
		l=names.length;
		form=document.createElement("form");
		form.action=link;
		form.method="post";

		for (i=0;i<l;i++) {	
			input=document.createElement("input");
			input.type="hidden";
			input.name=names[i];
			input.value=values[i];
			form.appendChild(input);
		}
		document.body.appendChild(form);
		form.submit();
	}
}

//for pop up forms
function postHiddenPop(linkpage, names, values) {

	var i, l;
	var form, input;

	if (names.length!=values.length)
		alert("Programming error, length of post arrays not same.");
	else {
		l=names.length;
		form=document.createElement("form");
		form.action=linkpage;
		form.method="post";
		form.target = "timeDetails";

		for (i=0;i<l;i++) {	
			input=document.createElement("input");
			input.type="hidden";
			input.name=names[i];
			input.value=values[i];
			form.appendChild(input);
		}
		document.body.appendChild(form);
		form.submit();
	}
}

function popWindow(wName){
	windowWidth = getWindowWidth();
	windowHeight = getWindowHeight();
	
	
	
	width = windowWidth * 0.45;
	height = windowHeight * 0.7;
	top = (screen.height-height)/2;
	left = (screen.width-width)/2;
	otherParams="\'toolbar=0,scrollbar=\"yes\",location=0,align=\"center\",statusbar=1,menubar=0,resizable=1,width="+
				width+",height="+height+",top="+top+",left="+left+"\'";
	
	
	//features = 'width=400,height=400,toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no';
	pop = window.open('',wName,otherParams);
	if(pop.focus){ pop.focus(); }
	return true;
}
