// document.domain=	'bunk1.com';
function val()
	{
	if ((document.search1.searchtext.value)== '')
		{
		alert('Please enter a keyword');
		document.search1.searchtext.focus();
		return false;
		}
	else
		return true;
	}

function opFavorites( url )
{
	if (which>0)
		document.location = url + "&pid=" + photosID[which] + "&which=" + which;
	else
		document.location = url + "&pid=" + photosID[which];	
}
function sndBunkNote( url )
{
	var s = photosUploader[which];
	/* 
	var loc = s.indexOf("iurl=");
	if (loc>0)
		s = s.substring(loc+5);
	loc = s.indexOf("/ImagesSrv")
	if (loc>0 )
		s = s.substring(loc+11)
	*/
	var s1 = s.substring(0, s.length-54)
	var loc = s1.lastIndexOf("/");
	if (loc>0) {
		s = s.substring(loc+1);
		document.location = url + "&img=" + s;
	}
}

var usingNewEzPrintForm=true;
function fillEzPrintForm(sPhoto, sTitle, sThumb, iImageX, iImageY)
{ 
	var EzPrint = document.EzPrint;
	if (sThumb.indexOf("/photogallery/thumbnail")==-1) {
		// howie@8/9/05: make sure using thumbnail pictures
		var re;
		re = /photogallery/g;
		sThumb = sThumb.replace(re, "photogallery/thumbnail");
	}
	if ( usingNewEzPrintForm ) {
		EzPrint.hi_res_url0.value = sPhoto;
		EzPrint.lo_res_url0.value = sThumb;
		EzPrint.title0.value = sTitle;
		EzPrint.width0.value = iImageX;
		EzPrint.height0.value = iImageY;
		EzPrint.count.value = "1";
	} else {	
		EzPrint.Photo.value = sPhoto;
		EzPrint.Thumb.value = sThumb;
		EzPrint.Title.value = sTitle;
		EzPrint.ImageX.value = iImageX;
		EzPrint.ImageY.value = iImageY;
		EzPrint.EntryType.value = "SingleImage";
	}
	var argc = fillEzPrintForm.arguments.length;
	if (argc>5)
		EzPrint.ProductID.value = '30001';
	EzPrint.submit();
}
function fillMultiEzPrintForm( )
{ 
	var EzPrint = document.EzPrint;
	if ( !usingNewEzPrintForm )
		EzPrint.EntryType.value = "MultiImage";
	EzPrint.submit();
}
// take 9 parameters
function fillShutterflyForm(raw, thumb, width, height, thumb_width, thumb_height, id, name, caption)
{ 
	var frm = document.Shutterfly;
	frm["imraw-0"].value = raw;	
	frm["imthumb-0"].value = thumb;
	frm["imrawwidth-0"].value = width;
	frm["imrawheight-0"].value = height;
	frm["imthumbwidth-0"].value = thumb_width;
	frm["imthumbheight-0"].value = thumb_height;
	frm.picid0.value = id;
	// frm.imgpath0.value = name;
	frm.caption0.value = unescape(caption);
	frm["imsel-0"].value = "1";
	frm.imnum.value = "1";
	frm.submit();
}
function fillMultiShutterflyForm()
{ 
	var frm = document.Shutterfly;
	frm.useonlyselected.value = "0";
	frm.submit();
}
// open a popup to see the large image
function popLargeImage( img_url ) {
	var loc = img_url.indexOf("iurl=");
	if (loc>0)
		img_url = img_url.substring(loc+5);
	window.open('/template/gallery.aspx?op=8&img='+img_url,'',
		'left=10,top=10,width=920,height=620,status=no,scrollbars=no,menubar=no,resizable=yes');
}
function openShare(url) {
	var n=open(url,'port','width=400,height=490,status=no,scrollbars=yes,menubar=no,resizable=yes');
}
function openFAQ() {
	//var n =open('/template/photo_faq.htm','port','width=760,height=475,status=no,scrollbars=yes,menubar=no,resizable=yes');
	//--irena 082406 -- new help integration
	url = 'contact_form.asp?form_camp_id='
	var n=open(url,"port","width=500,height=520,status=no,scrollbars=yes,menubar=no,resizable=yes");
}

function openAOL() {
	var n=open('/template/aol_users.htm','port','width=450,height=400,status=no,scrollbars=yes,menubar=no,resizable=yes');
}

var iTotalPages=0;
function reload( per_page, url)
{
	document.location = unescape(url) + '&PerPage=' + per_page; 
}

// evt is passed through eventHandler;
function gotoPageEvent(evt, iTotalPages, url)
{
	if (evt!==null)
		if (evt.keyCode!=10 && evt.keyCode!=13) return false;
	gotoPage( iTotalPages, url );
	return false;
}
function gotoPage(iTotalPages, url)
{
	// get the page;
	var page = NaN;
	if ( typeof(document.paging)=='object' )
		page = parseInt(document.paging.go_page.value);
	if (isNaN(page)) {
		if (is.ie) {
			page = parseInt( document.all['go_page'].value );
			if ( isNaN(page) )
				page = parseInt( document.all['go_page'][0].value );
		} else if (is.ns)
			page = parseInt( document.getElementById('go_page').value );
	}
	if (isNaN(page)) {
		alert('Input a page no between 1 to ' + iTotalPages + '!' );
		return false;
	} else {
	    if ( page<=1) page=1;
	    if ( page>=iTotalPages ) page=iTotalPages;
		document.location = unescape(url) + '&Page=' + page;
		return false;
	}	
}
function imgHover( obj )
{
	//with ( obj.style )
	//{
	//	border-left = "solid 1px black";
	//	border-top = "solid 1px black";
	//	border-right = "solid 1px white";
	//	border-bottom = "solid 1px white";
	//}
}
function openMedia(strMediaId, intCampId, booVoSS, CampName) {
	var strUrl = '/include/media.aspx?bpf=1&Id=' + strMediaId + '&form_camp_id='+ intCampId + '&bvss=' + booVoSS + '&CampName=' + CampName;
	var n=open(strUrl,"port","width=450,height=500,status=yes,scrollbars=yes,left=80,top=80,menubar=no,resizable=yes");
}
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
function getInternetExplorerVersion(){
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}
function disable(link){
    //if (getInternetExplorerVersion() != -1){
	    var hyperlink = document.getElementById(link.id);
	    //var href = hyperlink.href;
	    hyperlink.innerHTML = "Loading... Please Wait!";
	    hyperlink.disabled = true;  //ie only
	    //hyperlink.href = "";
	    //hyperlink.setAttribute("class", "DisabledPhotoLink");
	    //hyperlink.setAttribute("className", "DisabledPhotoLink");
		hyperlink.className = "DisabledPhotoLink";
	    //window.location = href;
	    return false;
	//}
}
