
/* load begin */

var checkedWord = '';

$(document).ready(function() { 
		if($('ul.sf-menu')){
	        $('ul.sf-menu').superfish({ 
	            delay:       1000,
	            animation:   {opacity:'show'}, 
	            speed:       'fast',
	            autoArrows:  false, 
	            dropShadows: false
	        }); 
		}
	        
	       // $(document).pngFix();
	       
		if($('input[name|=formtype_mail]')){
			$('input[name|=formtype_mail]').css("width", "auto");
		}
		if($("a[rel=images_group]")){
	        $("a[rel=images_group]").fancybox({
						'transitionIn'		: 'none',
						'transitionOut'		: 'none',
						'titlePosition' 	: 'over'
						
					});
		}
			if($('#ContactPersonInfo')){	
				$('#ContactPersonInfo').click(function() {
					if($('#ContactInfo').css("display")!='none'){
						$('#ContactInfo').slideUp('slow', function() {
							$('#ContactPersonInfoCC').html = '+';
						});
					}else{
						$('#ContactInfo').slideDown('slow', function() {
							$('#ContactPersonInfoCC').html = '-';
						});
					}
				}); 
			}
				
				
				
				
			if($('#MoreInfo')){	
				$('#MoreInfo').click(function() {
					if($('#MoreInfoLay').css("display")!='none'){
						$('#MoreInfoLay').slideUp('slow', function() {
							$('#MoreInfoCC').html = '+';
						});
					}else{
						$('#MoreInfoLay').slideDown('slow', function() {
							$('#MoreInfoCC').html = '-';
						});
					}
				});
			}
			if($('#CompanyFormTitle')){	
				$('#CompanyFormTitle').click(function() {
					if($('#CompanyForm').css("display")!='none'){
						$('#CompanyForm').slideUp('slow', function() {
							$('#CompanyFormTitleCC').html = '+';
						});
					}else{
						$('#CompanyForm').slideDown('slow', function() {
							$('#CompanyFormTitleCC').html = '-';
						});
					}
				});
			}
			if($('a.detail_product')){
				$('a.detail_product').click(function(){
					$('#detail_product').show();
					$('#detail_profil').hide();
					$('#detail_contact').hide();
					$('#detail_other_products').hide();
				});
			}

			if($('a.detail_profil')){	
				$('a.detail_profil').click(function(){
					$('#detail_profil').show();
					$('#detail_product').hide();
					$('#detail_contact').hide();
					$('#detail_other_products').hide();
				});
			}
			if($('a.detail_contact')){
				$('a.detail_contact').click(function(){
					$('#detail_contact').show();
					$('#detail_product').hide();
					$('#detail_profil').hide();
					$('#detail_other_products').hide();
				});
			}
			if($('a.detail_other_products')){	
				$('a.detail_other_products').click(function(){
					$('#detail_other_products').show();
					$('#detail_product').hide();
					$('#detail_profil').hide();
					$('#detail_contact').hide();
				});
			}
			if($('.box1 h3')){
				$('.box1 h3').click(function(){
					if($(this).parents('.box1').find('.content').css("display")!='none'){
						$(this).parents('.box1').find('.content').slideUp('slow');
					}else{
						$(this).parents('.box1').find('.content').slideDown('slow');
					}
				});
			}
			if($('.box2 .titel')){
				$('.box2 .titel').click(function(){
					if($(this).parents('.box2').find('.content').css("display")!='none'){
						$(this).parents('.box2').find('.content').slideUp('slow');
					}else{
						$(this).parents('.box2').find('.content').slideDown('slow');
					}
				});
			}
			if($('.box3 > legend')){
				$('.box3 > legend').click(function(){
					if($(this).parents('.box3').find('.content').css("display")!='none'){
						$(this).parents('.box3').find('.content').slideUp('slow');
					}else{
						$(this).parents('.box3').find('.content').slideDown('slow');
					}
				});
			}
			if($('.box4 h3')){
				$('.box4 h3').click(function(){
					if($(this).parents('.box4').find('.content').css("display")!='none'){
						$(this).parents('.box4').find('.content').slideUp('slow');
						$(this).parents('.box4').removeClass('open');
						$(this).parents('.box4').addClass('close');
					}else{
						$(this).parents('.box4').find('.content').slideDown('slow');
						$(this).parents('.box4').removeClass('close');
						$(this).parents('.box4').addClass('open');
					}
				});
			}
			if($('.box1thin h3')){
				$('.box1thin h3').click(function(){
					if($(this).parents('.box1thin').find('.content').css("display")!='none'){
						$(this).parents('.box1thin').find('.content').slideUp('slow');
					}else{
						$(this).parents('.box1thin').find('.content').slideDown('slow');
					}
				});
			}
			if($("#search")){
				$("#search").autocomplete("/index.php?eID=tx_whiteboard_pi1", {
					width: 350,
					matchContains: true,
					mustMatch: false,
					minChars: 2,
					extraParams: {
						key: function() { return $("#search").val(); }
					},
					selectFirst: false
				});
			}
			if($('div.box4')){
				$('div.box4').each(function(i) {
					if($(this).children(".content").css("display")=='block'){
						$(this).removeClass('close');
						$(this).addClass('open');
					}else{
						$(this).removeClass('open');
						$(this).addClass('close');
					}
				});
			}
			if($('.glossarEnties div.list div')){
				$('.glossarEnties div.list div').click(function(){
					tmpListId 	= $(this).attr('id');
					tmpListArr 	= tmpListId.split('_');
					
					$('.glossarEnties div.list div').removeClass('activeGlossaryWord');
					$('.glossarEnties div.list div#'+tmpListId).addClass('activeGlossaryWord');
					
					$('.glossarEnties div.detail div').css('display', 'none');
					$('.glossarEnties div.detail div#d_'+tmpListArr[1]).css('display', 'block');
					
				});
			}
			if($("div.glossarEnties div.list div")){
				$("div.glossarEnties div.list div").mouseover(function() {
					$(this).addClass('GlossaryWordOver');
				}).mouseout(function(){
					$(this).removeClass('GlossaryWordOver');
				});
					
			}
				// search
				//$("#search").focus();
			if($(".tab_content")){
				$(".tab_content").hide(); //Hide all content
			}
			if($("ul.tabs li:first")){
				$("ul.tabs li:first").addClass("active").show(); //Activate first tab
			}
			if($(".tab_content:first")){
				$(".tab_content:first").show(); //Show first tab content
			}
			if($("ul.tabs li")){
				$("ul.tabs li").click(function() {
				
					$("ul.tabs li").removeClass("active"); //Remove any "active" class
					$(this).addClass("active"); //Add "active" class to selected tab
					$(".tab_content").hide(); //Hide all tab content
			
					var activeTab = $(this).find("a").attr("switchto"); //Find the href attribute value to identify the active tab + content
					$(activeTab).fadeIn(); //Fade in the active ID content
					return false;
				});
			}

				
	    });

/* load end */

function showListPic(pictrueSource){
	$.fancybox({
        'width': '40%',
        'height': '40%',
        'autoScale': true,
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'type': 'image',
        'overlayShow': false,
        'href': pictrueSource
    });

}

function searchFocus(Obj){

	checkedWord = Obj.value;
	if(Obj.value=="Suche" || Obj.value=="Search"){
		Obj.value = '';
		Obj.style.color = '#2e2382';
	}
}

function searchBlur(Obj){
	if(Obj.value==""){
		Obj.value = checkedWord;
		Obj.style.color = '#d6d7d9';
	}
}

function FormatRegistrationFields(Obj){
  Obj.styles.background = '#ffffff';    
} 

function SubmitIPP(){
	document.forms['frmIPP'].submit();
}

function checkBildBox(objInput, objStr){
	frmObj 		= document.forms["frmProduct"];
	objHtml 	= document.getElementById(objStr+"html");
	if(objInput.value!='' && objHtml.innerHTML!='()'){
		frmObj[objStr].checked = "checked";
	}else{
		frmObj[objStr].checked = false;
	}
}

function deleteProduct(uid, confirmmessage, l){
	if(confirm(confirmmessage)){
		document.location.href = '/index.php?id=45&no_cache=1&L='+l+'&view=products&exe=product&mode=delete&uid='+uid;
	}
}

function showDetail(uid,l,producttitle,urlprefix){
//	document.location.href = '/index.php?id=giveaways&no_cache=1&pro='+uid+'&L='+l;
	document.location.href = urlprefix+'/'+uid+'/'+producttitle+'.html';
}

function CancelProduct(LangID){
	document.location.href = '/index.php?id=45&no_cache=1&view=products&L='+LangID;
} 

function ChangeImgPD(ImageToChange, BigImage){
	document.getElementById("previewImage").src = ImageToChange;
	$("#LinkHref").attr('href', BigImage);

}

function ChangeImgP(ImageToChange, BigImage){
	document.getElementById("previewImageP").src = ImageToChange;
	$("#LinkHrefP").attr('href', BigImage);

}

function ChangeImgQ(ImageToChange, BigImage){
	document.getElementById("previewImageQ").src = ImageToChange;
	$("#LinkHrefQ").attr('href', BigImage);

}

function CheckMailChange(Text1, Text2){
		frmObj 		= document.forms["frmChangeEmail"];
		if(confirm(Text1)){
			if(frmObj['email'].value!=frmObj['email2'].value || frmObj['email'].value==''){
				alert(Text2);
				return false;
			}else{
				return true;
			}
		}
}

function CheckPassChange(Text1, Text2){
	frmObj 		= document.forms["frmChangePass"];
		if(confirm(Text1)){
			if(frmObj['pass'].value!=frmObj['pass2'].value || frmObj['pass'].value==''){
				alert(Text2);
				return false;
			}else{
				return true;
			}
		}
}

function MessageInfo(divId){
	if($('#messageInfo_'+divId).css("display")!='none'){
		$('#messageInfo_'+divId).slideUp('slow', function() {});
	}else{
		$('#messageInfo_'+divId).slideDown('slow', function() {});
	}
}

function SendMessage(firmaName, CompanyMessageText1, CompanyMessageText2){
	frmObj 		= document.forms["frmMessage"];
	if(frmObj['name'].value=='' || frmObj['message'].value=='' || frmObj['email'].value==''){
		alert(CompanyMessageText1);
		return false;
	}else{
		alert(CompanyMessageText2);
		return true;
	}
}

function deleteMessage(mId, Mconf){
	if(confirm(Mconf)){
		document.location.href = '/index.php?id=45&no_cache=1&view=messages&mid='+mId+'&deleteM=1';
	}
}

function ShowPackageInfo(Obj){
	for(x=1;x<20;x++){
		if($('#detail_package_'+x)){
			$('#detail_package_'+x).hide();
		}
	}
	
	$('#detail_package_'+Obj.value).show();
	
	if($("#packSelect option:selected").attr("pkgPrice")=='0.00'){
		$(".paymentDropdown").css("display", 'none');
	}else{
		$(".paymentDropdown").css("display", 'block');
	}
	
	document.forms["frmRegistration"]["package"].value=Obj.value;
	
}

function checkCoupon(Obj){
	if(Obj.value!=''){
		document.forms["frmCoupon"].submit();
	}
}

function NoMore(Msg){
	alert(Msg);
}

function ProfileErr11(TxT, Lang){
	alert(TxT);
	document.location.href = '/index.php?id=45&no_cache=1&L='+Lang+'&view=profile';
}

function getMoreProducts(var1,var2,linkStr1,linkStr2){

	if($('.moreProd_'+var2).css('display')=='none'){
		$('.moreLink_'+var2).html(linkStr2);
		$('.moreProd_'+var2).css('display', 'block');
		$.ajax({
			url: '/index.php?id=werbeartikel&company='+var1+'&more=true&selProd='+var2,
			success: function(data) {
				$('.moreProd_'+var2).html(data);
			}
		});
	}else{
		$('.moreLink_'+var2).html(linkStr1);
		$('.moreProd_'+var2).css('display', 'none');
	}
}

function openSiteMapInfoLayer(obj){
	var actHeight = $(obj).height();
	var layHeight = $(obj+" div.infoDiv").innerHeight();
	if(actHeight==16){
		var NewHeight = 100;
		$(obj).css("height", NewHeight+"px");
		$(obj).css("overflow-y", "scroll");
	}else{
		$(obj).scrollTop(0);
		$(obj).css("height", "16px");
		$(obj).css("overflow-y", "hidden");
	}
}

function sitemapOpenAll(){
	$("#WerbeartikelSitemap .box4").removeClass("close");
	$("#WerbeartikelSitemap .box4 .content").slideDown('slow');
	$("#WerbeartikelSitemap .box4").addClass("open");
}

function sitemapCloseAll(){
	$("#WerbeartikelSitemap .box4").removeClass("open");
	$("#WerbeartikelSitemap .box4 .content").slideUp('slow');
	$("#WerbeartikelSitemap .box4").addClass("close");
}

function sitemapShowProducts(id){
	$(".prodCont").css("display", "none");
	$("#products_"+id).css("display", "block");
	$("#products_"+id).scrollTop(0);
}

