function insertVirTour(file,label) {
	var code = ''+
	'<object type="video/quicktime" id="vt" border="0" width="400" height="300" title="" codebase="http://www.apple.com/qtactivex/qtplugin.cab" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" style="visibility:visible">'+
	'<param name="src" value="./virtour360/'+file+'" />'+
	'<param name="cache" value="true" />'+
	'<param name="autoplay" value="false" />'+
	'<param name="controller" value="false" />'+
	'<param name="loop" value="false" />'+
	'<param name="wmode" value="transparent" />'+
	'<embed src="./virtour360/'+file+'" name="vt" width="400" height="300" loop="false" autoplay="false" pluginspage="http://www.apple.com/quicktime/download/" type="video/quicktime" controller="false"/>'+
	'</object>';
	document.getElementById('VirTourViewerContainer').innerHTML = '';
	document.getElementById('VirTourViewerContainer').innerHTML = code;
	document.getElementById('VirTourLabel').innerHTML = label;
}





function bookmark(lang){

  if (navigator.platform.indexOf('Mac') != -1) {
     var keys = "Cmd + D";
  } else {
     var keys = "Ctrl + D";
  }
  var bookmarktext = "Close this info box then press " + keys + " to bookmark this page.";
  var url = document.location.href;
  var title = document.title;
  if (lang=='pl')
    var bookmarktext = "Zamknij to okienko i wcisnij " + keys + " aby zrobic zakladke do tej strony.";
  else 
    var bookmarktext = "Close this info box then press " + keys + " to bookmark this page.";
  
  
  
  	if (window.sidebar) { 
        // Mozilla Firefox Bookmark		
        window.sidebar.addPanel(title, url,"");	
    } else if( window.external ) { 
        // IE Favorite
        window.external.AddFavorite( url, title); 
    }	else {
        // Opera Hotlist		
        alert(bookmarktext); 
    }
  
}






function emailFriend(lang){
	
	currentLanguage = lang;
    msgNotSigned = true;
    msgTxt = document.getElementById('iMsg').value;
	turnOnLightBox();
	document.getElementById('iRecipientAddr').focus();
	
}






function turnOnLightBox() {
	
	document.getElementById('lightBox').style.display = "block";
	document.getElementById('emailFriendBox').style.display = "block";
	
}






function turnOffLightBox() {
	
	document.getElementById('lightBox').style.display = "none";
	document.getElementById('emailFriendBox').style.display = "none";
	
}






function efLang(txt) {
	
	var ENG = [];
	var POL = [];
	var ref = [];
	
	ref[0] = "boxTitle";
	ENG[0] = "Share this page with your friend";
	POL[0] = "Wyslij linka znajomym";
	ref[1] = "RecipientAddrLabel";
	ENG[1] = "TO address";
	POL[1] = "Adres e-mail odbiorcy";
	ref[2] = "SenderAddrLabel";
	ENG[2] = "FROM address";
	POL[2] = "Adres e-mail nadawcy";
	ref[3] = "SenderNameLabel";
	ENG[3] = "FROM name";
	POL[3] = "Podpis nadawcy";
	ref[4] = "MsgLabel";
	ENG[4] = "Message";
	POL[4] = "Wiadomosc";
	ref[5] = "MsgContent";
	ENG[5] = "Hi,\r\n\r\nI\'d like to share an interesting website with you:\r\n\r\nhttp://www.prospectdental.net\r\n\r\nCheers";
	POL[5] = "Witaj,\r\n\r\nPolecam Ci ponizsza strone internetowa:\r\n\r\nhttp://www.prospectdental.net\r\n\r\nPozdrawiam";
	ref[6] = "ButtonSend";
	ENG[6] = "Send Message";
	POL[6] = "Wyslij wiadomosc";
	ref[7] = "ButtonCancel";
	ENG[7] = "Cancel";
	POL[7] = "Zamknij";
	ref[8] = "Disclaimer";
	ENG[8] = "Disclaimer: <br />Email addresses will not be stored or used for any unsolicited contacts.";
	POL[8] = "Informacja:<br />Adresy email wprowadzone powyzej nie beda przechowywane ani uzywane<br />do jakiejkolwiek komunikacji w przyszlosci.";
	ref[9] = "Processing";
	ENG[9] = "Processing";
	POL[9] = "Trwa komunikacja z serwerem";
	ref[10] = "WindowCloseP1";
	ENG[10] = "This window will close automatically in";
	POL[10] = "Okno zamknie sie automatycznie za";
	ref[11] = "WindowCloseP2";
	ENG[11] = "seconds";
	POL[11] = "sekund";
	ref[12] = "SentSuccess";
	ENG[12] = "Your message has been sent.";
	POL[12] = "Wiadomosc wyslana pomyslnie.";
	ref[13] = "SentFailure";
	ENG[13] = "Accept our apologies - your message cannot be sent at this moment due to technical difficulties.";
	POL[13] = "Przepraszamy, wiadomosc nie moze zostac wyslana z powodu trudnosci technicznych.";
	ref[14] = "NotEntered";
	ENG[14] = "Not entered";
	POL[14] = "Pole pominiete";
	ref[15] = "WrongFormat";
	ENG[15] = "Improperly formatted";
	POL[15] = "Adres wpisany blednie";
	ref[16] = "Subject";
	ENG[16] = "Website recommendation";
	POL[16] = "Rekomendacja strony internetowej";
	ref[17] = "Close";
	ENG[17] = "Close";
	POL[17] = "Zamknij";

	textNum=0;
	while(ref[textNum]!=txt) textNum++;	

	if (currentLanguage == "english") return ENG[textNum];
	if (currentLanguage == "polski") return POL[textNum];
	
}






function submitEmailFriend(){
	
	
	f = document.emailfriend;
	for (i=0; i<f.elements.length; i++) if (f.elements[i].name.substr(0,1)=='i') f.elements[i].value = allTrim(f.elements[i].value);
	toAddr = document.getElementById('iRecipientAddr').value;
	fromAddr = document.getElementById('iSenderAddr').value;
	fromName = document.getElementById('iSenderName').value;
	msg = document.getElementById('iMsg').value;
	msg = msg.replace(/\r/g,"%0D");
	msg = msg.replace(/\n/g,"%0A");
	validEntry = true;
    buttonsBox = document.getElementById('formButtons').innerHTML;

		
	
	//validate recipient's email address
	if (toAddr.length == 0) {
		document.getElementById("iRecipientAddrError").innerHTML = efLang('NotEntered');
		document.getElementById("iRecipientAddr").style.backgroundColor = "#FEA0A0";
		validEntry = false;
	} else if(! toAddr.match(/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/)) {
		document.getElementById("iRecipientAddrError").innerHTML = efLang('WrongFormat');
		document.getElementById("iRecipientAddr").style.backgroundColor = "#FEA0A0";
		validEntry= false;
	} else {
		document.getElementById("iRecipientAddrError").innerHTML = "";
		document.getElementById("iRecipientAddr").style.backgroundColor = "#FFFFFF";
	}
	
	//validate sender's email address
	if (fromAddr.length == 0) {
		document.getElementById("iSenderAddrError").innerHTML = efLang('NotEntered');
		document.getElementById("iSenderAddr").style.backgroundColor = "#FEA0A0";
		validEntry = false;
	} else if(! fromAddr.match(/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/)) {
		document.getElementById("iSenderAddrError").innerHTML = efLang('WrongFormat');
		document.getElementById("iSenderAddr").style.backgroundColor = "#FEA0A0";
		validEntry= false;
	} else {
		document.getElementById("iSenderAddrError").innerHTML = "";
		document.getElementById("iSenderAddr").style.backgroundColor = "#FFFFFF";
	}
	
	//validate sender's name
	if (fromName.length == 0) {
		document.getElementById("iSenderNameError").innerHTML = efLang('NotEntered');
		document.getElementById("iSenderName").style.backgroundColor = "#FEA0A0";
		validEntry = false;
	} else {
		document.getElementById("iSenderNameError").innerHTML = "";
		document.getElementById("iSenderName").style.backgroundColor = "#FFFFFF";
	}
	
	//validate message
	if (msg.length == 0) {
		document.getElementById("iMsgError").innerHTML = efLang('NotEntered');
		document.getElementById("iMsg").style.backgroundColor = "#FEA0A0";
		validEntry = false;
	} else {
		document.getElementById("iMsgError").innerHTML = "";
		document.getElementById("iMsg").style.backgroundColor = "#FFFFFF";
	}
	
	if (validEntry) {
		
		document.getElementById("formButtons").innerHTML = efLang('Processing')+' &nbsp; <img src="img/_loader-arrows.gif" alt="" />';
        
  		var xmlHttp;
		try {
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e) {
			// Internet Explorer    
			try {
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try {
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {
					alert("Your browser does not support AJAX! \nPlease update your browser and visit our site again.");
					return false;
				}
			}
		}
	
		xmlHttp.onreadystatechange=function() {
			if(xmlHttp.readyState==4) {
				var result = xmlHttp.responseText;
                cnt = 10;
				document.getElementById("formButtons").innerHTML = ''+
				'<p><span id="emailFriendResultMsg"></span></p>'+
				'<p>'+efLang('WindowCloseP1')+'&nbsp;<span id="cntdwn"></span>&nbsp;'+efLang('WindowCloseP2')+'.</p>'+
				'<p><button type="button" onclick="turnOffLightBox();">'+efLang('Close')+'</button></p>';
				if (result.substr(0,7) == "success") {
					document.getElementById("emailFriendResultMsg").innerHTML = efLang('SentSuccess');
				} else {
					document.getElementById("emailFriendResultMsg").innerHTML = efLang('SentFailure');
				}
				countdown(cnt);
			}
		}

        fromName = escape(fromName);
		scriptCall="index.php?page=process-email-friend&toAddr="+toAddr+"&fromAddr="+fromAddr+"&fromName="+fromName+"&subj="+efLang("Subject")+"&msg="+msg;
		xmlHttp.open("GET",scriptCall,true);
		xmlHttp.send(null);	
	}
	
}






function allTrim (str) {
	while (str.substring(0,1)==' ') {str=str.substring(1,str.length)}
	while (str.substring(str.length-1,str.length)==' ') {str=str.substr(0,str.length-1)}
	return str;
}






function countdown() {
	if (cnt==-1) {
		postSubmitCleanup();
		return;
	}
	document.getElementById('cntdwn').innerHTML = cnt;
	cnt--;
	t = setTimeout("countdown()",1000);
}





function signMsg(name) {
	if (msgNotSigned) {
		document.getElementById("iMsg").value = document.getElementById("iMsg").value + ",\n\n" + name.value;
		msgNotSigned = false;
	}
		
}






function postSubmitCleanup() {
    document.getElementById("iRecipientAddr").value = '';
    document.getElementById("iSenderAddr").value = '';
    document.getElementById("iSenderName").value = '';
    document.getElementById('iMsg').value = msgTxt;
    document.getElementById("formButtons").innerHTML = buttonsBox;
    turnOffLightBox();
}
