/*==============================================================================
 location.hrefで移動
 引数：オブジェクト
 戻り値：なし
--------------------------------------------------------------------------------*/
function location_href( set_obj ){

	//----- メソッド準備
	var param = new Array();
	for( i in set_obj ){
		param.push( i + '=' + set_obj[i] );
	}

	location.href = location.pathname + '?' + param.join( '&' );

}
/*==============================================================================
 location.searchの取得
 引数：なし
 戻り値：オブジェクト
--------------------------------------------------------------------------------*/
function location_search(){

	var param = location.search.substr( 1 ).split( '&' );

	var hash = new Object();
	for( i = 0; i < param.length; i ++ ){
		if( param[i] == '' ) continue;
		var temp = param[i].split( '=' );
		hash[ temp[0] ] = temp[1];
	}

	return hash;

}
/*==============================================================================
 メソッド（アンパック）
--------------------------------------------------------------------------------*/
function method_unpack(){

	var param = location.search.substr( 1 ).split( '&' );
	var method = new Object();
	for( i = 0; i < param.length; i ++ ){
		var temp = param[i].split( '=' );
		method[ temp[0] ] = temp[1];
	}

	return method;


}
/*==============================================================================
 メソッド（パック）
--------------------------------------------------------------------------------*/
function method_pack( set_obj ){

	var method = new Array();
	for( i in set_obj ){
		if( set_obj[i] == undefined ) continue;
		method.push( i + '=' + set_obj[i] );
	}

	return method.join( '&' );

}
/*==============================================================================
 特定のメソッド入れ替えchange method
------------------------------------------------------------------------------*/
function cm( set_key, set_value ){

	var hash = method_unpack();//new Object();
	hash[ set_key ] = set_value;
	location.href = location.pathname + '?' + method_pack( hash );

}
function cm2( set_obj ){

	var hash = method_unpack();//new Object();
	for( var key in set_obj ){
		var value = set_obj[ key ];
		if( value ){
			hash[ key ] = value;
		}
		else {
			delete hash[ key ];
		}
	}
	location.href = location.pathname + '?' + method_pack( hash );

}
//----- 詳細の保存用
function renew( set_obj, set_page, set_target, set_id ){
	var source = $(set_page+'_'+set_target).innerHTML;
	source = source.replace( /<br>/ig, "\n" );
	source = source.replace( /<\/?span.*?>/ig, '' );
	source = source.replace( /&lt;/ig, '<' ).replace( /&gt;/ig, '>' ).replace( /&amp;/ig, '&' );
	ajax_request( set_obj,set_target,set_page,set_id,'renew=1&query='+encodeURIComponent( source ) );
}

//----- 種別の切り替え用
function ct( set_type ){
	location.href = location.pathname + ( set_type != undefined ? ( '?type=' + set_type ) : '' );
}

