function display_infowindow(windowid, darken)
{
	if (!darken) darken = 'true';
	showdarkfiller(darken);
	document.getElementById(windowid).style.visibility = 'visible';
}

function hide_infowindow(windowid)
{
	showdarkfiller('true'); // hide darkfiller
	document.getElementById(windowid).style.visibility = 'hidden';
	document.getElementById(windowid).innerHTML = '';
	
} 

function showdarkfiller(darken)
{
	if ((document.getElementById('darkfiller')) && (darken == 'true')) //only tint window when allowed
	{
		var df = document.getElementById('darkfiller')
		
		if (df.style.visibility == 'visible') {df.style.visibility = 'hidden';}
		else
		{
			df.style.visibility = 'visible';
		    // expand it to fullscreen
			var oSize = get_document_size();
		    df.style.width = oSize.width + 'px';
		    df.style.height = oSize.height + 'px';
		}
	}
}

function get_document_size()
{
    var x,y;
    if (self.innerHeight) // all except Explorer
    {
	    x = self.innerWidth;
	    y = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
	    // Explorer 6 Strict Mode
    {
	    x = document.documentElement.clientWidth;
	    y = document.documentElement.clientHeight;
    }
    else if (document.body) // other Explorers
    {
	    x = document.body.clientWidth;
	    y = document.body.clientHeight;
    }
    
    var xx,yy;
    var test1 = document.body.scrollHeight;
    var test2 = document.body.offsetHeight
    if (test1 > test2) // all but Explorer Mac
    {
	    xx = document.body.scrollWidth;
	    yy = document.body.scrollHeight;
    }
    else // Explorer Mac;
    {
	    xx = document.body.offsetWidth;
	    yy = document.body.offsetHeight;
    }
    
	var oSize = {width:0, height:0};
    oSize.height = ((y > yy) ? y : yy);    
    oSize.width = xx;
    
    return oSize;
}

function check_email(emailfield)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var tableblock = document.getElementById('emailsend')
	if (filter.test(emailfield))
	{
//		tableblock.style.display = 'block';
//		document.getElementById('wantemail').checked = 'checked';
	}
	else
	{
//		tableblock.style.display = 'none';
//		document.getElementById('wantemail').checked = '';
	}
	return true;
}

function submit_comment(where)
{
//	var params = 'pic_id='+${'pic_id'}.value +'&comm_name=' + $('comm_name').value + '&comm_email=' + $('comm_email').value +'&comm_text=' + $('comm_text').value;
var params =  Form.serialize('commentform');
	var url = '/ajax/submit_comment/';
	
	var myAjax = new Ajax.Updater(
		 {success: where}, 
					url, 
					{
						method: 'get', 
						parameters: params 
					});	
}

function submit_vote(pic_vote,pic_id, where)
{
	var myAjax = new Ajax.Updater(
		 {success: where}, 
					'/ajax/submit_vote/', 
					{
						method: 'get', 
						parameters: 'pic_id=' + pic_id + '&pic_vote=' + pic_vote 
					});	

	// now let's update score
	var myAjax = new Ajax.Updater(
		 {success: 'photo_rating'}, 
					'/ajax/get_photorating/', 
					{
						method: 'get', 
						parameters: 'pic_id=' + pic_id 
					});	
					
}