var properties1;
var properties2;
var leftPos = (screen.width/2) - 330;

IE=document.all?1:0;


var isdrag=false;
var mx,my;
var obj_g;


//preload images
image1 = new Image();
image1.src = "/images/icon_close.gif";
image2 = new Image();
image2.src = "/images/icon_close2.gif";
image3 = new Image();
image3.src = "/images/google-logo.gif";



//no right click menu
document.oncontextmenu=new Function("return false");

var Enlarge = false;
var EnlargeLink = "";

properties1='width=675,height=745,left='+leftPos+',top=0,toolbar=no,scrollbars=yes,status=no,menubar=no,resizable=yes';
properties2='width=660,height=710,left='+leftPos+',top=0,toolbar=no,scrollbars=yes,status=no,menubar=no,resizable=yes';





function GotoNewWin(val){
myVar=val;


if(IE)
  newWin=window.open('../SlideShow.htm','gallery',properties1);
else
  newWin=window.open('../SlideShow.htm','gallery',properties2);
  
 
 newWin.focus();
}

//for user to provide the information of the specific gallery, so that it can propagate later
//on in function prop_tables...
function setCond(iPath, pre, suf, SN, EN){
	
imagePath = iPath;
prefix = pre;
suffix = suf;

indexStartNum = SN;
indexEndNum = EN;
imageRange = (indexEndNum - indexStartNum + 1);

loopNum = Math.ceil(imageRange / 3);
remainNum = imageRange % 3;

indexNum = indexStartNum;
	
}


function AddGalleryHeader(tag, hname){
	
  document.write("<A name="+tag+"></a><table border =1 width = 100%><tr>");
  document.write("<td><strong><center>"+hname+"</center></strong></td>");
  document.write("</tr></table>");
	
}


//get the information which are set during executing the setCond function by user, 
//and then propagate tables for showing the pictures...
function prop_tables(){
	
	
	document.write("<Table border = '2' width = 100%>");
	
	
	for(i=0;i<loopNum;i++){

  document.write("<tr>");

  document.write("<td><center><a href=\"javascript:void(0)\" >");
  document.write("<img name=\""+indexNum+"\" border=0 src="+prefix+ indexNum++ +suffix+".jpg width=120 height=100 onClick=\"GotoNewWin(name);\" ></a></center></td>");

  if((i == loopNum-1) && (remainNum==1)){
  }else{
    document.write("<td><center><a href=\"javascript:void(0)\" >");
    document.write("<img name=\""+indexNum+"\" border=0 src="+prefix+ indexNum++ +suffix+".jpg width=120 height=100  onClick=\"GotoNewWin(name);\"></a></center></td>");
  }

  if((remainNum != 0) && (i == loopNum-1)){
  }else{
    document.write("<td><center><a href=\"javascript:void(0)\" >");
    document.write("<img name=\""+indexNum+"\" border=0 src="+prefix+ indexNum++ +suffix+".jpg width=120 height=100 onClick=\"GotoNewWin(name);\"></a></center></td>");
  }

  document.write("</tr>");
}

document.write("</table>");
	
}

//adding a back link
function AddBackBtn(){
	
	document.write("<br>");
  document.write("<div align=center>");
  document.write("<a href=\"javascript:history.go(-1)\"><font size=4pt>Back</font></a>");
  document.write("</div>");
  document.write("<br>");
  document.write("<br><br>");

}
	
	
//remove the google_map tooltips...
function rem_descr(){
		document.getElementById('google_map').style.visibility= "hidden";
		document.getElementById('shadow').style.visibility= "hidden";
	  
	  document.forms[0].saddr.value='';
	  document.forms[0].saddr.blur();	
}
	

//display the google_map tooltips...
function dis_descr(num){
	
	if(document.getElementById('google_map').style.visibility=="visible")
	  return false;

	if(num==1){  //church address
		document.getElementById('hideInput_id').innerHTML = '<input name="q" value="200 W Commonwealth Ave, Alhambra, CA 91801" type="hidden"><input name="daddr" value="200 W Commonwealth Ave, Alhambra, CA 91801" type="hidden">';
	  document.getElementById('map_id').innerHTML = '<a href="http://www.google.com/maps?q=200+W+Commonwealth+Ave,+Alhambra,+CA+91801&sa=X&oi=map&ct=image" target=_blank><img src="http://www.google.com/mapdata?Point=b&Point.latitude_e6=34091086&Point.longitude_e6=4176840342&Point.iconid=33&Point=e&latitude_e6=34091086&longitude_e6=4176840342&zm=2400&w=304&h=156&cc=US&min_priority=1" title="200 W Commonwealth Ave, Alhambra, CA 91801" style="margin-right: 12px;" border="1" height="156" width="304"></a>';
	
	}	else if(num==0){  //small group address
		document.getElementById('hideInput_id').innerHTML = '<input name="q" value="111 Park St Alhambra, CA 91801-4447" type="hidden"><input name="daddr" value="111 E Park St, Alhambra, CA 91801" type="hidden">';
		document.getElementById('map_id').innerHTML = '<a href="http://google.com/maps?q=111+E+Park+St,+Alhambra,+CA+91801&amp;sa=X&amp;oi=map&amp;ct=image" target=_blank><img src="http://google.com/mapdata?Point=b&amp;Point.latitude_e6=34089121&amp;Point.longitude_e6=4176846069&amp;Point.iconid=33&amp;Point=e&amp;latitude_e6=34089121&amp;longitude_e6=4176846069&amp;zm=2400&amp;w=304&amp;h=156&amp;cc=US&amp;min_priority=1" title="111 E Park St, Alhambra, CA 91801" style="margin-right: 12px;" border="1" height="156" width="304"></a>';
	}	else if(num==2){  //VKC address
		document.getElementById('hideInput_id').innerHTML = '<input name="q" value="3518 Trousdale Parkway, Los Angeles, CA 90089" type="hidden"><input name="daddr" value="3518 Trousdale Parkway, Los Angeles, CA 90089" type="hidden">';
		document.getElementById('map_id').innerHTML = '<a href="http://google.com/maps?q=3518+Trousdale+Parkway+,+Los+Angeles,+CA+90089&amp;sa=X&amp;oi=map&amp;ct=image" target=_blank><img src="http://www.google.com/mapdata?Point=b&Point.latitude_e6=34021456&Point.longitude_e6=4176682783&Point.iconid=33&Point=e&latitude_e6=34021456&longitude_e6=4176682783&zm=2400&w=304&h=156&cc=US&min_priority=1" title="3518 Trousdale Parkway, Los Angeles, CA 90089" style="margin-right: 12px;" border="1" height="156" width="304"></a>';
	}
	
	
		
	if(document.all){ //IE browser
	  browserO = document.body.scrollTop;
	}else{
	  browserO = window.pageYOffset;
	}

	
	document.getElementById('google_map').style.top = browserO + 55;
	document.getElementById('google_map').style.left = 48;
	
	tt_top = parseInt(document.getElementById('google_map').style.top);
	tt_left = parseInt(document.getElementById('google_map').style.left);

	document.getElementById('shadow').style.top = tt_top+11;
	document.getElementById('shadow').style.left = tt_left+11;

  document.getElementById('google_map').style.visibility= "visible";
	document.getElementById('shadow').style.visibility= "visible";
	
	setTimeout('document.forms[0].saddr.focus()',500);
}
	
	
function showShadow(){
	tt_top = parseInt(document.getElementById('google_map').style.top);
	tt_left = parseInt(document.getElementById('google_map').style.left);

	document.getElementById('shadow').style.top = tt_top+11;
	document.getElementById('shadow').style.left = tt_left+11;

document.getElementById('shadow').style.visibility = "visible";

    obj_g.style.opacity = 1;
    obj_g.style.filter = 'alpha(opacity=100)';

}


//event occurs when mousedown an object...
function ifObjSelected(e){
  obj = (!IE)?e.target:event.srcElement;
  topElement =(obj.tagName == "HTML" || obj.tagName == "BODY" || obj.tagName == "INPUT")?1:0;


  while (!topElement && obj.className != "noDragme" && obj.className != "dragme"){
    obj = (!IE)?obj.parentNode:obj.parentElement;
  }
  
  //in IE, 'e' is not recognize, so it will set 'e' as event, otherwise it will be act like event in FF
  e = (e)?e:event;
    
  if (obj.className=="dragme" && e.button!=2){
    isdrag = true;
    obj_g = obj;  //creating a new object for changing a new position while user drags the object...

    tx = parseInt(obj.style.left+0);
    ty = parseInt(obj.style.top+0);
    mx = e.clientX;
    my = e.clientY;
    document.onmousemove=movingObj;
    
    document.getElementById('shadow').style.visibility = 'hidden';
    
    obj_g.style.opacity = 0.7;
    obj_g.style.filter = 'alpha(opacity=70)';

    return false;
  }
}

//while user is dragging the object, it will update the location following the position of the mouse
function movingObj(e){
  if (isdrag){
    e = (e)?e:event;
    
    obj_g.style.left = tx + e.clientX - mx;
    obj_g.style.top = ty + e.clientY - my;

  }
}


