

function getObj(id){
	return $('#' + id)[0];
}

function getTicks(){
    var d = new Date();
    var s= 'a'
    try{
	    s += padout(d.getMonth())
	    s += padout(d.getDate())
	    s += padout(d.getYear())
	    s += padout(d.getHours())
	    s += padout(d.getMinutes())
	    s += padout(d.getSeconds())
    }catch(e){}
    return s
}

function ShowImg(image,id,imageHref,width,height){
    m = getObj(id);
    href = getObj(imageHref);
    href.href = image;
    m.src = image;
    if(width > 235)
        m.width = 235;
     else
        m.width = width;
}

function openfile(id,site, from){
	var loc = site + '/Common/OpenFile.aspx?from=' + from + '&id=' + id;
    //w = window.location = loc;
	OpenDocument(loc);
}

function openFileForObject(objID, site, from, entityID, fieldID){
	var loc = site + '/Common/OpenFile.aspx?from=' + from + '&id=' + objID + '&entID=' + entityID + '&fieldID=' + fieldID;
	//w = window.location = loc;
	OpenDocument(loc);
}

function OpenDocument(site){
	var iframeId = "DownloadPanel";
	if(!jQuery('#' + iframeId)[0]){
		jQuery("body").append('<iframe id="' + iframeId + '" style="display:none;" />');
	}
	jQuery('#' + iframeId).attr('src', site);
}

function printResults(site){
    w = window.open(site + '/Common/PrintMembers.aspx?all=0', null, 'resizable=no,scrollbars=yes status=no, width=650, height=800, left=10, top=10');
}

function printAll(site){
    w = window.open(site + '/Common/PrintMembers.aspx?all=1', null, 'resizable=no, scrollbars=yes, status=no, width=650, height=800, left=10, top=10');
}

function printOne(site, id){
    w = window.open(site + '/Common/Print.aspx?all=0&NID='+id+'', null, 'resizable=no,scrollbars=yes status=no, width=650, height=800, left=10, top=10');
}

function printMany(site,fv1,fv2,fv3){
    w = window.open(site + '/Common/Print.aspx?all=1&fv1='+fv1+'&fv2='+fv2+'&fv3='+fv3+'', null, 'resizable=no, scrollbars=yes, status=no, width=650, height=800, left=10, top=10');
}

function keyUp(e, id){
    try { 
        k = event.keyCode   // ie
    }catch(e){}
    
    try { 
        k = e.keyCode       // mozilla
    }catch(e){}
    
    if(k == 13){
        $('#' + id).focus();
        $('#' + id).click();
    }
}

function searchClick(e, id){
    if(getObj(id).value == "Search...")
        getObj(id).value = ""; 
}

function searchOut(e, id){
    if(getObj(id).value == "")
        getObj(id).value = "Search..."
}

function DownloadFile(buttonId, panelId){
	$('#' + panelId).show();
	setTimeout(function(){$('#' + buttonId).click();}, 100);
}

