
var isFlashInstalled=false;
noautoinstall = "";
if(navigator.appName == "Microsoft Internet Explorer" && 
                (navigator.appVersion.indexOf("Mac") != -1 || 
                 navigator.appVersion.indexOf("3.1") != -1)){
                        noautoinstall = "true";
        }

if (navigator.appName == "Microsoft Internet Explorer" && noautoinstall != "true")
        {
                isFlashInstalled=true;
        }
else if(navigator.plugins)
        {
                if(navigator.plugins["Shockwave Flash"] || navigator.plugins["Shockwave Flash 2.0"])
                {
                       isFlashInstalled=true;
                }
          }
if(isFlashInstalled){
        if(document.getElementById){
        //alert('hiding image for flash replacement');
        document.writeln('<style type="text/css">div#flashcontent {        background-image: none!important;}</style>');
        }
}
 function is_iemac(){
        var SniffVer=navigator.appVersion;
        SniffVer=SniffVer.substring(0,4);
        var SniffClient=navigator.appName;
        var SniffOS=navigator.platform;
        if(SniffOS=='MacPPC' && SniffClient=='Microsoft Internet Explorer'){
                        return true;
                        }
                        else{return false;}
}
                   




function imgPopup(url,alt){
        var openIpix='';
        var closeIpix='';
        var isIpix=false;
        urlExtension=url.split(".");
        if(urlExtension[urlExtension.length-1]=='ipx'){isIpix=true;}
        //else{alert('not an ipix, must be an image');}
                                        var imgPopup=window.open('','imgPopup','height=50,width=50,toolbar=no,scrollbars=no,resizable=yes,menubar=no,status=no,directories=no,location=no,50,50');
                                        imgPopup.document.open();
                                        imgPopup.document.writeln('<html><head><title>image</title> \n <style type="text/css"> \n a{color:#3f3479;} p#caption{background-color:#eeeeee;text-align: left;padding-left: 10px;padding-right: 10px;}  \n body {font-family: Tahoma, Arial, Helvetica, sans-serif;text-align: center;} \n p {font-size: 70%;margin-top: 0px;padding-top: 0.5em;padding-bottom: 1em;} \n img {display: block; margin-right: auto; margin-left: auto;} \n  p.close {text-align: center; margin-bottom: 0px;        width: 9em;        float: right;        color: #FFFFFF;           padding: 3px;        font-weight: normal;}  \n </style> \n </head> \n <body>');
                                                                               imgPopup.document.writeln('<img src="' + url + '" alt="' + alt + '" id="lrgimage" />');
                                                                               imgPopup.document.writeln(' \n<p class="close"><a href="javascript:window.close();">Close Window</a></p> \n </body> \n </html>');
                                                                               imgPopup.document.title=alt;
                                                                               var bigImage=imgPopup.document.getElementById('lrgimage');
                                        var captiontxt=imgPopup.document.getElementById('caption');
                                                                                //alert(bigImage.width);
                                        //captiontxt.style.color='#333333';
                                        //captiontxt.style.fontsize='70%';
                                        //1st resize for shitty explorer
                                                var newwidth=bigImage.width+60;
                                                if(!newwidth){newwidth=490;}
                                                var newheight=imgPopup.document.body.scrollHeight+40;
                                                imgPopup.resizeTo(newwidth,newheight);
                                                imgPopup.window.focus;
                                                
                                        bigImage.onload = function ()
                                        //for firefox
                                        {
                                                newwidth=bigImage.width+40;
                                                newheight=imgPopup.document.body.scrollHeight+60;
                                                imgPopup.resizeTo(newwidth,newheight);
                                                imgPopup.window.focus;
                                        }
                                                                                window.onload = function ()
                                        //for firefox
                                        {
                                                newwidth=bigImage.width+40;
                                                newheight=imgPopup.document.body.scrollHeight+60;
                                                imgPopup.resizeTo(newwidth,newheight);
                                                imgPopup.window.focus;
                                        }
                                                                                imgPopup.onblur=imgPopup.window.focus;
}

function docPopup(url){
                                                window.open(url,'popup');
}

function popupLinks(){
if(!document.getElementById)return false;
var aLinks=document.getElementsByTagName('a');
//alert('running script');
for (var i=0;i<aLinks.length;i++) {
        if (aLinks[i].className == 'popup')
                        {
                                aLinks[i].onclick = function ()
                                {
                                        //alert(linktype);]
                                        //
										//alert('clicked');
                                        var linktype=this.getAttribute('href');
                                        var linktype_array=linktype.split(".");
                                        var linkex=linktype_array[linktype_array.length-1];
                                                                                linkex=linkex.toLowerCase();
                                        //if(this.protocol=="file:"){
                                        if(linkex=='jpg' || linkex=='gif' || linkex=='ipx'){
                                                imgPopup(this.getAttribute('href'),this.getAttribute('title') );}
                                        else{docPopup(this.getAttribute('href'));}
                                return false;
                                }
                                //return false;
                        }
                        aLinks[i].onkeypress = aLinks[i].onclick;
                }
}





function swaprandom(){
	
	if (!document.getElementById('homepage'))return false;
	var imgRoot="/css/linkage/";
	var img1;	
	
	Images=new Array(randommax);
	
	Images[0]="home_rnd1.jpg";
	Images[1]="home_rnd2.jpg";
	Images[2]="home_rnd3.jpg";
	Images[3]="home_rnd4.jpg";
	Images[4]="home_rnd5.jpg";
	Images[5]="home_rnd6.jpg";
	Images[6]="home_rnd7.jpg";
	Images[7]="home_rnd8.jpg";
	//Images[8]="home_rnd9.jpg";

	
	var randommax=Images.length;
	var rndnumber1;
	var rndnumber2;
	rndnumber1=Math.floor(Math.random()*randommax);
	rndnumber2=Math.floor(Math.random()*randommax);
	while(rndnumber2==rndnumber1){
		rndnumber2=Math.floor(Math.random()*randommax);
	}
	
	//randommax--;
	
	
		

	
	//img1="<img src=\""+imgRoot+Images[rndnumber1]+"\" div id=\"homeIntro\" class=\"top\"/>";

	var thediv=document.getElementById('homeIntro');
	
	thediv.style.backgroundImage="url("+imgRoot+Images[rndnumber1]+")";	
	//alert(thediv.style.backgroundImage);
	//alert(a.innerHTML);
}






 



 function swapflash(movieName,container,flashid,width,height){
	 	var baseUrl="http://"+location.host+"/clients/swarthmore/flash/";
		var newCode='';
        var flashCode='';
        var flashContainer='';
		//alert(container);
        //var activestyle=getActiveStyleSheet();
        //if(isFlashInstalled&&activestyle=="regular"){
        if(isFlashInstalled){
			//if(document.location.pathname=="/view.aspx"){movieName="flash/"+movieName;}
			 //  else{movieName="../../../../flash/"+movieName;}
                        var flashContainer=document.getElementById(container);
						//alert(container+''+flashContainer.innerHTML);
                        //customisation
                        //flashContainer.style.position="relative";        
                       //flashContainer.style.backgroundImage="";
                        ///////////////
						
						flashCode="<OBJECT  WIDTH=\""+width+"\" HEIGHT=\""+height+"\" id=\""+flashid+"\"  classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" >";
   						flashCode=flashCode+"<PARAM NAME=movie VALUE=\""+ movieName + "\"> ";
    					flashCode=flashCode+"<PARAM NAME=quality VALUE=high> ";
    					flashCode=flashCode+"<PARAM NAME=bgcolor VALUE=#3fefef> ";
						flashCode=flashCode+"<PARAM NAME=base VALUE=\""+baseUrl+"\" > ";
						flashCode=flashCode+"<param name=\"wmode\" value=\"transparent\" />";
						flashCode=flashCode+"<param name=\"allowScriptAccess\" value=\"always\" /> ";
						flashCode=flashCode+"<param name=\"wmode\" value=\"transparent\" />";
						flashCode=flashCode+"<embed  src=\""+movieName+"\" wmode=\"transparent\" base=\""+baseUrl+"\" quality=\"high\"  NAME=\""+flashid+"\"  TYPE=\"application/x-shockwave-flash\" width=\""+width+"\"  height=\""+height+"\" ></embed> ";
						
						flashCode=flashCode+"</OBJECT> ";
						
						//base=\""+baseUrl+"\"
						
						//flashCode="<p>This paragraph has been output in html</p>";
						
                        var newCode=flashCode;
						//alert(flashContainer.innerHTML);
                       	flashContainer.innerHTML=newCode;
						//alert(flashContainer.innerHTML);
						//alert(flashContainer.innerHTML);
						//alert(baseUrl);
                        }
}


/*function formcontrol(){
	
	if(!document.getElementById("email"))return false;
		if(!document.getElementById("Submit"))return false;
		
		var submits = document.getElementById("Submit");
		
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var emails = document.getElementById("email").value
   if(reg.test(emails) == false) {
      alert('Invalid Email Address');
	  var emails = document.getElementById("email");
	  emails.style.border = "2px solid #ff0000";
      return false;
   }
 
}
*/

function ClearTextSubmits(){
	// For all the input elements
	for(var i = 0; i < document.getElementsByTagName("input").length; i++){
		// If of type text
		var inputs = document.getElementsByTagName("input")[i];
		if(document.getElementsByTagName("input")[i].type.toLowerCase() == 'submit'){
			// Add the onclick function
			document.getElementsByTagName("input")[i].onclick = function formcontrol(){
			if(document.getElementById("email").value == "" && document.getElementById("Phone").value == "" ){	
var error = document.createTextNode("Please Enter either a Phone Number or an email address");
var div = document.createElement("div");
var p = document.createElement("p");
var contactform = document.getElementById("contactform");
div.style.color = '#ff0000';
div.style.bgcolor = 'pink';
div.setAttribute('id','error');
p.setAttribute('id','errormsg');
p.appendChild(error);
div.appendChild(p);
contactform.appendChild(div);
return false;


			}
			}
		}
	}
}
 

function loadfunctions(){
	if((document.parent)||document.getElementById('bblitebar'))return false;
	popupLinks();
	//formcontrol();
	ClearTextSubmits();
	//hideAdvancedSearch();
	//preparelinks();
	//getFontSize();
    //swapTextTool();	
	//swaprandom();	
	//getstyle();
	swapflash("/clients/swarthmore/flash/slideshow.swf",'noFlash','flashHeader',369,98)
}



window.onload=loadfunctions;


