PHP Libraries
by Kristoffe Brodeur.
All of this code is cross-browser compatible. They are always being modified as browser compliance changes.
accordion_test
/*
accordion_test.js by Kristoffe Brodeur. ©2010 ALl Rights Reserved.
02-20-2010
*/
//-----accordion an area with jquery
function test(sObjStr)
{
var debug=document.getElementById('debug');
var oStr="#"+sObjStr;
//debug.innerHTML=sObjStr;
//
if($(oStr).is(":hidden"))
{
$(oStr).slideDown('fast');
}
else
{
$(oStr).slideUp('fast');
}
}
//-----slideUp areas (different on each page type per section to fake a continuous animation)
function multiTest(str)
{
var strArr=str.split(",");
var len=strArr.length;
//
for(a=0;a<len;a++)
{
test(strArr[a]);
}
}
anchor_imgText
/*
imgs inplace of anchor tags v2.0 by Kristoffe Brodeur. ©2010 All Rights Reserved.
02-17-2010
*/
var menuCode=document.getElementById('menu_main');
var debug=document.getElementById('debug');
//toggleDiv('debug');
//menuCode.style.visibility='hidden';
var anchorTags=menuCode.getElementsByTagName("a");
var len=anchorTags.length;
var nodeImg="";
var nName="";
//
for(n=0;n<len;n++)
{
nName=anchorTags[n].id;
//debug.innerHTML+=nName;
nodeImg="<img src='"+to_root+"mach/img/"+anchorTags[n].id+".png' width='200px' height='18px'/>";
document.getElementById(nName).innerHTML=nodeImg;
}
docTools
/*
docTools.js v2.0 by Kristoffe Brodeur. ©2010 All Rights Reserved
04-19-2010 good for even IE6
only works with a doctype declared, otherwise it doesn't measure the height properly
without doctype declared, measuring the document.clientHeight works better
*/
var docW=-1;
var docH=-1;
//
if(typeof window.innerWidth !='undefined')
{
docW=window.innerWidth,
docH=window.innerHeight
}
//IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
else if(typeof(document.documentElement)!='undefined' && typeof(document.documentElement.clientWidth)!='undefined' && document.documentElement.clientWidth !=0)
{
docW=document.documentElement.clientWidth,
docH=document.documentElement.clientHeight
}
// older versions of IE
else
{
docW=document.getElementsByTagName('body')[0].clientWidth;
docH=document.getElementsByTagName('body')[0].clientHeight;
}
getStyleVal
//getStyleVal v1.0 by Kristoffe Brodeur. ©2010 All Rights Reserved.
//-----
function getStyleVal(sourceID,IEname,CSSname)
{
var prop="";
var node=document.getElementById(sourceID);
//
if(node.currentStyle)
{
prop=node.currentStyle[IEname];
}
else if(window.getComputedStyle)
{
prop=window.getComputedStyle(node,"").getPropertyValue(CSSname);
}
return(prop);
}
home_accordion
/*
home menu accordion v1.0 by Kristoffe Brodeur. ©2010 All Rights Reserved.
02-04-2010 figuring out compatible FF IE CHROME and SAFARI bugs
*/
var size_shrink=62;
var buttons=new Array();
buttons[0]=new Array("mm0","mm1","mm2","mm3");
buttons[1]=new Array("mm4","mm5","mm6","mm7");
var cols=buttons[0].length;
var len1=buttons.length;
var home_prev=-1;
var home_curr=-1;
var busy=-1;
var debug=document.getElementById('debug');
var swf="";
var blurbStr="";
var pt=0;
var squish=3;
var sWidth="208";
var sHeight="126";
var buttID=-1;
//-----
function change_case(sID)
{
//
if(flash_gallery.style.display=="none"){toggleDiv('flash_gallery');}
//toggleDiv('flash_gallery');
debug.innerHTML=sID;
var fWidth="500";
var fHeight="500";
swf=to_root+"mS/admin/show_caseGallery.swf?to_root=&bID="+sID;
var caseSwf="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' width='"+fWidth+"' height='"+fHeight+"' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='"+swf+"' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#ffffff' /><embed src='"+swf+"' quality='high' wmode='transparent' bgcolor='#ffffff' width='"+fWidth+"' height='"+fHeight+"' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer' /></object>";
flash_gallery.innerHTML=caseSwf;
}
//-----
//
for(var m=0;m<len1;m++)
{
var len2=buttons[m].length;
//
for(var n=0;n<len2;n++)
{
pt=m*4+n+1;
//image area
var bName=buttons[m][n];
//flash text area
var blurb=bName+"b";
setAlpha(document.getElementById(bName),.5);
var blurbObj=document.getElementById(blurb);
blurbObj.style.height=sHeight+"px";
var nStr='"'+(cols*m+n)+'"';
swf=to_root+"mS/admin/show_casestudy.swf?to_root=&bID="+pt;
blurbStr="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' width='"+sWidth+"' height='"+sHeight+"' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='"+swf+"' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#ffffff' /><embed src='"+swf+"' quality='high' wmode='transparent' bgcolor='#ffffff' width='"+sWidth+"' height='"+sHeight+"' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer' /></object>";
blurbObj.innerHTML=blurbStr;
blurbObj.style.width=squish+"px";
blurbObj.style.visibility="hidden";
//
$("#"+bName).mouseover
(
function()
{
var num=parseInt(this.id.replace(/[a-z]/g,""));//get rid of a-z and keep 0-9 etc
changeHomeIcon(num);
}
);
}
}
//-----
function homeGallery(sID)
{
debug.innerHTML=sID;
}
//-----
function setAlpha(sObj,sAmt)
{
//FF 0.0-1.0
sObj.style.opacity=sAmt;
//IE 0-100
sObj.style.filter='alpha(opacity="'+(sAmt*100)+'")';
}
var prevCol=-1;
var PrevRow=-1;
var currCol=-1;
var currRow=-1;
//-----
function changeHomeIcon(sID)
{
var cCol=Math.floor(sID/4);
var cRow=sID-cCol*4;
var debug=document.getElementById('debug');
//
if(home_curr!=-1&home_curr!=sID&busy!=1)
{
debug.innerHTML=currCol+":"+currRow+"|"+buttons[currCol][currRow];
setAlpha(document.getElementById(buttons[currCol][currRow]),.5);
currCol=cCol;
currRow=cRow;
setAlpha(document.getElementById(buttons[currCol][currRow]),1);
busy=1;
home_prev=home_curr;
home_curr=sID;
var pCol=Math.floor(home_prev/4);
var pRow=home_prev-pCol*4;
toggleDivVis(buttons[cCol][cRow]+"b");
$("#"+buttons[cCol][cRow]+"b").animate({width:sWidth+"px"},300);
$("#"+buttons[pCol][pRow]+"b").animate({width:squish+"px"},300,function(){busy=-1;toggleDivVis(buttons[pCol][pRow]+"b");});
//
if(pCol==cCol)
{
$("#"+buttons[pCol][pRow]).animate({width:"64px"},300);
$("#"+buttons[cCol][cRow]).animate({width:"132px"},300);
}
else
{
//
for(var r=0;r<4;r++)
{
//
if(r!=pRow)
{
$("#"+buttons[pCol][r]).animate({width:"132px"},300);
}
//
if(r!=cRow)
{
$("#"+buttons[cCol][r]).animate({width:"64px"},300);
}
}
$("#"+buttons[cCol][cRow]).animate({width:"132px"},300);
}
}
//
if(home_curr==-1&&home_prev==-1)
{
busy=1;
home_curr=sID;
currCol=cCol;
currRow=cRow;
debug.innerHTML=currCol+"~ "+currRow;
setAlpha(document.getElementById(buttons[currCol][currRow]),1);
toggleDivVis(buttons[cCol][cRow]+"b");
$("#"+buttons[cCol][cRow]+"b").animate({width:sWidth+"px"},300,function(){busy=-1;});
//
for(var r=0;r<4;r++)
{
//
if(r!=cRow)
{
$("#"+buttons[cCol][r]).animate({width:"64px"},300);
}
}
home_curr=sID;
}
}
index
<?php
//
if(isset($_POST['cw'])&&isset($_POST['ch']))
{
$cw=$_POST['cw'];
$ch=$_POST['ch'];
$flashHeight=110;
$botBanHeight=24;
$docWidth=1000;
$iFrameHeight=$ch-$flashHeight-$botBanHeight-32;
//-----
$str='<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="index.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Supercala ©2009 by Kristoffe | Multimedia Entertainment | Education | Visualization | Research |</title>
</head>
<body>
<div class="wrap">
<table width="'.$docWidth.'" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'.$docWidth.'" height="'.$flashHeight.'">
<param name="movie" value="_index.swf" />
<param name="quality" value="high" />
<embed src="_index.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'.$docWidth.'" height="'.$flashHeight.'"></embed>
</object>
</td>
</tr>
<tr>
<td>
<iframe name="bodycopy" frameborder="0" width="'.$docWidth.'" height="'.$iFrameHeight.'" src="intro.html"></iframe>
</td>
</tr>
<tr>
<td><img src="banners/footer1000.jpg" width="'.$docWidth.'" height="'.$botBanHeight.'"/></td>
</tr>
</table>
</div>
</body>
</html>';
//-----
echo $str;
}
else
{
$str='
<form name="browser_dim" method="POST" action="index.php">
<script type="text/javascript">
document.write("You must have javascript enabled to view this site.");
var cw=window.innerWidth;
var ch=window.innerHeight;
</script>
<!--[if IE]>
<script type="text/javascript">
var cw=document.body.clientWidth;
var ch=document.body.clientHeight;
</script>
<![endif]-->
<script type="text/javascript">
var hidden="<input type=\"hidden\" name=\"cw\" value=\""+cw+"\" />";
hidden+="<input type=\"hidden\" name=\"ch\" value=\""+ch+"\" />";
document.write(hidden);
</script>
</form>
<script type="text/javascript">
document.browser_dim.submit();
</script>';
echo $str;
}
?>
menu_placement
var menu_main=document.getElementById('menu_main');
var bot_menu=document.getElementById('bot_menu');
var wrap=document.getElementById('wrap_main');
bot_menu.style.left=(docW/2-wrap.clientWidth/2)+"px";
bot_menu.style.top="600px";
textCounter
/*
01-24-2010 modified so the textCounter can work with both text and textarea fields and made countfield output in either case < or =>
*/
function textCounter(field,countfield,maxlimit)
{
var cnt=0;
var fTgt="";//inline evaluation of field type
var cfTgt="";//inline eval of countfield type
//
switch(field.type)
{
case "text":
fTgt="value";
break;
case "textarea":
fTgt="innerHTML";
break;
}
//
if(field[fTgt].length>=maxlimit)
{
field[fTgt]=field[fTgt].substring(0,maxlimit);
}
else
{
cnt=maxlimit-field[fTgt].length;
}
//
switch(countfield.type)
{
case "text":
cfTgt="value";
break;
case "textarea":
cfTgt="innerHTML";
break;
case undefined:
//div or span has no type sent
cfTgt="innerHTML";
break;
}
countfield[cfTgt]=cnt;
}
//-----textareas only
function initFieldCheck(sBase,sField)
{
//
if(sField.innerHTML==sBase)
{
sField.innerHTML="";
}
}
toggleDiv
/*
toggleDiv v1.0 by Kristoffe Brodeur. ©2010 All Rights Reserved.
01-24-2010
*/
//-----
function toggleDivVis(sId)
{
var tgt=document.getElementById(sId);
//
if(tgt.style.visibility=='hidden'){tgt.style.visibility='visible';}
else{tgt.style.visibility='hidden';}
}
//-----
function toggleDiv(sId)
{
var tgt=document.getElementById(sId);
//
if(tgt.style.display=='none'){tgt.style.display='block';}
else{tgt.style.display='none';}
}
//-----
function init_popUpBack(sId)
{
sTgt=document.getElementById(sId);
var shHeight=-1;
//
if(typeof window.innerWidth!='undefined')
{vpHeight=window.innerHeight;}
else
{vpHeight=document.documentElement.clientHeight;}
//FF | SAFARI | CHROME
if((vpHeight>document.body.parentNode.scrollHeight)&&(vpHeight>document.body.parentNode.clientHeight))
{shHeight=vpHeight;}
//IE
else
{
//
if(document.body.parentNode.clientHeight>document.body.parentNode.scrollHeight)
{shHeight=document.body.parentNode.clientHeight;}
else
{shHeight=document.body.parentNode.scrollHeight;}
}
sTgt.style.height=shHeight+"px";
}