$(document).ready(function() {

	function getUrlVars() {
	    var vars = [], hash;
	    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	    for(var i = 0; i < hashes.length; i++)
	    {
	        hash = hashes[i].split('=');
	        vars.push(hash[0]);
	        vars[hash[0]] = hash[1];
	    }
	    return vars;
	}
	function jobDetail(url, width, height) {
		var winl = (screen.width - width) / 2;
		var wint = (screen.height - height) / 2;
		if( typeof job_ad_window == 'object')
			job_ad_window.close();
		job_ad_window = window.open(url, 'job_ad', 'scrollbars=yes,menubar=no,toolbar=no,status=yes,directories=no,location=no,width=' + width + ',height=' + height + ',top=' + wint + ',left=' + winl + ',resizable=yes');
		// if((typeof job_ad_window == 'object')) job_ad_window.window.focus();
		return false;
	}

	var jobID = getUrlVars()["jobID"];
	
	// open jobs.ch url if jobID is provided
	if (jobID > 0){
		// alert('jobID: '+jobID);
		var url = 'http://kombi.jobs.ch/basic_kombi/display.php?aid='+jobID+'&cat=115&oid=35986';
		jobDetail(url,690,590);
	}



	$('#jobOffer').hover(function() {
		$('#butterfly').attr('src', 'fileadmin/templates/img/schmetterling_over.jpg');	
	}, function() {
		$('#butterfly').attr('src', 'fileadmin/templates/img/schmetterling.jpg');	
	});





	jQuery.fn.reverse = [].reverse;
	
	var x = 1;
	while (x < 100) {
		$('#team > div').each(function(index) {
			var name   = $(this).attr('class');
			var source = 'fileadmin/Dateien/Bilder/Mitarbeiter/'+name+'.jpg';
			$('#teampic').fadeOut(3500, function () {
			    $('#teampic').attr('src', source);	
			    $('#teampic').attr('alt', name);
			    $('#teampic').attr('title', name);	
			});
			$('#teampic').fadeIn(3500);
	    	// alert ('my var: '+index);

			$('#team > div').hover(function() {
				var name   = $(this).attr('class');
				var source = 'fileadmin/Dateien/Bilder/Mitarbeiter/'+name+'.jpg';
				// alert ('my var: '+source);
				$('#teampic').show($('#teampic').attr('src', source));
			});

	    });
	    x = x + 1;
   }

	// var name   = $('#team div:first-child').attr('class');
	// var source = 'fileadmin/Dateien/Bilder/Mitarbeiter/'+name+'.jpg';
	// // alert ('my var: '+source);
	// $('#teampic').show($('#teampic').attr('src', source));


	//	show more background pic
	//  move down
	$('#zoomdown').click(function() {
		$('#bottomWrapper').animate({
			top : '320px'
		}, 400, function() {
			// Animation complete.
			$('#zoomdown').hide();
			$('#zoomup').show();
		});
	});
	//  move up
	$('#zoomup').click(function() {
		$('#bottomWrapper').animate({
			top : '160px'
		}, 400, function() {
			// Animation complete.
			$('#zoomup').hide();
			$('#zoomdown').show();
		});
	});
	
	
	//  animation for start_claim1 - Für Unternehmen
	$('#start_claim1').click(function() {
		$('#jobOffer').hide();
		$('#start_claim2').animate({
			opacity : 0.25,
			top : '-=500',
			height : 'toggle'
		}, 700, function() {
			// Animation complete.
			$('#start_claim1').animate({
				opacity : 0.25,
				top : '-=800',
				height : 'toggle'
			}, 700, function() {
				// Animation complete.
				$('#logo_start').slideUp('slow', function() {
					// Animation complete.
					$('#mainNavigation').fadeOut('slow', function() {
						// Animation complete.
						$('#mainWrapper').animate({
							opacity : 0
						}, 1000, function() {
							// Animation complete.
							$('#mainWrapper').hide(10, function() {
								// Animation complete.
								$('#startWrapper1').show();
								$('#startWrapper1').animate({
									opacity : 1
								}, 500, function() {
									// Animation complete.
									window.location.href = 'index.php?id=9';
								});
							});
						});
					});
				});
			});
		});
	});
	
	
	//  animation for start_claim1 - Für Arbeitnehmer
	$('#start_claim2').click(function() {
		$('#jobOffer').hide();
		$('#start_claim1').animate({
			opacity : 0.25,
			top : '-=500',
			height : 'toggle'
		}, 700, function() {
			// Animation complete.
			$('#start_claim2').animate({
				opacity : 0.25,
				top : '-=800',
				height : 'toggle'
			}, 700, function() {
				// Animation complete.
				$('#logo_start').slideUp('slow', function() {
					// Animation complete.
					$('#mainNavigation').fadeOut('slow', function() {
						// Animation complete.
						$('#mainWrapper').animate({
							opacity : 0
						}, 1000, function() {
							// Animation complete.
							$('#mainWrapper').hide(10, function() {
								// Animation complete.
								$('#startWrapper2').show();
								$('#startWrapper2').animate({
									opacity : 1
								}, 500, function() {
									// Animation complete.
									window.location.href = 'index.php?id=16';
								});
							});
						});
					});
				});
			});
		});
	});
	
	
});




