       /* 
        * To store reference of zoomer window
        */
       
       var newwin2 = null;
       var downloadwin = null;
       var x=0;
       var y=0;
       var screenw = screen.availWidth;
	   var screenh = screen.availHeight;
             
    /*
	* Display the set of images of next page
	*/
	
	       /*
	* Zooms the selected image.
	*/
	function zoomer(media_id, height, width, srch_type)
	
	{
		var URL = "";
		
		if (navigator.appName == 'Netscape') {
			if(checkMinorVerNS6(navigator.userAgent)){
				URL = "search/zoomimage.jsp?media_id=" + media_id + "&srchtype=" + srch_type;
			} else {
				URL = "products/search/zoomimage.jsp?media_id=" + media_id + "&srchtype=" + srch_type;
			} 
		} else if (navigator.appName == 'Microsoft Internet Explorer') {
			if(navigator.platform.indexOf('Mac')!=-1){
				URL = "products/search/zoomimage.jsp?media_id=" + media_id + "&srchtype=" + srch_type;
			} else {
				if(navigator.userAgent.indexOf('Opera') != -1){
					URL = "products/search/zoomimage.jsp?media_id=" + media_id + "&srchtype=" + srch_type;
				} else {
					URL = "search/zoomimage.jsp?media_id=" + media_id + "&srchtype=" + srch_type;
				}

			}
	 	}
		
		

		if (newwin2 != null)
		{
			if (newwin2.closed == false)
			{
				newwin2.focus();
			}
		}
				
		
		getWindowPostion();
					
		newwin2 = window.open(URL, "newwindow", "width=555,height=410,left="+x+",top="+y+",scrollbars=yes,menubar=no,directories=no,location=no,toolbar=no");
	}
	
	/*
	 * Opens  the requisition page for high resolution images in a new window.
	 */
	
	function requestpop(media_id, mname, format) {
			mname = unescape(mname);		
			if (navigator.appName == 'Microsoft Internet Explorer')
			{
				if(navigator.platform.indexOf('Mac')!=-1){
					b='ie';
					p='mac';
					URL = "products/search/media_request.jsp?b="+b+"&p="+p+"&mid="+escape(media_id)+"&mname="+escape(mname)+"&format="+escape(format);
				}else{
				    	b='ie';
				    	p='';
				    	if(navigator.userAgent.indexOf('Opera') != -1){
						URL = "products/search/media_request.jsp?b="+b+"&p="+p+"&mid="+escape(media_id)+"&mname="+escape(mname)+"&format="+escape(format);
					} else {
						URL = "media_request.jsp?b="+b+"&p="+p+"&mid="+escape(media_id)+"&mname="+escape(mname)+"&format="+escape(format);
					}
				}
			} else if (navigator.appName == 'Netscape') {
				if(navigator.platform.indexOf('Mac')!=-1){
					b='';
					p='mac';
				}
				else {
					b='';
					p='';
					if(checkMinorVerNS6(navigator.userAgent)){
						URL = "media_request.jsp?b="+b+"&p="+p+"&mid="+escape(media_id)+"&mname="+escape(mname)+"&format="+escape(format);
					} else {
						URL ="products/search/media_request.jsp?b="+b+"&p="+p+"&mid="+escape(media_id)+"&mname="+escape(mname)+"&format="+escape(format);
					}
				}	
				
			}
			
			
			if(window.opener.newwin2 != null && !window.opener.newwin2.closed){
				if(x == 0 && y == 0){
					x	= (screenw-555)/2;
					y	= (screenh-410)/2;
				}
			}
			
			
			getWindowPostion();
						
			//URL = "media_request.jsp?b="+b+"&p="+p+"&mid="+escape(media_id)+"&mname="+escape(mname)+"&format="+escape(format);
			reqwin = window.open(URL, "reqwindow", "width=555,height=410,left="+x+",top="+y+",scrollbars=yes,menubar=no,directories=no,location=no,toolbar=no,");
	}
	/*
	 * Opens a new window displaying search results based on the keyword(s).
	 */
	function searchWin(skey,groupInd,isLart,srchType){
		var URL = "";
	 	if (navigator.appName == 'Microsoft Internet Explorer')
	 	{	
	 		skey = escape(skey);
	 		groupInd = escape(groupInd);
	 		isLart = escape(isLart);
	 		srchType = escape(srchType);
	 		if(navigator.platform.indexOf('Mac')!=-1){
				URL = 'products/mediafinder?k='+skey+'&priv='+groupInd+'&lart='+isLart+'&srch='+srchType;
			} else {
				if(navigator.userAgent.indexOf('Opera') != -1){
					URL = 'products/mediafinder?k='+skey+'&priv='+groupInd+'&lart='+isLart+'&srch='+srchType;
				} else {
					URL = '../mediafinder?k='+skey+'&priv='+groupInd+'&lart='+isLart+'&srch='+srchType;
				}
			}
	 	} else if (navigator.appName == 'Netscape') {
	 		skey = escape(skey);
			groupInd = escape(groupInd);
			isLart = escape(isLart);
	 		srchType = escape(srchType);
	 		URL = 'products/mediafinder?k='+skey+'&priv='+groupInd+'&lart='+isLart+'&srch='+srchType;
	 	}
	 	
	 	//URL = '../mediafinder?k='+skey+'&priv='+groupInd+'&lart='+isLart+'&srch='+srchType;
	 	window.opener.document.location.href= URL;
	 	window.opener.focus();
	}
	
	
	 
	
	/*
	 * Opens up the FAQ page in a new window.
	 */
	function popFaq(){
		
		var URL = "";
		
		if (navigator.appName =='Netscape') {
			if(checkMinorVerNS6(navigator.userAgent)){
				URL = "faq.jsp";
			} else {
				URL = "products/search/faq.jsp";
			}
		} else if (navigator.appName == 'Microsoft Internet Explorer') {
			if(navigator.platform.indexOf('Mac')!=-1){
				URL = "products/search/faq.jsp";
			} else {
				if(navigator.userAgent.indexOf('Opera') != -1){
					URL = "products/search/faq.jsp";
				} else {
					URL = "faq.jsp";
				}
			}
	 	}
	 	
		getWindowPostion();
		
		newwin = window.open(URL, "FAQ", "width=555,height=410,left="+x+",top="+y+",scrollbars=yes,menubar=no,directories=no,location=no,toolbar=no,");
		//newwin = window.open("faq.jsp", "FAQ", "width=555,height=410,left="+x+",top="+y+",scrollbars=yes,menubar=no,directories=no,location=no,toolbar=no,");
	}
	/*
	Opens up FAQ page in a new window when the Usage Tips link is clicked on the zoomer window
	*/
	
	function popFaqZoom(){
		
				
		var URL = "";
		
		if (navigator.appName =='Netscape') {
			if(checkMinorVerNS6(navigator.userAgent)){
				URL = "faq.jsp";
			} else {
				URL = "products/search/faq.jsp";
			}
		}
		
		  else if (navigator.appName == 'Microsoft Internet Explorer') {
			if(navigator.platform.indexOf('Mac')!=-1){
				URL = "products/search/faq.jsp";
			} else {
				if(navigator.userAgent.indexOf('Opera') != -1){
					URL = "products/search/faq.jsp";
				} else {
					URL = "faq.jsp";
				}
			}
	 	}
	 	
	 	if(window.opener.newwin2 != null && !window.opener.newwin2.closed){
			if(x == 0 && y == 0){
				x	= (screenw-555)/2;
				y	= (screenh-410)/2;
			}
		}
	 	
		getWindowPostion();
		
		newwin = window.open(URL, "FAQ", "width=555,height=410,left="+x+",top="+y+",scrollbars=yes,menubar=no,directories=no,location=no,toolbar=no,");
		//newwin = window.open("faq.jsp", "FAQ", "width=555,height=410,left="+x+",top="+y+",scrollbars=yes,menubar=no,directories=no,location=no,toolbar=no,");
	}
	
	/*
	 * Check to see if the user has entered valid keyword(s).
	 */
	function validateKeyword(){
		if(document.SearchByKeyWordForm.keywords.value == "Enter keyword"){
			alert("Enter a valid keyword(s) for search.");
			return false;
		} else {
			return true;
		}
	}
	
	/*
	 * Check to see if the user has entered a valid media id.
	 */
	function validateMediaID(){
		if(document.SearchByIDForm.media_id.value == "or enter Media ID"){
			alert("Enter a valid media id for search.");
			return false;
		} else {
			return true;
		}
	}
	
	
	/*
	 * Verify whether the media request form has been provided sufficient data or not.
	 */
	function verifyMediaRequest(){
		
			var f1='n';
			var f2='n';
			var f3='n';
			var f4='n';
			var f5='n';
			var f6='n';
			var f7='n';
			var f8='n';
			var f9='n';
			var controlToFocus;
			
			if(document.MediaRequestForm.uname.value==''){
				f1='y';
				document.getElementById("fnMsg").style.visibility = "visible";
				if(controlToFocus == null){
					controlToFocus = "uname";
				}
			} else {
				document.getElementById("fnMsg").style.visibility = "hidden";
				f1='n';
			}
			
			if(document.MediaRequestForm.company.value==''){
				document.getElementById("cmpMsg").style.visibility = "visible";
				f2='y';
				if(controlToFocus == null){
					controlToFocus = "company";
				}
			} else {
				document.getElementById("cmpMsg").style.visibility = "hidden";
				f2='n';
			}
			
			if(document.MediaRequestForm.phone.value==''){
				document.getElementById("phMsg").style.visibility = "visible";
				f3='y';
				if(controlToFocus == null){
					controlToFocus = "phone";
				}
			} else {
				document.getElementById("phMsg").style.visibility = "hidden";
				f3='n';
			}

			if(document.MediaRequestForm.email.value==''){
				document.getElementById("emlMsg").style.visibility = "visible";
				f4='y';
				if(controlToFocus == null){
					controlToFocus = "email";
				}
			} else {
				document.getElementById("emlMsg").style.visibility = "hidden";
				f4='n';
			}
			
			if(document.MediaRequestForm.use.value==''){
				document.getElementById("useMsg").style.visibility = "visible";
				f5='y';
				if(controlToFocus == null){
					controlToFocus = "use";
				}
			} else {
				document.getElementById("useMsg").style.visibility = "hidden";
				f5='n';
			}
			
			if(document.MediaRequestForm.date.value==''){
				document.getElementById("dateMsg").style.visibility = "visible";
				f6='y';
				if(controlToFocus == null){
					controlToFocus = "date";
				}
			} else {
				document.getElementById("dateMsg").style.visibility = "hidden";
				f6='n';
			}
			
			if(document.MediaRequestForm.address.value==''){
				document.getElementById("addMsg").style.visibility = "visible";
				f7='y';
				if(controlToFocus == null){
					controlToFocus = "address";
				}
			} else {
				document.getElementById("addMsg").style.visibility = "hidden";
				f7='n';
			}
			
			if(document.MediaRequestForm.city.value==''){
				document.getElementById("cityMsg").style.visibility = "visible";
				f8='y';
				if(controlToFocus == null){
					controlToFocus = "city";
				}
			} else {
				document.getElementById("cityMsg").style.visibility = "hidden";
				f8='n';
			}
			
			if(document.MediaRequestForm.country.value=='0'){
				document.getElementById("cntMsg").style.visibility = "visible";
				f9='y';
				if(controlToFocus == null){
					controlToFocus = "country";
				}
			} else {
				document.getElementById("cntMsg").style.visibility = "hidden";
				f9='n';
			}
			
			
			
			//if(document.MediaRequestForm.use.value.length>1000){
			//	err='y';
			//}
			
			//if(document.MediaRequestForm.address.value.length>1000){
			//	msg+='\nPlease reduce the words for "Full Address" to under 1000 charactors.\n';
			//	err='y';
			//}
			
			
			
			if(document.MediaRequestForm.mmedia.checked==true) 
				document.MediaRequestForm.action='products/search/member_media_request.jsp';
			else
				document.MediaRequestForm.action='products/search/media_response.jsp';
				
				
			if(f1=='n' && f2=='n' && f3=='n' && f4=='n' && f5=='n' && f6=='n' && f7=='n' && f8=='n' && f9=='n'){
				if(document.MediaRequestForm.accept.checked==false){
					alert("You have to accept the terms in order to request an image.");
					document.MediaRequestForm.accept.focus();
					return false;
				} else {
					return true;
				}
			} else {
				document.getElementById(controlToFocus).focus();
				return false;
			}
	}
	
	/*
	 * Verify whether the member media request form has been provided sufficient data or not.
	 */
	function verifyMemberMediaRequest(){
			var f1='n';
			var f2='n';
			var f3='n';
			var f4='n';
			var f5='n';
			var controlToFocus;
			
			if(document.MemberMediaRequestForm.publisher.value==''){
				f1='y';
				document.getElementById("pubMsg").style.visibility = "visible";
				if(controlToFocus == null){
					controlToFocus = "publisher";
				}
			} else {
				document.getElementById("pubMsg").style.visibility = "hidden";
				f1='n';
			}
			
			if(document.MemberMediaRequestForm.author.value==''){
				f2='y';
				document.getElementById("autMsg").style.visibility = "visible";
				if(controlToFocus == null){
					controlToFocus = "author";
				}
			} else {
				document.getElementById("autMsg").style.visibility = "hidden";
				f2='n';
			}
			
			if(document.MemberMediaRequestForm.media_use.value==''){
				f3='y';
				document.getElementById("useMsg").style.visibility = "visible";
				if(controlToFocus == null){
					controlToFocus = "media_use";
				}
			} else {
				document.getElementById("useMsg").style.visibility = "hidden";
				f3='n';
			}
			
			if(document.MemberMediaRequestForm.publication.value==''){
				f4='y';
				document.getElementById("publMsg").style.visibility = "visible";
				if(controlToFocus == null){
					controlToFocus = "publication";
				}
			} else {
				document.getElementById("publMsg").style.visibility = "hidden";
				f4='n';
			}
			
			if(document.MemberMediaRequestForm.pub_date.value==''){
				f5='y';
				document.getElementById("dateMsg").style.visibility = "visible";
				if(controlToFocus == null){
					controlToFocus = "pub_date";
				}
			} else {
				document.getElementById("dateMsg").style.visibility = "hidden";
				f5='n';
			}
			
			if(f1=='n' && f2=='n' && f3=='n' && f4=='n' && f5=='n'){
				if(document.MemberMediaRequestForm.agree.checked==false){
					alert("You have to accept the terms in order to request an image.");
					document.MemberMediaRequestForm.agree.focus();
					return false;
				} else {
					return true;
				}
			} else {
				document.getElementById(controlToFocus).focus();
				return false;
			}
		}
	

	/*
	 * Pops up the image to downloaded
	 */
	 function popupDownloadImage(media_id,filename){
	 	media_id = escape(media_id);
	 	filename = escape(filename);
	 	
	 	
		
	 	
	 	var URL = "";
	 	
	 	if (downloadwin != null)
		{
			if (downloadwin.closed == false)
			{
				downloadwin.focus();
			}
		}
		
		if (navigator.appName == 'Netscape') {
			if(checkMinorVerNS6(navigator.userAgent)){
			URL = "pop_download_img.jsp";
			} else {
			URL = "products/search/pop_download_img.jsp";
		} 
			} else if (navigator.appName == 'Microsoft Internet Explorer') {
			if(navigator.platform.indexOf('Mac')!=-1){
				URL = "products/search/pop_download_img.jsp";
			} else {
				if(navigator.userAgent.indexOf('Opera') != -1){
					URL = "products/search/pop_download_img.jsp";
				} else {
					URL = "pop_download_img.jsp";
				}
			}
		}
		
		if(window.opener.newwin2 != null && !window.opener.newwin2.closed){
			if(x == 0 && y == 0){
				x	= (screenw-555)/2;
				y	= (screenh-410)/2;
			}
		}

		getWindowPostion();			
		URL = URL + "?media_id="+media_id+"&filename="+filename;
		downloadwin = window.open(URL, "dnwwindow", "width=555,height=410,left="+x+",top="+y+",scrollbars=yes,menubar=no,directories=no,location=no,toolbar=no,resizable=yes");
	 	
	 }



	/*
	 * Calculates the window position for the 
	 */
	 function getWindowPostion() {
	  	
	  	if (x != 0 && y != 0){
			x = x+24;
			y = y+24;
			
		} 
		else {
			x	= (screenw-555)/2;
			y	= (screenh-410)/2;
		}
		
		if(((x+555)>screenw) ||  ((y+410)>screenh)) {
			x=0;
			y=0;
		}
			
	 }
	 /*
	 Called when the browser used is Netscape. If the NS version is 6.1+ it returns true and the corresponding chaged URL is called.
	 */
	 
	 function checkMinorVerNS6(userAgent) {
			var index  = userAgent.indexOf("Netscape");
	 		var browserver = userAgent.substring(index);
	 		var tempArr = browserver.split("/");
	 		var verArr = tempArr[1].split(".");
	 		if(verArr[0] == '6'){
				if (verArr[1] >= 1){
		 			return true;
	 			} else {
		 			return false;
	 			}
	 		}
	 		return false;
	 
	 }
	 
	 
	 
	 