	if(window.opener)
		target = window.opener.document;

	function SetCookie (name,value,expires,path,domain,secure) {

	if(name == "path" || name == "expires" || name == "domain" || name == "version") {
		name = "badCookieName";
	}
	
  		document.cookie = name + "=" + value +
    		((expires) ? "; expires=" + expires.toGMTString() : "") +
    		((path) ? "; path=" + path : "") +
    		((domain) ? "; domain=" + domain : "") +
    		((secure) ? "; secure" : "");
	}
	
	//Set up cookies for sending the photo
	function submitEmailPhoto(indexPos) {
	
		SetCookie ("imageSRC", imageLoc[indexPos], null, "/");
		SetCookie ("imageCaption", imageCap[indexPos], null, "/");
		SetCookie ("imageCredit", imageCre[indexPos], null, "/");
		SetCookie ("articleURL", location.pathname, null, "/");
		SetCookie ("articleTitle", window.document.title, null, "/");
		
		var host = location.hostname;
		host = host.substring(host.indexOf("."));

		if(host == ".nba.com") {
		SetCookie ("teamPath", location.pathname.substring(1, location.pathname.indexOf('/', 1)), null, "/");
		SetCookie("site", 'NBA', null, "/");
		}
		
		attrs = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,screenX=25,screenY=25,top=25,left=25,copyhistory=no,,width=740,height=550';
		newPopup=window.open('/components/EmailAPhotoForm.html','EmailaPhoto',attrs);
		newPopup.focus();

	}

function drawPhotoLink() {	
	document.write("<div style=\"font-family:arial; color:#ffffff;font-size:12px;font-weight:bold;text-decoration:none\"><a style=\"font-family:arial;color:#ffffff;font-size:12px;font-weight:bold;text-decoration:none\" href=\"javascript:submitEmailPhoto('" + currentEPhoto + "');\">E-mail photo</a>");

	if(imageCaption.length < 1)
		imageCaption = "&nbsp;";
	if(imageCredit.length < 1)
		imageCredit = "&nbsp;";

	imageLoc[currentEPhoto] = imageLocation;
	imageCap[currentEPhoto] = imageCaption;
	imageCre[currentEPhoto] = imageCredit;
	
	currentEPhoto++;

}

if(omitEmailPhoto)
	drawPhotoLink();

