var site = {
	
	rotations : null,
	index : 0,
	t : null,

	init : function() {
		
		$('.accordion').accordion({header:'h4'});

		//var $tabs = $('.home #hero').tabs({
										  
			//select: function(ui) {
        		//rotations--;
				//if (!rotations) {
					//$tabs.tabs({fx:{opacity:'toggle'}}).tabs('rotate', null);
				//}
			//}
		//});
		
		//var rotations = $tabs.tabs('length');
		//$tabs.tabs({fx:{opacity:'toggle'}}).tabs('rotate', 2000);
		
		<!--$("#hero .slide").hide();-->
		<!--$("#hero .slide").eq(0).hide();-->
		<!--$("#hero .nav li").eq(0).addClass("ui-tabs-selected");-->
	<!--	$("#hero .nav li a").eq(0).css("background-position", "0 -10px");-->-->
		
		$("#hero .nav li").each(function(i) {
			
			$("a", this).eq(0).click(function(e) {
				
				$("#hero .slide").hide();
				$("#hero .nav li").removeClass("ui-tabs-selected");
				$("#hero .nav li a").css("background-position", "0 0");
				$("#hero .slide").eq(i).fadeIn("slow");
				$("#hero .nav li").eq(i).addClass("ui-tabs-selected");
				$("#hero .nav li a").eq(i).css("background-position", "0 -10px");
				
				clearTimeout(site.t);
				
				e.preventDefault();
			});
			
		});
		
		
		site.rotations =  $("#hero .nav li").length;
		site.t = setTimeout("site.updateSlide()", 8000);
		
		
		// carousel
		$('.home #brands .carousel').carousel({
											  
				beforeStart: function(before, after) {
					$('.home #brands button').removeClass('disabled');
					if (after.index($('.home #brands .carousel').find('li:first')) >= 0)
						$('.home #brands .previous').addClass('disabled');
					if (after.index($('.home #brands .carousel').find('li:last')) >= 0)
						$('.home #brands .next').addClass('disabled');
				},
				circular: false,
				visible: 1
				
		});
		
		$('.home #brands .previous').click(function() {
  			$('.home #brands .carousel').carousel('prev');
		});
		$('.home #brands .next').click(function() {
  			$('.home #brands .carousel').carousel('next');
		});
		
		var search_label = $('#masthead .utilities label').text();
		$('#masthead .utilities input[type="text"]').val(search_label);
		$('#masthead .utilities input[type="text"]').focus(function(){
			if($(this).val() == search_label){
				$(this).val("");
			}
		});
		$('#masthead .utilities input[type="text"]').blur(function(){
			if(!$(this).val()){
				$(this).val(search_label);
			}
		});
		
		$("#selected_country").click(function(e) {
  			$("#country_container").show();
			
			
			
			var theScreen =  document.createElement('div');
			var theBody = document.getElementsByTagName('body')[0];
			
			theBody.appendChild(theScreen);
			theScreen.id = "screen";
			
			$("#screen").css("height", $(document).height() + "px");
			$("#screen").click(function() {
				$("#country_container").hide();	
				$("#screen").remove();
			});
			
			e.preventDefault();
		});
						   
		
		// ie6 selector support
		if($.browser.msie && $.browser.version == '6.0'){
			$('input[type="submit"]').addClass('submit');
			$('input[type="text"]').addClass('text');
			$('li:first-child').addClass('first-child');
			$('#main_nav>li, #main_nav>li>a').addClass('child');
			$('#main_nav>li').hover(
				function(){
					$(this).addClass('hover');
				},
				function(){
					$(this).removeClass('hover');
				}
			);
			$('#sub_nav>li, #sub_nav>li>a').addClass('child');
			$('#sub_nav>li').hover(
				function(){
					$("ul", this).show();
				},
				function(){
					$("ul", this).hide();
				}
			);
		}
	},
	
	updateSlide : function() {
		site.t = setTimeout("site.updateSlide()", 7000);
		site.index++;
		
		$("#hero .slide").hide();
		$("#hero .nav li").removeClass("ui-tabs-selected");
		$("#hero .nav li a").css("background-position", "0 0");
		
		if(site.index < site.rotations) {
			$("#hero .slide").eq(site.index).fadeIn("slow");
			$("#hero .nav li").eq(site.index).addClass("ui-tabs-selected");
			$("#hero .nav li a").eq(site.index).css("background-position", "0 -10px");
		} else {
			$("#hero .slide").eq(0).fadeIn("slow");
			$("#hero .nav li").eq(0).addClass("ui-tabs-selected");
			$("#hero .nav li a").eq(0).css("background-position", "0 -10px");
			//clearTimeout(site.t);
			site.index=0;
			if(site.index < site.rotations) {
				$("#hero .slide").eq(site.index).fadeIn("slow");
				$("#hero .nav li").eq(site.index).addClass("ui-tabs-selected");
				$("#hero .nav li a").eq(site.index).css("background-position", "0 -10px");
			}
		}
		
	}
	
}


$(document).ready(function(){
  	
	if (jQuery.browser.safari && document.readyState != "complete"){
    	setTimeout(site.init, 100);
    	return;
  	} else {
	
		site.init();
	}
	
	$("a:eq(0)").attr('title', 'Home');
});



/* MT - For print and pop up window - Added on 03/05 */
function popup_print(){
	document.getElementById('printheader').innerHTML = document.getElementById('printheader_content').innerHTML;
	document.getElementById('printcontent').innerHTML = document.getElementById('main_content_print').innerHTML;
	window.print();
}

function popup_download(fleId){
	var file_Id=fleId;
	//alert(fleId);
	//takeit = document.getElementById(fleId).innerHTML;
	//alert(takeit);
	window.open(file_Id);
}


function popup_download_eps(fleId){
	var file_Id=fleId;
	//alert(fleId);
	//takeit = document.getElementById(fleId).innerHTML;
	//alert(takeit);
	window.open(file_Id, target='_parent');
}

$(document).ready( function() {
	//Get the window height and width 
	var winH = $(window).height();  
    var winW = $(window).width();
	
	//Set the popup window to center 
	var cWin = $("#contentContainer"); 
    //$(cWin).css('top',  winH/2-$(cWin).height()/2);  
    $(cWin).css('left', winW/2-$(cWin).width()/2-90); 	
	  
    $(".ciba_box").click(function(){
	   var page = $(this).attr("href");
	   //alert(page);
	   if (page=="##")
	   {
		  //alert(this.parentNode.id);
			page=this.parentNode.id;
		//page=document.getparentElementById('flepath').innerHTML;
	   }
	   $(cWin).css('top',$(window).scrollTop()+10 )
	   //$("#contentContainer .content, #contentContainer .page_title").empty();
	   //$("#contentContainer .page_title1").html(document.getElementById('printheader_content').innerHTML);
	    $("#contentContainer .page_title").html($(this).attr("title"));
	  // $("#contentContainer .content").load(page);
	  $("#cb-iframe").attr("src",page);


	  
//	  $("#cb-iframe").load( function() {
//	  	var iFrame = $("#cb-iframe").contents().find("head").append("<meta title='narayan'></meta>");
//		console.log(iFrame);	
//	  });
	  
	  
	   if($.browser.msie && $.browser.version == '6.0')
	   		$('#contentContainer').bgiframe();
       $(cWin).fadeIn("fast");
       return false;
    });
	$("#contentContainer .close").click( function() {
		$("#contentContainer").fadeOut("slow");
	});
	
	
	
	$(".ciba_box1").click(function(){
	   var page = $(this).attr("href");
	   //alert(page);
	   if (page=="##")
	   {
			page=this.parentNode.id;
			//var strUrl = parent.window.location.host;
			//alert(page)
			page1 = "/Email-Kommunikation1.shtml?img="+page;
		//page=document.getparentElementById('flepath').innerHTML;
	   }
	   $(cWin).css('top',$(window).scrollTop()+10 )
	   //$("#contentContainer .content, #contentContainer .page_title").empty();
	   //$("#contentContainer .page_title1").html(document.getElementById('printheader_content').innerHTML);
	    $("#contentContainer .page_title").html($(this).attr("title"));
	  // $("#contentContainer .content").load(page);
	  $("#cb-iframe").attr("src",page1);
	  //location.href = "/Email-Kommunikation1.shtml?"+page;


	  
//	  $("#cb-iframe").load( function() {
//	  	var iFrame = $("#cb-iframe").contents().find("head").append("<meta title='narayan'></meta>");
//		console.log(iFrame);	
//	  });
	  
	  
	   if($.browser.msie && $.browser.version == '6.0')
	   		$('#contentContainer').bgiframe();
       $(cWin).fadeIn("fast");
       return false;
    });
	$("#contentContainer .close").click( function() {
		$("#contentContainer").fadeOut("slow");
	});
	
	$("#emailSub").click( function() {
		//subscribeEmail();
		location.href = "http://www.cibavision.com/email-communication-center.shtml?email=" + $("#email").val();
		return false;
	});
	
	$("#emailContainer .close").click( function() {
		$("#emailContainer").fadeOut("slow");
	});
	
    function subscribeEmail(){
    
        var chkFilter = /^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/;
        var email = $("#email").val();
        
        if (email.length == 0) {
            $("#emailContainer .content").html("Email address is required!").css({color: "red",'font-weight': 'bold'
            });
            //document.getElementById("emailContent").innerHTML="Email address is required!";
        }
        else 
            if (!chkFilter.test(email)) {
                $("#emailContainer .content").html("Invalid email address").css({color: "red",'font-weight': 'bold'});
            //document.getElementById("emailContent").innerHTML="Invalid email address!";
            }
            else {
                $("#emailContainer .content").load("/subscribe-action.html")
            }
        var eWin = $("#emailContainer");
        $(eWin).css('top', $(window).scrollTop() + winH / 2 - $(eWin).height() / 2);
        $(eWin).css('left', winW / 2 - $(eWin).width() / 2 - 90);
        eWin.fadeIn("fast");
        //document.getElementById("emailContainer").style.display="block";
        //alert("Enter Trapped");
        return false;
    }	
	
});

//Reusable pop-up layer box
$(document).ready( function() {
	$("a.ciba_popup").cibadialog({width:400});
	$('.backtotopdiv').click(function(){$('#masthead').ScrollTo(800);return false});
	$("#aside a").click( function() {
			
		var sId = $(this).attr('class');
		if( $("#"+sId).prev(".backtotopcontainerdiv").length )
			sTo = $("#"+sId).prev(".backtotopcontainerdiv");
		else
			sTo= $("#"+sId).prev().prev(".backtotopcontainerdiv");
		$(sTo).ScrollTo(800);
		return false;
	});
	
	/*flash overlay*/
	$("#beauty-video").click( function(){
		openDivCenter("tv-ads-overlay","closeBtnLink");
		var vars = { } 
		var params = {
			  scale: "noScale", 
			  salign: "", 
			  menu: "true", 
			  allowFullScreen: "true", 
			  scale: "showall", 
			  wmode: "transparent"
			};
		var attributes = { 
			  id: "swfTVSpot", 
			  name:"swfTVSpot" 
		};
		//swfobject.embedSWF("/images/swf/Beauty-Of-Sight.swf", "flashcontent", "665", "370", "8.0.0.0", "", vars, params, attributes);		
		//swfobject.embedSWF("/images/swf/flvplayer.swf?click=/images/swf/flvplaybutton.jpg&amp;file=/images/swf/Beauty-Of-Sight.flv&amp;showfsbutton=true&amp;play=auto", "flashcontent", "665", "370", "8.0.0.0", "", vars, params, attributes);		
		
		var strVar="";
				strVar += "<object type=\"application\/x-shockwave-flash\" width=\"665\" height=\"370\"";
				strVar += "		wmode=\"transparent\" data=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/Beauty-Of-Sight.flv&autoStart=true\">";
				strVar += "		<param name=\"movie\" value=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/Beauty-Of-Sight.flv&autoStart=true\" \/>";
				strVar += "		<param name=\"wmode\" value=\"transparent\" \/>";
				strVar += "		<\/object>";
		
		document.getElementById("flashcontent").innerHTML =strVar;
		return false;
	});
	$("#inno").click( function(){

		openDivCenter("tv-ads-overlay","closeBtnLink");
		var vars = { } 
		var params = {
			  scale: "noScale", 
			  salign: "", 
			  menu: "true", 
			  allowFullScreen: "true", 
			  scale: "showall", 
			  wmode: "transparent"
			};
		var attributes = { 
			  id: "swfTVSpot", 
			  name:"swfTVSpot" 
		};
		//swfobject.embedSWF("/images/swf/cibavision-innovation.swf", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		//swfobject.embedSWF("/images/swf/flvplayer.swf?click=/images/swf/flvplaybutton.jpg&amp;file=/images/swf/cibavision-innovation.flv&amp;showfsbutton=true&amp;play=auto", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		
		
		var strVar="";
		strVar += "<object type=\"application\/x-shockwave-flash\" width=\"665\" height=\"370\"";
		strVar += "		wmode=\"transparent\" data=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/cibavision-innovation.flv&autoStart=true\">";
		strVar += "		<param name=\"movie\" value=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/cibavision-innovation.flv&autoStart=true\" \/>";
		strVar += "		<param name=\"wmode\" value=\"transparent\" \/>";
		strVar += "		<\/object>";

		document.getElementById("flashcontent").innerHTML =strVar;
		return false;
	});

	/* donload video script end*/
	$(".dwnld_video").click( function(){

		openDivCenter("tv-ads-overlay","closeBtnLink");
		var vars = { } 
		var params = {
			  scale: "noScale", 
			  salign: "", 
			  menu: "true", 
			  allowFullScreen: "true", 
			  scale: "showall", 
			  wmode: "transparent"
			};
		var attributes = { 
			  id: "swfTVSpot", 
			  name:"swfTVSpot" 
		};
		//swfobject.embedSWF("/images/swf/cibavision-innovation.swf", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		//swfobject.embedSWF("/images/swf/flvplayer.swf?click=/images/swf/flvplaybutton.jpg&amp;file=/images/swf/cibavision-innovation.flv&amp;showfsbutton=true&amp;play=auto", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		
		var vdo=this.parentNode.id;
		var strVar="";
		strVar += "<object type=\"application\/x-shockwave-flash\" width=\"665\" height=\"370\"";

		strVar += "		wmode=\"transparent\" data=\"\/images\/swf\/flvplayer.swf?file="+vdo+"&autoStart=true\" \/>";

		strVar += "		<param name=\"movie\" value=\"\/images\/swf\/flvplayer.swf?file="+vdo+"&autoStart=true\" \/>";

		strVar += "		<param name=\"wmode\" value=\"transparent\" \/>";

		strVar += "		<\/object>";



		document.getElementById("flashcontent").innerHTML =strVar;
		return false;
	});
	/* donload video script end*/

	$("#tips").click( function(){
		openDivCenter("tv-ads-overlay","closeBtnLink");
		var vars = { } 
		var params = {
			  scale: "noScale", 
			  salign: "", 
			  menu: "true", 
			  allowFullScreen: "true", 
			  scale: "showall", 
			  wmode: "transparent"
			};
		var attributes = { 
			  id: "swfTVSpot", 
			  name:"swfTVSpot" 
		};
		//swfobject.embedSWF("/images/swf/getting-started-in-soft-contact-lenses.swf", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		//swfobject.embedSWF("/images/swf/flvplayer.swf?click=/images/swf/flvplaybutton.jpg&amp;file=/images/swf/getting-started-in-soft-contact-lenses.flv&amp;showfsbutton=true&amp;play=auto", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		
		var strVar="";
			strVar += "<object type=\"application\/x-shockwave-flash\" width=\"665\" height=\"370\"";
			strVar += "		wmode=\"transparent\" data=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/getting-started-in-soft-contact-lenses.flv&autoStart=true\">";
			strVar += "		<param name=\"movie\" value=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/getting-started-in-soft-contact-lenses.flv&autoStart=true\" \/>";
			strVar += "		<param name=\"wmode\" value=\"transparent\" \/>";
			strVar += "		<\/object>";
		
		document.getElementById("flashcontent").innerHTML =strVar;
		return false;
	});

	$("#cibastian").click( function(){
		openDivCenter("tv-ads-overlay","closeBtnLink");
		var vars = { } 
		var params = {
			  scale: "noScale", 
			  salign: "", 
			  menu: "true", 
			  allowFullScreen: "true", 
			  scale: "showall", 
			  wmode: "transparent"
			};
		var attributes = { 
			  id: "swfTVSpot", 
			  name:"swfTVSpot" 
		};
		//swfobject.embedSWF("/images/swf/getting-started-in-soft-contact-lenses.swf", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		//swfobject.embedSWF("/images/swf/flvplayer.swf?click=/images/swf/flvplaybutton.jpg&amp;file=/images/swf/getting-started-in-soft-contact-lenses.flv&amp;showfsbutton=true&amp;play=auto", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		
		var strVar="";
			strVar += "<object type=\"application\/x-shockwave-flash\" width=\"640\" height=\"360\"";
			strVar += "		wmode=\"transparent\" data=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/CIBASTIAN_640.flv&autoStart=true\">";
			strVar += "		<param name=\"movie\" value=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/CIBASTIAN_640.flv&autoStart=true\" \/>";
			strVar += "		<param name=\"wmode\" value=\"transparent\" \/>";
			strVar += "		<\/object>";
		
		document.getElementById("flashcontent").innerHTML =strVar;
		return false;
	});
	
	$("#tips_zip").click( function(){
		openDivCenter("tv-ads-overlay","closeBtnLink");
		var vars = { } 
		var params = {
			  scale: "noScale", 
			  salign: "", 
			  menu: "true", 
			  allowFullScreen: "true", 
			  scale: "showall", 
			  wmode: "transparent"
			};
		var attributes = { 
			  id: "swfTVSpot", 
			  name:"swfTVSpot" 
		};
		//swfobject.embedSWF("/images/swf/getting-started-in-soft-contact-lenses.swf", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		//swfobject.embedSWF("/images/swf/flvplayer.swf?click=/images/swf/flvplaybutton.jpg&amp;file=/images/swf/getting-started-in-soft-contact-lenses.flv&amp;showfsbutton=true&amp;play=auto", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		
		var strVar="";
			strVar += "<object type=\"application\/x-shockwave-flash\" width=\"720\" height=\"576\"";
			strVar += "		wmode=\"transparent\" data=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/Handhabungshinweise.flv&autoStart=true\">";
			strVar += "		<param name=\"movie\" value=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/Handhabungshinweise.flv&autoStart=true\" \/>";
			strVar += "		<param name=\"wmode\" value=\"transparent\" \/>";
			strVar += "		<\/object>";
		
		document.getElementById("flashcontent").innerHTML =strVar;
		return false;
	});
	$("#tipsseealso").click( function(){
		openDivCenter("tv-ads-overlay","closeBtnLink");
		var vars = { } 
		var params = {
			  scale: "noScale", 
			  salign: "", 
			  menu: "true", 
			  allowFullScreen: "true", 
			  scale: "showall", 
			  wmode: "transparent"
			};
		var attributes = { 
			  id: "swfTVSpot", 
			  name:"swfTVSpot" 
		};
		//swfobject.embedSWF("/images/swf/getting-started-in-soft-contact-lenses.swf", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		//swfobject.embedSWF("/images/swf/flvplayer.swf?click=/images/swf/flvplaybutton.jpg&amp;file=/images/swf/getting-started-in-soft-contact-lenses.flv&amp;showfsbutton=true&amp;play=auto", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		
		var strVar="";
			strVar += "<object type=\"application\/x-shockwave-flash\" width=\"720\" height=\"576\"";
			strVar += "		wmode=\"transparent\" data=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/Handhabungshinweise.flv&autoStart=true\">";
			strVar += "		<param name=\"movie\" value=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/Handhabungshinweise.flv&autoStart=true\" \/>";
			strVar += "		<param name=\"wmode\" value=\"transparent\" \/>";
			strVar += "		<\/object>";
				
		document.getElementById("flashcontent").innerHTML =strVar;
		return false;
	});

	$("#eyedoll").click( function(){
		openDivCenter("tv-ads-overlay","closeBtnLink");
		var vars = { } 
		var params = {
			  scale: "noScale", 
			  salign: "", 
			  menu: "true", 
			  allowFullScreen: "true", 
			  scale: "showall", 
			  wmode: "transparent"
			};
		var attributes = { 
			  id: "swfTVSpot", 
			  name:"swfTVSpot" 
		};
		//swfobject.embedSWF("/images/swf/getting-started-in-soft-contact-lenses.swf", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		//swfobject.embedSWF("/images/swf/flvplayer.swf?click=/images/swf/flvplaybutton.jpg&amp;file=/images/swf/Teens-Eyedoll-AR.f4v&amp;showfsbutton=true&amp;play=auto", "flashcontent", "660", "400", "8.0.0.0", "", vars, params, attributes);
		
		var strVar="";
			strVar += "<object type=\"application\/x-shockwave-flash\" width=\"665\" height=\"370\"";
			strVar += "		wmode=\"transparent\" data=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/CIBASTIAN_640.flv&autoStart=true\">";
			strVar += "		<param name=\"movie\" value=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/CIBASTIAN_640.flv&autoStart=true\" \/>";
			strVar += "		<param name=\"wmode\" value=\"transparent\" \/>";
			strVar += "		<\/object>";

		document.getElementById("flashcontent").innerHTML =strVar;
		return false;
	});

	$("#jog").click( function(){
		openDivCenter("tv-ads-overlay","closeBtnLink");
		var vars = { } 
		var params = {
			  scale: "noScale", 
			  salign: "", 
			  menu: "true", 
			  allowFullScreen: "true", 
			  scale: "showall", 
			  wmode: "transparent"
			};
		var attributes = { 
			  id: "swfTVSpot", 
			  name:"swfTVSpot" 
		};
		//swfobject.embedSWF("/images/swf/getting-started-in-soft-contact-lenses.swf", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		//swfobject.embedSWF("/images/swf/flvplayer.swf?click=/images/swf/flvplaybutton.jpg&amp;file=/images/swf/JOG_30_V1.f4v&amp;showfsbutton=true&amp;play=auto", "flashcontent", "660", "400", "8.0.0.0", "", vars, params, attributes);
		
		var strVar="";
			strVar += "<object type=\"application\/x-shockwave-flash\" width=\"665\" height=\"370\"";
			strVar += "		wmode=\"transparent\" data=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/JOG_30_V1.flv&autoStart=true\">";
			strVar += "		<param name=\"movie\" value=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/JOG_30_V1.flv&autoStart=true\" \/>";
			strVar += "		<param name=\"wmode\" value=\"transparent\" \/>";
			strVar += "		<\/object>";
		
		document.getElementById("flashcontent").innerHTML =strVar;
		return false;
	});

	$("#lib").click( function(){
		openDivCenter("tv-ads-overlay","closeBtnLink");
		var vars = { } 
		var params = {
			  scale: "noScale", 
			  salign: "", 
			  menu: "true", 
			  allowFullScreen: "true", 
			  scale: "showall", 
			  wmode: "transparent"
			};
		var attributes = { 
			  id: "swfTVSpot", 
			  name:"swfTVSpot" 
		};
		//swfobject.embedSWF("/images/swf/getting-started-in-soft-contact-lenses.swf", "flashcontent", "665", "498", "8.0.0.0", "", vars, params, attributes);		
		//swfobject.embedSWF("/images/swf/flvplayer.swf?click=/images/swf/flvplaybutton.jpg&amp;file=/images/swf/LIB30_V1.f4v&amp;showfsbutton=true&amp;play=auto", "flashcontent", "660", "400", "8.0.0.0", "", vars, params, attributes);
		
		var strVar="";
			strVar += "<object type=\"application\/x-shockwave-flash\" width=\"665\" height=\"370\"";
			strVar += "		wmode=\"transparent\" data=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/LIB30_V1.flv&autoStart=true\">";
			strVar += "		<param name=\"movie\" value=\"\/images\/swf\/flvplayer.swf?file=\/images\/swf\/LIB30_V1.flv&autoStart=true\" \/>";
			strVar += "		<param name=\"wmode\" value=\"transparent\" \/>";
			strVar += "		<\/object>";
				
		document.getElementById("flashcontent").innerHTML =strVar;
		return false;
	});

	$("#map").click( function(){
		openDivCenter("tv-ads-overlay","closeBtnLink");
		var vars = { } 
		var params = {
			  scale: "noScale", 
			  salign: "", 
			  menu: "true", 
			  allowFullScreen: "true", 
			  scale: "showall", 
			  wmode: "transparent"
			};
		var attributes = { 
			  id: "swfTVSpot", 
			  name:"swfTVSpot" 
		};
		swfobject.embedSWF("/images/Worldwide-Locations.jpg", "flashcontent", "620", "509", "8.0.0.0", "", vars, params, attributes);		
		//swfobject.embedSWF("/images/swf/flvplayer.swf?click=/images/swf/flvplaybutton.jpg&amp;file=/images/swf/LIB30_V1.f4v&amp;showfsbutton=true&amp;play=auto", "flashcontent", "660", "400", "8.0.0.0", "", vars, params, attributes);
		return false;
	});

});



//-------------------------------------------------------------------------------------------
// POSITION DIV IN THE CENTER OF WINDOW
//------------------------------------------------------------------------------------------
function centerLyr(divID)
{
    $('#'+divID).css("position","absolute");
 
    var newTop = ( $(window).height() - $('#'+divID).height() ) / 2+$(window).scrollTop();
    if(newTop<0) newTop = 0;

    var newLeft = ( $(window).width() - $('#'+divID).width() ) / 2+$(window).scrollLeft();
    if(newLeft<0) newLeft = 0;

    $('#'+divID).css("top", newTop + "px");
    $('#'+divID).css("left", newLeft + "px");
}

//-------------------------------------------------------------------------------------------
// RE-POSITION DIV IN THE CENTER OF WINDOW ON WINDOW RESIZE
//------------------------------------------------------------------------------------------
function rePositionLyr(status,divID) 
{
    switch(status) {
	case true:
		$(window).bind('resize', function() {
			centerLyr(divID);
		});
		//scroll is not used here
		//$(window).bind('scroll', function() {
		//	centerLyr(divID);
		//});
	    break;
	case false:
		$(window).unbind('resize');
		//scroll is not used here
		//$(window).unbind('scroll');
	    break;
    }
}

//-------------------------------------------------------------------------------------------
// POSITION OVERLAY IN THE CENTER OF WINDOW
//------------------------------------------------------------------------------------------
function showPopupDivCenter(divID) 
{
   if($.browser.msie && $.browser.version == '6.0') $('#'+divID).bgiframe();
    var toShow = $("#"+divID); 
    toShow.css({"z-index":"9000","visibility":"visible","display":"block"});
    centerLyr(divID);
    rePositionLyr(true,divID);
}

//-------------------------------------------------------------------------------------------
// OPEN DIV OVERLAY AND POSITION CENTER
//------------------------------------------------------------------------------------------
function openDivCenter(divID,closeBtnID)
{
    var toShow="";
    // Build the background overlay div
    toShow += "<div class='site_overlay'></div>";
    $('body').append(toShow);

    $('div.site_overlay').css('height',$(document).height()).bind('click',function(){
	closeDiv(divID);
	return false;
    });

    $('div.site_overlay').css('opacity',0).fadeTo('slow',0.65, function(){
	showPopupDivCenter(divID);
	$('div.site_overlay').css("z-index","9000");
	$('#'+divID).css("z-index","9500");
    });

    if(closeBtnID!=""){
        $("#"+closeBtnID).bind('click',function(){
	        closeDiv(divID);
		return false;
        });
    }
}

//-------------------------------------------------------------------------------------------
// CLOSE OPENED DIV OVERLAY
//------------------------------------------------------------------------------------------
function closeDiv(divID)
{
    $('div.site_overlay').remove();
    rePositionLyr(false,divID);
    var toHide = $("#"+divID); 
    toHide.css({"z-index":"0","visibility":"hidden"});
    if(divID=="all-products"){
	toHide.css("width", "1px");
	toHide.css("height", "1px");
    }
    if(divID=="tv-ads-overlay")
    {
		$('#swfTVSpot').remove();
		$('#flashcontent').remove();
		$("#tv-ads-overlay").children("div.lyrRel").append("<div id='flashcontent'></div>");
    }	
}


(function($){
	$.fn.cibadialog = function(options) {
		var $dropShadow, $cibaDialog, $cibaContent;
		
		var defaults = {
			width: 400,
			height: 200,
			position: 'center',
			cibaZindex : 10 
		};
		
		var options = $.extend(defaults, options);
		var cibaZindex = options.cibaZindex;
		
		return this.each( function() {
			
			var $this = $(this);
			
			if( !$("#ciba-widget").length) {
				$(['<div id="ciba-widget">',
					'<div id="ciba-dialog">',
//						'<div class="top">',
							'<h3 class="page_title"></h3>',
//							'<div class="lt"><h3 class="page_title" style="border:1px solid red;"></h3></div>',
							'<div style="position:absolute; right:4px;top:4px;_top:12px;_right:12px;cursor:pointer;" class="ciba-close close"><img src="/images/ico_close.png" alt="Close" title="Close"/></div>',
//							'<div class="clrboth"></div>',
//						'</div>',
						'<div class="content">',
						'</div>',
					'</div>',
				'</div>'].join('')).appendTo('body');
				
				$(".ciba-close").bind('click', function(){
					$("#ciba-widget").fadeOut('slow');
					return false;
				});
			}
			
			var $cibaWidget = $("#ciba-widget").css({width:options.width, zIndex:cibaZindex});
			$cibaDialog = $("#ciba-dialog").css({zIndex:cibaZindex});
			
			if (!$dropShadow) {
				$dropShadow = $([]);
				for( var i=0;i<7; i++ ) {
					$dropShadow = $dropShadow.add($('<div></div>').css({zIndex: cibaZindex-1, opacity:.1, top: 1+i, left: 1+i}));
				}
				$dropShadow.css({position:'absolute', backgroundColor:'#000', width:options.width}).attr("class","shdw");
				$dropShadow.prependTo($cibaWidget);
			}
			
			$cibaContent = $("#ciba-dialog .content");
			 
			$this.bind('click', function(event){
				var page = $this.attr('href');
				if( !$cibaWidget.is(':hidden')) {
					$cibaWidget.hide();
				}
				$.ajax({
					url: page,
					context: $cibaContent,
					success : function(data, textStatus) {
						$cibaContent.html(data);
						var title = $cibaContent.find('h3').text();
						$("#ciba-widget .page_title").html(title);
						$("#ciba-dialog .content h3").remove();
						$cibaWidget.css({top:event.pageY + 15,left:event.pageX}).fadeIn('fast');
						var cHeight = $cibaDialog.height();
						$dropShadow.css({height:cHeight+35});
					}
				});
				return false;
			});
			
		});
	}
})(jQuery);		

//////////////////// scroll ////////////////////////////////////////////////////////////////////////////
jQuery.getPos = function (e)
{
	var l = 0;
	var t  = 0;
	var w = jQuery.intval(jQuery.css(e,'width'));
	var h = jQuery.intval(jQuery.css(e,'height'));
	var wb = e.offsetWidth;
	var hb = e.offsetHeight;
	while (e.offsetParent){
		l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
		t += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
		e = e.offsetParent;
	}
	l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
	t  += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
	return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
};
jQuery.getClient = function(e)
{
	if (e) {
		w = e.clientWidth;
		h = e.clientHeight;
	} else {
		w = (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth;
		h = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;
	}
	return {w:w,h:h};
};
jQuery.getScroll = function (e) 
{
	if (e) {
		t = e.scrollTop;
		l = e.scrollLeft;
		w = e.scrollWidth;
		h = e.scrollHeight;
	} else  {
		if (document.documentElement && document.documentElement.scrollTop) {
			t = document.documentElement.scrollTop;
			l = document.documentElement.scrollLeft;
			w = document.documentElement.scrollWidth;
			h = document.documentElement.scrollHeight;
		} else if (document.body) {
			t = document.body.scrollTop;
			l = document.body.scrollLeft;
			w = document.body.scrollWidth;
			h = document.body.scrollHeight;
		}
	}
	return { t: t, l: l, w: w, h: h };
};

jQuery.intval = function (v)
{
	v = parseInt(v);
	return isNaN(v) ? 0 : v;
};

jQuery.fn.ScrollTo = function(s) {
	o = jQuery.speed(s);
	return this.each(function(){
		new jQuery.fx.ScrollTo(this, o);
	});
};

jQuery.fx.ScrollTo = function (e, o)
{
	var z = this;
	z.o = o;
	z.e = e;
	z.p = jQuery.getPos(e);
	z.s = jQuery.getScroll();
	z.clear = function(){clearInterval(z.timer);z.timer=null};
	z.t=(new Date).getTime();
	z.step = function(){
		var t = (new Date).getTime();
		var p = (t - z.t) / z.o.duration;
		if (t >= z.o.duration+z.t) {
			z.clear();
			setTimeout(function(){z.scroll(z.p.y, z.p.x)},13);
		} else {
			st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;
			sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;
			z.scroll(st, sl);
		}
	};
	z.scroll = function (t, l){window.scrollTo(l, t)};
	z.timer=setInterval(function(){z.step();},13);
};


/* ..........................script for second level nav*/
var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 



/*  script for Dynamic BreadCrumb */

function Breadcrumb(){
	this.homeLinkText = 	'Home'; 	// Text for the home link
	this.separator = 		' > ';		// Character(s) to use between breadcrumbs
	this.homeLinkPosition = 0;			// Where is home? 0 = domain, 1 = 1st directory, and so on ...
	this.attachTo = '#breadCrumb';	// Attach breadcrumb to a tag or an ID: e.g., body, h1, div, #header, #breadcrumb
	this.replaceTheseCharacters = [		// You can replace any text with customized text
		["-", " "],["&amp;","&"],
		["Standorte-Deutschland","Standorte Deutschland"],
		["cv-gmbh-gw","CIBA VISION GmbH"],
		["cv gmbh gw","CIBA VISION Gmbh GroBwallstadt"],
		['Uber-uns', 'Ueber uns'],
		['Uber uns', $('#bredTxt').html()],
		['media_daten', 'Media Daten'],
		['focus_night_day', 'Focus Night Day'],
		['sonstige_dateien', 'Sonstige Dateien'],
		['focus_dailies', 'Focus Dailies'],
		['Kontaktlinsen_jahreskampagne', 'Kontaktlinsen-Jahreskampagne'],
		
		
		
		['', '']
		];
	////////////////////
	// End customization
	////////////////////
 
	var homeText = this.homeLinkText;
	var sep = this.separator;
	var position = this.homeLinkPosition;
	var tag = this.attachTo;
	var replacements = this.replaceTheseCharacters;
	var d = document;
	var url = d.location.href.split('//')[1];
	var text = url;
	url = url.split('/');
	if(url[url.length-1] === '') {url.pop();}
	url.pop();
	
	//var title1=document.getElementById("printheader_content").innerHTML;
	//cntTNo=title1.indexOf(">");
	//title2=title1.substr(cntTNo+1,1000);
	//asd=title2.indexOf("<");
	//title=title2.substr(0,asd);
	var title_p;
	var title_pff;
	var title_pg;
	var title_pf;

	title_p = $("h2.page_title").html();
	if (title_p==null)
	{
		title_p="";
	}
	title_p=title_p.replace("<sup>", "");
	title_p=title_p.replace("</sup>", "");
	title_p=title_p.replace("&amp;", "&");
	
	
	
	var rex;
	for (var i=0; i < replacements.length; i++) {
		rex = new RegExp(replacements[i][0], "g");
		text = text.replace(rex,replacements[i][1]);
		title_pff = title_p.replace(rex,replacements[i][1]);
	}
	text = text.split('/');
 
	function createBreadcrumbs() {
		var href = '', a, div = d.createElement('div');
		div.setAttribute('id', 'breadcrumbs');
		//alert(url);
		for (var i = 0; i < url.length; i++) {
			href += url[i] + '/';
			if (i < position) {continue;}
			if (i === position) {text[i] = homeText;}
			//text[i] = text[i].charAt(0).toUpperCase() + text[i].substr(1);
			a = d.createElement('a');		
			
	
		href=href.replace("/rund-ums-auge/", "/rund-ums-auge/warum-kontaktlinsen.shtml")
		href=href.replace("/Presse/", "/Presse/neuste-presse-informationen.shtml")
	
		href=href.replace("/innovation/", "/innovation/Geschichte-der-Produktinnovationen.shtml")
		href=href.replace("/KontaktlinsenundPflege/", "/Kontaktlinsen-und-Pflege.shtml")
		href=href.replace("/Uber-uns/", "/Uber-uns.shtml")
		href=href.replace("/Uber-uns.shtmlStandorte-Deutschland/", "/Uber-uns/Standorte-Deutschland.shtml")
		href=href.replace("/Uber-uns.shtmlStandorte-Deutschland.shtmlcv-gmbh-gw/",	"/Uber-uns/Standorte-Deutschland/cv-gmbh-gw.shtml")
		
		href=href.replace("/Uber-uns.shtmlkarriere/","/Uber-uns/karriere.shtml")
		href=href.replace("/Uber-uns.shtmlkarriere.shtmlBerufsausbildung/","/Uber-uns/karriere/Berufsausbildung.shtml")
		href=href.replace("/Uber-uns.shtmlkarriere.shtmlAusbildungsangebot/","/Uber-uns/karriere/Ausbildungsangebot.shtml")
		href=href.replace("/press-releases/", "")
		
		href=href.replace("/Uber-uns.shtmlkarriere/Ausbildungsangebot/", "/Uber-uns/karriere/Ausbildungsangebot.shtml")	
		href=href.replace("/professionals.shtmlseminare/", "/professionals/seminare.shtml")	
		href=href.replace("/professionals.shtmlservice/", "/professionals/service/news-und-infos.shtml")
		href=href.replace("/professionals.shtmlmedia_daten/", "/professionals/media_daten/index.shtml")
		href=href.replace("/professionals/media-date/", "/professionals/media_daten/index.shtml")
		href=href.replace("/professionals/seminare.shtmlseminare.shtmlseminare/","	/professionals/seminare.shtml")
		href=href.replace("/professionals/seminare.shtmlseminare.shtmlservice/","	/professionals/service/news-und-infos.shtml")
		href=href.replace("/professionals/seminare.shtmlseminare.shtmlmedia_daten/","	/professionals/media_daten/index.shtml")
		href=href.replace("/professionals/", "/professionals.shtml")
		href=href.replace("/professionals/media_daten/", "/professionals/media_daten/index.shtml")
		
		
	
		href=href.replace("/professionals.shtmlmedia_daten/index.shtml", "/professionals/media_daten/index.shtml")
		
		href=href.replace("/professionals/media_daten/index.shtmlcibavision/", "/professionals/media_daten/cibavision/index.shtml")
		href=href.replace("/professionals/media_daten/index.shtmlairoptix/", "/professionals/media_daten/airoptix/index.shtml")
		href=href.replace("/professionals/media_daten/index.shtmlfocus_dailies/", "/professionals/media_daten/focus_dailies/index.shtml")
		href=href.replace("/professionals/media_daten/index.shtmlfreshlook/", "/professionals/media_daten/freshlook/index.shtml")	
		href=href.replace("/professionals/media_daten/index.shtmlsonstige_dateien/", "/professionals/media_daten/sonstige_dateien/index.shtml")	
		
		href=href.replace("/professionals.shtmlseminare.shtml", "/professionals/seminare.shtml")	
		href=href.replace("/professionals.shtmlservice/news-und-infos.shtml", "/professionals/service/news-und-infos.shtml")	

		href=href.replace("/professionals/media_daten/index.shtmldailies/", "/professionals/media_daten/dailies/index.shtml")	
		
		
		href=href.replace("/professionals/media_daten/index.shtmlKontaktlinsen_jahreskampagne/", "/professionals/media_daten/Kontaktlinsen_jahreskampagne/index.shtml")	
				
		
									
									
						

			//alert(href);
			a.setAttribute('href', 'http://' + href);
			
			//alert(text[i]);
			text[i] = text[i].capitalize();
			//alert(capitalizedString);
			
			a.setAttribute('title', text[i]);//set title for breadCrumLinks

			a.appendChild(d.createTextNode(text[i]));
			div.appendChild(a);
			div.appendChild(d.createTextNode(sep));
		}
		div.appendChild(d.createTextNode(title_pff));
		return div;
	}
 
	function writeHTML() {
		tag = tag.match('#') ? d.getElementById(tag.substring(1)) : d.getElementsByTagName(tag)[0];
		if (tag) {
			tag.appendChild(createBreadcrumbs());
		}
	}
	this.output = writeHTML;
}
 
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload !== 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		};
	}
}
 
addLoadEvent(function() {
	var crumb = new Breadcrumb();
	crumb.output();					  
});

String.prototype.capitalize = function(){
  return this.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );
};



