// siehe => http://docs.jquery.com/Using_jQuery_with_Other_Libraries
jQuery.noConflict();
var PaymentTypeIdBefore = "";
var PersonCharacCategoryIDBefore = "";
jQuery(document).ready(function() {
	
	jQuery('.PaymentLink').click(function() {
		paymentTypeId = jQuery(this).attr("id");
		personCharacCategoryID = jQuery(this).attr("pccID");

		if (paymentTypeId != PaymentTypeIdBefore)
		{
			jQuery("#PaymentDescription"+paymentTypeId).slideToggle("normal");
	
			if (personCharacCategoryID != "")
				jQuery("#PersonCharacCategoryID"+personCharacCategoryID).slideToggle("normal");
	
			if (PersonCharacCategoryIDBefore != "")
				jQuery("#PersonCharacCategoryID"+PersonCharacCategoryIDBefore).slideToggle("normal");
			
			if (PaymentTypeIdBefore != "")
				jQuery("#PaymentDescription"+PaymentTypeIdBefore).slideToggle("normal");
			
			PersonCharacCategoryIDBefore = personCharacCategoryID;
			PaymentTypeIdBefore = paymentTypeId;
		}
	});
	
	jQuery(".PaymentDescriptions").css("display", "none");

	jQuery("a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded'});
});

function showBAInfoDialog()
{
	//$('#AjaxContainer').html(unescape(msg.Content));
	//$('#AjaxContainer').html(unescape('tst'));
	
	ModalDialog = jQuery('#BAInfoDiv').modal({
		overlayCss: {
	    backgroundColor: '#000',
	    cursor: 'wait',
	    overflow: 'auto'
	  },
	  containerCss: {
	    height: 355,
	    width: 470,
	    overflow: 'auto'
	  },
	  onShow : function(dialog){
		  //Dialog schliessen, wenn man ausserhalb des Dialogs klickt. 
		  //dialog.overlay.click(jQuery.modal.close);
		  
	  }
	});
}

function showBAProductsDialog()
{
	ModalDialog = jQuery('#BATopProductsDiv').modal({
		overlayCss: {
	    backgroundColor: '#000',
	    cursor: 'wait',
	    overflow: 'auto'
	  },
	  containerCss: {
	    height: 520,
	    width: 780,
	    overflow: 'auto'
	  },
	  onShow : function(dialog){
		  //Dialog schliessen, wenn man ausserhalb des Dialogs klickt. 
		  //dialog.overlay.click(jQuery.modal.close);
		  
	  }
	});
}


function openUmfragePopup()
{
	window.open('http://files.titus.de/TestMaFo/formulare/Fragebogen_nachBestellvorgang.htm', 'umfragePopup', 'menubar=no,resizable=yes,scrollbars=yes,height=800,width=800');
} // function openGalleryPopup(PostingID, BildNo)



function checkAllProductInformer()
{
	var elem = document.getElementById('ProductInformerSelectAll');
	var objForm =  document.ProructInformerForm
	for (var i = 0; i < objForm.elements.length; i++)
	{
		if (objForm.elements[i].name == 'DeleteItem[]')
		{
			objForm.elements[i].checked = elem.checked;
		}
		
	}
}


function ShowMap()
{
	document.write ('<object width="550" height="740" align="middle" id="titus_shops_karte" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">');
	document.write ('<param value="sameDomain" name="allowScriptAccess"></param>');
	document.write ('<param value="binaries/flash/titus_shops_karte.swf" name="movie"></param>');
	document.write ('<param value="high" name="quality"></param>');
	document.write ('<param value="#f8f4f1" name="bgcolor"></param>');
	document.write ('<embed width="550" height="740" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="sameDomain" name="titus_shops_karte" bgcolor="#f8f4f1" quality="high" src="binaries/flash/titus_shops_karte.swf">');
	document.write ('</embed></object>');

} // function FlashHeader ()

function Flipbook(source)
{
	document.write(source);
} // function Flipbook(source)

function openGalleryPopup(PostingID, BildNo, ThumbIdentifiers)
{
	window.open('scripts/popup_gallery.phtml?PostingID=' + PostingID + '&BildNo=' + BildNo + '&ThumbIdentifiers=' + ThumbIdentifiers, 'galleryPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=480,width=560');
} // function openGalleryPopup(PostingID, BildNo)

function openVideoPopup(PostingID, VideoNo)
{
	window.open('scripts/popup_video.phtml?PostingID=' + PostingID + '&VideoNo=' + VideoNo, 'videoPopup', 'menubar=no,resizable=no,scrollbars=no,height=280,width=360');
} // function openGalleryPopup(PostingID, BildNo)

function openHilfePopup(Title)
{
	window.open('popup.phtml?screen=mi_popup_help&title='+Title, 'helpPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=500,width=580');
} // function openHelpPopup(Title)

function openHilfePopupVainstream(Title)
{
	window.open('popup.phtml?screen=vs_popup_help&title='+Title, 'helpPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=500,width=580');
} // function openHelpPopup(Title)

function openFindCustomerNoPopup(Title)
{
	window.open('popup.phtml?screen=or_popup_findcustomerno&title='+Title, 'findCustomerNoPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=400,width=430');
} // function openFindCustomerNoPopup(Title)

function openFindCustomerNoPopupVainstream(Title)
{
	window.open('popup.phtml?screen=vs_popup_findcustomerno&title='+Title, 'findCustomerNoPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=400,width=430');
} // function openFindCustomerNoPopup(Title)

function openFindCustomerPasswordPopup(Title, ShowInputField, PTIDForEMail )
{
	window.open('popup.phtml?screen=or_popup_findcustomerpassword&title='+Title+'&showInputField='+ShowInputField+'&PTID='+PTIDForEMail, 'findCustomerPasswordPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=400,width=430');
} // function openFindCustomerPasswordPopup(Title)

function openFindCustomerPasswordPopupVainstream(Title, ShowInputField, PTIDForEMail )
{
	window.open('popup.phtml?screen=vs_popup_findcustomerpassword&title='+Title+'&showInputField='+ShowInputField+'&PTID='+PTIDForEMail, 'findCustomerPasswordPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=400,width=430');
} // function openFindCustomerPasswordPopup(Title)

function openBestellHotlinePopup(Title)
{
	window.open('popup.phtml?screen=or_popup_orderhotline&title='+Title, 'bestellHotlinePopup', 'menubar=no,resizable=no,scrollbars=no,height=440,width=430');
} // function openBestellHotlinePopup(Title)

function openSteckbriefPopup(Title, CommunityMemberID, Admin, openFromInstantMessage)
{
	window.open('popup.phtml?screen=co_popup_steckbrief&title='+Title+'&CommunityMemberID='+CommunityMemberID+'&Admin='+Admin+'&openFromInstantMessage='+openFromInstantMessage, 'steckbriefPopup' + GetRandomWindowKey( 3 ), 'menubar=no,resizable=yes,scrollbars=yes,height=500,width=500');
} // function openSteckbriefPopup(CommunityMemberID)

function openAddRelationshipPopup(Title, CommunityMemberID)
{
	window.open('popup.phtml?screen=co_popup_addrelationship&title='+Title+'&CommunityMemberID=' + CommunityMemberID, 'addRelationshipPopup', 'menubar=no,resizable=no,scrollbars=no,height=220,width=430');
} // function openAddRelationshipPopup(CommunityMemberID)

function openWriteIMPopup(Title, CommunityMemberID)
{
	window.open('popup.phtml?screen=co_popup_writeim&title='+Title+'&CommunityMemberID=' + CommunityMemberID, 'writeIMPopup' + GetRandomWindowKey( 3 ), 'menubar=no,resizable=yes,scrollbars=no,height=400,width=340,screenX=100,screenY=100');
} // function openWriteIMPopup(Title, CommunityMemberID)

function openReceivedIMPopup(Title, MessageNo, WindowKey)
{
	window.open('popup.phtml?screen=co_popup_receivedim&title='+Title+'&MessageNo=' + MessageNo, 'receivedIMPopup' + WindowKey, 'menubar=no,resizable=yes,scrollbars=no,height=400,width=340,screenX=100,screenY=100');
} // function openReceivedIMPopup(Title, MessageNo, WindowKey)

function openIMHistoryPopup(Title, CommunityMemberID, Nickname)
{
	window.open('popup.phtml?screen=co_popup_imhistory&title='+Title+'&CommunityMemberID=' + CommunityMemberID + '&Nickname=' + Nickname + "#bottom", 'writeIMPopup', 'menubar=no,resizable=no,scrollbars=yes,height=420,width=480');
} // function openIMHistoryPopup(Title, CommunityMemberID)

function openFriendsListPopup(Title, CommunityMemberID, TargetFormName, TargetFieldName, SourceProperty, Overwrite, ShowMyEMails)
{
	window.open('popup.phtml?screen=co_popup_friendslist&title='+Title+'&CommunityMemberID=' + CommunityMemberID + '&TargetFormName=' + TargetFormName + '&TargetFieldName=' + TargetFieldName + '&SourceProperty=' + SourceProperty + "&Overwrite=" + Overwrite + "&ShowMyEMails=" + ShowMyEMails, 'friendsListPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=420,width=320');
} // function openFriendsListPopup(Title, CommunityMemberID, TargetFormName, TargetFieldName, SourceProperty)

function openCommunityMemberBinaryPopup(Title , CommunityBinaryID, CommunityMemberID, CommunityBinaryCategoryID, SortNo, Width, Height)
{
	if (Width == '')
		Width = '800';
	if (Height == '')
		Height = '600';
	window.open('popup.phtml?screen=co_popup_communitybinary&title=' + Title + '&CommunityBinaryID=' + CommunityBinaryID + '&CommunityMemberID=' + CommunityMemberID + '&CommunityBinaryCategoryID=' + CommunityBinaryCategoryID + '&SortNo=' + SortNo, 'communityBinaryPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=' + (Height+60) + ',width=' + (Width+35) );	
} // function openCommunityMemberBinaryPopup(Title , CommunityBinaryID, Width, Height)

function showSendMail( TargetWindow, CommunityMemberID )
{
	showInTargetWindow( TargetWindow, 'screen.phtml?screen=co_sendmail' + ( CommunityMemberID != '' ? '&CommunityMemberID=' + CommunityMemberID : '' ) );
} // function showSendMail( TargetWindow )

function showInTargetWindow( TargetWindow, Location )
{
	TargetWindow.location.href=Location;
} // function showInTargetWindow( TargetWindow, Location )

function openShowHTMLMailBodyPopup(Title , MessageNo)
{
	window.open('popup.phtml?screen=co_popup_showhtmlmailbody&blank=1&title=' + Title + '&MessageNo=' + MessageNo, 'showHTMLMailBodyPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=550,width=700' );	
} // function openCommunityMemberBinaryPopup(Title , CommunityBinaryID, Width, Height)

function checkAll( objSelectAllCheckbox1, objSelectAllCheckbox2, objForm, identifier)
{
	// Überprüfen, ob selectAll angehakt ist, oder nicht
	var check = objSelectAllCheckbox1.checked;
	
	// Zweites selectAll auch entsprechend checken
	objSelectAllCheckbox2.checked = check;
	
	for (var i = 0; i < objForm.elements.length; i++)
		if ((objForm.elements[i].name != objSelectAllCheckbox1.name) && (objForm.elements[i].name != objSelectAllCheckbox2.name))
			objForm.elements[i].checked = check;
} // function CheckAll()

function checkAll_Wishlist( objSelectAllCheckbox1, objForm, identifier)
{
	// Überprüfen, ob selectAll angehakt ist, oder nicht
	var check = objSelectAllCheckbox1.checked;
	
	for (var i = 0; i < objForm.elements.length; i++)
		if (objForm.elements[i].name != objSelectAllCheckbox1.name)
			objForm.elements[i].checked = check;
} // function checkAll_Wishlist()

function openProductDetailsPopup( detailsLink )
{
	window.open(detailsLink, 'productDetailsPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=700,width=720');
}

function openAGBPopupVainstream()
{
	window.open('popup.phtml?screen=vs_popup_agb', 'productAGBPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=500,width=550');
}

function openAGBPopupTitus()
{
	window.open('popup.phtml?screen=mi_popup_agb', 'productAGBPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=500,width=550');
}

function openSendProductPopup( Title, VariantTreeNodeID, ColorValueID, TreeNodeID )
{
	window.open('popup.phtml?screen=ws_popup_sendproduct&VariantTreeNodeID='+VariantTreeNodeID+'&Farbe_ValueID='+ColorValueID+'&TreeNodeID=' + TreeNodeID + '&title=' + Title, 'sendProductPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=490,width=417');
}

function GetRandomWindowKey( length )
{
	return (Math.ceil((Math.random() * Math.pow(10,length))));
} // function GetRandomWindowKey( length )

function submitAfterConfirmation(Message, TargetForm)
{
	answer = confirm( Message );
	if (answer == true)
		TargetForm.submit();
} // function submitAfterConfirmation(Message, TargetForm)

function bestaetigen(RedirectUrl, Message)
{
	decision = confirm(Message);
	if (decision)
		document.location.href = RedirectUrl;
} // function bestaetigen(RedirectUrl, Message)

function loeschenBestaetigen(Message)
{
	decision = confirm(Message);
	if (decision)
	{
		document.CheckpointForm.Task.value = 'RemoveAllSelectedFromCheckpoint';
		document.CheckpointForm.submit();
	}
} // function bestaetigen(RedirectUrl, Message)

function doPassVar()
{
   window.document.webheader.SetVariable("getIM", 1);
}

function openPostingPopup(Title, PostingID, SearchString)
{
	window.open('popup.phtml?screen=co_popup_posting&title='+Title+'&PostingID=' + PostingID + "&SearchString=" + SearchString, 'writeIMPopup' + GetRandomWindowKey( 3 ), 'menubar=no,resizable=no,scrollbars=yes,height=420,width=430');
} // function openPostingPopup(Title, PostingID)

function openGroessentabellePopup(Title, PostingID, h, w)
{
	window.open('popup.phtml?screen=ws_popup_groessentabelle&title=Gr%F6%DFentabelle&PostingID=' + PostingID, 'groessenTabellePopup', 'menubar=no,resizable=no,scrollbars=yes,height='+h+',width='+w+'');
} // function openGroessentabellePopup(Title, PostingID)




function openOnlineListPopup(Title, RelationshipIndex)
{
	window.open('popup.phtml?screen=co_popup_onlinelist&title='+Title+'&IsPopup=1&RelationshipIndex=' + RelationshipIndex, 'onlineListPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=600,width=540');
} // function openOnlineListPopup(Title, CommunityMemberID, TargetFormName, TargetFieldName, SourceProperty)

function openUserGalleryPopup(PostingID, BildNo)
{
	window.open('scripts/popup_usergallery.phtml?PostingID=' + PostingID + "&BildNo=" + BildNo, 'UserGalleryPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=480,width=560');
} // function openUserGalleryPopup(Title, MainPostingNo)

function openWishlistPopup(Title, Layout, TreeNodeIDs )
{
	window.open('popup.phtml?screen=ws_popup_wishlist&title='+Title+'&Layout='+Layout+'&TreeNodeIDs='+TreeNodeIDs, 'wishlistPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=535,width=680');
} // function openWishlistPopup(Title)

function openMailWishlistPopup(Title)
{
	window.open('popup.phtml?screen=ws_popup_mailwishlist&title='+Title, 'wishlistPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=535,width=680');
} // function openWishlistPopup(Title)

function appendToValue( Field, Text )
{
	Field.value += Text;
	Field.focus();
} // function appendToValue( Field, Text )

function openSmileysPopup(Title, TargetFieldName, regardLength )
{
	window.open('popup.phtml?screen=co_popup_smileys&title='+Title+'&TargetFieldName='+TargetFieldName+'&regardLength='+regardLength, 'smileysPopup', 'menubar=no,resizable=yes,scrollbars=yes,height=360,width=340');
} // function openSmileysPopup(Title, TargetFieldName )

function xmax_openMovie(MovieID, UniqueID)
{
	window.open('http://titus.p14.de/mixamovie/get.php?'+MovieID+'&UniqueID='+UniqueID, 'moviePopup', 'menubar=no,resizable=no,scrollbars=no,height=480,width=640');	
}

function openRubbelWindow()
{
	window.open('popup.phtml?screen=mi_popup_rubbeldichreich&blank=1', 'rubbelDichReichPopup', 'menubar=no,resizable=no,scrollbars=no,height=435,width=305');	
}

function openTeamTitusVideoPopup()
{
	window.open('popup.phtml?screen=mi_popup_teamtitusvideo&blank=1', 'TeamTitusVideoPopup', 'menubar=no,resizable=no,scrollbars=no,height=319,width=400');	
}

function openBotB()
{
	window.open('http://bob.titus.de/', 'winBoB', 'width=800,height=600,scrollbars=yes,menubar=yes,resizable=yes,status=yes,toolbar=yes,location=yes');
	window.open('scripts/battleofbands/mainpostings.phtml', 'winBoBForum', 'width=650,height=600,scrollbars=yes,menubar=yes,resizable=yes,status=yes,toolbar=yes,location=yes');
}

Indexes = new Array();
BinaryCodeIDs = new Array();
TreeNodeIDs = new Array();

function changePic(identifier, forward, newLink)
{
	if (forward)
		if (Indexes[identifier] == (BinaryCodeIDs[identifier].length - 1))
			Indexes[identifier] = 0;
		else
			Indexes[identifier] = Indexes[identifier] + 1;
	else
		if (Indexes[identifier] == 0)
			Indexes[identifier] = (BinaryCodeIDs[identifier].length - 1);
		else
			Indexes[identifier] = Indexes[identifier] - 1;
	
	// Bild wechseln
	var el = document.all ? document.all[identifier] : document.getElementById(identifier);
	
	bgStyle = el.style.backgroundImage;
	bgStyleSplitted = bgStyle.split(",");
	bgStyleSplitted[2] = bgStyleSplitted[2].replace('"', "");

	el.style.backgroundImage = 'url(binary,'+BinaryCodeIDs[identifier][Indexes[identifier]]+','+ bgStyleSplitted[2].replace(/ /g, "_");
	
	// Verlinkung wechseln
	var el = document.all ? document.all['link_' + identifier] : document.getElementById('link_' + identifier);
	el.href = newLink + '&VariantTreeNodeID=' + TreeNodeIDs[identifier][Indexes[identifier]];
	var el = document.all ? document.all['link2_' + identifier] : document.getElementById('link2_' + identifier);
	el.href = newLink + '&VariantTreeNodeID=' + TreeNodeIDs[identifier][Indexes[identifier]];
} // function changePic

function openFlashCatalog(OriginalPromoCode)
{
	if (OriginalPromoCode.indexOf('title=') > 0)
		OriginalPromoCode = OriginalPromoCode.substr(OriginalPromoCode.indexOf('title=') + 6);

	newwindow = window.open('', OriginalPromoCode, 'width=780,height=580,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,top=100,left=100');

	if (newwindow.location.href == 'about:blank' || newwindow.location.href.indexOf('ws_product') > 0)
	{
		newwindow=window.open('popup.phtml?screen=ws_popup_flipbook&title='+OriginalPromoCode, OriginalPromoCode, 'width=780,height=580,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,top=100,left=100');
		newwindow.focus();
	}
	else
	{
		newwindow.focus();
	}
}

function openFlashDankoJones(linkurl, linktarget)
{
	tomwin = window.open(linkurl, linktarget, 'menubar=no,resizable=no,scrollbars=no,height=486,width=766');	
	tomwin.focus();
}

function openMastershipSpecial(linkurl, linktarget)
{
	mswin = window.open(linkurl, linktarget, 'menubar=no,resizable=no,scrollbars=no,height=580,width=780');	
	mswin.focus();
}

function getItem(TreeNodeID)
{
	link = 'screen.phtml?screen=ws_product&TreeNodeID='+TreeNodeID+'&showMagalogButton=1&PromoCode=FlashMagalog205';
	windowName = 'tituswin';
	
	if (opener)
	{ 
		if (opener.closed)
		{
			window.open(link, windowName, '');	
			window.close();
		}
		else
		{ 
			opener.location.href = link;
			window.close(); 
		} 
	}
	else
	{ 
		window.open(link, windowName, '');	
		window.close();
	}
}

function getItem_Mastership(TreeNodeID)
{
	link = 'screen.phtml?screen=ws_product&TreeNodeID='+TreeNodeID+'&showMagalogButton=2&PromoCode=MastershipSpecial205';
	windowName = 'tituswin';
	
	if (opener)
	{ 
		if (opener.closed)
		{
			window.open(link, windowName, '');	
			window.close();
		}
		else
		{ 
			opener.location.href = link;
			window.close(); 
		} 
	}
	else
	{ 
		window.open(link, windowName, '');	
		window.close();
	}
}

function openItem(TreeNodeID, type)
{
	if (type == 3)
		promocode = 'FlashMagalog0305';
	else if (type == 4)
		promocode = 'DickiesSpecial';
	else if (type == 5)
		promocode = 'NovemberRain';
	else if (type == 6)
		promocode = 'FlashMagalog0405';
	else if (type == 7)
		promocode = 'FlyingChristmas';
	else if (type == 8)
		promocode = 'TheMeaningOfXmas';
	else if (type == 9)
		promocode = 'TitusNewYearsFlyer';
	else if (type == 10)
		promocode = 'TitusPreview2006';
	else if (type == 11)
		promocode = 'TitusMagalog0106';
	else if (type == 12)
		promocode = 'DankoJones';
	else if (type == 13)
		promocode = 'WildEastern2006';	
		
	link = 'screen.phtml?screen=ws_product&TreeNodeID='+TreeNodeID+'&showMagalogButton='+type+'&PromoCode='+promocode;
	windowName = 'tituswin';
	
	if (opener)
	{ 
		if (opener.closed)
		{
			window.open(link, windowName, '');	
			window.close();
		} // if (opener.closed)
		else
		{ 
			opener.location.href = link;
			window.close(); 
		} // else
	} // if (opener)
	else
	{ 
		window.open(link, windowName, '');	
		window.close();
	} // else
} // function openItem(TreeNodeID, type)


function openItem_DynFB(TreeNodeID, name)
{
	link = 'screen.phtml?screen=ws_product&TreeNodeID='+TreeNodeID+'&PromoCode='+name+'&SelectSmallestVariant=1'
	windowName = 'tituswin';
	
	if (opener)
	{ 
		if (opener.closed)
		{
			newwindow = window.open(link, windowName, 'height=650,width=700,menubar=yes,resizable=yes,scrollbars=yes,location=yes,toolbar=yes');
			newwindow.focus();
		} // if (opener.closed)
		else
		{ 
			opener.location.href = link;
			opener.focus();
 
		} // else
	} // if (opener)
	else
	{ 
		newwindow = window.open(link, windowName, 'height=650,width=700,menubar=yes,resizable=yes,scrollbars=yes,location=yes,toolbar=yes');
		newwindow.focus();
	} // else
} // function openItem_DynFB(TreeNodeID, type)


function openPopup(Description, Height, Width, Url, scrollbars)
{
	if (scrollbars == null)
		scrollbars = "no";

	window.open(Url, Description, 'menubar=no,resizable=yes,scrollbars='+scrollbars+',height='+Height+',width='+Width);	
}

function openCommunityNutzungsbedingungen()
{
	window.open('popup.phtml?screen=co_popup_nutzungsbedingungen', 'CommunityNutzungsbedingungen', 'menubar=no,resizable=yes,scrollbars=yes,height=650,width=530');	
}

function redirectOpener(Url)
{
	windowName = 'tituswin';
	
	if (opener)
	{ 
		if (opener.closed)
		{
			window.open(Url, windowName, '');	
			window.close();
		}
		else
		{ 
			opener.location.href = Url;
			window.close();
		} 
	}
	else
	{ 
		window.open(Url, windowName, '');	
		window.close();
	}	
}

function assignedCustomerNO(CustomerNo)
{
	window.opener.document.LoginForm.a1.value = CustomerNo;
	window.close();
}

function copyCustomerNO(CustomerNo)
{
	url = window.opener.location.href;
	if (url.indexOf('aaa_daten') > 0)
	{
		window.opener.document.LoginForm.a1.value = CustomerNo;
		window.close();
	}
	else
	{
		window.opener.document.PersonalData.a1.value = CustomerNo;
		window.close();
	}
	
}

function changeImage(target, state)
{
	if(typeof(target.getAttribute) == 'undefined' || !document.loaded || !target.getAttribute(state+'Image'))
		return;
	if(!target.getAttribute("outImage") && state == "over")
		target.setAttribute('outImage', target.getAttribute('src'));
	target.setAttribute('src',target.getAttribute(state+'Image'));
}

function changeClass(target, state)
{
	if(typeof(target.getAttribute) == 'undefined' || !document.loaded)
		return;
	if(target.getAttribute('static') == "true")
		return;
	if(!target.getAttribute('outClass') && state == 'over')
		target.setAttribute('outClass', target.getAttribute('class'));
	target.setAttribute('class',target.getAttribute(state+'Class'));
	// to make ie happy
	target.setAttribute('className',target.getAttribute(state+'Class'));
	if(subElement = document.getElementById("_"+target.getAttribute('id')))
		changeClass(subElement, state);
	images = scanDomTreeForNodeAttribute(target, state+'Image');
	if(images.length == 0)
		return;
	for(var i=0; i < images.length; i++)	
	{
		changeImage(images[i], state);
	}
}

function preloadOverImages()
{
	preloadedImages = new Array();
	document.loaded = true;
	images = scanDomTreeForNodeAttribute("", 'overImage');
	for(var i=0; i < images.length; i++)	
	{
		src = images[i].getAttribute('overImage');
		preloadedImages[i] = new Image();
		preloadedImages[i].src = src;
	}
}

function addMouseSwitches()
{
	classes = scanDomTreeForNodeAttribute("", 'overClass');
	for(var i=0; i < classes.length; i++)	
	{
		if(classes[i].getAttribute('onMouseOver'))
			continue;
		classes[i].onmouseover = function()	{ changeClass(this, 'over'); return; }
		classes[i].onmouseout = function() { changeImage(this, 'out'); return; }
	}
	images = scanDomTreeForNodeAttribute("", 'overImage');
	for(var i=0; i < images.length; i++)	
	{
		if(images[i].getAttribute('onMouseOver'))	
			continue;
		images[i].onmouseover = function() { changeImage(this, 'over'); return; }
		images[i].onmouseout = function() { changeImage(this, 'out'); return; }
	}
}

function scanDomTreeForNodeAttribute(start_node,attribute)	{
     if(start_node == "")
		var start_node = document;
  	var foundNodeArray = [];
	var childs = start_node.childNodes;
	for(var i=0; i < childs.length; i++){
		if(typeof(childs[i].getAttribute) != 'undefined')	{
			var found = childs[i].getAttribute(attribute);
			if(found)	{
				foundNodeArray[foundNodeArray.length] = childs[i];
			}
			if(childs[i].childNodes.length > 0)	{
				var recursiveNodeArray = scanDomTreeForNodeAttribute(childs[i],attribute);
    				for(var j=0; j < recursiveNodeArray.length; j++)	{
        					foundNodeArray[foundNodeArray.length] = recursiveNodeArray[j];
				}
			}
		}
  	}
	return foundNodeArray;
}

function Advertisements(pos)
{
	document.write('<A HREF="' + OAS_url + 'click_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + OAS_query + '" TARGET=_top>');
	document.write('<IMG SRC="' + OAS_url + 'adstream_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + OAS_query + '" BORDER=0 ALT="Click!"></A>');
}

function OAS_Version()
{
	OAS_version = 11;
	if (navigator.userAgent.indexOf('Mozilla/3') != -1)
		OAS_version = 10;
	if (OAS_version >= 11)
		document.write('<SC'+'RIPT LANGUAGE=JavaScript1.1 SRC="' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + OAS_query + '"><\/SCRIPT>');
} // function OAS_Version()

function OAS_AD(pos) 
{
	if (OAS_version >= 11 && typeof(OAS_RICH!='undefined'))
		OAS_RICH(pos);
	else
		OAS_NORMAL(pos);
} // function OAS_AD(pos)

function OAS_NORMAL(pos) 
{ 
	document.write('<A HREF="' + OAS_url + 'click_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + OAS_query + '" TARGET=_top>');
	document.write('<IMG SRC="' + OAS_url + 'adstream_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + OAS_query + '" BORDER=0 ALT="Click!"></A>');
} // function OAS_NORMAL(pos)

function changeTopFive()
{
	// Produkte
	document.getElementById(ActiveTopFiveCategory).style.display = "none";
	NewTopFiveCategory = document.getElementById("Top5SelectBox").value;
	document.getElementById(NewTopFiveCategory).style.display = "";
	
	// Button
	document.getElementById(ActiveTopFiveCategory + "_Button").style.display = "none";
	NewTopFiveCategory = document.getElementById("Top5SelectBox").value;
	document.getElementById(NewTopFiveCategory  + "_Button").style.display = "";
	
	ActiveTopFiveCategory = NewTopFiveCategory;
}

function initMultiteaser(initElements, sortNosHauptbild, secondsToLife, fadeable, sortNosKleinesBild, bild_On, bild_Off, sortNoByPositionsSmallPictures) {

	if (MultiteaserInit == false)
	{
		// Für Main Teaser
		sortNosHauptbildSplitted = sortNosHauptbild.split("_");
		secondsToLifeSplitted = secondsToLife.split("_");
		fadeableSplitted = fadeable.split("_");
		
		// Für kleineBilder
		sortNosKleinesBildSplitted = sortNosKleinesBild.split(",");
		bild_OnSplitted = bild_On.split(",");
		bild_OffSplitted = bild_Off.split(",");
		sortNoByPositionsSmallPicturesSplitted = sortNoByPositionsSmallPictures.split(",");
		elements = initElements;
		aktStep = 0;
		SortNoBefore = 0;
		firstDisplayed = 0;
		lastDisplayed = 3;
		// Für den Scroller
		limitRight=0;
		limitLeft=(-164*elements)+648;
		a=0;
	   while(a < elements){
	   
		    hauptbildArray.push(sortNosHauptbildSplitted[a]);
	       secondsToLifeArray.push(secondsToLifeSplitted[a]);
	       fadeableArray.push(fadeableSplitted[a]);
	       
	       sortNosKleinesBildArray.push(sortNosKleinesBildSplitted[a]);
	       bild_OnArray.push(bild_OnSplitted[a]);
	       bild_OffArray.push(bild_OffSplitted[a]);
	       sortNoByPositionsSmallPicturesArray.push(sortNoByPositionsSmallPicturesSplitted[a]);
	       a++;
	   }
		MultiteaserInit = true;
	} // if (MultiteaserInit == false)

 	if (siteLoaded == false)
 	{
 		window.clearTimeout(timeout);
		timeout = window.setTimeout('initMultiteaser("'+initElements+'","'+sortNosHauptbild+'","'+secondsToLife+'","' +fadeable+'","'+sortNosKleinesBild+'","'+bild_On+'","'+bild_Off+'","'+sortNoByPositionsSmallPictures+'")', 100);
 	} // if (siteLoaded == false)
 	else
 	{
		var elem=document.getElementById("preview_scroller");
	 	var posLeft=parseInt(elem.style.left);
	 	elem.style.left=posLeft+limitLeft+'px';
	
		if(document.getElementById('SortNoHauptbild'+sortNosHauptbildSplitted[0]))
		{
			moveRight = true;
			
			difference = limitLeft / numberOfSteps;
			
			fastLimit = Math.round(difference * fastSteps);
			mediumLimit = Math.round(difference * mediumSteps);
			slowLimit = Math.round(difference * slowSteps);
	
		   divMoveRightWithLimit("preview_scroller", -4, fastLimit, mediumLimit, slowLimit);
		   window.setTimeout("startMultiteaser()" , 1000); 
		    
		} else {
			window.clearTimeout(timeout);
			timeout = window.setTimeout('initMultiteaser("'+initElements+'","'+sortNosHauptbild+'","'+secondsToLife+'","' +fadeable+'","'+sortNosKleinesBild+'","'+bild_On+'","'+bild_Off+'","'+sortNoByPositionsSmallPictures+'")', 100);
		}
 	} // else [ if (siteLoaded == false) ]
}
function startMultiteaser(){
	time = secondsToLifeSplitted[0] * 1000;
	
	if (time < 1500) { time = 1500; }
	
	window.clearTimeout(timeout);
	timeout = window.setTimeout('nextMultiteaserElement()', time);
}
function restartMultiteaser(){
	next=true;
	
	window.clearTimeout(timeout);
	timeout = window.setTimeout('nextMultiteaserElement()', 20000);
}
function stopMultiteaser(){
   next=false;
   timeout = window.clearTimeout(timeout);
}

function setSiteIsLoaded()
{
	siteLoaded = true;
} // function SetSiteIsLoaded()

function editMultiteaserStep(sortNo)
{
	if (MultiteaserInit == false || siteLoaded == false)
		return;

	stepBefore = i;

	sortNo = sortNo;

	for(var j=0; j < sortNosKleinesBildArray.length; j++)
		if (sortNosKleinesBildArray[j] == sortNo)
			i = j;

	if (i == -1) {i = elements;}
	if(i>=elements){ i=0;}

	if (stepBefore == i)
		return;
	
	if (fadeableArray[stepBefore] == 0 || fadeableArray[i] == 0 )
		document.getElementById("SortNoHauptbild"+hauptbildArray[stepBefore]).style.display = "none";
	else
		Effect.Fade('SortNoHauptbild'+hauptbildArray[stepBefore], {duration:0.5,from:1.0,to:0.0});
	
	if (document.getElementById("VisibilitySortNoHauptbild"+hauptbildArray[stepBefore]) != null)
		document.getElementById("VisibilitySortNoHauptbild"+hauptbildArray[stepBefore]).style.display = "none";
	
	if (fadeableArray[stepBefore] == 0 || fadeableArray[i] == 0 )
		document.getElementById("SortNoHauptbild"+hauptbildArray[i]).style.display = "";
	else
		Effect.Appear('SortNoHauptbild'+hauptbildArray[i], {duration:0.5,from:0.0,to:1.0});	

	if (document.getElementById("VisibilitySortNoHauptbild"+hauptbildArray[i]) != null)
		document.getElementById("VisibilitySortNoHauptbild"+hauptbildArray[i]).style.display = "";	
	
	if (activeSmallTeaser == i)
		return;

//	if(multiteaserWorking == false)
//		hightlightSmallTeaser(sortNosKleinesBildArray[activeSmallTeaser]);

	activeSmallTeaser = i;
	
	time = secondsToLifeSplitted[i] * 1000;
	window.clearTimeout(timeout);
	timeout = window.setTimeout('nextMultiteaserElement()', time);
	next=false;
}

function nextMultiteaserElement() {

	if(multiteaserWorking == false)
	{
		if (next == true)
	  	{
			stepBefore = i;
			i++;
			
			if(i==elements){ i=0;}
			if(i>elements){ i=0;}

			if (parseFloat(hauptbildArray[i]) >= 1000)
			{
				while(parseFloat(hauptbildArray[i]) >= 1000){
					i++;

					if(i==elements){ i=0;}
				}
			}
	
			SortNoBefore = sortNosKleinesBildArray[i];
	
			if (fadeableArray[stepBefore] == 0 || fadeableArray[i] == 0 )
				document.getElementById("SortNoHauptbild"+hauptbildArray[stepBefore]).style.display = "none";
			else
				Effect.Fade('SortNoHauptbild'+hauptbildArray[stepBefore], {duration:0.5,from:1.0,to:0.0});
	
			if (document.getElementById("VisibilitySortNoHauptbild"+hauptbildArray[stepBefore]) != null)
				document.getElementById("VisibilitySortNoHauptbild"+hauptbildArray[stepBefore]).style.display = "none";

			if (fadeableArray[stepBefore] == 0 || fadeableArray[i] == 0)
				document.getElementById("SortNoHauptbild"+hauptbildArray[i]).style.display = "";
			else
				Effect.Appear('SortNoHauptbild'+hauptbildArray[i], {duration:0.5,from:0.0,to:1.0});	
	
			if (document.getElementById("VisibilitySortNoHauptbild"+hauptbildArray[i]) != null)
				document.getElementById("VisibilitySortNoHauptbild"+hauptbildArray[i]).style.display = "";	
				
			// Kleine Bilder 
			sortNoKleinesBild = sortNosKleinesBildArray[activeSmallTeaser];
			sortNoKleinesBildNext = sortNosKleinesBildArray[i];

			if (sortNoKleinesBild != sortNoKleinesBildNext)
			{
				Effect.Fade('SortNoKleinesBildOn'+sortNoKleinesBild, {duration:0.3,from:1.0,to:0.0,
						beforeStart:
	               function()
	               {
		               multiteaserWorking = true;
	               }
					});
				Effect.Fade('SortNoKleinesBildOff'+sortNoKleinesBildNext, {duration:0.3,from:1.0,to:0.0});
				
				Effect.Appear("SortNoKleinesBildOff"+sortNoKleinesBild, {duration:0.3,from:0.0,to:1.0});
				Effect.Appear("SortNoKleinesBildOn"+sortNoKleinesBildNext, {duration:0.4,from:0.0,to:1.0,
					afterFinish:
	               function()
	               {
	                   multiteaserWorking = false;
	               }
				});
			} // if (sortNoKleinesBild != sortNoKleinesBildNext)
			activeSmallTeaser = i;
			
			time = secondsToLifeSplitted[i] * 1000;
			
			if (time < 1500) { time = 1500; }
	
			moveToSortNo(sortNosKleinesBildArray[i]);
	
			window.clearTimeout(timeout);
			timeout = window.setTimeout('nextMultiteaserElement()', time);
			stepBefore = "";
		} // if (next == true)
	} // if(multiteaserWorking == false)
}

function hightlightSmallTeaser(sortNo)
{
	if (MultiteaserInit == false || siteLoaded == false)
		return;

	if(multiteaserWorking == false)
	{
		stopMultiteaser();

		if (SortNoHightlightSmallTeaser == false)
			sortNoKleinesBild = sortNosKleinesBildArray[activeSmallTeaser];
		else
			sortNoKleinesBild = SortNoHightlightSmallTeaser;
		
		if (
			//	document.getElementById("SortNoKleinesBildOn"+sortNo).style.display == "none"
			//	&&
				sortNoKleinesBild != sortNo
			)
		{
			Effect.Fade('SortNoKleinesBildOn'+sortNoKleinesBild, {duration:0.3,from:1.0,to:0.0,
					beforeStart:
               function()
               {
	               multiteaserWorking = true;
               }
				});
			
			Effect.Fade('SortNoKleinesBildOff'+sortNo, {duration:0.3,from:1.0,to:0.0});
			
			Effect.Appear("SortNoKleinesBildOff"+sortNoKleinesBild, {duration:0.3,from:0.0,to:1.0});
			Effect.Appear("SortNoKleinesBildOn"+sortNo, {duration:0.3,from:0.0,to:1.0,
				afterFinish:
               function()
               {
                   multiteaserWorking = false;
               }
			});

			SortNoHightlightSmallTeaser = sortNo;
		} // if (document.getElementById("SortNoKleinesBildOn"+sortNo).style.display == "none")
	} // if(multiteaserWorking == false)
} // function hightlightSmallTeaser()

function reverseHightlightSmallTeaser()
{
	hightlightSmallTeaser(sortNosKleinesBildArray[activeSmallTeaser]);
} // function reverseHightlightSmallTeaser()

function setHighlightTimeOut(sortNo)
{
	if (MultiteaserInit == false || siteLoaded == false)
		return;
	
	window.clearTimeout(hightlightTimeOut);
	hightlightTimeOut = window.setTimeout("hightlightSmallTeaser('"+sortNo+"');", 150);
	
} // function setHighlightTimeOut()

function stopHighlightTimeOut()
{
	if (MultiteaserInit == false || siteLoaded == false)
		return;

	window.clearTimeout(hightlightTimeOut);
	
	hightlightTimeOut = window.setTimeout("reverseHightlightSmallTeaser();", 150);
} // function stopHighlightTimeOut()


function startDivMove(direction){
	if(direction=='left'){
		divMoveLeft();
	} else if(direction=='right'){
		divMoveRight();
	}
}

function stopDivMove(){
	moveRight=false;
	moveLeft=false;
}

function divMoveLeft() 
{
	if ((sortNoByPositionsSmallPicturesArray.length - 1) >= (lastDisplayed + 1))
	{
		position = lastDisplayed + 1;
	}
	else
	{
		position = sortNoByPositionsSmallPicturesArray.length - 1;
	}
	stopMultiteaser();
	moveToSortNo(sortNoByPositionsSmallPicturesArray[position]); 
}

function divMoveRight() 
{
	if ((firstDisplayed - 1) > 0)
	{
		position = firstDisplayed - 1;
	}
	else
	{
		position = 0;
	}
	stopMultiteaser();

	moveToSortNo(sortNoByPositionsSmallPicturesArray[position]); 
}

function moveToSortNo(SortNo)
{
	sortNoFirstDisplayed = parseFloat(sortNoByPositionsSmallPicturesArray[firstDisplayed]);
	sortNoLastDisplayed = parseFloat(sortNoByPositionsSmallPicturesArray[lastDisplayed]);
	var positionSortNo;
	SortNo = parseFloat(SortNo);

	if (SortNo < sortNoFirstDisplayed || SortNo > sortNoLastDisplayed)
	{
		for (var b = 0; b < sortNoByPositionsSmallPicturesArray.length; b++)
			if (sortNoByPositionsSmallPicturesArray[b] == SortNo)
				positionSortNo = parseInt(b);

		if (SortNo < sortNoFirstDisplayed)
		{
			difference = positionSortNo * -1;

			firstDisplayed = positionSortNo;
			lastDisplayed = firstDisplayed + 3;
			scrollLimit = 156 * difference + ((difference  - 1) * 8);
		
			differenceSteps = (156 * ((difference * -1) + 1) + ((difference) * 8)) / numberOfSteps;
		}
		else if (SortNo > sortNoLastDisplayed)
		{
			difference = positionSortNo - 3;

			lastDisplayed = positionSortNo;
			firstDisplayed = lastDisplayed - 3;
			scrollLimit = ((156 * difference) + ((difference) * 8)) * -1;

			differenceSteps = scrollLimit / numberOfSteps;
		}

		SortNoBefore = SortNo;

		fastLimit = scrollLimit - Math.round(differenceSteps * fastSteps);
		mediumLimit = scrollLimit - Math.round(differenceSteps * mediumSteps);
		slowLimit = scrollLimit - Math.round(differenceSteps * slowSteps);

		if (difference > 0)
		{
			moveRight=false;
			moveLeft=true;
			divMoveLeftWithLimit("preview_scroller", scrollLimit, fastLimit, mediumLimit, slowLimit);
		}
		else
		{
			moveRight=true;
			moveLeft=false;
			divMoveRightWithLimit("preview_scroller", scrollLimit, fastLimit, mediumLimit, slowLimit);
		}
	}
} // function moveToSortNo(SortNo)

function divMoveLeftWithLimit(divID, limit, fastLimit, mediumLimit, slowLimit) {
 	var elem=document.getElementById(divID);
 	var posLeft=parseInt(elem.style.left);

 	if (posLeft > fastLimit)
 		seconds = 20;
 	else if (posLeft > mediumLimit)
 		seconds = 25;
 	else
 		seconds = 30;

 	if(moveLeft && posLeft>limitLeft && limit <= posLeft){
	 	elem.style.left=posLeft-4+'px';
 		setTimeout("divMoveLeftWithLimit('"+divID+"', '"+limit+"', '"+fastLimit+"', '"+mediumLimit+"','"+slowLimit+"')", seconds);
 	}
 	
 	if (elements > 4)
 	{
		if (posLeft < limitLeft + 10)
			document.getElementById("arrow_forward").src = "binaries/icons/arrow_grey_forward.gif";
		else
			document.getElementById("arrow_forward").src = "binaries/icons/arrow_forward.gif";
		
		if (posLeft < -10)
			document.getElementById("arrow_back").src = "binaries/icons/arrow_back.gif";	
	} // if (document.getElementById("arrow_back") != "")	
}

function divMoveRightWithLimit(divID, limit, fastLimit, mediumLimit, slowLimit) {
 	var elem=document.getElementById(divID);
 	var posLeft=parseInt(elem.style.left);

	if (posLeft < fastLimit)
 		seconds = 20;
 	else if (posLeft < mediumLimit)
 		seconds = 25;
 	else
 		seconds = 30;

 	if(moveRight && posLeft<limitRight && limit >= posLeft){
	 	elem.style.left=posLeft+4+'px';
 		setTimeout("divMoveRightWithLimit('"+divID+"', '"+limit+"', '"+fastLimit+"', '"+mediumLimit+"','"+slowLimit+"')", seconds);
 	}
 	
 	if (elements > 4)
 	{
	 	 if (posLeft > -10)
	 	 	document.getElementById("arrow_back").src = "binaries/icons/arrow_grey_back.gif";
	 	 else
	 	 	document.getElementById("arrow_back").src = "binaries/icons/arrow_back.gif";
	 	 	
	 	 if (posLeft > limitLeft + 10)
	 	 	document.getElementById("arrow_forward").src = "binaries/icons/arrow_forward.gif";	
 	} // if (document.getElementById("arrow_back") != "")
}

function setHighlightMarkenshopMenu(ID, Description)
{
	if (activeMarkenshopMenuPoint != ID)
	{
		document.getElementById("MarkenshopBackground"+ID).style.backgroundColor = "#e2001a";
		document.getElementById("MarkenshopMenuPoint"+ID).src = "scripts/ttf.phtml?text="+Description+"&color=FFFFFF&bgcolor=e2001a&size=12&entireLineHeight";
	} // if (activeMarkenshopMenuPoint != ID)
} // function chighlightMarkenshopMenu()

function reverseHighlightMarkenshopMenu(ID, Description)
{
	if (activeMarkenshopMenuPoint != ID)
	{
		document.getElementById("MarkenshopBackground"+ID).style.backgroundColor = "#999999";
		document.getElementById("MarkenshopMenuPoint"+ID).src = "scripts/ttf.phtml?text="+Description+"&color=FFFFFF&bgcolor=999999&size=12&entireLineHeight";
	} // if (activeMarkenshopMenuPoint != ID)
} // function chighlightMarkenshopMenu()