/**

PHP 3D Postcard generator v2.0.6
Copyright (c) 2008-2010 JF Nutbroek <jfnutbroek@gmail.com>
Visit http://www.mywebmymail.com for more information

See the included End User License Agreement (EULA)

*/

var boxname  = 'fontcolor';
var tempX    = 0;
var tempY    = 0;
var IE       = document.all?true:false;

document.onmousemove = getMouseXY;

function expandCollapse(divsection) {
    try {
        for(i=0;i<15;i++) {Collapse('div' + i);}
        var element = document.getElementById(divsection.replace(/#/,''));
        element.style.display = "block";
    } catch (err) {}
}

function Collapse(divsection) {
    try {
        var element = document.getElementById(divsection);
        element.style.display = "none";
    } catch (err) {}
}

function colorbox(inputobj) {
	try {
        eval("document.forms[0].colorsample_" + boxname + ".style.backgroundColor='#" + inputobj.value + "'");
    } catch(err) {
        eval("document.forms[0].colorsample_" + boxname + ".style.backgroundColor='#FAFAFA'");
    }
	if (inputobj.value.length<6) {eval("document.forms[0].colorsample_" + boxname + ".style.backgroundColor='#FAFAFA'");}
	this.targetobj=inputobj;
	if (boxname==inputobj.name) {setTimeout("colorbox(this.targetobj);",100);}
}

function selectcolor(inputobj) {
	try {
        eval("document.forms[0]." + boxname + ".value='" + inputobj.firstChild.nodeValue +"'");
        eval("document.forms[0]." + boxname + ".focus()");
    } catch(err) {}
}

function setcolors() {
	try {
	document.forms[0].colorsample_framecolor.style.backgroundColor='#' + document.forms[0].framecolor.value;
	document.forms[0].colorsample_framecolor.focus();	
	document.forms[0].colorsample_fontcolor.style.backgroundColor='#' + document.forms[0].fontcolor.value;	
	document.forms[0].colorsample_fontcolor.focus();	
	document.forms[0].colorsample_fontshadowcolor.style.backgroundColor='#' + document.forms[0].fontshadowcolor.value;
	document.forms[0].colorsample_fontshadowcolor.focus();	
	document.forms[0].colorsample_bordercolor.style.backgroundColor='#' + document.forms[0].bordercolor.value;
	document.forms[0].colorsample_bordercolor.focus();
        document.forms[0].colorsample_bgcolor.style.backgroundColor='#' + document.forms[0].bgcolor.value;
	document.forms[0].colorsample_bgcolor.focus();
	document.forms[0].colorsample_cardcolor.style.backgroundColor='#' + document.forms[0].cardcolor.value;
	document.forms[0].colorsample_cardcolor.focus();	
	document.forms[0].colorsample_bordercardcolor.style.backgroundColor='#' + document.forms[0].bordercardcolor.value;
	document.forms[0].colorsample_bordercardcolor.focus();
    } catch(err) {}
}

function getMouseXY(e) {
    try {
        if (IE) {
            tempX = event.clientX + document.body.scrollLeft;
            tempY = event.clientY + document.body.scrollTop;
        } else {
            tempX = e.pageX;
            tempY = e.pageY;
        }  
        tempX = tempX + 25;
        tempY = tempY - 25;        
        if (tempX < 0){tempX = 0;}
        if (tempY < 0){tempY = 0;}
    } catch (err) {}
}

function unhide(hiddenlayer,offsetx,offsety) {
    try {
        var element = document.getElementById(hiddenlayer);
	if (!offsetx) {var offsetx = 0;}
	if (!offsety) {var offsety = 0;}
        element.style.top = tempY - offsety + 'px';
	element.style.left = tempX - offsetx + 'px';
        element.style.visibility = 'visible';
    } catch (err) {}
}

function reseterror() {
    try {
        var element = document.getElementById('errorinfo');
        element.width = 1 + 'px';
        element.height = 1 + 'px';
    } catch (err) {}
}

function validateform() {
    try {
        var valid1=true;valid2=true;valid3=true;valid4=true;valid5=true;
        document.forms[0].mailfrom.style.backgroundColor='#FFFFFF';    
        document.forms[0].mailto.style.backgroundColor='#FFFFFF';
        document.forms[0].captcha.style.backgroundColor='#FFFFFF';
        document.forms[0].mailtoname.style.backgroundColor='#FFFFFF';
        document.forms[0].mailfromname.style.backgroundColor='#FFFFFF';          
        if (document.forms[0].mailfrom.value!='' && !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.forms[0].mailfrom.value))) {valid1=false;}
        if (document.forms[0].mailto.value!='' && !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.forms[0].mailto.value))) {valid2=false;}
        if (document.forms[0].mailfrom.value=='') {valid1=false;}
        if (document.forms[0].mailto.value=='') {valid2=false;}
        if (document.forms[0].captcha.value.length!=5) {valid3=false;} 
        if (document.forms[0].mailfromname.value=='') {valid4=false;} 
        if (document.forms[0].mailtoname.value=='') {valid5=false;}   
        if ((valid1 && valid2 && valid3 && valid4 && valid5)) {
            expandCollapse('div0');
            document.forms[0].submit();
        } else {
            document.forms[0].sendcard.value='0';
            if (!valid1) {document.forms[0].mailfrom.style.backgroundColor='#FF0000';}    
            if (!valid2) {document.forms[0].mailto.style.backgroundColor='#FF0000';}
            if (!valid3) {document.forms[0].captcha.style.backgroundColor='#FF0000';}
            if (!valid4) {document.forms[0].mailfromname.style.backgroundColor='#FF0000';}    
            if (!valid5) {document.forms[0].mailtoname.style.backgroundColor='#FF0000';}
        }
    } catch (err) {}
}

function setlayout() {
    try {   
        document.forms[0].borderx.value=setlayout.arguments[0];
        document.forms[0].bordery.value=setlayout.arguments[1];
        document.forms[0].shading.value=setlayout.arguments[2];
        document.forms[0].deformstrength.value=setlayout.arguments[3];
        document.forms[0].fontsize.value=setlayout.arguments[4];
        document.forms[0].fontangle.value=setlayout.arguments[5];
        document.forms[0].fontshadowoffset.value=setlayout.arguments[6];
        document.forms[0].outputsize.value=setlayout.arguments[7];
        document.forms[0].framewidth.value=setlayout.arguments[8];
        document.forms[0].framecolor.value=setlayout.arguments[9];
        document.forms[0].fontcolor.value=setlayout.arguments[10];
        document.forms[0].fontshadowcolor.value=setlayout.arguments[11];
        document.forms[0].bordercolor.value=setlayout.arguments[12];
        document.forms[0].bgcolor.value=setlayout.arguments[13];
        document.forms[0].cardcolor.value=setlayout.arguments[14];
        document.forms[0].bordercardcolor.value=setlayout.arguments[15];
        for(i=0;i<25;i++) {
            if (document.forms[0].watermark.options[i].value==setlayout.arguments[16])
                document.forms[0].watermark.selectedIndex=i;
        }
        setcolors();
        var path=document.forms[0].selectedpostcard.src;
        if (path.search(/selectedphoto.png/)>0) {
            document.forms[0].postcard.value='postcard09.jpg';
            document.forms[0].selectedpostcard.src='3dgfx/postcards/postcard09_thumb.jpg';
        }
    } catch (err) {}
}
