var textfront;
var posleft = 0;
var postop = 0;

function refreshfront() {

	textfront = document.getElementById("inputfront").value;
	textfront = str_replace("\n","<br>",textfront);
	document.getElementById("textvorn").innerHTML = textfront;
}

function refreshback() {

	textback = document.getElementById("inputback").value;
	textback = str_replace("\n","<br>",textback);
	document.getElementById("texthinten").innerHTML = textback;
}

function changepic(pic) {

	document.getElementById("smc_divpic").style.background = "url('" + pic + "')";
	document.getElementById("input_pic").value = pic;
}

function changefontsize(fsize, id) {

	document.getElementById(id).style.fontSize = fsize;
}

function changetextalign(ta) {

	document.getElementById("textvorn").style.textAlign = ta;
}


function changefontcolor(fcolor, id) {

	document.getElementById(id).style.color = fcolor;
}


function changefontfamily(fface, id) {

	document.getElementById(id).style.fontFamily = fface;
}


function changefonttyp(ftyp, id) {

	if (ftyp == "bold") {
		document.getElementById(id).style.fontWeight = "bold";
		document.getElementById(id).style.fontStyle = "normal";
	}
	
	if (ftyp == "normal") {
		document.getElementById(id).style.fontWeight = "normal";
		document.getElementById(id).style.fontStyle = "normal";
	}	
	
	if (ftyp == "ib") {
		document.getElementById(id).style.fontWeight = "bold";
		document.getElementById(id).style.fontStyle = "italic";
	}

	if (ftyp == "italic") {
		document.getElementById(id).style.fontWeight = "normal";
		document.getElementById(id).style.fontStyle = "italic";
	}
		
}

function changepos(dir) {
	
	if (dir == "left")
		posleft = posleft - 10;
	if (dir == "right")
		posleft = posleft + 10;
	if (dir == "up")
		postop = postop - 10;
	if (dir == "down")
		postop = postop + 10;
	if (posleft < 0)
		posleft = 0;
	if (postop < 0)
		postop = 0;			

	document.getElementById("textvorn").style.margin = postop + "px 0px 0px " + posleft + "px";
	document.getElementById("input_postop").value = postop;
	document.getElementById("input_posleft").value = posleft;
}

function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
}

function checkEmail(emailadr) {

	reg_ex5=/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/;
	
	if(reg_ex5.test(emailadr)) 
		return true;
	else
		return false;	
}


function checkform() {

	var fehler = false;
	var msg = "";

	if (!checkEmail(document.getElementById("empf_email").value)) {
	
		fehler = true;
		msg = "Invalid email-address for recipient";
	}

	if (document.getElementById("empf_name").value == "") {
	
		fehler = true;
		msg = "Please enter the name of the recipient";
	}

	if (!checkEmail(document.getElementById("abs_email").value)) {
	
		fehler = true;
		msg = "Invalid email-address for sender";
	}

	if (document.getElementById("abs_name").value == "") {
	
		fehler = true;
		msg = "Please enter the name of the sender";
	}
	
	
	if (fehler) {
		alert(msg);
	}
	else {
		document.sendcard.submit();
	}

}
