var helpPage="help",iCurFolio = 0;

function popup(newURL)
{
    var prpopupwindow = window.open(newURL,"prpopupwindow","width=580,top=110,left=250,status=yes,toolbar=no,menubar=yes,resizable=yes,location=no,scrollbars=yes,titlebar=yes");
	prpopupwindow.focus();
}

function checkLength(field,len)
{
if (field.value.length>len)
 {
 alert('Please limit your entry to '+new String(len)+' characters.');
 field.value = field.value.substr(0,len);
 field.focus();
 }
}

function clickcartitem(cartitem)
{
cartitem.value=0;
document.cartform.submit();
}

function emptycart()
{
 for(i=0;i<document.cartform.elements.length;i++)
 {
 if (document.cartform.elements[i].name.indexOf('copies')!=-1)
   {
   document.cartform.elements[i].name = 'empty.x';
   break;
   }
 }
 document.cartform.submit();
}

function popHelp(newURL)
{
 switch(newURL)
  {
  case "help":
   newURL="main.shtm";
   break;
  case "helpalbum":
   newURL="main.shtm";
   break;
  case "helpcart":
   newURL="main.shtm?004003";
   break;
  case "helpeventorderpackages":
   newURL="main.shtm?004002001";
   break;
  case "helpeventthumbs":
   newURL="main.shtm?004001";
   break;
  case "heleventzoom":
   newURL="main.shtm?004002002";
   break;
  case "helpeventzoomnav":
   newURL="main.shtm?004002002";
   break;
  case "helpfindadvfaq":
   newURL="main.shtm";
   break;
  case "helpfindfaq":
   newURL="main.shtm";
   break;
  case "helpfindfaqcb":
   newURL="main.shtm";
   break;
  case "helpfindhome":
   newURL="main.shtm";
   break;
  case "helpphotograper":
   newURL="main.shtm";
   break;
  case "helpphotographer":
   newURL="main.shtm";
   break;
  case "helppurchase":
   newURL="main.shtm";
   break;
  case "helpsearch":
   newURL="main.shtm";
   break;
  case "helpstatus":
   newURL="main.shtm";
   break;

  case "Help":
   newURL="main.shtm";
   break;
  case "HelpAlbum":
   newURL="main.shtm";
   break;
  case "HelpCart":
   newURL="main.shtm?004003";
   break;
  case "HelpEventOrderPackages":
   newURL="main.shtm?004002001";
   break;
  case "HelpEventThumbs":
   newURL="main.shtm?004001";
   break;
  case "HelpEventZoom":
   newURL="main.shtm?004002002";
   break;
  case "HelpEventZoomNav":
   newURL="main.shtm?004002002";
   break;
  case "HelpFindAdvFaq":
   newURL="main.shtm";
   break;
  case "HelpFindFaq":
   newURL="main.shtm";
   break;
  case "HelpFindFaqCB":
   newURL="main.shtm";
   break;
  case "HelpFindHome":
   newURL="main.shtm";
   break;
  case "HelpPhotograper":
   newURL="main.shtm";
   break;
  case "HelpPhotographer":
   newURL="main.shtm";
   break;
  case "HelpPurchase":
   newURL="main.shtm";
   break;
  case "HelpSearch":
   newURL="main.shtm";
   break;
  case "HelpStatus":
   newURL="main.shtm";
   break;
  }
 
    var pWidth=370,pHeight=1200,pLeft=0,mWidth=1280;
    
	if(screen.availWidth)pLeft = screen.availWidth-pWidth-10;
    pHeight = (screen.availHeight>pHeight) ? pHeight:screen.availHeight-80;
	mWidth = (screen.availWidth>mWidth) ? mWidth-pWidth:screen.availWidth-(pWidth+10);
    var wFeatures = 'height='+pHeight+',width='+pWidth+',top=0,left='+pLeft+',status=no,toolbar=no,menubar=no,resizable=yes,location=no,scrollbars=yes,titlebar=no';
    var hDom = 'www';
    if(document.location.href.indexOf('www.')==-1)
     {
     if(document.location.href.indexOf('stage.')!=-1)hDom='stage';
     if(document.location.href.indexOf('web03.')!=-1)hDom='web03';
     }
    var prhelpwindow = window.open('http://'+hDom+'.photoreflect.com/help/'+newURL,'prhelpwin',wFeatures);
if(prhelpwindow)
 {
 if(window.location.href.indexOf('eventthumbs')!=-1)
  {
       prhelpwindow.opener.parent.moveTo(0,0);
       prhelpwindow.opener.parent.resizeTo(mWidth,pHeight);
       prhelpwindow.focus();
  }
  else
  {
       prhelpwindow.opener.moveTo(0,0);
       prhelpwindow.opener.resizeTo(mWidth,pHeight);
       prhelpwindow.focus();
  }
 }
}

function popHelpOLD(helpPage)
{
  if (helpPage!="help")
    {
    var helpString="openPopup(\'/scripts/prsm.dll?Page?page="+helpPage+"\',\'HelpWindow\',\'status,scrollbars,resizable,width=400,height=400\')";
    eval(helpString);
    }
    else
    {
    openPopup('/scripts/prsm.dll?Help','HelpWindow','status,scrollbars,resizable,width=400,height=400');
    }
}

function ClearThis(vDateName)
{
var enteredstring = new String(vDateName.value);
if(enteredstring.indexOf('mm')!=-1||enteredstring.indexOf('all events')!=-1)
 {
 vDateName.value = "";
 }
}

function setDefaultThis(thefield,thedefault)
{
if (thefield.value=="")thefield.value=thedefault;
}

function EmptyCartAlert()
{
  alert("Your cart is empty. Please add a photo or other item before viewing cart.");
}

function submitThis(form)
{
form.submit();
}

function dateMMDDYYYY(style)
{
var date= new Date();
var strDate = new String;
var datepart = new String;

datepart = new String(date.getMonth()+1);
if (datepart.length == 1)
 {
 datepart = "0" + datepart
 }
strDate = datepart+"/";

if (style != 1)
 {
 datepart = new String(date.getDate());
 if (datepart.length == 1)
  {
  datepart = "0" + datepart
  }
 strDate += datepart+"/";
 }

var datepart = new String(date.getYear());
if (datepart == '100')
  datepart = 2000;
strDate += datepart;

return strDate;
}

function popUpVeriSign() {
  sealWin=window.open('https://seal.verisign.com/splash?form_file=fdf/splash.fdf&type=GOLD&sealid=1&dn=WWW.PHOTOREFLECT.COM&lang=en',"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=570,height=450');
  self.name = "mainWin";
}

var message='All copyrights are the property of their respective owners.';
function clickIE() {if (document.all) {alert(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {alert(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")

function exChange()
{
 if(document.xImg)
 {
 var urlStart = new String("/scripts/prsm.dll?Market?g=");
 var oldURL = new String(), newURL = new String();
 var oldSrc = new String(), newSrc = new String(), arIndex = 0;
 var imgAr = new Array("Exposures1.jpg","Exposures2.jpg","Exposures3.jpg","Exposures4.jpg")
   if (document.xImg.src.indexOf("trans")==-1)
   {
    oldSrc = new String(document.xImg.src)
    newSrc = oldSrc.substr(oldSrc.indexOf("exposures/")+10,oldSrc.length)
    for(i=0;i<imgAr.length;i++)
     {
      if (imgAr[i]==newSrc)
       {
       arIndex = i+1;
       }
     }
    if (arIndex==imgAr.length)
     {
     arIndex=0;
     }
   }
  newSrc = new String("/images/exposures/"+new String(imgAr[arIndex]));
  document.xImg.src = newSrc;
  document.anchors[0].href = "/scripts/prsm.dll?Market"; //Removed jump to product
  var timerID = setTimeout('exChange()',8000);
 }
}

function openPopup(theURL,theName, theSpecs) {
  var openPackage = window.open(theURL, theName, theSpecs);
  openPackage.top.focus()
}

function thumbChecks()
{
for(i=0;i<document.forms[0].elements.length;i++)
 {
   if (String(document.forms[0].elements[i].name).substring(0,5) == "check" && document.forms[0].elements[i].checked)
     {
     if (confirm("You have photos selected.\n\nClick OK to lose photo selections or Cancel and \"add selected photos to album\" before changing pages"))
       {
       return true;
       }
     else
       {
       return false;
       }
     }
 }
}

function trim(value) 
{
	startposn=0;
	while((value.charAt(startposn)==" ")&&(startposn<value.length)) 
    {
		startposn++;
	}
	if(startposn==value.length) 
    {
		value="";
	} 
    else 
    {
		value=value.substring(startposn,value.length);
		endposn=(value.length)-1;
		while(value.charAt(endposn)==" ") 
        {
			endposn--;
		}
		value=value.substring(0,endposn+1);
	}
	return(value);
}

function checkAlpha(charn)
{
  if (charn > 47 && charn <58)
   {return true;}
   else
   {if (charn >64 && charn <91)
     {return true;}
     else
     {if (charn >96 && charn <123)
       {return true;}
       else
       {return false;}
     }
   }
}

function CheckLogin(form, newA)
{
  if(form.e)
   {
   field=form.e.value;
   field=trim(field);
   form.e.value=field;
   if (form.e.value=="")
   {
     alert("An E-mail address is required");
     return false;
   }
  }
  if(form.p&&newA!=2)
  {   
   field=form.p.value;
   field=trim(field);
   form.p.value=field;
   if (form.p.value=="")
   {
     alert("A password is required");
     return false;
   }
  }
  if(form.p1)
  {    
   field=form.p1.value;
   field=trim(field);
   form.p1.value=field;
   if (form.p1.value=="")
   {
     alert("A password is required");
     return false;
   }
  }
  FixPassword(form)
  if (newA > 0&&form.p2)
  {
	  if (form.p1.value != form.p2.value)
      {
	    alert("Password and Verify Password must be the same");
    	return false;
	  }
	  if (form.p1.value.length < 5 || form.p1.value.length > 16)
      {
	    alert("Passwords must be between 5 and 16 characters");
    	return false;
	  }
      len = form.p1.value.length;
      while (len > 0)
      {
      if (!checkAlpha(form.p1.value.charCodeAt(len-1)))
       {
       alert("Please specify a password with numbers and letters only");
       return false;
       }
      --len;
      }
  } 
}

function FixPassword(form)
{
      if (form.p&&!form.p1)
       {
       re = / /gi
       reand = /&/gi
       len = form.p.value.length;
       while (len > 0)
	 {
	   if (form.p.value.charAt(len-1) == ' ')
   	    form.p.value = form.p.value.substring(0,len-1);
          else
          break;
         --len;
	  }	
	  form.p.value = form.p.value.replace(re,'%20');
	  form.p.value = form.p.value.replace(reand,'%38');
       }

      if (form.password)
       {
       re = / /gi
       reand = /&/gi
       len = form.password.value.length;
       while (len > 0)
	 {
	   if (form.password.value.charAt(len-1) == ' ')
   	    form.password.value = form.password.value.substring(0,len-1);
          else
          break;
         --len;
	  }	
	  form.password.value = form.password.value.replace(re,'%20');
	  form.password.value = form.password.value.replace(reand,'%38');
       }

}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

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);


