function cp(imgID){
	try{
		if (document.images["img" + imgID] && eval("img" + imgID + "Over.src")){
			document.images["img" + imgID].src=eval("img" + imgID + "Over.src");
		}
	}catch(er) {
	}
}

function cp2(imgID){
	try{
		if (document.images["img" + imgID] && eval("img" + imgID + ".src")){
			document.images["img" + imgID].src=eval("img" + imgID + ".src");
		}
	}catch(er) {
	}
}

function CP(imgID, Level){
	try{
		if (document.images["img" + imgID] && eval("imgL" + Level + "Over.src")){
			document.images["img" + imgID].src=eval("imgL" + Level + "Over.src");
		}
	}catch(er) {
	}
}

function CP2(imgID, Level){
	try{
		if (document.images["img" + imgID] && eval("imgL" + Level + ".src")){
			document.images["img" + imgID].src=eval("imgL" + Level + ".src");
		}
	}catch(er) {
	}
}

function SetContentHeight(){ //Enables
	DwTopGraphicHeight = 0;
	if(document.getElementById("DwTopGraphic")){
		if(document.getElementById("DwTopGraphic").length){
			for(var iDT = 0; iDT < document.getElementById("DwTopGraphic").length; iDT++){
				DwTopGraphicHeight += document.getElementById("DwTopGraphic")[iDT].offsetHeight;
			}
		}
		else{
			DwTopGraphicHeight += document.getElementById("DwTopGraphic").offsetHeight;
		}
	}

	DwFooterHeight = 0;
	if(document.getElementById("DwFooter")){
		if(document.getElementById("DwFooter").length){
			for(var iDT = 0; iDT < document.getElementById("DwFooter").length; iDT++){
				DwFooterHeight += document.getElementById("DwFooter")[iDT].offsetHeight;
			}
		}
		else{
			DwFooterHeight += document.getElementById("DwFooter").offsetHeight;
		}
	}

	if(document.getElementById("DwContentCell")){
		document.getElementById("DwContentCell").style.overflow = "auto";
		height = document.body.clientHeight - DwFooterHeight - DwTopGraphicHeight; //- 15
		document.getElementById("DwContentCell").style.height = height;
	}
}

function isRadioButtonChecked(theOption, theForm){ 
	if (theForm.elements[theOption].checked){
		return true;
	}
	else{
		for (i=0;i < theForm.elements[theOption].length;i++) {
			if (theForm.elements[theOption][i].checked) {
				return true;
			}
		}
	}
	return false;
}

function validateEmail( email ){
  var regExp = /^[\w\-_]+(\.[\w\-_]+)*@[\w\-_]+(\.[\w\-_]+)*\.[a-z]{2,4}$/i;
  return regExp.test( email );
}


function changeCardImage(dir){
	//document.EcardForm.ECardImage.src = dir + '/' + document.EcardForm.AttachImage.value;
	//Changed for both Forefox and IE7 compatibility
	document.getElementsByName('ECardImage')[0].src = dir + '/' + document.getElementsByName('AttachImage')[0].value;
}

function CookieTest() {
	document.cookie = 'test';
	if(document.getElementById('favorites')){
		if (document.cookie == "") {
			document.getElementById('favorites').style.display = 'none';
		}
		else {
			document.getElementById('favorites').style.display = 'block';
		}
	}
}

//Ecom
function popUp(url, name, w, h, extra){
	str="height="+h+",width="+w+","+extra;
	if(parseInt(navigator.appVersion)>3){
		str+=",left="+(screen.width -w)/2+",top="+parseInt((screen.height -h)/2);
	}

	window.open(url,name,str);
}

function Zoom(pic){ 
	if (document.images) {
		popUp('/admin/public/ShowTemplate.aspx?Template=ecom/ViewImage.html&Image='+pic, '_blank',450,350,'resizable=1,scrollbars=1');
	}
}

window.fCopyToClipboard = function(value){
	if(window.clipboardData){ 
		var r=clipboardData.setData('Text',value);
		alert(value + ' now in clipboard.')
	}
	return false;
}

function __ajaxGetXHTTPObject(readyStateFunc) {  
	var xhttp = false;
	if (window.ActiveXObject) {  
        try {  
			// IE 6 and higher 
			xhttp = new ActiveXObject("MSXML2.XMLHTTP"); 
			xhttp.onreadystatechange=readyStateFunc; 
        } catch (e) { 
            try { 
                // IE 5 
                xhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
				xhttp.onreadystatechange=readyStateFunc; 
            } catch (e) { 
                xhttp=false; 
            } 
        } 
	} 
    else if (window.XMLHttpRequest) { 
        try { 
            // Mozilla, Opera, Safari ... 
            xhttp = new XMLHttpRequest();
            /* little hack */
            xhttp.onreadystatechange = function () {
				readyStateFunc();
			};

        } catch (e) { 
            xhttp=false;
        } 
    }

	return xhttp;
}

function __ajaxGetPage(url, readyStateFunc) {
	var xhttp = __ajaxGetXHTTPObject(readyStateFunc);
	if (!xhttp) { 
        return; 
    } 
	
	/* lets get data */
	xhttp.open("GET", url, false);
	xhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
    xhttp.send(null);
    
    return xhttp.responseText;
}

