newHeight = "";
newWidth = "";

/********************VCAT - Browserweiche*****************************************/
function checkBrowserName(name){  
   var agent = navigator.userAgent.toLowerCase();  
   if (agent.indexOf(name.toLowerCase())>-1) {  
     return true;  
   }  
   return false;  
 } 

//vertical
function fktImageStyle() {
	var i = 0;
	$('.slider_vcat').each(function(index) {
		i +=1;
	    //alert(index + ': ' + $(this).attr('style'));
	    attrStyle = $(this).attr('style');
	    var str = attrStyle
	    posBegin = str.search(/top:/i);
	    
	    posTop = attrStyle.substring(posBegin, attrStyle.length-3);
	    topPx = posTop.split(":");
	    //alert("H:" + newHeight + "W:" +newWidth); 
	    diff =  newHeight - topPx[1];
	   
	    if (topPx[1] == 0)	{
	    	
	    }
	    else if	(topPx[1] < 0)	{
	    	newTop = topPx[1]-diff;
	    	$(this).attr('style', 'display: inline; left: -2000px; top: '+newTop+'px;');
	    }
	    else if	(topPx[1] > 0)	{
	    	newTop = topPx[1]+diff;
	    	$(this).attr('style', 'display: inline; left: 2000px; top: '+newTop+'px;');
	    }
	});
	if (i == 1){
		$('.sb-nav-prev').css('visibility', 'hidden');
		$('.sb-nav-next').css('visibility', 'hidden');
	}
}
//horizontal
/*function fktImageStyle() {
	$('.slider_vcat').each(function(index) {
	    //alert(index + ': ' + $(this).attr('style'));
	    attrStyle = $(this).attr('style');
	    var str = attrStyle
	    posBegin = str.search(/left:/i);
	    
	    if(posBegin+11>attrStyle){
	    posTop = attrStyle.substring(posBegin, attrStyle.length-3);
	    }
	    else{
	    posTop = attrStyle.substring(posBegin, posBegin+11);
	    }
	    posTop = posTop.split("p")[0];
	    topPx = posTop.split(":");
	    //alert ("left:"+topPx[1]);
	    
	    diff =  newWidth - topPx[1];
	   
	    if (topPx[1] == 0)	{
	    	//alert("0");
	    }
	    else if	(topPx[1] < 0)	{
	    	//alert("1");
	    	newTop = topPx[1]-diff;
	    	$(this).attr('style', 'display: inline; top: 0px; left: '+newTop+'px;');
	    }
	    else if	(topPx[1] > 0)	{
	    	//alert("2");
	    	
	    	newTop = topPx[1]+diff;
	    	$(this).attr('style', 'display: inline; top: 0px; left: '+newTop+'px;');
	    }
	    alert(newTop);
	    
	});
}*/

/*function fktBackgroundStyle(newWidth,newHeight)	{
	$('.sb-side').each(function(index) {
		//alert( $(this).attr('style')	);
		alert(newHeight);
		if 	($(this).css('background-image'))	{
			$(this).css('width',newWidth+'px');
			$(this).css('height',newHeight+'px');
			alert( $(this).attr('style')	);
		}
	});	
}*/
/********************VCAT - resizing of headerimage*****************************************/
function picSize(){	
	
	var browserWidth = $(window).width();
	var browserHeight = $(window).height();
	
	//alert("brW: " + browserWidth);
	//alert("brH: " + browserHeight);
	
	imageWidth = $('.slider_vcat').width();
	imageHeight = $('.slider_vcat').height();
	
	$('.slider_vcat').each(function(index) {
			imageWidth =  $(this).width() ;	
			//alert(imageWidth);
			imageHeight = $(this).height();
	});
	if ($('.sb-slider'))	{
		imageWidth = $('.sb-slider').width();
		imageHeight = $('.sb-slider').height();
		//alert(imageWidth);
	}

	//alert("iW: " + imageWidth);
	//alert("iH: " + imageHeight);
	
	var zoom1 = (imageWidth / (browserWidth-340));
	var zoom2 = (imageHeight / (browserHeight-250));
	
	//alert("z1: " + zoom1);
	//alert("z2: " + zoom2);
	
	if (zoom1 > zoom2){
		var newWidth = imageWidth / zoom1;
		var newHeight = imageHeight / zoom1;
	}
	else{
		var newWidth = imageWidth / zoom2;
		var newHeight = imageHeight / zoom2;
	}
	
	if(newWidth<960){
		zoom3 = imageWidth / 780;
		newWidth = 780;
		newHeight = imageHeight / zoom3;
	}
	//if(checkBrowserName('MSIE') || checkBrowserName('firefox') || checkBrowserName('opera')){  
	
	/********VCAT - Bild an sich plus die zwei übergeordneten div's*********/
	//$('.slider_vcat').attr('width', newWidth + 'px');
	//$('.slider_vcat').attr('height', newHeight + 'px');
	
	$('.slider_vcat').each(function(index) {
			$(this).width( newWidth );	
			$(this).height(newHeight );
	});

	fktImageStyle(newWidth);
	/*fktBackgroundStyle(newWidth, newHeight);*/
	
	$('.slider_vcat').parent().removeAttr('style');
	$('.slider_vcat').parent().attr('style', 'width: ' + newWidth + 'px; ' + 'height: ' + newHeight + 'px; z-index: 10; position: relative; overflow: hidden;');
	$('#frame').css("width",newWidth+205+"px");
	
	$('.slider_vcat').parent().parent().removeAttr('style');
	$('.slider_vcat').parent().parent().addClass('left');
	$('.tx-imagecycle-pi5').removeAttr('style');


	//}
	/********VCAT - für den Chrome*********/
	
}
