var popUpWin=0;


function sh_popup(URLStr,widthw,heightw)
{
  var width=(widthw>0) ? widthw:380;
  var height=(heightw>0) ? heightw:470;
  var left = parseInt((screen.availWidth/2) - (width/2));
  var top = parseInt((screen.availHeight/2) - (height/2));

  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr+'?popup', 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function setHeight(){
var a1 = document.getElementById('textureFixBody').clientHeight;
var b1 = a1 % 16;
	if (b1!=0) a1=a1-b1+16;
	document.getElementById('textureFixBody').height=a1;


document.getElementById('textureFixContent').style.height=document.getElementById('2xInfoboxFix').clientHeight+'px';
var a2 = document.getElementById('textureFixContent').clientHeight;
var b2 = a2 % 96;
	if (b2!=0) a2=a2-b2+96;
	document.getElementById('textureFixContent').style.height=a2+'px';
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var timer;


function popImage(imageURL,imgTitle) {
	imageURL=location.protocol+'//'+location.host+imageURL;
	var defWidth=0.75*screen.availWidth;
	var defHeight=0.75*screen.availHeight;
	var defWidth1=10;
	var defHeight1=10;
	var f="width="+defWidth1+",height="+defHeight1;
	f+=",left="+((screen.availWidth-defWidth)/2)+",scrollbars=yes,resizable=yes,top="+((screen.availHeight-defHeight)/2);
	imgWin=window.open('about:blank','',f);
	imDoc=imgWin.document;
	with (imDoc) {
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
		writeln('width=100-(document.body.clientWidth-document.images[0].width);if (width>0.75*screen.availWidth) width=0.75*screen.availWidth;');
		writeln('height=100-(document.body.clientHeight-document.images[0].height);if (height>0.75*screen.availHeight) height=0.75*screen.availHeight;');
		writeln('window.resizeTo(width,height);}');writeln('else {');
		writeln('window.innerWidth=document.images["George"].width<0.75*screen.availWidth ? document.images["George"].width:0.75*screen.availWidth;');
		writeln('window.innerHeight=document.images["George"].height<0.75*screen.availHeight ? document.images["George"].height:0.75*screen.availHeight;}}');
		writeln('function doTitle(){document.title="'+imgTitle+'";}');writeln('</sc'+'ript>');
		writeln('</head><body bgcolor="#FFFFFF" onload="reSizeToImage();doTitle();self.focus()">')
		writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');

		close();
	}
}


function sitemap_open(img, id){
	if (document.getElementById(id).style['display']=='block'){
		document.getElementById(id).style['display']='none';
		img.src='/images/plus.gif';
	}
	else{
		document.getElementById(id).style['display']='block';
		img.src='/images/minus.gif';
	}
}

var quick_image_01 = new Image(1000, 394);
var quick_image_02 = new Image(1000, 394);
var quick_image_03 = new Image(1000, 394);
var quick_image_04 = new Image(1000, 394);
quick_image_01.src = "/images/quick_01.jpg";
quick_image_02.src = "/images/quick_02.jpg";
quick_image_03.src = "/images/quick_03.jpg";
quick_image_04.src = "/images/quick_def.jpg";

/* jQuery menu */
jQuery(document).ready(function($){
  $("div[id*=top_menu_0]").hover(show_top_menu, hidden_top_menu);
  $("div[id*=bottom_menu_0]").hover(show_bottom_menu, hidden_bottom_menu);
  $("div[id*=quick_box_0]").hover(show_quick_menu, hidden_quick_menu);
  $("div[id*=lnk_niz_]").hover(show_lnk_menu, hidden_lnk_menu);

  $('ul.vip_top_menu li:first-child a:last-child').addClass('vip_top_menu_link_top');
  $('ul.vip_top_menu li ul li a').removeClass('vip_top_menu_link_top');
  $('ul.vip_top_menu li:last-child a:last-child').addClass('vip_top_menu_link_bottom');
  $('ul.vip_top_menu li ul li a').removeClass('vip_top_menu_link_bottom');
  $('ul.vip_top_menu li ul li:first-child a:last-child').addClass('vip_top_menu_link_top_in');
  $('ul.vip_top_menu li ul li:last-child a:last-child').addClass('vip_top_menu_link_bottom_in');

  $('ul.left_menu li:first').css('background', '#e3ebee url(/images/left_menu_fon_top.png) no-repeat top left');
  $('ul.left_menu li:last').css('background', '#e3ebee url(/images/left_menu_fon_bottom.png) no-repeat bottom left');
  $('marquee').marquee('pointer');
  
  if(isIE){
	 $('div.list_art_karkas_04').css('height',  $('div.list_art_karkas_05').height()+11+'px' );
 }
 
 
  $('#inside_menu').find('div.m2f:first')
  		.css('position', 'relative')
		.prepend('<div class= "fft" style="height:5px; width:201px; background:url(/images/left_menu_fon_top.png) no-repeat top left; position:absolute;"></div>');
						

  $('#inside_menu').find('div.m2f:last')
  		.css('position', 'relative')
		.prepend('<div class= "ffb" style="height:5px; width:201px; background:url(/images/left_menu_fon_bottom.png) no-repeat top left; position:absolute; top:'+Number($('#inside_menu').find('div.m2f:last').height()-5)+'px "></div>'); 
 
  //$('#search_form').click(function(){document.location.href = 'mailto:kundenbetreuung@digital-print-group.de'});
 //$('div.mini_box_top').click(function(){document.location.href = 'http://www.digital-print-group.de/mcp/'});
 $('div.mini_box_top_inside_left').click(function(){document.location.href = 'http://www.digital-print-group.de/mcp/'});
 $('#mini_box_top_inside_left').click(function(){document.location.href = 'http://www.digital-print-group.de/mcp/'});
  
  
  var parentId;
  $("div[id*=m_]").hover(
    function(event)
    {
      var x = this.id.length - 4;
      var y = this.id.substring(x);
      var my_img_id = 'm_box_' + y;
	  if (parentId != my_img_id){	  	
      	$('#' + parentId).hide();
		$('#' + my_img_id).show();
		parentId = my_img_id;
	  }
	else
		$('#' + my_img_id).show();
		
      x = document.getElementById(my_img_id);
      if (x){ $('#m_' + y).find('a:first').css('background', '#b1c7d0 url(/images/minus.gif) no-repeat 10px 8px');
	  		$('#m_' + y).find('div.fft').css('background', 'url(/images/left_menu_fon_top_a.png) no-repeat top left');
			$('#m_' + y).find('div.ffb').css('background', 'url(/images/left_menu_fon_bottom_a.png) no-repeat top left');
	  }
	  else{
		  if(this.id == $('div.m2f:first').attr('id'))
		  	$('div.fft').css('background', 'url(/images/left_menu_fon_top_a.png) no-repeat top left');
		if(this.id == $('div.m2f:last').attr('id'))	
			$('div.ffb').css('background', 'url(/images/left_menu_fon_bottom_a.png) no-repeat top left');
		  
	  }
    },
    function(event)
    {
      var x = this.id.length - 4;
      var y = this.id.substring(x);
      var my_img_id = 'm_box_' + y;
      //$('#' + my_img_id).hide();
      x = document.getElementById(my_img_id);
      if (x){ $('#m_' + y).find('a:first').css('background', '#e3ebee url(/images/plus.gif) no-repeat 10px 8px');
	  		$('#m_' + y).find('div.fft').css('background', 'url(/images/left_menu_fon_top.png) no-repeat top left');
			$('#m_' + y).find('div.ffb').css('background', 'url(/images/left_menu_fon_bottom.png) no-repeat top left');
	  }
	  else{
		  if(this.id == $('div.m2f:first').attr('id'))
		  	$('div.fft').css('background', 'url(/images/left_menu_fon_top.png) no-repeat top left');
		if(this.id == $('div.m2f:last').attr('id'))	
			$('div.ffb').css('background', 'url(/images/left_menu_fon_bottom.png) no-repeat top left');
		  
	  }	  
	  
    }
  );
	$("div[id*=m_box_]").hover(
		function(event)
		{
		},
		function(event)
		{
			$(this).hide();
		}
	)						 
  
  /*$("div[id*=m_]").hover(
    function(event)
    {
      var x = this.id.length - 4;
      var y = this.id.substring(x);
      var my_img_id = 'm_box_' + y;
      $('#' + my_img_id).show();
      $('#m_' + y).find('a:first').css('background', '#b1c7d0 url(/images/minus.gif) no-repeat 14px 12px');
    },
    function(event)
    {
      var x = this.id.length - 4;
      var y = this.id.substring(x);
      var my_img_id = 'm_box_' + y;
      $('#' + my_img_id).hide();
      $('#m_' + y).find('a:first').css('background', '#e3ebee url(/images/plus.gif) no-repeat 14px 12px');
    }
  );
  $("div[id*=tm_]").hover(
    function(event)
    {
      $(this).css('background', '#b1c7d0');
    },
    function(event)
    {
      $(this).css('background', '#e3ebee');
    }
  );

  $("img[id*=but_m_]").click(function(event){
      var x = this.id.length - 4;
      var y = this.id.substring(x);
      var my_img_id = 'm_box_' + y;
      z = $('#' + my_img_id).is(':hidden');
      if (z)
      {
        this.src = '/images/minus.gif';
        $('#' + my_img_id).show();
      }
      else
      {
        this.src = '/images/plus.gif';
        $('#' + my_img_id).hide();
      }
  });*/

  $("#mini_quick_but").hover(
    function(event)
    {
      this.src = '/images/mini_quick_2.jpg';
    },
    function(event)
    {
      this.src = '/images/mini_quick_2_no.jpg';
    }
  );

  // for quickfinder
  $("a[class*=q_box_link_]").hover(
    function(event)
    {
	  var tmp = this.className.match(/q_box_link_(\d+)/);
	  if (tmp){
		var y = tmp[1];
	  }else
		return;
      $(this).css('background', 'url(/images/for_link_' + y + '_big.png) no-repeat 0px 2px');
    },
    function(event)
    {
      $(this).css('background', 'url(/images/for_link_01.png) no-repeat 0px 2px');
    }
  );
})

function show_top_menu(event)
{
	var x = this.id.length - 1;
	var y = this.id.substring(x);
	var my_img_id = 'top_menu_img_0' + y;
	document.getElementById(my_img_id).src = '/images/top_menu_0' + y + 'a.png';
	var my_div_id = '#top_menu_0' + y;
	$(function(){
      var $my_obj = $("#top_menu_0" + y + " ul:first")
      $my_obj.show();
      $my_obj.find('li').hover(
        function(e){
          $(this).find('ul').show();
        },
        function(e){
          $(this).find('ul').hide();
        }
      );
	});
	//var my_div = 'div.for_menu_0' + y;
	//$(my_div).show();
}

function hidden_top_menu(event)
{
	var x = this.id.length - 1;
	var y = this.id.substring(x);
	var my_img_id = 'top_menu_img_0' + y;
	document.getElementById(my_img_id).src = '/images/top_menu_0' + y + '.png';
	$(function(){
      $('#top_menu_0' + y + ' ul').hide();
	});
	//var my_div = 'div.for_menu_0' + y;
	//$(my_div).hide();
}

function show_bottom_menu(event)
{
	var x = this.id.length - 1;
	var y = this.id.substring(x);
	var my_img_id = 'bottom_menu_img_0' + y;
	document.getElementById(my_img_id).src = '/images/bottom_menu_0' + y + 'a.png';
}

function hidden_bottom_menu(event)
{
	var x = this.id.length - 1;
	var y = this.id.substring(x);
	var my_img_id = 'bottom_menu_img_0' + y;
	document.getElementById(my_img_id).src = '/images/bottom_menu_0' + y + '.png';
}

function show_quick_menu(event)
{
	var x = this.id.length - 1;
	var y = this.id.substring(x);
	document.getElementById('quick_pic').src = '/images/quick_0' + y + '.jpg';
	$("#q_box_0" + y).show();
}

function hidden_quick_menu(event)
{
	var x = this.id.length - 1;
	var y = this.id.substring(x);
	document.getElementById('quick_pic').src = '/images/quick_def.jpg';
	$("#q_box_0" + y).hide();
}

function show_lnk_menu(event)
{
	var x = this.id.length - 4;
	var y = this.id.substring(x);
	var z = $('#lnk_niz_box_' + y).height();
	z = z + 6;
	$('#lnk_niz_box_' + y).css('margin-top', '-' + z +'px');
	$('#lnk_niz_box_' + y).show();
}

function hidden_lnk_menu(event)
{
	var x = this.id.length - 4;
	var y = this.id.substring(x);
	$('#lnk_niz_box_' + y).hide();
}

var dop_hight_element = ''; // содержит дополнительный элемент, который нужно закрывать вместе с 'подложкой'

function show_element(per)
{
  document.getElementById(per).style.display = 'block';
}

function hide_element(per)
{
  document.getElementById(per).style.display = 'none';
}

function hide_podlojka()
{
  hide_element('podlojka');
  if (document.getElementById(dop_hight_element)) hide_element(dop_hight_element);
}

function show_quickfinder()
{
	dop_hight_element = 'dop_quickfinder';

	show_element('podlojka');
	//show_element('dop_quickfinder');
  
	/*
	var podlojka = $('#podlojka');
	podlojka.fadeIn();*/

	var dop_quickfinder = $('#dop_quickfinder');
	dop_quickfinder.find('#quick_pic').hide();
	dop_quickfinder.show('slow', function(){ $(this).find('#quick_pic').show('slow')});

}

function reset_form()
{
  document.getElementById('ruck_name').value = '';
  document.getElementById('ruck_telefon').value = '';
  document.getElementById('ruck_text').value = '';
}

function findDimensions()
{
	if(document.domain == 'dpg-site2.kreadoc' || document.domain == 'www.digital-print-group.de'){
		width = screen.width;
		document.getElementById('screen_width_box').value = width;
		x = document.getElementById('screen_width_box').value
		document.getElementById('detect_sub').click();
	}
}

function skip_intro()
{
  $('#intro_karkas_id').hide();
  $('#logo_id').show();
  $('#quick_karkas_id').show();
  $(function(){
    $.post(
      '/',
      {intro:'kos'},
      function(data){}
    );
  });
}

function no_intro()
{
  $('#intro_karkas_id').hide();
  $('#logo_id').show();
  $('#quick_karkas_id').show();
  setCookie('no_intro', 1, 365);
}

function setCookie(c_name, value, expiredays)
{
  var exdate = new Date();
  exdate.setDate(exdate.getDate() + expiredays);
  document.cookie = c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
