IMAGES_ROOT="images/";

function replaceHoverImg(obj)
{
    var s=obj.src;
	var src;

 /* Get the suspected "_on" string */
 var on=s.substr(s.length-7,3);

 /* If the image is NOT the "on" version we turn it to the "on" version */
 if(on!='_on')
 {

  var s1=s.substr(0,s.length-4);
  var s2=s.substr(s.length-4,s.length);
  src=s1+'_on'+s2;

  obj.src=src;
 }
 
 /* If the image is the "on" version we turn it to the NOT "on" version */
 if(on=='_on')
 {
  var s1=s.substr(0,s.length-7);
  var s2=s.substr(s.length-4,s.length);
  src=s1+s2;
  obj.src=src;
 }
}

function newImage(arg)
{
		rslt = new Image();
		rslt.src = IMAGES_ROOT+arg;
		return rslt;
}




function make_links_open_in_new_page(p_domain)
{
	anchors = document.getElementsByTagName('a');
	for (var i=0; i<anchors.length; i++)
	{
		if((anchors[i].href.indexOf('http') < 0) || (anchors[i].href.indexOf(p_domain) > -1))
		{
			// noop
		}
		else
		{
			anchors[i].target = '_blank';
		}
	}
}

function openWindow(p_w,p_h,p_url,p_name,scrollbars)
{
	//alert(p_url);
	features = '';
	var w = p_w;
	var h = p_h;
	var top = (screen.height - h)/4;
	var left = (screen.width - w)/2; 
	if(top < 0) top = 0; 
	if(left < 0) left = 0; 
	features =  "'top=";
	features += top;
	features += ',left=';
	features += left;
	features += ',height=';
	features += p_h;
	features += ',width = ';
	features += p_w;
	features += ',scrollbars = ';
	features += scrollbars;
	features += ',status=no,toolbar=no,menubar=no,location=no';
	//alert (top);alert (left);alert (features);
	window.open(p_url,p_name,features);
}


function add_link(id)
{
	//alert('p_content');
//	var element_id = document.getElementById(id);

//	var link = document.createElement('a');
//	link.setAttribute('href', 'mypage.htm');


//	element_id.appendChild(link);

//	var my_img = document.createTextNode('Some content.');
//	link.appendChild(theText);

	
}

function doStuffBeforeSubmit()
{
	if(document.comments_form.url.value == "")
		document.comments_form.url.value = " ";

	if(document.comments_form.bakecookie[0].checked)
		rememberMe(document.comments_form);
}

// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.

function setCookie (name, value, expires, path, domain, secure)
{
    var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
	//alert(curCookie);
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f)
{
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    setCookie('mtcmtauth', f.author.value, now, '', HOST, '');
    setCookie('mtcmtmail', f.email.value, now, '', HOST, '');
    setCookie('mtcmthome', f.url.value, now, '', HOST, '');
}

function forgetMe (f) {
    deleteCookie('mtcmtmail', '', HOST);
    deleteCookie('mtcmthome', '', HOST);
    deleteCookie('mtcmtauth', '', HOST);
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
}

