function setUpScripts() {
	borderReplace("main");
}
//
function borderReplace(container) {
	//
	var allElements;
	//
	if(container){
		allElements = document.getElementById(container).getElementsByTagName("*");
	} else {
		allElements = document.getElementsByTagName("*");
	}
	var cornerElements = new Array();
	var borderElements = new Array();
	var dropElements = new Array();
	//
	for(var i=0; i<allElements.length; i++){
		//
		var tempClassNameArray = allElements[i].className.split(" ");
		//
		for(var k=0; k<tempClassNameArray.length; k++) {
			if(tempClassNameArray[k] == "setCorner"){
				cornerElements.push(allElements[i]);
				break
			} else if(tempClassNameArray[k] == "setBorder"){
				borderElements.push(allElements[i]);
				break
			} else if (tempClassNameArray[k] == "setDrop") {
				dropElements.push(allElements[i]);
				break
			}
		}
		//
	}
	//	
	for(var i=0; i<cornerElements.length; i++){
		//
		var source = cornerElements[i];
		//
		var width = source.offsetWidth;
		var height = source.offsetHeight;
		//
		var topleft = document.createElement("span");
		topleft.className = "topleft brdr";
		//
		var topright = document.createElement("span");
		topright.className = "topright brdr";
		//
		var bottomleft = document.createElement("span");
		bottomleft.className = "bottomleft brdr";
		//
		var bottomright = document.createElement("span");
		bottomright.className = "bottomright brdr";
		//
		if(source.tagName != "IMG" && source.tagName != "img"){
			source.appendChild(topleft);
			source.appendChild(topright);
			source.appendChild(bottomleft);
			source.appendChild(bottomright);
		} else {
			var mainDiv = document.createElement("div");
			//
			mainDiv.style.height = height+"px";
			mainDiv.style.width = width+"px";
			//
			stripStyles(source, mainDiv);
			//
			mainDiv.appendChild(source.cloneNode(true));
			mainDiv.appendChild(topleft);
			mainDiv.appendChild(topright);
			mainDiv.appendChild(bottomleft);
			mainDiv.appendChild(bottomright);
			//
			source.parentNode.replaceChild(mainDiv, source);
		}
		//
	}
	//
	for(var i=0; i<borderElements.length; i++){
		//
		var source = borderElements[i];
		//
		var tempClassNameArray = source.className.split(" ");
		var borderType = tempClassNameArray[1];
		//
		var width = source.offsetWidth;
		var height = source.offsetHeight;
		//
		var borderTopWidth = stripUnits(getStyle(source, 'borderTopWidth'));
		var borderLeftWidth = stripUnits(getStyle(source, 'borderLeftWidth'));
		var borderRightWidth = stripUnits(getStyle(source, 'borderRightWidth'));
		var borderBottomWidth = stripUnits(getStyle(source, 'borderBottomWidth'));
		//
		//
		if(source.tagName == "IMG" || source.tagName == "img"){
			borderTopWidth = 0;
			borderLeftWidth = 0;
			borderRightWidth = 0;
			borderBottomWidth = 0;
		}
		//
		var borderImgSize = 7;
		//
		var top = document.createElement("span");
		top.className = "top brdr";
		top.style.height = borderImgSize+"px";
		top.style.width = width+"px";
		top.style.top = "-"+(borderImgSize+borderTopWidth)+"px";
		top.style.left = "-"+borderLeftWidth+"px";
		top.style.backgroundImage = 'url("images/borders/'+borderType+'/top_tile.gif")';
		top.style.backgroundPosition = "bottom left";
		top.style.backgroundRepeat = "repeat-x";
		//
		var bottom = document.createElement("span");
		bottom.className = "bottom brdr";
		bottom.style.height = borderImgSize+"px";
		bottom.style.width = width+"px";
		bottom.style.bottom = "-"+(borderImgSize+borderBottomWidth)+"px";
		bottom.style.left = "-"+borderLeftWidth+"px";
		bottom.style.backgroundImage = 'url("images/borders/'+borderType+'/bottom_tile.gif")';
		bottom.style.backgroundPosition = "top left";
		bottom.style.backgroundRepeat = "repeat-x";
		//
		var left = document.createElement("span");
		left.className = "left brdr";
		left.style.height = height+"px";
		left.style.width = borderImgSize+"px";
		left.style.top = "-"+borderTopWidth+"px";
		left.style.left = "-"+(borderImgSize+borderLeftWidth)+"px";
		left.style.backgroundImage = 'url("images/borders/'+borderType+'/left_tile.gif")';
		left.style.backgroundPosition = "top right";
		left.style.backgroundRepeat = "repeat-y";
		//
		var right = document.createElement("span");
		right.className = "right brdr";
		right.style.height = height+"px";
		right.style.width = borderImgSize+"px";
		right.style.top = "-"+borderTopWidth+"px";
		right.style.right = "-"+(borderImgSize+borderRightWidth)+"px";
		right.style.backgroundImage = 'url("images/borders/'+borderType+'/right_tile.gif")';
		right.style.backgroundPosition = "top left";
		right.style.backgroundRepeat = "repeat-y";
		//
		var topleft = document.createElement("span");
		topleft.className = "topleft brdr";
		topleft.style.height = borderImgSize+"px";
		topleft.style.width = borderImgSize+"px";
		topleft.style.top = "-"+(borderImgSize+borderTopWidth)+"px";
		topleft.style.left = "-"+(borderImgSize+borderLeftWidth)+"px";
		topleft.style.backgroundImage = 'url("images/borders/'+borderType+'/top_left.gif")';
		topleft.style.backgroundPosition = "bottom right";
		topleft.style.backgroundRepeat = "no-repeat";
		//
		var topright = document.createElement("span");
		topright.className = "topright brdr";
		topright.style.height = borderImgSize+"px";
		topright.style.width = borderImgSize+"px";
		topright.style.top = "-"+(borderImgSize+borderTopWidth)+"px";
		topright.style.right = "-"+(borderImgSize+borderRightWidth)+"px";
		topright.style.backgroundImage = 'url("images/borders/'+borderType+'/top_right.gif")';
		topright.style.backgroundPosition = "bottom left";
		topright.style.backgroundRepeat = "no-repeat";
		//
		var bottomleft = document.createElement("span");
		bottomleft.className = "bottomleft brdr";
		bottomleft.style.height = borderImgSize+"px";
		bottomleft.style.width = borderImgSize+"px";
		bottomleft.style.bottom = "-"+(borderImgSize+borderBottomWidth)+"px";
		bottomleft.style.left = "-"+(borderImgSize+borderLeftWidth)+"px";
		bottomleft.style.backgroundImage = 'url("images/borders/'+borderType+'/bottom_left.gif")';
		bottomleft.style.backgroundPosition = "top right";
		bottomleft.style.backgroundRepeat = "no-repeat";
		//
		var bottomright = document.createElement("span");
		bottomright.className = "bottomright brdr";
		bottomright.style.height = borderImgSize+"px";
		bottomright.style.width = borderImgSize+"px";
		bottomright.style.bottom = "-"+(borderImgSize+borderBottomWidth)+"px";
		bottomright.style.right = "-"+(borderImgSize+borderRightWidth)+"px";
		bottomright.style.backgroundImage = 'url("images/borders/'+borderType+'/bottom_right.gif")';
		bottomright.style.backgroundPosition = "top left";
		bottomright.style.backgroundRepeat = "no-repeat";
		//
		//
		if(source.tagName != "IMG" && source.tagName != "img"){
			source.appendChild(top);
			source.appendChild(bottom);
			source.appendChild(left);
			source.appendChild(right);
			source.appendChild(topleft);
			source.appendChild(topright);
			source.appendChild(bottomleft);
			source.appendChild(bottomright);
		} else {
			var mainDiv = document.createElement("div");
			//
			mainDiv.style.height = height+"px";
			mainDiv.style.width = width+"px";
			//
			stripStyles(source, mainDiv);
			//
			mainDiv.appendChild(source.cloneNode(true));
			mainDiv.appendChild(top);
			mainDiv.appendChild(bottom);
			mainDiv.appendChild(left);
			mainDiv.appendChild(right);
			mainDiv.appendChild(topleft);
			mainDiv.appendChild(topright);
			mainDiv.appendChild(bottomleft);
			mainDiv.appendChild(bottomright);
			//
			source.parentNode.replaceChild(mainDiv, source);
		}
		//
	}
	//
	for(var i=0; i<dropElements.length; i++){
		//
		var source = dropElements[i];
		//
		var tempClassNameArray = source.className.split(" ");
		var borderType = tempClassNameArray[1];
		//
		var width = source.offsetWidth;
		var height = source.offsetHeight;
		//
		var borderTopWidth = stripUnits(getStyle(source, 'borderTopWidth'));
		var borderLeftWidth = stripUnits(getStyle(source, 'borderLeftWidth'));
		var borderRightWidth = stripUnits(getStyle(source, 'borderRightWidth'));
		var borderBottomWidth = stripUnits(getStyle(source, 'borderBottomWidth'));
		//
		if(source.tagName == "IMG" || source.tagName == "img"){
			borderTopWidth = 0;
			borderLeftWidth = 0;
			borderRightWidth = 0;
			borderBottomWidth = 0;
		}
		//
		var borderImgSize = 7;
		//
		var bottom = document.createElement("span");
		bottom.className = "bottom brdr";
		bottom.style.height = borderImgSize+"px";
		bottom.style.width = width+borderLeftWidth+borderRightWidth+(borderImgSize*2)+"px";
		bottom.style.bottom = "-"+(borderImgSize+borderBottomWidth)+"px";
		bottom.style.left = "-"+(borderImgSize+borderLeftWidth)+"px";
		bottom.style.backgroundImage = 'url("images/borders/'+borderType+'/bottom.gif")';
		bottom.style.backgroundPosition = "top center";
		bottom.style.backgroundRepeat = "no-repeat";
		//
		var left = document.createElement("span");
		left.className = "left brdr";
		left.style.height = height+"px";
		left.style.width = borderImgSize+"px";
		left.style.top = "-"+(borderBottomWidth+borderTopWidth)+"px";
		left.style.left = "-"+(borderImgSize+borderLeftWidth)+"px";
		left.style.backgroundImage = 'url("images/borders/'+borderType+'/left.gif")';
		left.style.backgroundPosition = "bottom right";
		left.style.backgroundRepeat = "no-repeat";
		//
		var right = document.createElement("span");
		right.className = "right brdr";
		right.style.height = height+"px";
		right.style.width = borderImgSize+"px";
		right.style.top = "-"+(borderBottomWidth+borderTopWidth)+"px";
		right.style.right = "-"+(borderImgSize+borderRightWidth)+"px";
		right.style.backgroundImage = 'url("images/borders/'+borderType+'/right.gif")';
		right.style.backgroundPosition = "bottom left";
		right.style.backgroundRepeat = "no-repeat";
		//
		if(source.tagName != "IMG" && source.tagName != "img"){
			source.appendChild(bottom);
			source.appendChild(left);
			source.appendChild(right);
		} else {
			var mainDiv = document.createElement("div");
			//
			mainDiv.style.height = height+"px";
			mainDiv.style.width = width+"px";
			//
			stripStyles(source, mainDiv);
			//
			mainDiv.appendChild(source.cloneNode(true));
			
			mainDiv.appendChild(bottom);
			mainDiv.appendChild(left);
			mainDiv.appendChild(right);
			//
			source.parentNode.replaceChild(mainDiv, source);
		}
		//
	}
}
//
function getStyle(el, styleProp) {
	var y;
	if (el.currentStyle) {
		y = el.currentStyle[styleProp];
	} else if (document.defaultView.getComputedStyle) {
		var style = document.defaultView.getComputedStyle(el, null);
		y = style[styleProp];
	}
	return y;
}
//
function stripUnits(targetValue) {
	targetValue = targetValue.replace(/px/gi, "");
	targetValue = targetValue.replace(/%/g, "");
	targetValue = targetValue.replace(/em/gi, "");
	targetValue = Number(targetValue);
	if(isNaN(targetValue)){
		return false;
	} else {
		return targetValue;
	}
}
//
function stripStyles (targetElement, targetParent) {
	//
	/*targetParent.style.marginLeft = getStyle(targetElement, "marginLeft");
	targetParent.style.marginRight = getStyle(targetElement, "marginRight");
	targetParent.style.marginTop = getStyle(targetElement, "marginTop");
	targetParent.style.marginBottom = getStyle(targetElement, "marginBottom");
	targetElement.style.margin = "0";
	//
	targetElement.style.paddingLeft = getStyle(targetElement, "paddingLeft");
	targetElement.style.paddingRight = getStyle(targetElement, "paddingRight");
	targetElement.style.paddingTop = getStyle(targetElement, "paddingTop");
	targetElement.style.paddingBottom = getStyle(targetElement, "paddingBottom");
	//
	targetElement.style.borderTopWidth = getStyle(targetElement, "borderTopWidth");
	targetElement.style.borderBottomWidth = getStyle(targetElement, "borderBottomWidth");
	targetElement.style.borderLeftWidth = getStyle(targetElement, "borderLeftWidth");
	targetElement.style.borderRightWidth = getStyle(targetElement, "borderRightWidth");
	targetElement.style.borderTopStyle = getStyle(targetElement, "borderTopStyle");
	targetElement.style.borderBottomStyle = getStyle(targetElement, "borderTopStyle");
	targetElement.style.borderLeftStyle = getStyle(targetElement, "borderTopStyle");
	targetElement.style.borderRightStyle = getStyle(targetElement, "borderTopStyle");
	targetElement.style.borderTopColor = getStyle(targetElement, "borderTopColor");
	targetElement.style.borderBottomColor = getStyle(targetElement, "borderBottomColor");
	targetElement.style.borderLeftColor = getStyle(targetElement, "borderLeftColor");
	targetElement.style.borderRightColor = getStyle(targetElement, "borderRightColor");*/
	//
	targetParent.className = targetElement.className;
	targetParent.id = targetElement.id;
	targetElement.className = "child";
	targetElement.id = '';
	//
	if (targetElement.getAttribute("align") == "left") {
		targetParent.className += " borderedImageLeft";
	} else if (targetElement.getAttribute("align") == "right") {
		targetParent.className += " borderedImageRight";
	}
	targetElement.removeAttribute("align");
}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=500,left = 415,top = 262');");
}

$(document).ready(function(){
	$("#mailing").validationEngine();
});
