function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function lightbox(sku,image,path){
 var compURL = "lbminic0ab.html?action=add&amp;pp_sku=" + sku + "&image_name=" + image + "&image_path=" + path;
 var w = window.open(compURL,"Lightbox","width=450,height=500,toolbar=0,titlebar=0,scrollbars=1");
	if (w == null) { 
		window.alert("Pop-ups are blocked for this site. Please unblock pop-ups and try again.");
	}
 w.focus();
}

function audiopreview(pathinfo){
 var compURL = "audiod41d.html?" + pathinfo;
 var w = window.open(compURL,"audio","width=325,height=150,toolbar=0,titlebar=0,scrollbars=1,resizable=yes");
 w.focus();
}

function videopreview(pathinfo){
 var compURL = "videod41d.html?" + pathinfo;
 var w = window.open(compURL,"video","width=325,height=300,toolbar=0,titlebar=0,scrollbars=1,resizable=yes");
 w.focus();
}


function fsgo(vars,page,path,domainsuffix,ext,secure,newwin,iserver){
  var pathinfo = ""
  var domaininfo = ""

  if (path != '') {
    pathinfo = "/"+path;
  }


  if (domainsuffix != '') {
    if (secure == 1) {
      domaininfo = "https://www.fotosearch."+domainsuffix;
    } else {
      domaininfo = "http://www.fotosearch."+domainsuffix;
    }
  }

  if (iserver == 1) {
    domaininfo = "http://images.fotosearch.com/";
  } else if (iserver == 2) {
    domaininfo = "http://www.publishingperfection.com/";
  } else if (iserver == 3) {
    domaininfo = "http://www.adobe.com/";
  } else if (iserver == 4) {
    domaininfo = "http://www.apple.com/";
  } else if (iserver == 5) {
    domaininfo = "http://www.unlistedimages.com/";
  } else if (iserver == 6) {
    domaininfo = "http://www.canstockphoto.com/";
  }

  if (ext != '') {
    ext = "."+ext;
    if (vars != '' && ext == '.asp'){
      if (vars.substring(0,1) == '#') {
        ext = ".asp" + vars;
      } else {
        ext = ".asp?" + vars;
      }
    }
    if (vars != '' && ext == '.php'){
      ext = ".php?" + vars;
    }

  } else if (page == '') {
    ext = "";
  } else {
    ext = "index-2.html";
  }

  newpage = domaininfo+pathinfo+"/"+page+ext;

  if (newpage == '//') {
	newpage = 'index-2.html';
  }

  if (newwin == 1) {
    if (iserver == 6) {
	window.open(newpage,"","toolbar=1,location=1,titlebar=1,status=1,menubar=yes,scrollbars=1,resizable=yes");
    } else {
	window.open(newpage,"","width=800,height=600,toolbar=1,location=1,titlebar=1,status=1,menubar=yes,scrollbars=1,resizable=yes");
    }
  } else {
    window.location = newpage;
  }

}



function fsgox(vars,page,path,domainsuffix,ext,secure,newwin,iserver){
  var pathinfo = ""
  var domaininfo = ""

  if (path != '') {
    pathinfo = "/"+path;
  }


  if (domainsuffix != '') {
    if (secure == 1) {
      domaininfo = "https://www.fotosearch."+domainsuffix;
    } else {
      domaininfo = "http://www.fotosearch."+domainsuffix;
    }
  }

  if (iserver == 1) {
    domaininfo = "http://images.fotosearch.com/";
  } else if (iserver == 2) {
    domaininfo = "http://www.publishingperfection.com/";
  } else if (iserver == 3) {
    domaininfo = "http://www.adobe.com/";
  } else if (iserver == 4) {
    domaininfo = "http://www.apple.com/";
  } else if (iserver == 5) {
    domaininfo = "http://www.unlistedimages.com/";
  }

  if (ext != '') {
    ext = "."+ext;
    if (vars != '' && ext == '.asp'){
      if (vars.substring(0,1) == '#') {
        ext = ".asp" + vars;
      } else {
        ext = ".asp?" + vars;
      }
    }
  } else {
    ext = "index-2.html";
  }

  newpage = domaininfo+pathinfo+"/"+page+ext;
alert(newpage);
  if (newpage == '//') {
	newpage = 'index-2.html';
  }

  if (newwin == 1) {
    if (iserver == 5) {
	window.open(newpage,"","width=900,height=600,toolbar=1,location=1,titlebar=1,status=1,menubar=yes,scrollbars=1,resizable=yes");
    } else {
	window.open(newpage,"","width=800,height=600,toolbar=1,location=1,titlebar=1,status=1,menubar=yes,scrollbars=1,resizable=yes");
    }
  } else {
    window.location = newpage;
  }

}



function fslink(page){
 window.location=page;
}
function fslink_m(page,path){
 var pathinfo = ""
 if (path != '') {
	pathinfo = "/"+path;
 }
 window.location = pathinfo+"/"+page;
}
function fslink_md(page,path,domain){
 var pathinfo = ""
 if (path != '') {
	pathinfo = "/"+path;
 }
 var domaininfo = ""
 if (domain != '') {
	domaininfo = "http://"+domain;
 }
 window.location = domaininfo+pathinfo+"/"+page;
}
function fspoplink(page){
  window.open(page,"","width=800,height=600,toolbar=1,location=1,titlebar=1,status=1,menubar=yes,scrollbars=1");
}
function fspoplink_m(page,path){
var pathinfo = "/"+path+"/"+page 
window.open(pathinfo,"","width=800,height=600,toolbar=1,location=1,titlebar=1,status=1,menubar=yes,scrollbars=1");
}
function fspoplink_pdf(page,path){
var pathinfo = "/"+path+"/"+page 
window.open(pathinfo,"","toolbar=1,location=1,titlebar=1,status=1,menubar=yes,resizable=yes,scrollbars=1");
}
function fspoplink_ac(page){
  window.open(page,"","toolbar=1,titlebar=1,scrollbars=1,location=1,status=1,menubar=yes,resizable=yes");
}
function fslink_addcart(vars){
 window.location= "https://" + window.location.hostname + "/addtocart.asp?" + vars;
}
function fslink_addcart2(vars){
 window.location= "https://" + window.location.hostname + "/addtocart2.asp?" + vars;
}
function fssub_download(vars){
  page="http://images.fotosearch.com/oneclick.asp?" + vars + "&sd=1";
  window.open(page,"","width=410,height=400,toolbar=1,titlebar=1,scrollbars=1,location=0,status=0,resizable=yes");
}
function vidbigcomp(vars){
  window.open("http://images.fotosearch.com/vidcomp.asp?"+ vars,"","width=800,height=600,toolbar=1,location=1,titlebar=1,status=1,menubar=yes,scrollbars=1");
}
function fspoplink_lbm(page){
  window.open(page,"","width=410,height=400,toolbar=1,titlebar=1,scrollbars=1,location=0,status=0,resizable=yes");
}
function fssearch(path,page,style){
	if (style == "c"){
		window.location = "/" + path + "/" + page + ".html"
	} else {
	
		window.location = "resultsd41d.html?" +  page ;
	}
}
function loadpdf(page){
	var compURL = "loadpdfd41d.html?" +  page ;
	var w = window.open(compURL,"PDF","width=600,height=600,toolbar=1,titlebar=1,scrollbars=1,resizable=yes");
	w.focus();
}
function zoom(sku,image,language,fp){
 var compURL = "http://images.fotosearch.com/fszoom.asp?ref=xyiou&amp;pp_sku=" + sku + "&image_name=" + image + "&l=" + language + "&fp=" + fp;
 //var compURL = "/fszoom.asp?sku=" + sku + "&image_name=" + image + "&l=" + language;
 window.open(compURL,"Zoom","width=400,height=450,toolbar=0,titlebar=0,scrollbars=0");
}
function emailcomp(sku,image,path){
 var compURL = "emailcomp3525.html?sku=" + sku + "&image_name=" + image + "&image_path=" + path;
 window.open(compURL,"","width=400,height=450,toolbar=0,titlebar=0,scrollbars=0");
}

function bigcomp(path) {
   finalurl = "bigcomp0746.html?path=" + path;
   window.open(finalurl, "", "width=530,height=600");
}
function go(form) {
   var s = form.options[form.selectedIndex].value;
   parent.location = s;
}
function popUp(url) {
  sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
  self.name = "mainWin"; }

function clear_price() {
	document.criteria.price.value=0;
}

function reset_price() {
  var len2 = document.forms.criteria.elements.length;
  for(var i=2 ; i<len2 ; i++) {
    if (document.forms.criteria.elements[i].value == "") {
	clear_price();
    }
  }
}
function validate_RM(wbutton) {
  var len = document.forms.criteria.elements.length;
  for(var i=2 ; i<len ; i++) {
    if (document.forms.criteria.elements[i].value == "") {
		
		document.forms.criteria.elements[i].className='inputred';
		return false;
    } else {
		document.forms.criteria.elements[i].className='inputnorm';
    }
  }
  if (wbutton == 2){

		if (document.forms.criteria.tr.value == "1") {
			if (document.forms.criteria.terrestr.checked == false) {
				document.forms.criteria.terrestr.focus();
				document.getElementById('terrp').style.border='2px solid #f00';
				return false;
			} else {
				document.getElementById('terrp').style.border='1px solid #000';
			}
		}

 		document.forms.criteria.action="interview.html";
 } else {
   		document.forms.criteria.action="#";
 
		}
  return true;
}
function setPublishers()
{
  var len = document.forms[0].elements.length;
  for(var i=7 ; i<len ; i++) {
    if (document.forms[0].elements[7].checked) {
      document.forms[0].elements[i].checked = true;
    }
    else {
      document.forms[0].elements[i].checked = false;
    }
  }
}

function addbookmark(url,name){
if (document.all)
window.external.AddFavorite(url,name)
}
function isrcharspace(str){
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		return true;
	}
}
function searchfocus(){
	if (document.searchform.keyword.value != '<%=Glossary("searchlang")%>'){
		if (document.searchform.keyword.value != '' && isrcharspace(document.searchform.keyword.value) != 1){
			document.searchform.keyword.value=document.searchform.keyword.value + ' ';
			}
		document.searchform.keyword.focus();
	}
}
function isrcharspace(str){
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		return true;
	}
}

function RandRange( intFrom, intTo, intSeed ){
  intFrom = Math.floor( intFrom );
  intTo = Math.floor( intTo );
  return(Math.floor(intFrom + ((intTo - intFrom + 1) * Math.random((intSeed != null) ? intSeed : 0 ))));
}

function fvar(){
  var intI = 0;
  var sid = "";
  var xid = "";
  var intValue = 0;

  xid = Math.random() * 100000 + ''
  xid = String(xid).substring(0,11)

  for (intI = 0 ; intI < 10 ; intI++){
    intValue = RandRange( 97, 122, intI );
    sid += String.fromCharCode( intValue );
  }
  return "sid="+sid+"&xid="+xid
}

function browserwidth(){
	name = "browserwidth";
	days = 1;
	value = window.document.body.clientWidth;

	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function do_populate(){
	document.searchform.keyword.value = document.searchform.recentsearch.options[document.searchform.recentsearch.selectedIndex].value;
}

function calcpixels_adv(){
	var selres = document.searchform_adv.imageres.options[document.searchform_adv.imageres.selectedIndex].value;
	var inchheight = document.searchform_adv.printh.value;
	var inchwidth = document.searchform_adv.printw.value;
	if (document.searchform_adv.dimtype.options[document.searchform_adv.dimtype.selectedIndex].value == 'px'){
		document.searchform_adv.pixelh.value = Math.round(inchheight*1);
		document.searchform_adv.pixelw.value = Math.round(inchwidth*1);
	} else {

		if (document.searchform_adv.dimtype.options[document.searchform_adv.dimtype.selectedIndex].value == 'cm'){
			var inchheight = inchheight/2.54;
			var inchwidth = inchwidth/2.54;
		}
		document.searchform_adv.pixelh.value = Math.round(inchheight*selres);
		document.searchform_adv.pixelw.value = Math.round(inchwidth*selres);
	}
}

function selectAll(selectBox,selectAll) {
	// have we been passed an ID
	if (typeof selectBox == "string") {
		selectBox = document.getElementById(selectBox);
	}
	// is the select box a multiple select box?
	if (selectBox.type == "select-multiple") {
		for (var i = 0; i < selectBox.options.length; i++) {
			selectBox.options[i].selected = selectAll;
		}
	}
	name = "advancedsearch_pub";
	days = 1;
	value = "all";

	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function toggleAdvsearch(isload){
	if (document.getElementById('simplesearch').style.display == 'none'){
		name = "advsearch";
		days = 365;
		value = 0;
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		document.cookie = name+"="+value+expires+"; path=/";

	   document.getElementById('simplesearch').style.display = 'block';
	   document.getElementById('advsearch').style.display = 'none';
	   document.getElementById('body').style.top = '130px';

	} else {

		name = "advsearch";
		days = 365;
		value = 1;
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		document.cookie = name+"="+value+expires+"; path=/";

	   document.getElementById('simplesearch').style.display = 'none';
	   document.getElementById('advsearch').style.display = 'block';
	   document.getElementById('body').style.top = '280px';

	}
}

function togglePane(paneWidth){

   var paneWidth = paneWidth + 'px';

   if (document.getElementById('rightpanecontent').style.display == 'none') {
	var date = new Date();
	date.setTime(date.getTime()+(365*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "rightpanel=1"+expires+"; path=/";
	document.getElementById('rightpanecontent').style.display='block';
	document.getElementById('rightpanetopcontent').style.display='block';
	document.getElementById('rightpane').style.width=paneWidth;
	document.getElementById('rightpanetop').style.width=paneWidth;
	document.getElementById('rightpanemin').style.display='none';
	document.getElementById('rightpane').style.border='1px solid #777';
	document.getElementById('rightpane').style.borderTop=0;
   } else {
	var date = new Date();
	date.setTime(date.getTime()+(365*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "rightpanel=0"+expires+"; path=/";
	document.getElementById('rightpanecontent').style.display='none';
	document.getElementById('rightpanetopcontent').style.display='none';
	document.getElementById('rightpane').style.width=paneWidth;
	document.getElementById('rightpanetop').style.width=paneWidth;
	document.getElementById('rightpanemin').style.display='block';
	document.getElementById('rightpane').style.border=0;
   }
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}
