
/**
 * @autor mikettel
 * @see http://tablesorter.com/docs/
 */
$(document).ready( function() 
{		
	// shadowbox 3.0.3
	Shadowbox.init({
		flashVersion: 	"9",
		overlayColor: 	'#000000', 
		overlayOpacity:	0.6,
		initialWidth: 	350,
		initialHeigh: 	460,			
		//handleOversize: 'drag', //resize none scroll			 drag
		modal: 			false,
		displayCounter: false,
		displayNav: 	false
    });

	/* */
	$("#rightnavigation .hasChildren").hover(
		function() {
			$(this).addClass('hoverDown');		
		}, 
		function() {
			$(this).removeClass('hoverDown');
		}
	);
	
	validateContactForm();
	contactFormRegionSelect();
	
});

/**
 * validate the contactform content
 */
function validateContactForm() 
{
	// http://www.hieblmedia.de/weblog/tips-tricks/yaml-formularbaukasten-und-jquery-validate.html
	$("#contactformular").validate({
   		rules: {
     		name: "required",
     		company: "required",
     		topic: "required",
     		message: "required",     		
     		email: {
       			required: true,
       			email: true
     		}
	   	},
		errorPlacement: function(error, element) {		
			$(element).closest('.input').append(error);
		},
		errorClass:"errorMsg"		
	});
}


/**
 * on contact form region select
 */
function contactFormRegionSelect() 
{	
	$('#region_select').change(function() {		
		
		var str = "";		
		
		// read the selected item
		$("select option:selected").each(function () {
			str += $(this).val();
		});	
						
		// hide all contact blocks
		$('#contact_europe').css('display', 'none');
		$('#contact_usa').css('display', 'none');
		$('#contact_china').css('display', 'none');
		$('#contact_japan').css('display', 'none');
		$('#contact_korea').css('display', 'none');		
				
		// show the active conact block
		// and save receiver email to hidden formfield
		if(str == "europe") {
			$('#contact_europe').css('display', 'block');				
		}
		if(str == "usa") {
			$('#contact_usa').css('display', 'block');			
		}
		if(str == "china") {
			$('#contact_china').css('display', 'block');
		}
		if(str == "japan") {
			$('#contact_japan').css('display', 'block');			
		}
		if(str == "korea") {
			$('#contact_korea').css('display', 'block');			
		}		
		$('#selected_country').attr('value', str);		
	});
}

/**
 * open a shadowbox with video player or any other swf inside
 */
function openShadowbox(_content, _title, _flashvars, _width, _height, _transparent)
{

	_flashparams = {bgColor:"#ffffff", allowFullScreen:'true'};	
	if(_transparent) {		
		_flashparams = {wmode:'transparent',allowFullScreen:'true'};
	}
	
	_title = "";
	Shadowbox.open({			    	
		content:    _content,
		player:     "swf",
		title:      _title,
		width:      _width,
		height:     _height,
		
		options: {
			flashParams: _flashparams, 
			flashVars: _flashvars		
		}
	});
}
function closeShadowBox() {	
	//Shdadowbox.clearCache();
	Shadowbox.close();
}
