function doBlink() {
  var blink = document.all.tags("BLINK")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  if (document.all)
    setInterval("doBlink()",500)
}
function checkEmail(emailString) {
	splitVal = emailString.split('@');
	if(splitVal.length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	if(splitVal[0].length <= 0 || splitVal[1].length <= 0) {
		alert("Please enter a valid email address");
		return false;
	}
	
	splitDomain = splitVal[1].split('.');
	if(splitDomain.length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	if(splitDomain[0].length <= 0 || splitDomain[1].length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	return true;
}
function trimSpaces(stringValue) {
	// Checks the first occurance of spaces and removes them
	for(i = 0; i < stringValue.length; i++) {
		if(stringValue.charAt(i) != " ") {
			break;
		}
	}
	if(i > 0) {
		stringValue = stringValue.substring(i);
	}
	
	// Checks the last occurance of spaces and removes them
	strLength = stringValue.length - 1;
	for(i = strLength; i >= 0; i--) {
		if(stringValue.charAt(i) != " ") {
			break;
		}
	}
	if(i < strLength) {
		stringValue = stringValue.substring(0, i + 1);
	}
	
	// Returns the string after removing leading and trailing spaces.
	return stringValue;
}
function showProjectPhoto(photoname) 
{ 
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 900;
	winHeight = 720;
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2; 
	window.open("showProjectPhoto.php?photoname=" + photoname,"ProjectPhoto","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function opendynamicwindow(url) 
{ 
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 920;
	winHeight = 720;
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2; 
	window.open(url,"ProjectPhoto","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function opendynamicnewwindow(url) 
{ 
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth =600;
	winHeight = 600;
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2; 
	window.open(url,"newwindow","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function newsletterhome() {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth=776;
	winHeight=680; 
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open("newsletter/newsletter.htm", "recipes", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function signup() {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth=400;
	winHeight=360; 
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open("php/ebu.php", "recipes", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
} 
function incnewsletter() {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth=776;
	winHeight=680; 
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open("../newsletter/newsletter.htm", "recipes", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function incsignup() {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth=400;
	winHeight=360; 
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open("ebu.php", "recipes", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
} 
function forplanview(prid)
{

PopUp('php/showForplans.php?projid='+prid);
function PopUp(url)
				{ 
					//alert(url);
					day = new Date();
					id = day.getTime();
					eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=2,location=0,statusbar=0,menubar=0,resizable=0,width=900,height=700,left = 262,top = 0');");
				}


}
function checkContact() 
{
       
 uname=trimSpaces(document.forms[0].uname.value);
 email=trimSpaces(document.forms[0].email.value);
address=trimSpaces(document.forms[0].address.value);
phone=trimSpaces(document.forms[0].phone.value);

  if(uname.length<=0)
  { 
	 alert("You have to enter your name.");
		document.forms[0].uname.focus();
		return false;
  }

  if(address.length<=0)
  { 
	 alert("You have to enter your address.");
		document.forms[0].address.focus();
		return false;
  }
  if(phone.length<=0)
  { 
	 alert("You have to enter your phone number.");
		document.forms[0].phone.focus();
		return false;
  }
  
		if(!checkEmail(email)) {
			document.forms[0].email.focus();
			return false;
	 }
  
	document.forms[0].frmAction.value="Update"; 
	return true;
}

function checkGuestBook()
{
	uname=trimSpaces(document.forms[0].uname.value);
 	email=trimSpaces(document.forms[0].email.value);
	phone=trimSpaces(document.forms[0].phone.value);
	
	if(uname.length<=0)
  	{ 
	 	alert("You have to enter your name.");
		document.forms[0].uname.focus();
		return false;
  	}
	
	if(phone.length<=0)
  	{ 
	 	alert("You have to enter your phone number.");
		document.forms[0].phone.focus();
		return false;
  	}
	
	if(!checkEmail(email))
	{
		document.forms[0].email.focus();
		return false;
	}
	return true;
}

function checkOrder()
{
	appName=trimSpaces(document.forms[0].appName.value);
 	appEmail=trimSpaces(document.forms[0].appEmail.value);
	appPhone=trimSpaces(document.forms[0].appPhone.value);
	
	if(appName.length<=0)
  	{ 
	 	alert("You have to enter your name.");
		document.forms[0].appName.focus();
		return false;
  	}
	
	if(appPhone.length<=0)
  	{ 
	 	alert("You have to enter your phone number.");
		document.forms[0].appPhone.focus();
		return false;
  	}
	
	if(!checkEmail(appEmail))
	{
		document.forms[0].appEmail.focus();
		return false;
	}
	return true;
}

function checkEmailfrnd()
{
	yourName=trimSpaces(document.forms[0].yourName.value);
 	yourEmail=trimSpaces(document.forms[0].yourEmail.value);
	
	frndName=trimSpaces(document.forms[0].frndName.value);
 	frndEmail=trimSpaces(document.forms[0].frndEmail.value);
	
	if(yourName.length<=0)
  	{ 
	 	alert("You have to enter your name.");
		document.forms[0].yourName.focus();
		return false;
  	}
	
	if(!checkEmail(yourEmail))
	{
		document.forms[0].yourEmail.focus();
		return false;
	}
	
	if(frndName.length<=0)
  	{ 
	 	alert("You have to enter your friend's name.");
		document.forms[0].frndName.focus();
		return false;
  	}
	
	if(!checkEmail(frndEmail))
	{
		document.forms[0].frndEmail.focus();
		return false;
	}
	
	return true;
}

function speciview(prid)
{

PopUp('showSpec.php?projid='+prid);
function PopUp(url)
				{ 
					//alert(url);
					day = new Date();
					id = day.getTime();
					eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=2,location=0,statusbar=0,menubar=0,resizable=0,width=900,height=700,left = 262,top = 0');");
				}


}

function speciview1(prid)
{

PopUp('php/showSpec.php?projid='+prid);
function PopUp(url)
				{ 
					//alert(url);
					day = new Date();
					id = day.getTime();
					eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=2,location=0,statusbar=0,menubar=0,resizable=0,width=900,height=700,left = 262,top = 0');");
				}


}