function getLinkWithMiles(link){

	var URL = link;
	if(document.getElementById("furnitureList1_ddDistance").value){
		if (document.getElementById("furnitureList1_ddDistance").value > 0){
			URL = link+"&miles="+document.getElementById('furnitureList1_ddDistance').value;
		}
	}
	open(URL, "_self");
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function SendSuggestion(){
    window.location="mailto:support@furniturefindex.com?subject=My FurnitureFindex.com Suggestion, Comment, or Idea!";
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function SendEmail(url){
if (url==""){url = document.location.href;}

var to = "";
var subject = "Check out this listing on FurnitureFindex.com!";
var body = "You should check out this listing: \n\n" + 
url +
"\n\nBuy and Sell Home Furnishings, New and Once Loved... at FurnitureFindex.com"

// BUILD MAIL MESSAGE COMPONENTS
var doc = "mailto:" + to + "?subject=" + escape(subject) + "&body=" + escape(body);

// POP UP EMAIL MESSAGE WINDOW
window.location = doc;
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function SendEmailEmbed(url, ptitle) {

  	var newURL = "";
	var newQueryString = "";
	var parentURL = url;
	var childURL = document.location.href;
	var queryPOSChild = childURL.lastIndexOf("?")
	var queryPOSParent = parentURL.lastIndexOf("?")
	var ShowroomName = document.Form1.hidShowroomName.value;
	var MailFooter = document.Form1.hidShowSig.value;
	newQueryString = childURL.substring(queryPOSChild+1,childURL.length);
	
	//Fix in case Embedded Showroom has a ? in there search URL already.	
	if (queryPOSParent > -1){
		parentURLARR = parentURL.split("?");
		newURL = parentURLARR[0] + '?pi=' + getQueryVariable('pi') + '&showitem=1&' + parentURLARR[1];
	}else{
	newURL = parentURL + '?pi=' + getQueryVariable('pi') + '&showitem=1&name=' + ptitle;
    }

	var to = "";
	var subject = "Check out this listing from " + ShowroomName + "!";
	var body = "You should check out this listing: \n\n" + 
	newURL +
	"\n\n" + MailFooter

	// BUILD MAIL MESSAGE COMPONENTS
	var doc = "mailto:" + to + "?subject=" + escape(subject) + "&body=" + escape(body);

	// POP UP EMAIL MESSAGE WINDOW
	window.location = doc;
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////





function ReportListing(){
   if (document.getElementById("aReport")){
   	if (confirm("You are about to report this listing as offensive.\n\nAre you sure this item is offensive?")){
			//if user selects "ok" (yes, mark as offensive)
			document.getElementById("aReport").click();
		}    
   }
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function showProd(pImage){
  if (!pImage.match("default.gif")){

	  //var URL = 'viewImage.aspx?image=' + pImage;
		  var URL = 'viewImage.aspx?image=' + pImage;
  	
	  //myWin = window.open(URL);
  	


	  var w = 750, h = 600;
	  if (document.all || document.layers) {
	  w = screen.availWidth;
	  h = screen.availHeight;
	  }
  	
	  var popW = 750, popH = 600;
	  var leftPos = (w-popW)/2, topPos = (h-popH)/2;
  	
	  var window=0;
	  var parameters="directories=no,toolbar=no,scrollbars=yes,resizable=yes,width="+popW+",height="+popH+",top="+topPos+",left="+leftPos;
    focusPopup(window,URL,parameters);

	}
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function focusPopup(window,page,parameters) {
  window=open(page,'popup',parameters);
  if(window){if(!window.closed){window.focus();}}
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function showProdEmbed(pImage, serverpath){
  if (!pImage.match("default.gif")){
      //alert(serverpath);
      var URL = serverpath + '/cat/viewImage.htm?image=' + pImage;
	  var w = 750, h = 600;
	  if (document.all || document.layers) {
	  w = screen.availWidth;
	  h = screen.availHeight;
	  }
  	
	  var popW = 750, popH = 600;
	  var leftPos = (w-popW)/2, topPos = (h-popH)/2;
  	
	  var window=0;
	  var parameters="directories=no,toolbar=no,scrollbars=yes,resizable=yes,width="+popW+",height="+popH+",top="+topPos+",left="+leftPos;
    focusPopup(window,URL,parameters);

	}
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////

function selectPortfolio(pItemId, pCategory, flagToPortfolio){

	document.getElementById("hidCategory").value = pCategory; 
	document.getElementById("hidFCID").value = pItemId; 

	var w = 500, h = 325;
	var URL = 'popSelectPortfolio.aspx?item=' + pItemId + '&cat=' + pCategory;
	if(flagToPortfolio){
		URL += '&toPort=yes'
	}
	
	if (document.all || document.layers) {
	w = screen.availWidth;
	h = screen.availHeight;
	}
	
	var popW = 800, popH = 600;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
  myWin = window.open(URL,'popup','width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
	if (myWin) myWin.focus();
	
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////

function openWin(myURL){

	var w = 750, h = 600;
	if (document.all || document.layers) {
	w = screen.availWidth;
	h = screen.availHeight;
	}
	
	var popW = 750, popH = 600;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
	
	var myWin = window.open(myURL,'popup','directories=no,toolbar=no,scrollbars=yes,resizable=yes, width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
	if (myWin) myWin.focus();
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function openPreview(myURL){
	var w = 661, h = 600;
	
	if (document.all || document.layers) {
	w = screen.availWidth;
	h = screen.availHeight;
	}
	
	var popW = 661, popH = 525;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
	var myWin = window.open(myURL,'preview','directories=no,toolbar=no,scrollbars=yes,resizable=no, width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
	if (myWin) myWin.focus();
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function changeZIPCode(){
	var myURL = 'ZIPCodePopUp.aspx';
	var w = 800, h = 600;
	if (document.all || document.layers) {
	w = screen.availWidth;
	h = screen.availHeight;
	}
	var popW = 350, popH = 225;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	var myWin = window.open(myURL,'popup','directories=no,toolbar=no, width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
	if (myWin) myWin.focus();

}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function refreshOpener() {
  opener.location.reload();
  window.close();
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function submitZIPCode(){
	//document.getElementById('aSubmit').click();
	__doPostBack('aSubmit','');
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function checkZIP() {
  var message = "";
	var nDim = document.getElementById("tbZIP5").value;
	
	if (nDim == ""){
		message += "Please enter your 5-digit ZIP Code.\n";
	}else{
	  nDim = stripCharacter(nDim,"+")
	  nDim = stripCharacter(nDim,"-")
		if (isNaN(nDim)){
		  nDim = "";
		  message += "Please enter a numeric ZIP Code.\n";
		}else{
		  if (nDim.length < 5){
		  nDim = "";
		  message += "Please enter a 5-digit ZIP Code.\n";
		  }
		}
	}
	document.getElementById("tbZIP5").value = nDim
	if (message != ""){
	  document.getElementById("tbZIP5").focus();
		alert(message);
		return false;
	}else{
		return true;
	} 
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function disableLinks(){
	//showPrompt();
	var x = document.getElementsByTagName('a');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].getAttribute('id') == "aClose1" || x[i].getAttribute('id') == "aClose2"){
		}else{
				x[i].onclick = function () {
				return false;
			}
		}
	}
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function openPopWin(myURL, width, height){

	var w = width, h = height;
	if (document.all || document.layers) {
	w = screen.availWidth;
	h = screen.availHeight;
	}
	
	var popW = width, popH = height;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
		
	var myWin = window.open(myURL,'popup','directories=no,toolbar=no,scrollbars=yes,resizable=yes, width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
	if (myWin) myWin.focus();
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function openPopWinNoResize(myURL, width, height){

	var w = width, h = height;
	if (document.all || document.layers) {
	w = screen.availWidth;
	h = screen.availHeight;
	}
	
	var popW = width, popH = height;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
		
	var myWin = window.open(myURL,'popup','directories=no,toolbar=no,scrollbars=yes,resizable=no, width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
	if (myWin) myWin.focus();
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
