var sc_project=401383;
var sc_partition=2;

function mailpopup(page)
{
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resize=yes,width=450,height=200");
}
function miniwindow(page)
{
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resize=yes,width=550,height=500");
}
function showemail(page)
{
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resize=yes,width=400,height=200");
}


normal0 = new Image();
normal0.src = "images/nav/welcome.gif";
normal1 = new Image();
normal1.src = "images/nav/aboutpmg.gif";
normal2 = new Image();
normal2.src = "images/nav/ourclients.gif";
normal3 = new Image();
normal3.src = "images/nav/pressreleases.gif";
normal4 = new Image();
normal4.src = "images/nav/photography.gif";


over0 = new Image();
over0.src = "images/nav/welcomeon.gif";
over1 = new Image();
over1.src = "images/nav/aboutpmgon.gif";
over2 = new Image();
over2.src = "images/nav/ourclientson.gif";
over3 = new Image();
over3.src = "images/nav/pressreleaseson.gif";
over4 = new Image();
over4.src = "images/nav/photographyon.gif";


function over(num)
{
	if (document.images)
	{
		document.images['button'+ num].src = eval('over' + num).src;
	}
}
function out(num)
{
	if (document.images)
	{
		document.images['button'+ num].src = eval('normal' + num ).src;
	}
}

function viewlarge(page) 
{ 
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resize=yes,width=640,height=480");
}
	
	
	var theImages = new Array();
	theImages[0] = "images/banners/banner0.jpg";
	theImages[1] = "images/banners/banner1.jpg";
	theImages[2] = "images/banners/banner2.jpg";
	theImages[3] = "images/banners/banner3.jpg";
	theImages[4] = "images/banners/banner4.jpg";
	theImages[5] = "images/banners/banner5.jpg";
	theImages[6] = "images/banners/banner6.jpg";
	theImages[7] = "images/banners/banner7.jpg";
	theImages[8] = "images/banners/banner8.jpg";
	theImages[9] = "images/banners/banner9.jpg";
	theImages[10] = "images/banners/banner10.jpg";
	theImages[11] = "images/banners/banner11.jpg";
	theImages[12] = "images/banners/banner12.jpg";
	theImages[13] = "images/banners/banner13.jpg";
	theImages[14] = "images/banners/banner14.jpg";
	theImages[15] = "images/banners/banner15.jpg";
	theImages[16] = "images/banners/banner16.jpg";
	theImages[17] = "images/banners/banner17.jpg";	
	
	var j = 0;
	var p = theImages.length;
	var preBuffer = new Array;
	
	for (var i=0; i<p; i++)
	{
		preBuffer[i] = new Image();
		preBuffer[i].src = theImages[i];
	}
	

function showImage()
{
	var whichImage = Math.round(Math.random()*(p-1));
	document.write("<img style=\"margin-left:1px\" src=\""+theImages[whichImage]+"\" />");
}

function emailButton()
{
	var prefix="pmginfo@";
	var domain="phelpsmediagroup.com";
	
	document.write("<a href=\"mailto:"+prefix+domain+"\"><img src=\"images/email.jpg\" border=\"0\" alt=\"Email Us!\" /></a>");
}

function prformvalidate()
{
	var invalid = "       ERROR: INCOMPLETE FIELD(S)...\n\nThe following incomplete fields MUST be filled out \nbefore this Press Release can be submitted: \n";
	var ok = "true";
	var dateerror = "";
	
	if(addarticle.title.value == "")
	{
		ok = "false";
		invalid += "--> PRESS RELEASE TITLE\n";
	}
	if(addarticle.year.value == "2000" && addarticle.month.value == "1" && addarticle.day.value == "1")
	{
		ok = "false";
		dateerror = "\nPlease enter the proper date for this Press Release.\nJanuary 1st, 2000 is unavailable for use as a date.";
	}
	if(addarticle.body.value == "")
	{
		ok = "false";
		invalid += "--> PRESS RELEASE BODY";
	}
	
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid + "\n" + dateerror);
		return(false);
	}
}



function preditformvalidate()
{
	var invalid = "       ERROR: INCOMPLETE FIELD(S)...\n\nThe following incomplete fields MUST be filled out \nbefore your edits can be saved: \n";
	var ok = "true";
	var dateerror = "";
	
	if(editarticle.title.value == "")
	{
		ok = "false";
		invalid += "--> PRESS RELEASE TITLE\n";
	}
	if(editarticle.year.value == "2000" && editarticle.month.value == "1" && editarticle.day.value == "1")
	{
		ok = "false";
		dateerror = "\nPlease enter the proper date for this Press Release.\nJanuary 1st, 2000 is unavailable for use as a date.";
	}
	if(editarticle.body.value == "")
	{
		ok = "false";
		invalid += "--> PRESS RELEASE BODY";
	}
	
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid + "\n" + dateerror);
		return(false);
	}
}



function articleselectorverify()
{
	var invalid = "";
	var ok = "true";
			
	if(articleselector.articles.value == "")
	{
		invalid = "Please select a press release first, THEN click on GO.";
		ok = "false";
	}
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid);
		return(false);
	}
}

function photoselectorverify()
{
	var invalid = "";
	var ok = "true";
			
	if(photoselector.photoid.value == "")
	{
		invalid = "Please select a photo first, THEN click on GO.";
		ok = "false";
	}
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid);
		return(false);
	}
}

function clientselectorverify()
{
	var invalid = "";
	var ok = "true";
			
	if(clientselector.clients.value == "")
	{
		invalid = "Please select a client first, THEN click on GO.";
		ok = "false";
	}
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid);
		return(false);
	}
}

function staffselectorverify()
{
	var invalid = "";
	var ok = "true";
			
	if(staffselector.staffid.value == "")
	{
		invalid = "Please select a staff member first, THEN click on GO.";
		ok = "false";
	}
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid);
		return(false);
	}
}

function staffshow()
{
	for (var i=0; i < addstaff.display.length; i++)
	{
		if (addstaff.display[i].checked)
		{
			var radval = addstaff.display[i].value;
		}
	}
	return radval;
}

function addstaffformvalidate()
{
	var invalid = "       ERROR: INCOMPLETE FIELD(S)...\n\nThe following incomplete fields MUST be filled out \nbefore this staff member can be added: \n";
	var ok = "true";
	var showerror = "";
	
	var theform = addstaff;
	
	if(theform.first.value == "")
	{
		ok = "false";
		invalid += "--> FIRST NAME\n";
	}
	
	if(theform.last.value == "")
	{
		ok = "false";
		invalid += "--> LAST NAME\n";
	}

	if(theform.title.value == "")
	{
		ok = "false";
		invalid += "--> TITLE\n";
	}
	
	if(theform.bio.value.length < 3 && staffshow() == "yes")
	{
		ok = "false";
		invalid += "--> BIOGRAPHY\n";
		showerror = "\n\nYou can only choose to show this staff member\non the About PMG page when their biography information\nis filled in.  If you don't have the bio,\nyou'll have to hide this person for now by selecting NO.\nIf you get the bio later, you can easily edit\ntheir profile to add it, then they can appear on the About PMG page.";
	}	
	
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid+showerror);
		return(false);
	}
}

function editstaffformvalidate()
{
	var invalid = "       ERROR: INCOMPLETE FIELD(S)...\n\nThe following incomplete fields MUST be filled out \nbefore this staff member can be added: \n";
	var ok = "true";
	
	var theform = editstaff;
	
	if(theform.first.value == "")
	{
		ok = "false";
		invalid += "--> FIRST NAME\n";
	}
	
	if(theform.last.value == "")
	{
		ok = "false";
		invalid += "--> LAST NAME\n";
	}

	if(theform.title.value == "")
	{
		ok = "false";
		invalid += "--> TITLE\n";
	}
	
	if(theform.bio.value.length < 3)
	{
		ok = "false";
		invalid += "--> BIOGRAPHY\n";
	}	
	
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid);
		return(false);
	}
}

function get_radio_value()
{
	for (var i=0; i < addphotodata.attached.length; i++)
	{
		if (addphotodata.attached[i].checked)
		{
			var radval = addphotodata.attached[i].value;
		}
	}
	return radval;
}

function addphotoformverify()
{
	var invalid = "       ERROR: INCOMPLETE FIELD(S)...\n\nThe following incomplete fields MUST be filled out \nbefore this photo can be added: \n";
	var ok = "true";
	var prerror = "";
	
	
	
	if(addphotodata.title.value.length <= 3)
	{
		ok = "false";
		invalid += "--> PHOTO TITLE\n";
	}
	
	if(get_radio_value() == "YES" && addphotodata.releaseid.value == "")
	{
		ok = "false";
		invalid += "--> PRESS RELEASE\n";
		prerror = "\n\nYou chose YES to specify that this photo would\nbe attached to a specific press release.\nYou did not select a press release.\nTo not attach this photo to a press release,\nplease select NO instead of YES.";
	}
	
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid+prerror);
		return(false);
	}	
}


function populateCurrentDate()
{
	var thisDate = new Date();
	var dayfield = document.getElementById("today");
	var monthfield = document.getElementById("tomonth");
	var yearfield = document.getElementById("toyear");
	
	dayfield.value = thisDate.getDate();
	monthfield.value = thisDate.getMonth() + 1;
	yearfield.value = thisDate.getFullYear();
}

function deleteTempPhoto()
{
	window.location = "changeph.php?mode=delete&hasdata=no";
}
	
function get_editpr_radio_value()
{
	for (var i=0; i < editphotodata.attached.length; i++)
	{
		if (editphotodata.attached[i].checked)
		{
			var radval = editphotodata.attached[i].value;
		}
	}
	return radval;
}

function editphotoformverify()
{
	var invalid = "       ERROR: INCOMPLETE FIELD(S)...\n\nThe following incomplete fields MUST be filled out \nbefore your edits can be saved: \n";
	var ok = "true";
	var prerror = "";
	
	
	
	if(editphotodata.title.value.length <= 3)
	{
		ok = "false";
		invalid += "--> PHOTO TITLE\n";
	}
	
	if(get_editpr_radio_value() == "YES" && editphotodata.releaseid.value == "")
	{
		ok = "false";
		invalid += "--> PRESS RELEASE\n";
		prerror = "\n\nYou chose YES to specify that this photo would\nbe attached to a specific press release.\nYou did not select a press release.\nTo not attach this photo to a press release,\nplease select NO instead of YES.";
	}
	
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid+prerror);
		return(false);
	}	
}

function addclientformvalidate()
{
	var invalid = "";
	var ok = "true";
	var httperror = "";
	
	
	
	if(addclient.clientname.value.length < 3)
	{
		invalid = "       ERROR: INCOMPLETE FIELD(S)...\n\nThe following incomplete fields MUST be filled out \nbefore this client can be added: \n";
		ok = "false";
		invalid += "--> CLIENT NAME\n";
	}
	
	if(addclient.URL.value.substr(0,7) != "http://" && addclient.URL.value != "")
	{
		ok = "false";
		httperror = "\nIf the client has a web site address, please use the following format:\nhttp://www.example.com\nIf the client doesn't have a web site,\nleave the web address field blank.";
	}
	
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid+httperror);
		return(false);
	}	
}

function editclientformvalidate()
{
	var invalid = "";
	var ok = "true";
	var httperror = "";
	
	
	
	if(editclient.clientname.value.length < 3)
	{
		invalid = "       ERROR: INCOMPLETE FIELD(S)...\n\nThe following incomplete fields MUST be filled out \nbefore your edits can be saved: \n";
		ok = "false";
		invalid += "--> CLIENT NAME\n";
	}
	
	if(editclient.URL.value.substr(0,7) != "http://" && editclient.URL.value != "")
	{
		ok = "false";
		httperror = "\nIf the client has a web site address, please use the following format:\nhttp://www.example.com\nIf the client doesn't have a web site,\nleave the web address field blank.";
	}
	
	if(ok == "true")
	{
		return(true);
	}
	else
	{
		alert(invalid+httperror);
		return(false);
	}	
}
