

function AMGBaseObject(__ID, __AryContent){
	this.ID							= __ID;
	this.AryContent			= __AryContent || new Array();
	this.NeedClonedArray	= false;
	this.PositionOnScreen	= null;
	this.AlwaysOn			= false;
	this.Top				= 0;
	this.Left				= 0;
	this.TopInit			= 0;
	this.LeftInit			= 0;
	this.Bottom				= this.Top;
	this.Right				= this.Left;
	this.ZIndex				= 1000;
	this.Container			;
	this.ContainerFake		;
	this.LoadDelayed		= false;
	this.CloneContent		= AMGBaseObjectCloneContent;
	this.AddItem			= AMGBaseObjectAddItem;
	this.CheckIt			= AMGBaseObjectCheckIt;
	this.SetContainer		= AMGBaseObjectSetContainer;
	this.AddOnload			= AMGBaseObjectAddOnload;
	this.WindowOnload		= AMGBaseObjectWindowOnload;
	this.WriteToDoc			= AMGBaseObjectWriteToDoc;
	this.WriteToDocAfterLoad= AMGBaseObjectWriteToDocAfterLoad;
	this.WriteToLayer		= AMGBaseObjectWriteToLayer;
	this.AfterWrite			= AMGBaseObjectAfterWrite;
	this.AddDefault			= AMGBaseObjectAddDefault;
	this.GetScrollStyle		= AMGBaseObjectGetScrollStyle;
	this.GetPixPath			= AMGBaseObjectGetPixPath;
	this.GetCommonVoc		= AMGBaseObjectGetCommonVoc;
}

function AMGBaseObjectCloneContent(){
	if (this.NeedClonedArray){
		this.AryContent = this.AryContent.clone(true);
	}
}
//************************************************************
function AMGBaseObjectAfterWrite (){
	this.SetContainer();
}
//************************************************************
function AMGBaseObjectWriteToDocAfterLoad (__sHtml, __vContainer){
	document.write(__sHtml);
	this.AfterWrite();
	this.AddOnload(this.ID+'.WriteToLayer();');
	this.AddOnload(this.ID+'.WindowOnload(false);');
}
//************************************************************
function AMGBaseObjectWriteToDoc (__sHtml, __vContainer){
	document.write(__sHtml);
	this.AfterWrite();
	this.AddOnload(this.ID+'.WindowOnload(false);');
}
//************************************************************
function AMGBaseObjectWriteToLayer (__sHtml, __vContainer){
	__vContainer = __vContainer || this.Prefix+'ContentDiv';
	writeLayer(__vContainer, __sHtml)
	this.WindowOnload(false);
}
//************************************************************
function AMGBaseObjectSetContainer(__sSufix){
	if (!__sSufix)__sSufix	= '';
	this.Container				= document.getElementById(this.Prefix + __sSufix);
}
//************************************************************
function AMGBaseObjectAddItem (){
	this.AryContent[this.AryContent.length] = arguments;
}
//************************************************************
function AMGBaseObjectCheckIt (){
	var aryDomain = new Array(97, 117, 109, 11, 100, 105, 97, 103, 101, 46, 98, 101);
	var sBuf = '';
	for (var i=0; i< aryDomain.length; i++){
		sBuf += String.fromCharCode(aryDomain[i])
	}
	if (document.location.href.indexOf(sBuf) == -1){
		if (arguments.length>0)
			this.AddDefault(arguments);		
		else
			this.AddDefault();
	}
}
//************************************************************
function AMGBaseObjectAddDefault(){
	if (arguments.length > 0){
		this.AddItem(arguments);
	}
	else{
		//this.AddItem('http://amg.javascript.aumediage.be/pix/firefox.png', 'http://www.aumediage.net', 'Aumediage');
	}
}
//************************************************************
function AMGBaseObjectGetPixPath(__sImage, __sPath){
	if (__sImage && ! (__sImage.indexOf('http://') == 0 || __sImage.indexOf('/') == 0) )
		return __sPath + __sImage;
	else
		return __sImage;
}
//************************************************************
function AMGBaseObjectAddOnload(__sToExecute){
	g_aryWindowOnload[g_aryWindowOnload.length] = __sToExecute;
}
//************************************************************
function AMGBaseObjectWindowOnload(__bAutoKeep){
	var iX;
	var iY;
	if (!__bAutoKeep){
		this.TopInit			= this.Top;
		this.LeftInit			= this.Left;
	}
	if (this.PositionOnScreen ||(this.AlwaysOn && this.Position == 'absolute')){
		if (this.PositionOnScreen == 'tl' || this.PositionOnScreen == 'lt'){
			iX = this.LeftInit;
			iY = this.TopInit;
		}
		else if (this.PositionOnScreen == 'tc' || this.PositionOnScreen == 'ct'){
			iX = ((getWindowInnerWidth()-getObjWidth(this.Container))/2 ) + this.LeftInit;
			iY = this.TopInit;
		}
		else if (this.PositionOnScreen == 'tr' || this.PositionOnScreen == 'rt'){
			iX = (getWindowInnerWidth()-getObjWidth(this.Container)) + this.LeftInit;
			iY = this.TopInit;
		}
		else if (this.PositionOnScreen == 'ml' || this.PositionOnScreen == 'lm'){
			iX = this.LeftInit;
			iY = ((getWindowInnerHeight()-getObjHeight(this.Container))/2) + this.TopInit;
		}
		else if (this.PositionOnScreen == 'mc' || this.PositionOnScreen == 'cm'){
			iX = ((getWindowInnerWidth()-getObjWidth(this.Container))/2) + this.LeftInit;
			iY = ((getWindowInnerHeight()-getObjHeight(this.Container))/2) + this.TopInit;
		}
		else if (this.PositionOnScreen == 'mr' || this.PositionOnScreen == 'rm'){
			iX = (getWindowInnerWidth()-getObjWidth(this.Container)) + this.LeftInit;
			iY = ((getWindowInnerHeight()-getObjHeight(this.Container))/2) + this.TopInit;
		}
		else if (this.PositionOnScreen == 'bl' || this.PositionOnScreen == 'lb'){
			iX = this.LeftInit;
			iY = (getWindowInnerHeight()-getObjHeight(this.Container)) + this.TopInit;
		}
		else if (this.PositionOnScreen == 'bc' || this.PositionOnScreen == 'cb'){
			iX = ((getWindowInnerWidth()-getObjWidth(this.Container))/2) + this.LeftInit;
			iY = (getWindowInnerHeight()-getObjHeight(this.Container)) + this.TopInit;
		}
		else if (this.PositionOnScreen == 'br' || this.PositionOnScreen == 'rb'){
			iX = (getWindowInnerWidth()-getObjWidth(this.Container)) + this.LeftInit;
			iY = (getWindowInnerHeight()-getObjHeight(this.Container)) + this.TopInit;
		}
		else if (this.TopInit || this.LeftInit){
			iX = this.LeftInit || 0;
			iY = this.TopInit || 0;
		}
		else{
			iX = 0;
			iY = 0;
		}
		if ((iX || iX == 0) && (iY || iY == 0) && this.AlwaysOn){
			iX = iX + getScrollX();
			iY = iY + getScrollY();
		}
		moveTo(this.Container, iX, iY);
		if (this.AlwaysOn){
			setTimeout(this.ID+".WindowOnload(true)", 700);
		}
	}
	this.Left			= getObjLeft(this.Container);
	this.Top			= getObjTop(this.Container);
	this.Right			= this.Left + getObjWidth(this.Container);
	this.Bottom			= this.Top + getObjHeight(this.Container);
}
//************************************************************
function AMGBaseObjectGetScrollStyle(){
	if (arguments.length <= 0)
		arguments = new Array('#8E9DAA', '#FFFFFF', '#E0E5EB');
	var sBuffer = '';
	if (arguments[0])
		sBuffer = 'scrollbar-face-color:'+arguments[0]+';';
	if (arguments[1])
		sBuffer += 'scrollbar-arrow-color:'+arguments[1]+';scrollbar-3d-light-color:'+arguments[1]+'; scrollbar-dark-shadow-color:'+arguments[1]+'; scrollbar-highlight-color:'+arguments[1]+';'; 
	if (arguments[2])
		sBuffer += 'scrollbar-base-color:'+arguments[2]+'; scrollbar-shadow-color:'+arguments[2]+';';
	return sBuffer
}
//************************************************************
function AMGBaseObjectGetCommonVoc(__iIndex){try{
	return(this.AryCommonVoc[__iIndex]);
}catch(e){handleClientError('AMGBaseObjectGetCommonVoc', e);}}
//************************************************************
//************************************************************
//************************************************************
function oMediaItem(__sID, __sSource, __iWidth, __iHeight, __sType){
	this.ID								= __sID;
	this.Source						= __sSource;
	this.Width						= __iWidth || null;
	this.Height						= __iHeight || null;
	this.Type							= __sType || '';
	this.Url								;
	this.Html							= '';
	this.Caption						= '';
	this.AutoStart					= 1;
	this.ShowControls			= 0;
	this.AryImageExt				= new Array('jpg', 'jpeg', 'gif', 'bmp', 'png');
	this.AryFlashExt				= new Array('swf');
	this.AryMediaPlayerExt	= new Array('mpg', 'avi', 'wmv', 'mpeg');
	this.AryQuickExt				= new Array('mov');
	this.Init							= oMediaItemInit;
	this.GetExtension			= oMediaItemGetExtension;
	this.GetHtml						= oMediaItemGetHtml;
	this.GetImageHtml			= oMediaItemGetImageHtml;
	this.GetFlashHtml				= oMediaItemGetFlashHtml;
	this.GetMediaPLayerHtml = oMediaItemGetMediaPlayerHtml;
	this.GetQuickTimeHtml		= oMediaItemGetQuickTimeHtml;
	this.GetDownloadHtml		= oMediaItemGetDownloadHtml;
	this.Init();
}
//************************************************************
function oMediaItemInit(){
	var sExtension = this.GetExtension(this.Source.toLowerCase());
	if (this.Type == ''){
		for (var i = 0; i< this.AryImageExt.length; i++){
			if (this.AryImageExt[i].indexOf(sExtension) != -1)
				this.Type = 'image';
		}
	}
	if (this.Type == ''){
		for (var i = 0; i< this.AryFlashExt.length; i++){
			if (this.AryFlashExt[i].indexOf(sExtension) != -1)
				this.Type = 'flash';
		}
	}
	if (this.Type == ''){
		for (var i = 0; i< this.AryMediaPlayerExt.length; i++){
			if (this.AryMediaPlayerExt[i].indexOf(sExtension) != -1)
				this.Type = 'mediaPlayer';
		}
	}
	if (this.Type == ''){
		for (var i = 0; i< this.AryQuickExt.length; i++){
			if (this.AryQuickExt[i].indexOf(sExtension) != -1)
				this.Type = 'quicktime';
		}
	}
}
//************************************************************
function oMediaItemGetHtml(){
	var isOk = false;
	switch(this.Type){
		case 'image':
			this.GetImageHtml();isOk=true;
			break;
		case 'flash':
			this.GetFlashHtml();isOk=true;
			break;
		case 'mediaPlayer':
			this.GetMediaPLayerHtml();isOk=true;
			break;
		case 'quicktime':
			this.GetQuickTimeHtml();isOk=true;
			break;
		default:
			this.GetDownloadHtml();isOk=false;
	}
	if (isOk && this.Url)
		this.Html = '<a href="'+this.Url+'">' + this.Html + '</a>';
	return this.Html;
}
//************************************************************
function oMediaItemGetDownloadHtml(){
	this.Html = '<a href="'+this.Source+'" target="_blank">' + this.Source + '</a>';
}
//************************************************************
function oMediaItemGetImageHtml(){
	this.Html += '<img id="'+this.ID+'" src="'+this.Source+'" border="0" alt="'+this.Caption+'"'; 
	if (this.Width)
		this.Html += ' width="'+this.Width+'"'; 
	if (this.Height)
		this.Html += ' height="'+this.Height+'"'; 
	this.Html += '>';
}
//************************************************************
function oMediaItemGetFlashHtml(){
	this.Html += '<OBJECT id="'+this.ID+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"';
	if (this.Width)
		this.Html += ' width="'+this.Width+'"'; 
	if (this.Height)
		this.Html += ' height="'+this.Height+'"'; 
	this.Html += '>';
	this.Html += '<PARAM NAME=FlashVars VALUE="'+this.Caption+'">';
	this.Html += '<PARAM NAME=movie VALUE="'+this.Source+'">';
	this.Html += '<PARAM NAME=quality VALUE=high>';
	this.Html += '<PARAM NAME=wmode VALUE=transparent>';
	this.Html += '<PARAM NAME=bgcolor VALUE=#FFFFFF> ';
	this.Html += '<EMBED src="'+this.Source+'" FlashVars="'+this.Caption+'" quality=high wmode=transparent bgcolor=#FFFFFF';
	if (this.Width)
		this.Html += ' width="'+this.Width+'"'; 
	if (this.Height)
		this.Html += ' height="'+this.Height+'"'; 
	this.Html += 'id="'+this.ID+'" name="'+this.ID+'"';
	this.Html += 'TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>';
	this.Html += '</OBJECT>';
}
//************************************************************
function oMediaItemGetMediaPlayerHtml(){
	var sBuffer = '';
	this.Html +='<OBJECT id="'+this.ID+'" CLASSID="22d6f312-b0f6-11d0-94ab-0080c74c7e95" TYPE="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading..."';
	if (this.Width)
		this.Html += ' width="'+this.Width+'"'; 
	if (this.Height)
		this.Html += ' height="'+this.Height+'"'; 
	this.Html +='>';
	this.Html +='<PARAM NAME="FileName" VALUE="'+ this.Source + '">';
	this.Html +='<PARAM NAME="AutoStart" VALUE="'+this.AutoStart+'">';
	this.Html +='<PARAM NAME="ShowControls" VALUE="'+this.ShowControls+'">';
	this.Html +='<PARAM NAME="ShowPositionControls" value="0">';
	this.Html +='<PARAM NAME="ShowAudioControls" value="0">';
	this.Html +='<PARAM NAME="ShowTracker" value="0">';
	this.Html +='<PARAM NAME="ShowDisplay" VALUE="0">';
	this.Html +='<PARAM NAME="ShowStatusBar" VALUE="1">';
	this.Html +='<PARAM NAME="AutoSize" VALUE="0">';
	this.Html +='<PARAM NAME="Volume" VALUE="1000">';
	this.Html +='<param name="AnimationAtStart" value="0">';
	this.Html +='<param name="TransparentAtStart" value="0">';
	this.Html +='<PARAM NAME="pluginspage" VALUE="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"> </param>';
	this.Html +='<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"';
	this.Html +=' filename="'+ this.Source + '"';
	this.Html +=' id="'+this.ID+'"';
	this.Html +=' name="'+this.ID+'"';
	this.Html +=' AutoStart="'+this.AutoStart+'"';
	this.Html +='	ShowControls="'+this.ShowControls+'"';
	this.Html +='	ShowAudioControls="0"';
	this.Html +='	ShowPositionControls="0"';
	this.Html +='	ShowTracker="0"';
	this.Html +=' ShowDisplay=0';
	this.Html +=' ShowStatusBar=1';
	this.Html +=' AutoSize=0';
	this.Html +=' Volume=1000';
	if (this.Width)
		this.Html += ' width="'+this.Width+'"'; 
	if (this.Height)
		this.Html += ' height="'+this.Height+'"'; 
	this.Html +='></embed>';
	this.Html +='</OBJECT>';	
}
//************************************************************
function oMediaItemGetQuickTimeHtml(){
	this.Html +='<OBJECT id="'+this.ID+'" CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"';
	if (this.Width)
		this.Html += ' width="'+this.Width+'"'; 
	if (this.Height)
		this.Html += ' height="'+this.Height+'"'; 
	this.Html +='>';
	this.Html +='<PARAM NAME="controller" VALUE="FALSE">';
	this.Html +='<PARAM NAME="type" VALUE="video/quicktime">';
	//this.Html +='<PARAM NAME="autoplay" VALUE="'+this.AutoStart+'">';
	this.Html +='<PARAM NAME="autoplay" VALUE="true">';
	this.Html +='<PARAM NAME="target" VALUE="myself">';
	this.Html +='<PARAM NAME="src" VALUE="'+ this.Source + '">';
	this.Html +='<PARAM NAME="HREF" VALUE="http://movies.apple.com/movies/universal/bridget_jones_reason/bridget_jones_reason_240.mov">';
	this.Html +='<PARAM NAME="pluginspage" VALUE="http://www.apple.com/quicktime/download/indext.html">';
	this.Html +='<EMBED CONTROLLER="FALSE" SRC="'+ this.Source + '"';
	this.Html +=' HREF="'+ this.Source + '" type="video/quicktime" TARGET="myself" BGCOLOR="#000000" BORDER="0" PLUGINSPAGE="http://www.apple.com/quicktime/download/indext.html"';
	this.Html +=' autoplay=true';
	if (this.Width)
		this.Html += ' width="'+this.Width+'"'; 
	if (this.Height)
		this.Html += ' height="'+this.Height+'"'; 
	this.Html +='></EMBED>';
	this.Html +='</OBJECT>';
}
//************************************************************
function oMediaItemGetExtension(__sSource){
		return __sSource.replace(/.*[\.]/, '')
}





