var url = (location.search).split('=');
if(url[1] != null){
	var tmp = url[1].replace(/\+/g, '');
	jQuery('span.typeselect option').each(
		function(i){
			var value = encodeURI((jQuery(this).val()).replace(/\ /g, ''));
			if(value == tmp){
				jQuery(this).attr('selected','selected');
			}
		}
	);
}
function typecheck(){
	var plan = jQuery('span.typeselect option:selected').val();
	
	jQuery('span.planselect option').remove();
	jQuery('<option value="---">---</option>').appendTo('span.planselect select');
	jQuery('<option value="STARTER">STARTER</option>').appendTo('span.planselect select');
	jQuery('<option value="BASIC">BASIC</option>').appendTo('span.planselect select');
	jQuery('<option value="VALUE">VALUE</option>').appendTo('span.planselect select');
	jQuery('<option value="ENHANCED">ENHANCED</option>').appendTo('span.planselect select');
	jQuery('<option value="PREMIUM">PREMIUM</option>').appendTo('span.planselect select');
	
	if( ( plan == '共有ホスティング' ) || ( plan == 'cPanel VPS ホスティング' ) ){
		jQuery('span.planselect option:contains("STARTER")').remove();
		jQuery('span.planselect option:contains("VALUE")').remove();
	}else if( ( plan == '専用 Linux ホスティング' ) || ( plan == 'Windows VPS ホスティング' ) ){
		jQuery('span.planselect option:contains("STARTER")').remove();
		jQuery('span.planselect option:contains("BASIC")').remove();
	}else if( plan == 'Linux VPS ホスティング' ){
		jQuery('span.planselect option:contains("BASIC")').remove();
	}else{
		jQuery('span.planselect option').remove();
	}
}

jQuery(document).ready(function(){
	jQuery('.global ul.sub-menu').hide();
	jQuery('.global li:has("ul")').hover(
		function(){jQuery('.global ul.sub-menu').slideDown('fast');},
		function(){jQuery('.global ul.sub-menu').delay(200).slideUp('fast');}
	);

    var sets = [], temp = [];
	jQuery('.double .text').each(function(i){temp.push(this);if (i % 2 == 1){sets.push(temp); temp = [];}});if(temp.length) sets.push(temp);jQuery.each(sets, function(){jQuery(this).flatHeights();});
    var sets = [], temp = [];
	jQuery('.double ul').each(function(i){temp.push(this);if (i % 2 == 1){sets.push(temp); temp = [];}});if(temp.length) sets.push(temp);jQuery.each(sets, function(){jQuery(this).flatHeights();});
    var sets = [], temp = [];
	jQuery('.triple .text').each(function(i){temp.push(this);if (i % 3 == 2){sets.push(temp); temp = [];}});if(temp.length) sets.push(temp);jQuery.each(sets, function(){jQuery(this).flatHeights();});
    var sets = [], temp = [];
	jQuery('.triple ul').each(function(i){temp.push(this);if (i % 3 == 2){sets.push(temp); temp = [];}});if(temp.length) sets.push(temp);jQuery.each(sets, function(){jQuery(this).flatHeights();});
	
	jQuery('.side-module tr:nth-child(2n)').addClass('even');

	typecheck();
	jQuery('span.typeselect select').focusout(function(){
		jQuery(this).parent().children().attr('selected', false);
		jQuery(this).attr('selected','selected');
		typecheck();
	})
});

