var activeItem=""
//self.focus();

function BusinessCard(page) {
  window.open('/' + page + '','winContactPage','width=380,height=250,resizable=yes,status=no,scrollbars=yes,toolbar=no,copyhistory=no');
}

function newWindow(usePage,winName,winWidth,winHeight) {
  window.open('' + usePage + '','' + winName + '','width=' + winWidth + ',height=' + winHeight + ',resizable=yes,status=no,scrollbars=yes,toolbar=no,copyhistory=no');
}

function printWindow(printPage,winName,winWidth,winHeight) {
  window.open(''+ printPage +'','winPrintPage','width=750,height=480,resizable=yes,status=yes,scrollbars=yes,toolbar=no,copyhistory=no');
}

function viewImage(usePage,winName,winWidth,winHeight) {
  window.open('' + usePage + '','' + winName + '','width=' + winWidth + ',height=' + winHeight + ',resizable=yes,status=no,scrollbars=no,toolbar=no,copyhistory=no');
}

function setWindowHeight(){
	screenWidth = screen.width;
	screenHeight = screen.height;

	if (screenWidth == ""){maxWidth=780;} else {maxWidth=screenWidth;}
	if (screenHeight == ""){maxHeight=580;} else {maxHeight=screenHeight;}

	winWidth = document.body.offsetWidth + 50;
	winHeight = document.body.offsetHeight;

	selfHeight=self.document.body.scrollHeight;
	if (selfHeight>=maxHeight){newHeight=maxHeight;} else {newHeight=selfHeight;}

	// selfWidth=self.document.body.scrollWidth;
	// if (selfWidth>=maxWidth){newWidth=maxWidth;} else {newWidth=selfWidth;}

	self.resizeTo(winWidth,newHeight+100);
}

function setIframeHeight(inputElement){
	if (typeof inputElement=="object"){
		maxHeight=1000;
		tmpHeight=inputElement.contentWindow.document.body.scrollHeight;
		if (tmpHeight>=maxHeight){
			newHeight=maxHeight;
		}else{
			newHeight=tmpHeight;
		}
		inputElement.height=newHeight+5;
	}
}

function checkNumbers(strInput,okNumbers) {
	for (i=0;i<strInput.length;i++) {
		checkSubStr=strInput.substring(i,i+1)
		if (okNumbers.indexOf(checkSubStr) == -1){
			return false;
		}
	}
}

function showItem(itemID) {
	if (itemID.style.display == "none"){
		itemID.style.visibility="hidden";		
		itemID.style.display="";
		itemID.style.filter="blendTrans(duration=0.1)";
		if (itemID.filters.blendTrans.status != 2) {
			itemID.filters.blendTrans.apply();
			itemID.style.visibility="visible";
			itemID.filters.blendTrans.play();
		}
	}
}

function hideItem(itemID) {
	if (itemID.style.display == ""){
		itemID.style.filter="blendTrans(duration=0.1)";
		if (itemID.filters.blendTrans.status != 2) {
			itemID.filters.blendTrans.apply();
			itemID.style.visibility="hidden";
			itemID.filters.blendTrans.play();
			itemID.style.display="none";
		}
	}
}

function checkCheckbox(chkboxID,itemID){
	if (chkboxID.checked == true){
		showItem(itemID);
	}
	else {
		hideItem(itemID);
	}
}

function isEmail(str) {
  if (str=="")
	 return true;
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function printEmail(str1,str2,str3) {
	printStr = str1 + "@" + str2;
	if (str3 == "") {
		str3 = printStr;
	}
	document.write('<a href="mailto:' + printStr + '">' + str3 + '</a>');
}


function checkFormDate(check){
	var dateStr,dateArray;
	var dateDDCheck,dateMMCheck,dateYYCheck;
	dateDDCheck = false;
	dateMMCheck = false;
	dateYYCheck = false;
	dateStr = check;
	
	if(dateStr == "") {
	 return false;
	}
	dateArray = dateStr.split(".");
	
	if ((dateArray[0] > 0) && (dateArray[0] < 32)){
		dateDDCheck = true;	
	}
	if ((dateArray[1] > 0) && (dateArray[1] < 13)){
		dateMMCheck = true;	
	}
	if ((dateArray[2] > 1900) && (dateArray[2] < 2099)){
		dateYYCheck = true;	
	}
	if ((dateDDCheck) && (dateMMCheck) && (dateYYCheck)){
		return true;
	}
	else {
		return false;
	}
}