
/*
	--------------------------------------------------------------------------
	File: pagepeel.js
	Description:
	--------------------------------------------------------------------------
*/

	function pagepeel() {						 
		//if(Browser.Plugins.Flash.version<=0) return false;
		this.color = arguments[0];
		this.isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
		this.isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
		this.isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;      
		this.init = init;  
		this.writeObjects = writeObjects;  
		this.AC_AddExtension = AC_AddExtension;  
		this.AC_Generateobj = AC_Generateobj;  		
		this.AC_FL_RunContent = AC_FL_RunContent;  				
		this.AC_GetArgs = AC_GetArgs;  						
		this.utf8encode = utf8encode;  
		this.init();
	}	

	/* ----------------------- */	
			
	function init() {
		this.thumbWidth = 44;
		this.thumbHeight = 44;
		this.bigWidth = 143;
		this.bigHeight = 143;
		this.pagearSmallImg = '/includes/pagepeel/small.jpg'; 
		this.pagearBigImg = '/includes/pagepeel/large.jpg'; 
		this.jumpTo = 'http://www.whitesharkcreations.com';        
		this.pagearSmallSwf = '/includes/pagepeel/pagepeel_small.swf'; 
		this.pagearBigSwf = '/includes/pagepeel/pagepeel_large.swf'; 
		this.speedSmall = 2; 
		this.mirror = false; 
		this.pageearColor = this.color;
		this.openLink = 'new'; 
		this.openOnLoad = false; 
		this.closeOnLoad = 3; 
		this.setDirection = 'rt'; 
		this.softFadeIn = 0; 
		this.playSound = 'false' 
		this.playOpenSound = 'false'; 
		this.playCloseSound = 'false'; 
		this.closeOnClick = 'false';
		this.closeOnClickText = 'Close';	
		this.copyright = 'Webpicasso Media, www.webpicasso.de';
		this.xPos = 'right';
		this.queryParams = 'pagearSmallImg='+escape(this.pagearSmallImg); 
		this.queryParams += '&pagearBigImg='+escape(this.pagearBigImg); 
		this.queryParams += '&pageearColor='+this.pageearColor; 
		this.queryParams += '&jumpTo='+escape(this.jumpTo); 
		this.queryParams += '&openLink='+escape(this.openLink); 
		this.queryParams += '&mirror='+escape(this.mirror); 
		this.queryParams += '&copyright='+escape(this.copyright); 
		this.queryParams += '&speedSmall='+escape(this.speedSmall); 
		this.queryParams += '&openOnLoad='+escape(this.openOnLoad); 
		this.queryParams += '&closeOnLoad='+escape(this.closeOnLoad); 
		this.queryParams += '&setDirection='+escape(this.setDirection); 
		this.queryParams += '&softFadeIn='+escape(this.softFadeIn); 
		this.queryParams += '&playSound='+escape(this.playSound); 
		this.queryParams += '&playOpenSound='+escape(this.playOpenSound); 
		this.queryParams += '&playCloseSound='+escape(this.playCloseSound);  
		this.queryParams += '&closeOnClick='+escape(this.closeOnClick); 
		this.queryParams += '&closeOnClickText='+escape(this.utf8encode(this.closeOnClickText)); 
		this.queryParams += '&lcKey='+escape(Math.random()); 
		this.queryParams += '&bigWidth='+escape(this.bigWidth); 
		this.queryParams += '&thumbWidth='+escape(this.thumbWidth); 
		this.writeObjects();	
	}
	
	/* ----------------------- */
	
	function writeObjects() {   
		if(this.setDirection == 'lt') {
			xPosBig = 'left:-1000px';  
			xPos = 'left';   
		} else {
			xPosBig = 'right:1000px';
			xPos = 'right';              
		}                
		// Big Layers
		var peelHTML = '';
		peelHTML = '<div id="bigDiv" style="position:absolute;width:'+ this.bigWidth +'px;height:'+ this.bigHeight +'px;z-index:10000;'+xPosBig+';top:-100px;">';    	
		peelHTML += this.AC_FL_RunContent("src", this.pagearBigSwf+'?'+ this.queryParams,"width", this.bigWidth,"height", this.bigHeight,"align", "middle","id", "bigSwf","quality", "high","bgcolor", "#FFFFFF","name", "bigSwf","wmode", "transparent","scale", "noscale","salign", "tr");  
		peelHTML +='</div>';                 
		// Small Layers        
		peelHTML += '<div id="thumbDiv" style="position:absolute;width:'+ this.thumbWidth +'px;height:'+ this.thumbHeight +'px;z-index:10000;'+xPos+':0px;top:0px;">';
		peelHTML += this.AC_FL_RunContent("src", this.pagearSmallSwf+'?'+ this.queryParams,"width", this.thumbWidth,"height", this.thumbHeight,"align", "middle","id", "smallSwf","scale", "noscale","quality", "high","bgcolor", "#FFFFFF","name", "bigSwf","wmode", "transparent"); 
		peelHTML += '</div>';  
		
		// Write CSS		
		var pageCSS = document.createElement('div');		
		pageCSS.setAttribute('id','pageCSS');
		pageCSS.innerHTML = "<style type='text/css'>.hide { display: none; }</style>";
		document.body.insertBefore(pageCSS,document.body.firstChild);	
		
		// Write Footer		
		var ws_footer = document.createElement('div');		
		ws_footer.setAttribute('id','ws_footer');				
		ws_footer.className = "hide";
		ws_footer.innerHTML = "<a href='http://www.whitesharkcreations.com'>Designed by Whiteshark Creations</a>";	
		document.body.appendChild(ws_footer);

		// Write Page Peel		
		var pagePeel = document.createElement('div');		
		pagePeel.setAttribute('id','pagePeel');
		pagePeel.innerHTML = peelHTML;					
		document.body.insertBefore(pagePeel,document.body.firstChild);		
		
		setTimeout('document.getElementById("bigDiv").style.top = "-1000px";',100);     
	}	
	
	/* ----------------------- */
	
	function AC_AddExtension(src, ext) {
	  if (src.indexOf('?') != -1)
		return src.replace(/\?/, ext+'?'); 
	  else
		return src + ext;
	}
	
	/* ----------------------- */
	
	function AC_Generateobj(objAttrs, params, embedAttrs) { 
		var str = '';
		if (this.isIE && this.isWin && !this.isOpera) {
			str += '<object ';
			for (var i in objAttrs) str += i + '="' + objAttrs[i] + '" ';
			for (var i in params) str += '><param name="' + i + '" value="' + params[i] + '" /> '; str += '></object>';
		} else {
			str += '<embed ';
			for (var i in embedAttrs) str += i + '="' + embedAttrs[i] + '" ';
			str += '> </embed>';
		}
		return str;
	}
	
	/* ----------------------- */	    
	
	function AC_FL_RunContent(){
		var ret = this.AC_GetArgs(arguments, "", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash");
		return this.AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
	}
	
	/* ----------------------- */	    
	
	function AC_GetArgs (args, ext, srcParamName, classid, mimeType){
	  var ret = new Object();
	  ret.embedAttrs = new Object();
	  ret.params = new Object();
	  ret.objAttrs = new Object();
	  for (var i=0; i < args.length; i=i+2){
		var currArg = args[i].toLowerCase();    
		switch (currArg){	
		  case "classid":
			break;
		  case "pluginspage":
			ret.embedAttrs[args[i]] = args[i+1];
			break;
		  case "src":
		  case "movie":	
			args[i+1] = this.AC_AddExtension(args[i+1], ext);
			ret.embedAttrs["src"] = args[i+1];
			ret.params[srcParamName] = args[i+1];
			break;
		  case "onafterupdate":
		  case "onbeforeupdate":
		  case "onblur":
		  case "oncellchange":
		  case "onclick":
		  case "ondblClick":
		  case "ondrag":
		  case "ondragend":
		  case "ondragenter":
		  case "ondragleave":
		  case "ondragover":
		  case "ondrop":
		  case "onfinish":
		  case "onfocus":
		  case "onhelp":
		  case "onmousedown":
		  case "onmouseup":
		  case "onmouseover":
		  case "onmousemove":
		  case "onmouseout":
		  case "onkeypress":
		  case "onkeydown":
		  case "onkeyup":
		  case "onload":
		  case "onlosecapture":
		  case "onpropertychange":
		  case "onreadystatechange":
		  case "onrowsdelete":
		  case "onrowenter":
		  case "onrowexit":
		  case "onrowsinserted":
		  case "onstart":
		  case "onscroll":
		  case "onbeforeeditfocus":
		  case "onactivate":
		  case "onbeforedeactivate":
		  case "ondeactivate":
		  case "type":
		  case "codebase":
		  case "id":
			ret.objAttrs[args[i]] = args[i+1];
			break;
		  case "width":
		  case "height":
		  case "align":
		  case "vspace": 
		  case "hspace":
		  case "class":
		  case "title":
		  case "accesskey":
		  case "name":
		  case "tabindex":
			ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
			break;
		  default:
			ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
		}
	  }
	  ret.objAttrs["classid"] = classid;
	  if (mimeType) ret.embedAttrs["type"] = mimeType;
	  return ret;
	}   
	
	/* ----------------------- */	
	
	function utf8encode(txt) { 
		txt = txt.replace(/\r\n/g,"\n");
		var utf8txt = "";
		for(var i=0;i<txt.length;i++) {        
			var uc=txt.charCodeAt(i); 
			if (uc<128) {
				utf8txt += String.fromCharCode(uc);        
			} else if((uc>127) && (uc<2048)) {
				utf8txt += String.fromCharCode((uc>>6)|192);
				utf8txt += String.fromCharCode((uc&63)|128);
			} else {
				utf8txt += String.fromCharCode((uc>>12)|224);
				utf8txt += String.fromCharCode(((uc>>6)&63)|128);
				utf8txt += String.fromCharCode((uc&63)|128);
			}        
		}
		return utf8txt;
	}		
	
	/* ----------------------- */	
	
	function openPeel(){
		document.getElementById('bigDiv').style.top = '0px'; 
		document.getElementById('bigDiv').style[this.xPos] = '0px';
		document.getElementById('thumbDiv').style.top = '-1000px';
	}
	
	/* ----------------------- */
	
	function closePeel(){
		document.getElementById("thumbDiv").style.top = "0px";
		document.getElementById("bigDiv").style.top = "-1000px";
	}	