﻿/*****************************************************************
* Flash Fix script
* Fixes embedded object activation issues in Internet Explorer
*****************************************************************/

function flashfix() {
	theObjects = document.getElementsByTagName("object");
	for (var i = 0; i < theObjects.length; i++) {
	theObjects[i].outerHTML = theObjects[i].outerHTML;
	}
	
	var objCanvas = document.getElementById("flash_canvas");
	if(objCanvas) { 
		objCanvas.style.display = "block"; 
	}
	
	var objHideRotatingCanvas = document.getElementById("bigad_canvas");
	if(objHideRotatingCanvas && MM_FlashCanPlay)
	{
	    objHideRotatingCanvas.style.visibility = "hidden";
        objHideRotatingCanvas.style.display = "none";
    }
}


//if (window.attachEvent)
//	window.attachEvent("onload", start)
//else
//	window.onload=start;


/*************** Shared *****************/
function _selfregister(PREFIX){
	this._ref=PREFIX+control_reg.count++;
	eval(this._ref+'=this');
	if(window.CONTROL_REG){
		window.CONTROL_REG.add(this);
	}	
}
/***************************************/
function control_reg(){
	window.CONTROL_REG=this;
	this._items=new Object();
	window.onload= new Function('window.CONTROL_REG.init()');
}
function control_regAdd(item){
	this._items[item._ref]=item;
}
function control_regInit(){
	for(var s in this._items){
	//	try{
			this._items[s].init();
	//	}catch(e){	}
	}
	
	flashfix();
}
control_reg.count=0;
control_reg.prototype.add = control_regAdd
control_reg.prototype.init = control_regInit
/***************************************/
/* create the control registry							*/
/***************************************/
var CR= new control_reg();
/***************************************/
/***************************************/

function context_menu(sContext){
	this._context=sContext;
	this._ref=this._context+'MENU';
	this._items=new Object();
	this._initiated=false;
}
function context_menuAdd(oItem){
	this._items[oItem._id]=oItem;
	this._items[oItem._id]._parent=this;
}
function context_menuSetActive(item){
	this._currentItem=item
	for(var s in this._items){
		try{
			if(this._items[s]==this._currentItem){
				this._items[s].on();
			}else{
				this._items[s].off();
			}
		}catch(e){	}
	}
}
function context_menuSetInActive(item){
	this._currentItem=null;
	for(var s in this._items){
		try{
			if(this._items[s]._id==this._context){
					this._items[s].on();
			}else{
					this._items[s].off();
			}
		}catch(e){	}
	}
}
context_menu.prototype.add=context_menuAdd;
context_menu.prototype.setActive=context_menuSetActive;
context_menu.prototype.setInActive=context_menuSetInActive;

function context_menu_item(sKey,activeclass,inactiveclass){
	this.register('MENUITEM');
	this._id=sKey;
	this._activeClass=activeclass;
	this._inactiveClass=inactiveclass;
}
function context_menu_itemInit(){
	this._controlref=document.getElementById(this._id+'_image');
	if(this._controlref){
		
		this._controlref.onmouseover=new Function(this._ref+'.over()');
		this._controlref.onmouseout=new Function(this._ref+'.out()');
	}
}
function context_menu_itemOn(){
	if(!this._controlref)return;
	this._controlref.src=this._activeClass;
}
function context_menu_itemOff(){
	if(!this._controlref)return;
	this._controlref.src=this._inactiveClass;
}
function context_menu_itemOver(){
	if(!this._controlref)return;
	this._parent.setActive(this);
}
function context_menu_itemOut(){
	if(!this._controlref)return;
		this._parent.setInActive(this);
}

context_menu_item.prototype.init=context_menu_itemInit
context_menu_item.prototype.on=context_menu_itemOn;
context_menu_item.prototype.off=context_menu_itemOff;
context_menu_item.prototype.over=context_menu_itemOver;
context_menu_item.prototype.out=context_menu_itemOut;
context_menu_item.prototype.register=_selfregister;
context_menu_item.count=0;


/*****************************************/
/** scroller                            **/
/*****************************************/

var mn_SCROLLDELAY=10000;
var mn_READDELAY=2000;

var mn_SCROLLDELTA=40;

function Scroller(sKey,nHeight){
	this.register('Scroller');
	this._id=sKey;
	this._height=nHeight;
	this._paused=false;
	this._currentIndex=1;
	this._currentFace=null;
	this._faceCount=1;
}


function ScrollerInit(){
  //find each scroll facet.	
  var bDone  = false;
  var nFacetCount=1;	
  this._faces=new Object();
  while(!bDone){
	var elem = document.getElementById(this._id+'_facet_'+nFacetCount);
	if(elem){
		this._faces[nFacetCount]= elem;	
		this._faces[nFacetCount]._innerheight= this._faces[nFacetCount].offsetHeight;	
		nFacetCount++;
	}else{
 			bDone=true;
	} 
   }
   this._faceCount=nFacetCount-1;
   this._currentFace=this._faces[1];
   this._currentFace.style.top=(parseInt(this._height))+"px"
   this._currentFace.style.display='block';
   this._currentFace.style.z_Index='1';
  //if(this._controlref){
	//this._innerheight=this._controlref.offsetHeight
    //this._controlref.style.top=(parseInt(this._height))+"px";
  //}
  this.tick();
  //window.setTimeout(this._ref+'.tick();',mn_SCROLLDELAY,'javascript')
  window.setTimeout(this._ref+'.setNext();',mn_READDELAY,'javascript')
  
}


function ScrollerSetNextActive(){
  // alert('working on '+this._currentIndex +' of '+ this._faceCount)
  if(this._currentIndex = this._faceCount){
	this._currentIndex=1;
  }
  this._currentFace.style.top=(parseInt(this._height))+"px"
  this._currentFace.style.display='none';
  this._currentFace.style.z_Index='0';
  this._currentIndex++;
  this._currentFace=this._faces[this._currentIndex];
  this._currentFace.style.top=(parseInt(this._height))+"px"
  this._currentFace.style.display='block';
  this._currentFace.style.z_Index='1';
  this.tick();
}

function ScrollerTick(){
//alert('tick')
 if(!this._paused){
	if(this._currentFace ){
		if (parseInt(this._currentFace.style.top)>0){
			this._currentFace.style.top=(parseInt(this._currentFace.style.top)-1)+"px"
			window.setTimeout(this._ref+'.tick();',mn_SCROLLDELTA,'javascript')
		}else{
		    this._currentFace.style.top=(0)+"px";
		    window.setTimeout(this._ref+'.setNext();',mn_READDELAY,'javascript')
		}
	}
 }	 
 
}

function ScrollerOut(){
  this._paused=false;
}

function ScrollerOver(){
  this._paused=true;
}

Scroller.prototype.init=ScrollerInit;
Scroller.prototype.Out=ScrollerOut;
Scroller.prototype.Over=ScrollerOver;
Scroller.prototype.tick=ScrollerTick;
Scroller.prototype.setNext=ScrollerSetNextActive;

Scroller.prototype.register=_selfregister;







/****************************/
/**** Roller *******/
/****************************/

function Roller(sKey,on_Image,off_Image,onmouseover,onmouseout){
	this._id=sKey;
	this._on=on_Image;
	this._off=off_Image;
	this._onmouseover=onmouseover;
	this._onmouseout=onmouseout;
	this.register('Roller');
}

function RollerInit(){
	this._controlref=document.getElementById(this._id+"_roller");	
	this._imageref=document.getElementById(this._id+"_rollerimage");
	if(!this._controlref){
		this._controlref=this._imageref;
	}
	if(this._controlref){
		this._controlref.onmouseover=new Function(this._ref+'.over()');
		this._controlref.onmouseout=new Function(this._ref+'.out()');	
	}	
}

function RollerOver(){
	if(this._imageref){
		this._imageref.src=this._on;
	}
	try{
		eval(this._onmouseover)
	}catch(e){
	
	}
}

function RollerOut(){
	if(this._imageref){
		this._imageref.src=this._off;
	}
	try{
		eval(this._onmouseout)
	}catch(e){
	
	}
}

Roller.prototype.register=_selfregister;
Roller.prototype.init=RollerInit;
Roller.prototype.out=RollerOut;
Roller.prototype.over=RollerOver;




/**************************/
/**legacy functions**/
/***************************/

function openExampleWin(sUrl,features){
	if(!document.all){
		alert('This demonstration requires Internet Explorer 5.5 or higher on your computer, and you need to be running Windows 98, ME, NT, 2000, or XP.');
	}else{
	    window.open(sUrl,'exampleWindow',features);
	}    
  }

function openAttachedDialog(elemID){
	if(!document.all){
		alert('We are sorry but at this time attching files is only available in Internet Explorer 5.5 or higher. Please use IE to attach files to this case. ');
       var st='<img src="images/attachment.gif" alt=""/>&nbsp;&nbsp;<span>no attachment possible</span><br/>';     
       var elem= document.getElementById(elemID+'_img');
       elem.innerHTML=st;
	}else{
     win=window.showModalDialog('attachframe.htm','','dialogHeight: 220px; dialogWidth: 450px; dialogTop: px; dialogLeft: px; edge: Sunken; center: Yes; help: No; resizable: No; status: No;')
     if(win){
       var st='<img src="images/attachment.gif" alt=""/>&nbsp;&nbsp;<span>'+ win+'</span><br/>';     
       var elem= document.getElementById(elemID+'_img');
       elem.innerHTML=st;
     }
    } 
}



function toggleradioInput(elem){
  var gid=elem.name;
  var sid=elem.id+'_text';
  var inputcheck=eval('window.'+gid)
  if(inputcheck){
     inputcheck.value='';
     inputcheck.disabled=true;
  }
  var inp= document.getElementById(sid);
  if(inp){
     inp.disabled=false;
     inp.focus();
     eval('window.'+gid +'=inp')
     }
}

function togglecheckinput(elem){
  var sid=elem.id+'_text';
  var inp= document.getElementById(sid);
  if(elem.checked){
     if(inp){
        inp.disabled=false;
        inp.focus();
     }
  }else{
     if(inp){
       inp.value='';
       inp.disabled=true;
     }
  }   
}

/**
	

 **/

function SlideDeckInit(){
	window.setTimeout(this._ref+'.tick()' ,10000,'javascript');
}

function SlideDeckTick(){
	this._currentindex++;
	if(!this._paused){
		if(!this.deck[this._currentindex]){
			this._currentindex=1;
		}
		var key=this.deck[this._currentindex];
		var elem = document.getElementById(key);
		if(this._curElem){
			this._oldElem= this._curElem;
		}
		this._curElem=elem;
	
		//this.slide();
		for(s in this.deck){
			var elem= document.getElementById(s);
			if(elem){
				if(s==key){
					this._curElem=elem;
					elem.style.display='block';
					elem.style.zIndex=1;
				}else{
					elem.style.display='none';
					elem.style.zIndex=0;
				}
			}
		}
		
	}
	window.setTimeout(this._ref+'.tick()' ,10000,'javascript');
}

function SlideDeckPause(){
	this._paused=true;
	
	
}

function SlideDeckGo(){
	this._paused=false;
}

function SlideDeckSlide(){
	if(this._oldElem){
//		alert(this._oldElem.style.zIndex);
	}
	this.cur_left=this._curElem.parentNode.offsetWidth * -1;
//  this._curElem.style.left=this.cur_left;
	this._curElem.style.display='block';
	
	//this.step();
//alert(this._curElem.parentNode.offsetWidth);
//	var width = this._curElem.parentElement.offsetWidth;
//	alert(width);
}

function SlideDeckStep(){
	this.cur_left++;
	this._curElem.style.left=this.cur_left;
	if(this.cur_left < 0){
		window.setTimeout(this._ref+'.step()' ,5,'javascript');
	}else{
		if(this._oldElem){
			this._oldElem.style.display='none';
		}	
	}
}


function SlidingDeck(deck){
	this.register("SlidingDeck");
	this.deck=deck;
	this._currentindex=1;
	this._paused=false;

}

SlidingDeck.prototype.register=_selfregister;
SlidingDeck.prototype.init=SlideDeckInit;
SlidingDeck.prototype.tick=SlideDeckTick;
SlidingDeck.prototype.pause=SlideDeckPause;
SlidingDeck.prototype.go=SlideDeckGo;
SlidingDeck.prototype.slide=SlideDeckSlide;
SlidingDeck.prototype.step=SlideDeckStep;



/**



**/

function Panel(){
	this._images = new Array();
	this.text="";
}

function PanelAdd(image){
	var len = this._images.length;
	this._images[len]=image;
}

Panel.prototype.add= PanelAdd;

/**

**/


function PanelList(){
  this._panels= new Array();
}

function PanelListAdd(panel){
	var len = this._panels.length;
	this._panels[len]=panel;
}

PanelList.prototype.add= PanelListAdd;

/**

**/

function FaderPanel(id, panels,nDuration){
	this._numImages=0;
	this._numPanels=0;
	this._duration= nDuration;
	this.panels=panels;
	this._Images=new Array();
	if(panels){
		this._numPanels= this.panels._panels.length;
		if(panels._panels[1]){
			this._numImages = panels._panels[1]._images.length;
		}
	}
	this._id=id;
	this.register("FaderPanel");
	this._currentPanel=0;
}

function FaderPanelInit(){
	this.canvas= document.getElementById(this._id +"_canvas");
	this.canvas.onclick=new Function("window.location='"+this.panels._panels[this._currentPanel].href +"';");
	if(this._numImages > 0){
		for(var i=1; i <= this._numImages; i++){
			this._Images[i] = document.getElementById(this._id + "_img_" + i);
		}
	}
	this.content = document.getElementById(this._id +"_content");
	window.setTimeout(this._ref+".change()" ,this._duration,'javascript');
}

function FaderPanelChange(){


	var rand = Math.random();
	var num = this._numPanels * rand;
	this._currentPanel = Math.round(num);
	
//	this._currentPanel++;
	if(this._currentPanel >= this._numPanels){
		this._currentPanel=0;
	}
	this._currentOpacity=100;
	window.setTimeout(this._ref+".tickdown()" ,10,'javascript');
}

function FaderPanelTickUp(){
	this._currentOpacity+=5;
	if(this._currentOpacity<=99){
		for(var i=1; i <= this._numImages; i++){
			OpacityTools.set(this._Images[i],this._currentOpacity);
		}
		OpacityTools.set(this.content,this._currentOpacity)
		window.setTimeout(this._ref+".tickup()",5,'javascript');	
	}else{
		for(var i=1; i<= this._numImages; i++){
			OpacityTools.set(this._Images[i],99);
			this._Images[i].src= this.panels._panels[this._currentPanel]._images[i-1];
		}
		OpacityTools.set(this.content,99);
		window.setTimeout(this._ref+".change()" ,this._duration,'javascript');	
	}
}

function FaderPanelTickDown(){
	this._currentOpacity-=5;
	if(this._currentOpacity >=0){
		for(var i=1; i <= this._numImages; i++){
			OpacityTools.set(this._Images[i],this._currentOpacity);
		}
		OpacityTools.set(this.content,this._currentOpacity)
		window.setTimeout(this._ref+".tickdown()",5,'javascript');	
	}else{
		for(var i=1; i<= this._numImages; i++){
			OpacityTools.set(this._Images[i],0);
			this._Images[i].src= this.panels._panels[this._currentPanel]._images[i-1];
		}
		OpacityTools.set(this.content,0);
		this.content.innerHTML=this.panels._panels[this._currentPanel].text;
		this.canvas.onclick=new Function("window.location='"+this.panels._panels[this._currentPanel].href +"';");

		window.setTimeout(this._ref+".tickup()" ,800,'javascript');	
	}
}



FaderPanel.prototype.register=_selfregister;
FaderPanel.prototype.init=FaderPanelInit;
FaderPanel.prototype.change=FaderPanelChange;
FaderPanel.prototype.tickdown=FaderPanelTickDown;
FaderPanel.prototype.tickup=FaderPanelTickUp;



function OpacityToolsInit(oNode){
	this.isSupported = true;
	if(typeof oNode.style.MozOpacity != "undefined"){
		this._property = "MozOpacity";
	} else if(typeof oNode.style.opacity != "undefined"){
		this._property = "opacity";
	} else if(typeof oNode.style.KhtmlOpacity != "undefined"){
		this._property = "KhtmlOpacity";
	} else if(typeof oNode.style.filter != "undefined"){
		this._property = "filter";
		this._isIE = true;
		this._regExpGet = /.*opacity=([0-9]+).*/; // IE doesn't seem to understand \d
		this._regExpSet = /(.*opacity=)[0-9]+(.*)/;
	} else {
		this.isSupported = false;
	}
	this.isInitiated = true;
}

function OpacityToolsSet(oNode,nValue,skey){
	if(skey && !oNode){
		oNode=document.getElementById(skey);
	}
	if(!this.isInitiated){ this.initiate(oNode); }
	if(!this.isSupported){ return null; }	
	nValue = Math.round(nValue);
	if(!this._isIE){
		oNode.style[this._property] = nValue / 100;
		return nValue;
	} else if(this.get(oNode) != null){ // In IE we could be dealing with multiple filters
		oNode.style[this._property] = (oNode.currentStyle ? oNode.currentStyle[this._property] : oNode.style[this._property]).replace(this._regExpSet, "$1" + nValue + "$2");
		return nValue;
	} else {
		oNode.style[this._property] +=  "alpha(opacity=" + nValue + ")";
		return nValue;
	}
	return null;
}

function OpacityToolsGet(oNode){
	var sStyle;

	if(!this.isInitiated){ this.initiate(oNode); }
	if(!this.isSupported){ return null; }

	sStyle = document.defaultView ? document.defaultView.getComputedStyle(oNode, null)[this._property] : oNode.currentStyle ? oNode.currentStyle[this._property] : oNode.style[this._property];
	if(!this._isIE){
		return isNaN(sStyle) ? null : sStyle * 100;
	} else {
		return sStyle.match(this._regExpGet) ? sStyle.replace(this._regExpGet, "$1") : null;
	}
	
	return null;
}


OpacityTools = new Object();
OpacityTools.isSupported =null;
OpacityTools.isInitiated = false;
OpacityTools._IE=false;
OpacityTools._property= null;
OpacityTools._regexpGet= null;
OpacityTools._regexpSet= null;
OpacityTools.initiate = OpacityToolsInit;
OpacityTools.set = OpacityToolsSet;
OpacityTools.get = OpacityToolsGet;


function email(){
		
	  _url = document.location.href;
	  _base = _url.substring(0, _url.indexOf("/",8));
	  _new_url ="";
	 
		_new_url= _base + "/mailto_email_page.asp?url="+escape(document.location.href);
				
	setTimeout("location.href = _new_url;", 2000);
	
	_body = "\n"; //""Hello \n\n";//I recommend this tip -- " + document.title;
  _body += "Please review the information on the following Altova Web page: " + location.href; 
  _body += "\n\nAltova is the creator of XMLSpy and other leading XML, data management, UML, and Web services tools. With well over 2 million registered users worldwide, Altova's standards-based software tools are powerful, affordable, and easy to use.\n";
  _body += "\nYou can sign up for the monthly Altova Developer Connection Newsletter here: http://www.altova.com/joinspylist.html";
  _body += "\n\n";
	
  mail_str = "mailto:?subject=Useful information on www.altova.com";// + escape(document.title);
  mail_str += "&body=" + escape (_body);
  
  location.href = mail_str;

}

function delicious() {
	window.open('http://del.icio.us/post?v=4&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=700,height=400');
}

function digg() {
	window.open('http://digg.com/submit?phase=2&url='+encodeURIComponent(location.href));
}
 function toggleThumbByID (evt, uid) {
 	
 	toggleThumb(evt, document.getElementById(uid));
 	
}

 function toggleThumb (evt, obj) {
  	
 	var img = obj;
 	var id ;
 	
 	var enlarge = true;
 	if (obj.nodeName == "A" )
		 img = obj.childNodes.item(0);
		 
	var src = img.src;
	if (src.indexOf("_thumb.")>0)  {
		src = src.replace("_thumb.",".");
	}
	else {
		enlarge = false;
		 pos = src.lastIndexOf(".");
		 src = src.substring(0,pos) + "_thumb" + src.substring(pos);
		}
		
	id = img.id;
	img.src=src;

	var _iconObj = document.getElementById("enlarge_magnifier_" + id);
 	var _linkObj = document.getElementById("enlarge_link_" + id);

	swapImageText (_linkObj, getLang() , enlarge);
 	 	
 	if (_iconObj != null) {
 		
 		if (enlarge)
 			_iconObj.src = _iconObj.src.replace("enlarge", "reduce");
 		else 
 			_iconObj.src = _iconObj.src.replace("reduce", "enlarge");
 		 
 	}
}

function getLang() {
	_url = document.location.href;
	if (_url.indexOf("/de/") != -1) return "de";
	return "en";
}

function swapImageText(_linkObj, lang, enlarge){

	 	if (_linkObj != null) {
	 		
	 		_text  = escape(_linkObj.innerHTML);
 	 	
 	 		if (enlarge) {
 	 			 if (lang == "de") {
 	 			 	_text = _text.replace("Vergr%F6%DFern", "Verkleinern");
 					_linkObj.innerHTML = unescape(_text);
 				}
 				 else
 				 	_linkObj.innerHTML = _linkObj.innerHTML.replace("enlarge", "reduce");
 			} else
 				 if (lang == "de")
 					_linkObj.innerHTML = _linkObj.innerHTML.replace("Verkleinern", "Vergr&ouml;&szlig;ern");
 				 else
 				 	_linkObj.innerHTML = _linkObj.innerHTML.replace("reduce", "enlarge");
 	}
}

