function closeParent(){

	try{
		if(window.opener)
		{
			//alert("Yes")
			window.opener.location.href="http://www.bfr.com";
			window.close();
		}
		else
		{
			window.location.href="http://www.bfr.com";
		}
	}
	catch(e){
		window.location.href="http://www.bfr.com";
	}
}
var mymap
function openViewMapWin(url){
	mymap=window.open(url,'Window2','menubar=no,width=790,height=560,toolbar=no,resizable=0,scrollbars=yes,left=400,top=100,screenX=0,screenY=100');

	if(mymap){
		mymap.focus();
	}
}

function closemapwin(){

	try{
	if(mymap && mymap.open && !mymap.closed){
		mymap.close();
	}
	
	
	}	
	catch(e)
	{
		try{
			
			window.child.close();
		}
		catch(e){};
	}
}


var myaccount
function openMyAccount(){

	try{
		
		if(myaccount && myaccount.open && !myaccount.closed){
			myaccount.focus();
			
		}
		else
		{
			myaccount = window.open('https://devmya.bfr.com','myacctwin','menubar=yes,toolbar=yes,resizable=1,scrollbars=yes,location=yes,directories=yes,status=yes,alwaysRaised=true');
			myaccount.focus();
			try{
				myaccount.opener = window.opener.parent;
				
				window.close();
			}
			catch(e){}
		}
		


		
	}
	catch(e)
	{	
		
	}
}

function openHWin(url){


	//if(contents && contents.open && !contents.closed)
	//{
		if(url == "home")
		{
			
		}
		else
		{
			window.location.href= url
		}
	//}
	//else
	//{
		//contents = window.open(url,'Window3');
	//}

}

function printConfirmation(){
	
	var strfconfirm = document.getElementById("finalizeconfirm").innerHTML
	
	
	 var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      	 disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
 	
  
 	 var docprint=window.open("","fconfirm",disp_setting); 
  	 docprint.document.open(); 
	 docprint.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">')
  	 docprint.document.write('<html><head><title>Brook Furniture Rental - Finalize Confirmation</title>'); 
	 docprint.document.write('<link rel=stylesheet href="/css/styles.css" type="text/css">');
	 //docprint.document.write('<link rel=stylesheet href="/css/brook.css" type="text/css">');
	 docprint.document.write('<style>.rrtitleline { font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; color: #6f2001; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #6f2001;}</style>');
   	 docprint.document.write('</head><body onLoad="self.print()"><center><br>');          
  	 docprint.document.write('<table width="460" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="596" height="104">');
               	docprint.document.write('<img src="/images/BFRPrintLogo.jpg" border="0" alt="Brook Furniture Rental"></td></table><br>');
	
	docprint.document.write('<table width="460" cellspacing="0" cellpadding="0" border="0" >')
	
	docprint.document.write('<tr><td width="460" height="3"><p class="rrtitleline">Request Confirmation</p></td>')
	//docprint.document.write('</td></tr><tr><td width="460" height="40" class="whiteSpace"><br></td></tr>')	
	docprint.document.write('</table>')
	docprint.document.write(strfconfirm);     
	
	var a = docprint.document.getElementsByTagName("a");
	try{
	if(a[0].hasChildNodes())
       	 for(var i=0;i<a[0].childNodes.length;i++)
            		a[0].parentNode.insertBefore(a[0].childNodes[i].cloneNode(true),a[0]);
    
		a[0].parentNode.removeChild(a[0]);
	}
	catch(e)
	{}
  	 docprint.document.write('</center></body></html>'); 
  	 docprint.document.close(); 
  	 docprint.focus(); 
	// return false;
}


function printMap(){
	
	var strmapdetails = document.getElementById("container").innerHTML
	
	
	 var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      	 disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
 	
  
 	 var docprint=window.open("","mapdetails",disp_setting); 
  	 docprint.document.open(); 
	docprint.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">')
	docprint.document.write ('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Brook Furniture Rental - Showroom Locations</title>')
	docprint.document.write ('<link href="/css/brook.css" rel="stylesheet" type="text/css"  media="screen"/><link href="/css/brookprint.css" rel="stylesheet" type="text/css"  media="print"/>')
	docprint.document.write ('<link rel="stylesheet" href="/css/styles.css" type="text/css" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head>')
	docprint.document.write ('<body onLoad="self.print();window.resizeTo(790,645);" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">')
	 docprint.document.write(strmapdetails);     
	
	//var a = docprint.document.getElementsByTagName("a");
	var a = docprint.document.getElementById("mapprint")
	var lm = docprint.document.getElementById("largemap");
	a.style.display = "none";
	lm.style.display = "none";
  	 docprint.document.write('</center></body></html>'); 
  	 docprint.document.close(); 
  	 docprint.focus(); 
	// return false;
}



function printCatalogProduct(popimage){
	
	var strfconfirm = document.getElementById("catalogproduct").innerHTML
	
	
	 var disp_setting="toolbar=yes,location=no,directories=yes,"; 
      	 disp_setting+="menubar=no,width=630,height=500,toolbar=no,resizable=0"; 
 	
  
 	 var docprint=window.open("","cproduct",disp_setting); 
  	 docprint.document.open(); 
	 docprint.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">')
  	 docprint.document.write('<html><head><title>Brook Furniture Rental - Catalog Product</title>'); 
	 docprint.document.write('<link rel=stylesheet href="/css/styles.css" type="text/css">');
   	 docprint.document.write('</head><body onLoad="self.print()" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0"><center>');          
  	docprint.document.write('<table width="630" height="500" border="0" cellspacing="0" cellpadding="0">')
	docprint.document.write('<tr><td width="117" height="40" rowspan="6"  background="../images/popup_gradientbig.jpg" align="center"  valign="bottom"><img src="../images/popup_bfrlogo.png"><br>')
	docprint.document.write('</td><td colspan="2" width="500" height="40" class="popupHeader" background="../images/popup_gradient.jpg">' + popimage + ' - Product Detail</td></tr>')
	docprint.document.write('<tr><td width="499" height="1" class="popnewHR3x3"><img src="../../images/transp_1x1.gif" border="0"><br></td>')
	docprint.document.write('<td width="1" rowspan="5" class="popBorderBG"><img src="../../images/transp_1x1.gif" border="0"><br></td></tr>')
	docprint.document.write('<tr><td width="500" height="3" class="popnewHR3x3"><img src="../../images/transp_3x3.gif" border="0"><br></td>')
	docprint.document.write('</tr><tr><td width="500" valign="top">')
	docprint.document.write(strfconfirm);   
	docprint.document.write('</td></tr><tr><td width="500" height="1" class="popBorderBG">')
	docprint.document.write('<img src="../../images/transp_1x1.gif" border="0"><br></td></tr></table>')
	var a = docprint.document.getElementsByTagName("a");
	try{
	if(a[0].hasChildNodes())
       	 for(var i=0;i<a[0].childNodes.length;i++)
            		//a[0].parentNode.insertBefore(a[0].childNodes[i].cloneNode(true),a[0]);
    
		a[0].parentNode.removeChild(a[0]);
	}
	catch(e)
	{}
  	 docprint.document.write('</center></body></html>'); 
  	 docprint.document.close(); 
  	 docprint.focus(); 
	// return false;
}

function checkFeedbackform(){

	var FErrMsg = "";

	if(document.feedback.firstname.value == "")
	{
		FErrMsg = " * First Name is a required field \n";
	}
	if(document.feedback.phone.value == "")
	{
		FErrMsg = FErrMsg + " * Phone is a required field \n";
	}
	//else if(document.feedback.phone.value.search(/\d{3}\-\d{3}\-\d{4}/)==-1)
	//{
		//FErrMsg = FErrMsg + " * The phone number you entered is not valid.\r\nPlease enter a phone number with the format xxx-xxx-xxxx. \n";	
	//}
	
	if(document.feedback.emailaddress.value == "")
	{
		FErrMsg = FErrMsg + " * Email is a required field \n";
	}
	else if(document.feedback.emailaddress.value.indexOf('@')<0 || document.feedback.emailaddress.value.indexOf('.')<0)
	{
		FErrMsg = FErrMsg + " * The email address you have entered is invalid. Please enter a valid email address \n";	
	}

	if(document.feedback.feedbacktext.value == "")
	{
		FErrMsg = FErrMsg + " * Feedback is a required field \n";
	}
	for (var i=0; i < document.feedback.ptcontact.length; i++)
	{
		if (document.feedback.ptcontact[i].checked)
		{
			var rad_val = document.feedback.ptcontact[i].value;
      		}
   	}


	if(rad_val == "Yes" && document.feedback.contactp.value == "NA")
	{
		FErrMsg = FErrMsg + " * Please select Contact Preference \n";
	}
	
	if(FErrMsg !== "")
	{
		alert(FErrMsg);
		return false;
	}
}
function checkPLEF(){
	
	var PFErrMsg = "";
	if(document.pelf.companyname.value == "")
	{
		PFErrMsg = " * Company Name is a required field \n";
	}
	if(document.pelf.weblink.value == "")
	{
		PFErrMsg = PFErrMsg + " * Web link is a required field \n";
	}
	if (document.pelf.categoryid.value == 1) {
	    if (document.pelf.areaid.value == "0") {
	        PFErrMsg = PFErrMsg + " * Appropriate area is required \n";
	    }
	    else {
	        document.pelf.Hiddenareaid.value = document.pelf.areaid.value
	    }
	}
	//'else if (document.pelf.categoryid.value == 5) {
    else {
	   var area = "";
	   $("table tr").find("input:checked").each(function() {
	       if (area == "") {
	           area = $(this).parent().attr("areaid");
	       }
	       else {
	           area = area + "|" + $(this).parent().attr("areaid");
	       }
	   });
	   document.pelf.Hiddenareaid.value = area;
	   if (area == "") {
	       PFErrMsg = PFErrMsg + " * Appropriate area is required \n"
	   }
	}
	if(document.pelf.contactname.value == "")
	{
		PFErrMsg = PFErrMsg + " * Title is a required field \n";
	}
	if(document.pelf.title.value == "")
	{
		PFErrMsg = PFErrMsg + " * Phone is a required field \n";
	}
	if(document.pelf.emailaddress.value == "")
	{
		PFErrMsg = PFErrMsg + " * Email is a required field \n";
	}
	else if(document.pelf.emailaddress.value.indexOf('@')<0 || document.pelf.emailaddress.value.indexOf('.')<0)
	{
		PFErrMsg = PFErrMsg + " * The email address you have entered is invalid. Please enter a valid email address \n";	
	}
	
	if(document.pelf.phone.value == "")
	{
		PFErrMsg = PFErrMsg + " * Phone is a required field \n";
	}
	if(document.pelf.besttime.value == "")
	{
		PFErrMsg = PFErrMsg + " * Best time to contact is a required field \n";
	}
	
	if(PFErrMsg !== "")
	{
		alert(PFErrMsg);
		return false;
	}
}

function validateprofileform() {
    var PFErrMsg = "";
    if (document.pelf.WebPhone.value == "") {
        PFErrMsg = " * Sales Contact Phone is a required field \n";
    }
    if (document.pelf.WebEmail.value == "") {
        PFErrMsg = PFErrMsg + " * Sales Contact Email is a required field \n";
    }
    else if (document.pelf.WebEmail.value.indexOf('@') < 0 || document.pelf.WebEmail.value.indexOf('.') < 0) {
        PFErrMsg = PFErrMsg + " * The email address you have entered is invalid. Please enter a valid email address \n";
    }
    if (document.pelf.WebName.value == "0") {
        PFErrMsg = PFErrMsg + " * Sales Contact Name is required \n";
    }
    if (document.pelf.ZipCode.value == "") {
        PFErrMsg = PFErrMsg + " * Zip Code is a required field \n";
    }
    if (document.pelf.Address1.value == "") {
        PFErrMsg = PFErrMsg + " * Address1 is a required field \n";
    }
    if (document.pelf.City.value == "") {
        PFErrMsg = PFErrMsg + " * City is a required field \n";
    }
    if (document.pelf.aboutus.value == "") {
        PFErrMsg = PFErrMsg + " * AboutUs/Me is a required field \n";
    }
    if (PFErrMsg !== "") {
        alert(PFErrMsg);
        return false;
    }
}
