// Created: 2004-03-24
// Author Algirdas Noreika
// e-mail: alnor@delfi.lt

//-----------------------------------------------------------------------
// fnAddBookmark() - Adds a bookmark.
function fnAddBookmark(title,url){ 
	if (document.all) window.external.AddFavorite(url,title); 
}


//-----------------------------------------------------------------------
// fnZoomImage()
function fnZoomImage(sImage) {
	oDiv = document.getElementById('idPOPUP');
	
	if (oDiv != null) window.document.body.removeChild(oDiv);
	
		oDiv = window.document.createElement("DIV");
		oDiv.style.position="absolute";
		oDiv.style.visibility = "visible";
		oDiv.style.padding = "1px";
		oDiv.style.width = "0px";
		oDiv.style.height = "0px";
		oDiv.style.border = "0px";
		oDiv.style.left = 4;
		oDiv.style.top = window.document.body.scrollTop+4;
		
		oDiv.id = "idPOPUP";
		
		oDiv.innerHTML = "<table style=\"background-color:#DADADA;width:100%;height:100%;border:1px solid #505050\" cellspacing=\"0\">"+
		"<tr><td style=\"padding:1px;height:1px;border-bottom:1px solid #505050;\">"+
		"	<b style=\"color:#000000;font:normal bold 12px Verdana \">Zooming. Please wait...</b>"+
		"</td>"+
		"<td align=\"right\" valign=\"top\" style=\"border-bottom:1px solid #505050;\">"+
		"<table height=\"1px\" width=\"1px\" cellspacing=\"1\" onclick=\"oDiv = document.getElementById('idPOPUP'); window.document.body.removeChild(oDiv);\"><tr><td style=\"padding:2px;background-color:#BBBBBB;border:1px solid #939393;font:11px Verdana;color:#000000;\" onmouseover=\"this.style.cursor='default';\"><b>X</b></td></tr></table>"+
		"</td>"+
		"</tr>"+
		"<tr>"+
		"	<td colspan=\"2\" style=\"background-color:#EFEFEF;padding:1px 1px 1px 1px\" align=\"left\" valign=\"top\">"+
		"		<img src=\""+sImage+"\"></td>"+
		"</tr>"+
		"</table>";
		window.document.body.appendChild(oDiv);
}


//-----------------------------------------------------------------------
// fnZoomImage2()
function fnZoomImage2(sBasePath, sImage) {
	oDiv = document.getElementById('idPOPUP');
	
	if (oDiv != null) window.document.body.removeChild(oDiv);
	
		oDiv = window.document.createElement("DIV");
		oDiv.style.position="absolute";
		oDiv.style.visibility = "visible";
		oDiv.style.padding = "1px";
		oDiv.style.width = "0px";
		oDiv.style.height = "0px";
		oDiv.style.border = "0px";
		oDiv.style.left = 4;
		oDiv.style.top = window.document.body.scrollTop+4;
		
		oDiv.id = "idPOPUP";
		
		oDiv.innerHTML = "<table style=\"background-color:#DADADA;width:100%;height:100%;border:1px solid #505050\" cellspacing=\"0\">"+
		"<tr><td style=\"padding:1px;height:1px;border-bottom:1px solid #505050;\">"+
		"	<b style=\"color:#000000;font:normal bold 12px Verdana \">Zooming. Please wait...</b>"+
		"</td>"+
		"<td align=\"right\" valign=\"top\" style=\"border-bottom:1px solid #505050;\">"+
		"<table height=\"1px\" width=\"1px\" cellspacing=\"1\" onclick=\"oDiv = document.getElementById('idPOPUP'); window.document.body.removeChild(oDiv);\"><tr><td style=\"padding:2px;background-color:#BBBBBB;border:1px solid #939393;font:11px Verdana;color:#000000;\" onmouseover=\"this.style.cursor='default';\"><b>X</b></td></tr></table>"+
		"</td>"+
		"</tr>"+
		"<tr>"+
		"	<td colspan=\"2\" style=\"background-color:#EFEFEF;padding:1px 1px 1px 1px\" align=\"left\" valign=\"top\">"+
		"		<img src=\""+sBasePath+"fclasses/fresizeimg500.prf?ifname=../"+sImage+"\"></td>"+
		"</tr>"+
		"<tr class=\"CText2\"><td align=\"left\">&#160;<a class=\"cLink\" href=\"" + sBasePath + sImage + "\"target=\"blank\">Download Full Size (Right click this link, then: Save As...)</a></td></tr>"+
		"</table>";
		window.document.body.appendChild(oDiv);
}

//-----------------------------------------------------------------------
// Opens comments window.
function fnComments(nTID) {
	window.open('../fcomments/comments-' + nTID + '.html', '', 'menubar=0,status=0,toolbar=0,resizable=1,scrollbars=1,width=430', true);
}


//-----------------------------------------------------------------------
// Open Tell A Friend.
function fnTAF(sID, sMSGTitle, sURL) {
	oDiv = document.getElementById(sID);
	if (oDiv != null) {
		if(window.document.body.clientWidth || window.document.body.clientHeight) {
			oDiv.style.left = window.document.body.scrollLeft + window.document.body.clientWidth / 2 - oDiv.offsetWidth / 2;
			oDiv.style.top = window.document.body.scrollTop + window.document.body.clientHeight / 2 - oDiv.offsetHeight / 2;
		} else {
			oDiv.style.left = 20;
			oDiv.style.top = 20;
		}
	} else {
		oDiv = window.document.createElement("DIV");
		oDiv.style.position="absolute";
		oDiv.style.padding = "1px";
		oDiv.style.visibility = "hidden";
		oDiv.style.border = "0px";
		oDiv.id = sID;
		oDiv.style.left = 20;
		oDiv.style.top = 20;
		
		oDiv.innerHTML = "<table style=\"border:1px solid #333333\" class=\"cDWTitleBar\" cellspacing=\"0\">"+
		"<tr><td style=\"padding:1px;height:1px;border-bottom:1px solid #333333;\">"+
		"&#160;<b>Tell your friend about this ! - Algirdas.COM</b>"+
		"</td>"+
		"<td align=\"right\" valign=\"top\" style=\"border-bottom:1px solid #333333;\">"+
		"<table height=\"1px\" width=\"1px\" cellspacing=\"1\" onclick=\"oDiv = document.getElementById('"+sID+"'); window.document.body.removeChild(oDiv);\"><tr><td style=\"padding:2px;background-color:#BBBBBB;border:1px solid #939393;font:10px Verdana;color:#000000;\" onmouseover=\"this.style.cursor='default';\"><b>X</b></td></tr></table>"+
		"</td>"+
		"</tr>"+
		"<tr>"+
		"	<td colspan=\"2\" style=\"background-color:#EFEFEF;padding:1px 1px 1px 1px\" align=\"left\" valign=\"top\">"+
			"<form method='post' style='margin:0px;'>"+
			"<input type='hidden' name='ihTitle' value='" + sMSGTitle + "'>"+
			"<input type='hidden' name='ihURL' value='" + sURL + "'>"+
			"<input type='hidden' name='ihSubmitTAF' value='1'>"+
			"<table width='100%' height='100%' class='cText'>"+
			"<tr><td align='right'><nobr>Your name:</nobr></td><td><input type='text' name='itName'></td></tr>"+
			"<tr><td align='right'><nobr>Your e-mail:</nobr></td><td><input type='text' name='itEmail' id='idYEML'></td></tr>"+
			"<tr><td align='right'><nobr>Friend`s name:</nobr></td><td><input type='text' name='itFName'></td></tr>"+
			"<tr><td align='right'><nobr>Friend`s e-mail:</nobr></td><td><input type='text' name='itFEmail' id='idFEML'></td></tr>"+
			"<tr><td colspan='2' align='right'><input type='button' value='Submit' onclick='if(fnIsEmail(\"idYEML\") && fnIsEmail(\"idFEML\")) form.submit(); else alert(\"Incorrect e-mail(s).\");'></td></tr>"+
			"</table>"+
			"</form>"+
		"   </td>"+
		"</tr>"+
		"</table>";
		window.document.body.appendChild(oDiv);
		
		if(window.document.body.clientWidth || window.document.body.clientHeight) {
			oDiv.style.left = window.document.body.scrollLeft + window.document.body.clientWidth / 2 - oDiv.offsetWidth / 2;
			oDiv.style.top = window.document.body.scrollTop + window.document.body.clientHeight / 2 - oDiv.offsetHeight / 2;
		} else {
			oDiv.style.left = 20;
			oDiv.style.top = 20;
		}
		oDiv.style.visibility = "visible";
	}
	
}

//-----------------------------------------------------------------------
// Reports an Error.
function fnReport(sID, sMSGTitle, sURL) {
	oDiv = document.getElementById(sID);
	if (oDiv != null) {
		if(window.document.body.clientWidth || window.document.body.clientHeight) {
			oDiv.style.left = window.document.body.scrollLeft + window.document.body.clientWidth / 2 - oDiv.offsetWidth / 2;
			oDiv.style.top = window.document.body.scrollTop + window.document.body.clientHeight / 2 - oDiv.offsetHeight / 2;
		} else {
			oDiv.style.left = 20;
			oDiv.style.top = 20;
		}
	} else {
		oDiv = window.document.createElement("DIV");
		oDiv.style.position="absolute";
		oDiv.style.padding = "1px";
		oDiv.style.visibility = "hidden";
		oDiv.style.border = "0px";
		oDiv.id = sID;
		oDiv.style.left = 20;
		oDiv.style.top = 20;
		
		oDiv.innerHTML = "<table style=\"border:1px solid #333333\" class=\"cDWTitleBar\" cellspacing=\"0\">"+
		"<tr><td style=\"padding:1px;height:1px;border-bottom:1px solid #333333;\">"+
		"&#160;<b>Report - Algirdas.COM</b>"+
		"</td>"+
		"<td align=\"right\" valign=\"top\" style=\"border-bottom:1px solid #333333;\">"+
		"<table height=\"1px\" width=\"1px\" cellspacing=\"1\" onclick=\"oDiv = document.getElementById('"+sID+"'); window.document.body.removeChild(oDiv);\"><tr><td style=\"padding:2px;background-color:#BBBBBB;border:1px solid #939393;font:10px Verdana;color:#000000;\" onmouseover=\"this.style.cursor='default';\"><b>X</b></td></tr></table>"+
		"</td>"+
		"</tr>"+
		"<tr>"+
		"	<td colspan=\"2\" style=\"background-color:#EFEFEF;padding:1px 1px 1px 1px\" align=\"left\" valign=\"top\">"+
			"<form method='post' style='margin:0px;'>"+
			"<input type='hidden' name='ihTitle' value='" + sMSGTitle + "'>"+
			"<input type='hidden' name='ihURL' value='" + sURL + "'>"+
			"<input type='hidden' name='ihSubmitSRS' value='1'>"+
			"<table width='100%' height='100%' class='cText'>"+
			"<tr><td align='left'>Please enter your message:</td></tr>"+
			"<tr><td><textarea name='taMessage' style='width:300px;height:150px;'></textarea></td></tr>"+
			"<tr><td colspan='2' align='right'><input type='button' value='Submit' onclick='form.submit();'></td></tr>"+
			"</table>"+
			"</form>"+
		"   </td>"+
		"</tr>"+
		"</table>";
		window.document.body.appendChild(oDiv);
		
		if(window.document.body.clientWidth || window.document.body.clientHeight) {
			oDiv.style.left = window.document.body.scrollLeft + window.document.body.clientWidth / 2 - oDiv.offsetWidth / 2;
			oDiv.style.top = window.document.body.scrollTop + window.document.body.clientHeight / 2 - oDiv.offsetHeight / 2;
		} else {
			oDiv.style.left = 20;
			oDiv.style.top = 20;
		}
		oDiv.style.visibility = "visible";
	}
	
}

//-----------------------------------------------------------------------
// Reports an Error.
function fnLinkTo(sID, sLinkTitle, sLinkURL, sLinkDescription) {
	oDiv = document.getElementById(sID);
	if (oDiv != null) {
		if(window.document.body.clientWidth || window.document.body.clientHeight) {
			oDiv.style.left = window.document.body.scrollLeft + window.document.body.clientWidth / 2 - oDiv.offsetWidth / 2;
			oDiv.style.top = window.document.body.scrollTop + window.document.body.clientHeight / 2 - oDiv.offsetHeight / 2;
		} else {
			oDiv.style.left = 20;
			oDiv.style.top = 20;
		}
	} else {
		oDiv = window.document.createElement("DIV");
		oDiv.style.position="absolute";
		oDiv.style.padding = "1px";
		oDiv.style.visibility = "hidden";
		oDiv.style.border = "0px";
		oDiv.id = sID;
		oDiv.style.left = 20;
		oDiv.style.top = 20;
		
		oDiv.innerHTML = "<table style=\"border:1px solid #333333\" class=\"cDWTitleBar\" cellspacing=\"0\">"+
		"<tr><td style=\"padding:1px;height:1px;border-bottom:1px solid #333333;\">"+
		"&#160;<b>Link to this... - Algirdas.COM</b>"+
		"</td>"+
		"<td align=\"right\" valign=\"top\" style=\"border-bottom:1px solid #333333;\">"+
		"<table height=\"1px\" width=\"1px\" cellspacing=\"1\" onclick=\"oDiv = document.getElementById('"+sID+"'); window.document.body.removeChild(oDiv);\"><tr><td style=\"padding:2px;background-color:#BBBBBB;border:1px solid #939393;font:10px Verdana;color:#000000;\" onmouseover=\"this.style.cursor='default';\"><b>X</b></td></tr></table>"+
		"</td>"+
		"</tr>"+
		"<tr>"+
		"	<td colspan=\"2\" style=\"background-color:#EFEFEF;padding:1px 1px 1px 1px\" align=\"left\" valign=\"top\" width=\"1px\">"+
			"<table width=\"1px\" height='100%' class='cText'>"+
			"<tr><td align='left'><a href='" + sLinkURL + "'>" + sLinkTitle + "</a>" + sLinkDescription + "</td></tr>"+
			"<tr><td align='left'><hr></td></tr>"+
			"<tr><td align='left'>Please copy Link HTML below:</td></tr>"+
			"<tr><td><textarea name='taMessage' style='width:400px;height:100px;'><a href='" + sLinkURL + "'>" + sLinkTitle + "</a>" + sLinkDescription + "</textarea></td></tr>"+
			"</table>"+
		"   </td>"+
		"</tr>"+
		"</table>";
		window.document.body.appendChild(oDiv);
		
		if(window.document.body.clientWidth || window.document.body.clientHeight) {
			oDiv.style.left = window.document.body.scrollLeft + window.document.body.clientWidth / 2 - oDiv.offsetWidth / 2;
			oDiv.style.top = window.document.body.scrollTop + window.document.body.clientHeight / 2 - oDiv.offsetHeight / 2;
		} else {
			oDiv.style.left = 20;
			oDiv.style.top = 20;
		}
		oDiv.style.visibility = "visible";
	}
	
}

//-----------------------------------------------------------------------
// Checks if e-mail is correct.
function fnIsEmail(objID) {
	oIT = window.document.getElementById(objID);
	if (oIT.value.match(/^[a-z0-9_-]+@[\.a-z0-9-]+\.[a-z]+$/i)) {
		return true;
	}
return false;
}