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 repImgSrc(obj,newSrcString){
    obj.src=newSrcString;
}

function roll(id)
{
    rollObj=document.getElementById('roll_'+id);
    rollSignObj=document.getElementById('rollSign_'+id);
    if(rollObj.style.display=='block'){
        rollObj.style.display='none';
        rollSignObj.innerHTML='+';
    }
    else {
        rollObj.style.display='block';
        rollSignObj.innerHTML='-';
    }
    return false;
}

var openedObjId=null;
var openedWinObj=null;
function show(id, parentId)
{
    contentObj=document.getElementById(id);
    winObj=document.getElementById(parentId);
    viewState=false;
    if(winObj.style.display=='block') viewState=true;
    
    if(openedObjId==id && viewState==true){
        winObj.style.display='none';
    }
    else{
    	if(openedWinObj!=null){
    		openedWinObj.style.display='none';
    	} 
        winObj.innerHTML=contentObj.innerHTML;
        winObj.style.display='block';
    }
    openedObjId=id;
    openedWinObj = winObj;
    return false;
}

function popupLrg(imgObj,src)
{
    obj=document.getElementById('popupWin');
    obj.innerHTML="<div class='popuWin' style='padding: 5; background-color: #ffffff; border: 1px solid #cdcdcd;' onmouseout='popupHide();' ><img src='" + src + "' width='400' height='400' border='0' style='background-color: #F36E3F;' /></div>";
    
    var ox,oy;
    for(ox=oy=0;imgObj;imgObj=imgObj.offsetParent)ox+=imgObj.offsetLeft, oy+=imgObj.offsetTop;
    obj.style.top=oy;
    obj.style.left=ox;
    obj.style.display='block';
    return false;
 }
 
function popupHide()
{
    obj=document.getElementById('popupWin');
    obj.style.display='none';
    return false;
}

function showGallery(clientId)
{
	winObj=document.getElementById('popupWin');
	//winObj.style.top=300;
	//winObj.style.left=310;
	winObj.innerHTML='';
	winObj.style.display='block';
	change('gallery_ajax.asp?id='+clientId);
	return false;
}

function newWin(html){
	winObj=document.getElementById('popupWin');
	winObj.innerHTML=html;
	return false;
}

// AJAX stuff
ldr=null;
function change(theURL)
{
	 if(ldr&&ldr.readyState!=0) { ldr.abort() }
	 ldr=selector();
	 if(ldr)
	 {
		var now = new Date();
		ldr.open("GET",theURL+"&t="+now.getSeconds(),true);
		ldr.onreadystatechange=function()
		{
			if(ldr.readyState==4 && ldr.responseText)
			{
				newWin(ldr.responseText);
			}
		};
		ldr.send(null)
	 }
	 return false;
}

function selector()
{
	var A=null;
	try{A=new ActiveXObject("Msxml2.XMLHTTP")}
	catch(e){try{A=new ActiveXObject("Microsoft.XMLHTTP")}
	catch(oc){A=null}}
	if(!A&&typeof XMLHttpRequest!="undefined") {A=new XMLHttpRequest()}
	return A
}
