/*
---------------------------------------------------------------------------
BrainPeel (c) 2007 by brainquad / Michael Grossklos all rights reserved
---------------------------------------------------------------------------
CAUTION:
It is not allowed to:
-- copy, distribute, display, and perform the work
-- Derivative Works. You may not alter, transform, or build upon this work.
---------------------------------------------------------------------------
Filename: brainpeel.js -- JavaScirpt functions for brainpeel
---------------------------------------------------------------------------
*/
// ############  DO NOT CHANGE ANYTHING BELOW ##########################
// GLOBAL VARIABLES
var url= "brainpeel.xml";
var brainpeelRoot = '';
var customerName = "brainpeel"; // NOT CHAGEABLE!!
var PP_Small ;
var PP_Big ;



// GET XML FILE
function loadXMLDoc(dname){
	var xmlDoc;
	// CODE FOR IE
	if (window.ActiveXObject){
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	// CONDE FOR MOZILLA, SAFARI AND SO ON
	}else if (document.implementation && document.implementation.createDocument){
		xmlDoc=document.implementation.createDocument("","",null);
	}else{
		alert('Your browser cannot handle this script');
	}
	
	xmlDoc.async=false;
	xmlDoc.load(dname);
	return(xmlDoc);
}

// PARSE XML DATA
var xmlDoc = loadXMLDoc(url);
for(var i=0; i < xmlDoc.getElementsByTagName("customerName").length; i++){
	
	if( xmlDoc.getElementsByTagName("customerName")[i].firstChild.nodeValue == customerName ) {
		
		// DEFAULT SETTINGS
		if(xmlDoc.getElementsByTagName("widthSmall")[i].hasChildNodes() == false){			
			widthSmall = 100;
		}else{
			var widthSmall = xmlDoc.getElementsByTagName("widthSmall")[i].firstChild.nodeValue;	
		}
		
		if(xmlDoc.getElementsByTagName("widthBig")[i].hasChildNodes() == false){			
			widthBig = 500;
		}else{
			var widthBig = xmlDoc.getElementsByTagName("widthBig")[i].firstChild.nodeValue;	
		}
		
		var heightSmall =  widthSmall; 
		var widthBig = xmlDoc.getElementsByTagName("widthBig")[i].firstChild.nodeValue;
		var heightBig = (widthBig/100)*100;
		var name = xmlDoc.getElementsByTagName("customerName")[i].firstChild.nodeValue;
			
	} else {
		alert("BRAINPEEL FAILURE! \n\r The XML-tag <customerName> were changed! \n\r Please set it to <customerName>brainpeel</customerName>");
		
	}
}
	
// DECLARATION OF EMBED OBJECT FOR LOADING THE PAGEPEEL SWF
PP_Small = '<div id="myPeel_Catcher" style="position: absolute; top:0px; right: 0px; width:'+widthSmall+'px; height:'+heightSmall+'px; text-align: right; z-index: 999999;"><object id="myPeel_Catcher" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+widthSmall+'" height="'+heightSmall+'"><param name="allowScriptAccess" value="always" /><param name="movie" value="'+brainpeelRoot+'brainpeelS.swf" /><param name="wmode" value="transparent" /><embed name="myPeel_Catcher" src="'+brainpeelRoot+'brainpeelS.swf" wmode="transparent" width="'+widthSmall+'" height="'+heightSmall+'" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object></div>';

PP_Big ='<div id="myPeel_PagePeel" style="position: absolute; top:-1000px; right: 0px; width:'+widthBig+'px; height:'+heightBig+'px; text-align: right; z-index: 999998;"><object id="myPeel_PagePeel" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+widthBig+'" height="'+heightBig+'"><param name="loop" value="false" /><param name="menu" value="false" /><param name="allowScriptAccess" value="always" /><param name="movie" value="'+brainpeelRoot+'brainpeelB.swf" /><param name="wmode" value="transparent" /><embed name="myPeel_PagePeel" src="'+brainpeelRoot+'brainpeelB.swf" loop="false" wmode="transparent" width="'+widthBig+'" height="'+heightBig+'" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object></div>';

// PARSE EMBEDED OBJECTS
document.write(PP_Small);
document.write(PP_Big);	
	
// CALLED BY AS SCRIPT TO OPEN PEEL
function open_peel(){
		
	document.getElementById('myPeel_PagePeel').style.top = '0px'; 
	document.getElementById('myPeel_Catcher').style.top = '-1000px';
	document.getElementById('myPeel_PagePeel').style.position = 'absolute';
}

// CALLED BY AS SCRIPT TO CLOSE PEEL
function close_peel(){
	document.getElementById('myPeel_PagePeel').style.top = '-1000px';
	document.getElementById('myPeel_Catcher').style.top = '0px';
	document.getElementById('myPeel_Catcher').style.position = 'absolute';
}

	






