post_arg = Class.create();
post_arg.prototype = {
	'key': null,
	'val': null,
	initialize: function(variable, value){
		this.key = variable;
		this.val = value;
	},
	getKey: function(){
		return this.key;
	},
	getVal: function(){
		return this.val;
	}
}

function post_main(auto_data, data, current_view){
	var postvar; 
	var customdata = Array();
	var isViewDefined = false;
	var frm=document.createElement('form'); frm.name='frm_postback_'+randomString(5); frm.method = 'post'; frm.action='index.php';
	for(i=0; i<data.length; i++){
		if(data[i].getKey() == 'view'){
			isViewDefined = true;
		}
		customdata.push(data[i].getKey());
		postvar=document.createElement('input'); postvar.type = 'hidden'; postvar.name=data[i].getKey(); postvar.value=data[i].getVal(); frm.appendChild(postvar);
	}
	for(i=0; i<auto_data.length; i++){
		if(customdata.indexOf(auto_data[i].getKey())<0){
			if(auto_data[i].getKey() == 'view'){
				isViewDefined = true;
			}
			postvar=document.createElement('input'); postvar.type = 'hidden'; postvar.name=auto_data[i].getKey(); postvar.value=auto_data[i].getVal(); frm.appendChild(postvar);
		}
	}
	if(!isViewDefined){
		postvar=document.createElement('input'); postvar.type = 'hidden'; postvar.name='view'; postvar.value=current_view; frm.appendChild(postvar);
	}
	document.body.appendChild(frm);
	frm.submit();
	return true;
}

function randomString(length){
	chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	str = "";
	for(x=0;x<length;x++){
		i = Math.floor(Math.random() * 62);
		str += chars.charAt(i);
	}
	return str;
}