function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function submit_form(destination) {

var return_false = "0";

	if(destination == "client") {
		if(document.destination_selection.client.value=="") {
			return_false="1";
		}
		else {
			document.destination_selection.industry.value="";
			document.destination_selection.album.value="";
			document.destination_selection.date.value="";
			document.destination_selection.service.value="";
		}
	}
	if(destination == "industry") {
		if(document.destination_selection.industry.value=="") {
			return_false="1";
		}
		else {
			//document.destination_selection.service.value="";			
			document.destination_selection.client.value="";
			document.destination_selection.album.value="";
			document.destination_selection.date.value="";
			document.destination_selection.service.value="";
		}
	}
	if(destination == "search") {
		if(document.destination_selection.search.value=="" || document.destination_selection.search.value==" " || document.destination_selection.search.value == "Search for projects by keywords") {
			alert("Please enter text in the search field.");
			document.destination_selection.search.select();			
			return_false="1";
		}
		else {
			document.destination_selection.client.value="";
			document.destination_selection.album.value="";
			document.destination_selection.industry.value="";
			document.destination_selection.date.value="";
			document.destination_selection.service.value="";
			}
	}
	if(destination == "service") {
		if(document.destination_selection.service.value=="") {
			return_false="1";
		}
		else {
			document.destination_selection.album.value = document.destination_selection.service.value;
			document.destination_selection.client.value="";
			document.destination_selection.industry.value="";
			document.destination_selection.date.value="";
			document.destination_selection.service.value = document.destination_selection.service[document.destination_selection.service.selectedIndex].value;
			return_false="2";
		}
	}
	
	if(destination == "date") {
		if(document.destination_selection.date.value=="") {
			return_false="1";
		}
		else {
			document.destination_selection.client.value="";
			document.destination_selection.industry.value="";
			document.destination_selection.album.value="";
			document.destination_selection.service.value="";
			return_false="3";
		}
	}

	if(return_false == "3") {
		document.destination_selection.album.value="lastup";
		document.destination_selection.submit();
	}
	if(return_false == "2") {
		document.destination_selection.submit();
	}
	else if(return_false == "0") {
		document.destination_selection.album.value=destination;
		document.destination_selection.submit();
	}
}

function writeCookie(name, data, noDays){
  var cookieStr = name + "="+ data
  if (writeCookie.arguments.length > 2){
    cookieStr += "; expires=" + getCookieExpireDate(noDays)
    }
  document.cookie = cookieStr
}

function readCookie(cookieName){
   var searchName = cookieName + "="
   var cookies = document.cookie
   var start = cookies.indexOf(cookieName)
   if (start == -1){ // cookie not found
     return ""
     }
   start += searchName.length //start of the cookie data
   var end = cookies.indexOf(";", start)
   if (end == -1){
     end = cookies.length
     }
   return cookies.substring(start, end)
}

function blocking(nr, cookie, vis_state)
{
        if (document.layers)
        {
                current = (document.layers[nr].display == 'none') ? vis_state : 'none';
                if (cookie != '')
                        writeCookie(nr, current);
                document.layers[nr].display = current;
        }
        else if (document.all)
        {
                current = (document.all[nr].style.display == 'none') ? vis_state : 'none';
                if (cookie != '')
                        writeCookie(nr, current);
                document.all[nr].style.display = current;
        }
        else if (document.getElementById)
        {
                display = (document.getElementById(nr).style.display == 'none') ? vis_state : 'none';
                if (cookie != '')
                        writeCookie(nr, display);
                document.getElementById(nr).style.display = display;
        }
}

function sort_projects()
{
var base_loc = document.sort_options.base_url.value;
var sort_order = document.sort_options.sort_val.value;

var final_url = base_loc + "&sort=" + sort_order;
document.sort_options.submit();
window.location = final_url;
}										

function adjust_popup()
{
        var w, h, fixedW, fixedH, diffW, diffH;

        if (document.all) {
                fixedW = document.body.clientWidth;
                fixedH = document.body.clientHeight;
                window.resizeTo(fixedW, fixedH);
                diffW = fixedW - document.body.clientWidth;
                diffH = fixedH - document.body.clientHeight;
        } else {
                fixedW = window.innerWidth;
                fixedH = window.innerHeight;
                window.resizeTo(fixedW, fixedH);
                diffW = fixedW - window.innerWidth;
                diffH = fixedH - window.innerHeight;
        }
        w = fixedW + diffW;
        h = fixedH + diffH;
        if (h >= screen.availHeight) w += 16;
        if (w >= screen.availWidth)  h += 16;
        w = Math.min(w,screen.availWidth);
        h = Math.min(h,screen.availHeight);
        window.resizeTo(w,h);
        window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
}

