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">.nonflash {visibility:hidden;}</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 go(theFrame) {
        //alert('running go');
  if (movieIsLoaded(thisMovie(movieName))) {    thisMovie(movieName).GotoFrame(theFrame);  }
}
function golabel() {  if (movieIsLoaded(thisMovie(movieName))) {   thisMovie(movieName).TGotoLabel("_level0/","redframe");  }
}



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;   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" style="white-space:nowrap" "><a href="javascript:window.print();">Print</a> | <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;
												imgPopup.document.close(); 
                                                
                                        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 if(linkex=='pdf'){//newcode
												theiframe.src=this.getAttribute('href');//newcode
												var theidoftheiframe=document.getElementbyId('iframediv');
												this.getAttribute('href');//newcode
												theidoftheiframe.style.display=block;//newcode      
												}
                                        else{docPopup(this.getAttribute('href'));}
                                return false;
                                }
                                //return false;
                        }
                        aLinks[i].onkeypress = aLinks[i].onclick;
                }
}



 



 function swapflash(movieName,container,width,height,flashid){
		var newCode='';
        var flashCode='';
        var flashContainer='';
        
        //if(isFlashInstalled&&activestyle=="regular"){
        if(isFlashInstalled){
			//if(document.location.pathname=="/view.aspx"){movieName="flash/"+movieName;}
			 //  else{movieName="../../../../flash/"+movieName;}
                        flashContainer=document.getElementById(container);
 
						flashCode= "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " ;
                        flashCode=flashCode + "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" ";
                        flashCode=flashCode + "width=\"" + width + "\" height=\""+height+"\" >\n ";
						flashCode=flashCode+"<PARAM NAME=movie VALUE=\""+ movieName + "\"> ";
    					flashCode=flashCode+"<PARAM NAME=quality VALUE=high> ";
    					//flashCode=flashCode+"<PARAM NAME=bgcolor VALUE=#3fefef> ";
						flashCode=flashCode+"<EMBED src=\""+ movieName + "\" quality=high  WIDTH=\""+width+"\" HEIGHT=\""+height+"\" NAME=\""+flashid+"\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" > ";
    					flashCode=flashCode+"</EMBED> ";
						flashCode=flashCode+"</OBJECT> ";								
						
                       // newCode=flashCode+flashContainer.innerHTML;
						newCode=flashCode;
                       	flashContainer.innerHTML=newCode;
						//alert(flashContainer.innerHTML);
                        }
}



function simplePreload()

{ 

  var args = simplePreload.arguments;

  document.imageArray = new Array(args.length);

  for(var i=0; i<args.length; i++)

  {

    document.imageArray[i] = new Image;

    document.imageArray[i].src = args[i];

  }

}
function tagbrowser(doc){
	//johnathan kendall - 2007 
	//sets a series of classes related to browser profile 
	//get browser
	if(!document.getElementById)return false;
	var Tag='isDom';//is it a dom browser?
	if(window.getComputedStyle)Tag+=' isMoz';//opera reset after
	if(document.all){Tag+=' isIe';if(window.XMLHttpRequest){Tag+=' isIe7';}}//is ie then is ie7
	if(document.childNodes && !document.all && !navigator.taintEnabled && !navigator.accentColorName) Tag+=' isSaf';
	if(window.opera)Tag+=' isOp';	
	//get os
	var OSName='';
	if (navigator.appVersion.indexOf("Win")!=-1) OSName="isWin";
	if (navigator.appVersion.indexOf("Mac")!=-1) OSName="isMac";
	if (navigator.appVersion.indexOf("X11")!=-1) OSName="isUNIX";
	if (navigator.appVersion.indexOf("Linux")!=-1) OSName="isLin";
	if (navigator.appVersion.indexOf("iPhone") != -1) OSName="isIphone";
	if(OSName!=''){Tag+=' '+OSName;}	
	//get browser size
	var thewidth='w640';
	var w=document.documentElement.clientWidth;
	//alert(w);
	if(w>640){thewidth="w800";Tag+=' gtw640';}
	if(w>800){thewidth="w1024";Tag+=' gtw800';}
	if(w>1024){thewidth="w1280";Tag+=' gtw1024';}	
	if(w>1280){Tag+=' gtw1024'}	
	
	
	if(thewidth!=''){Tag+=' '+thewidth;}	
	//has flash
	var noautoinstall = "";
	if(navigator.appName == "Microsoft Internet Explorer" && (navigator.appVersion.indexOf("Mac") != -1 ||  navigator.appVersion.indexOf("3.1") != -1)){noautoinstall = "true";}
	if((navigator.plugins["Shockwave Flash"] || navigator.plugins["Shockwave Flash 2.0"])||(navigator.appName == "Microsoft Internet Explorer" && noautoinstall != "true")){Tag+=' hasFlash';}	
	
	if(document.height>window.innerHeight) Tag+=' hasScroll';
	
	//set style
	var t=document.getElementsByTagName('html');	
	
	t[0].className=Tag;//extra code for ie
	t[0].setAttribute('class',Tag);	
	
t[0].style.visibility='visible';
	//i[0].style.display="block";
	//alert(t[0].className);
	
}


function loadfunctions(){
	popupLinks();
	tagbrowser();
    //swapTextTool();	
	//swaprandom();	
	//getstyle();
	if(document.getElementById('home')){
	swapflash("flash/home_jk6.swf",'noFlash',690,558,'flashhome');
	//preloadimages();
	simplePreload( 'images/photography/Adam.jpg',
		'images/photography/Antique.jpg',
		'images/photography/BlackBed.jpg',
		'images/photography/BlackTable.jpg',
		'images/photography/Cap.jpg',
		'images/photography/CoffeeTable.jpg',
		'images/photography/Cups.jpg',
		'images/photography/Egg.jpg',
		'images/photography/Esino.jpg',
		'images/photography/GreenJumper.jpg',
		'images/photography/Jack.jpg',
		'images/photography/Jumpers.jpg',
		'images/photography/Koko.jpg',
		'images/photography/Legs.jpg',
		'images/photography/Orchid.jpg',
		'images/photography/Pants.jpg',
		'images/photography/Star.jpg',
		'images/photography/TableChairs.jpg',
		'images/photography/ben-sherman.jpg',
		'images/photography/still-life-set.jpg',
		'images/photography/shimu.jpg',
		'images/photography/oranges.jpg',
		'images/photography/esino.jpg',
		'images/photography/bentley.jpg',
		'images/photography/falling.jpg',
		'images/photography/gardening.jpg',
		'images/photography/meat+2.jpg',
		'images/photography/TRAINERS.jpg',
		'images/photography/worship-me.jpg',
		'images/design/Esino.jpg',
		'images/design/meat+2.jpg',
		'images/design/gardening.jpg',
		'images/design/falling.jpg',
		'images/design/worship-me.jpg',
		'images/design/TRAINERS.jpg');
	
	
	}
		
}



window.onload=loadfunctions;



