/**
 * @author cashbit
 */

function MxKartCheckForCombination(WantedCondition, Conditions){
	
	var i = Conditions.checklist[WantedCondition] ;
	var ok = true ;
	for (var combi in Conditions.combinations){
		if (Conditions.combinations[combi][i]) {
			if (Conditions.styles.clear) {
				Ext.get(combi).applyStyles(Conditions.styles.clear);
			}
			var v = Ext.get(combi).getValue() ;
			var v = MxKartTrim(v) ;
			var localok = (v != '');
			if (Conditions.styles){
				if (localok){
					Ext.get(combi).applyStyles(Conditions.styles.ok) ;
				} else {
					Ext.get(combi).applyStyles(Conditions.styles.ko) ;
				}
			}
			if (ok) {
				ok = localok ;
			}
		}
	}
	return ok ;
	
}

function MxKartCheckMail(value)
{
	var x = value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) 
		return true;
	else 
		return false;
}

function MxKartTrim(str){
	return str;
	//return str.replace(/^s+/, '').replace(/s+$/, '');
}

function js2php(obj,path,new_path) {
  if (typeof(path) == 'undefined') var path=[];
  if (typeof(new_path) != 'undefined') path.push(new_path);
  var post_str = [];
  if (typeof(obj) == 'array' || typeof(obj) == 'object') {
    for (var n in obj) {
      post_str.push(js2php(obj[n],path,n));
    }
  }
  else if (typeof(obj) != 'function') {
    var base = path.shift();
    post_str.push(base + (path.length > 0 ? '[' + path.join('][') + ']' : '') + '=' + encodeURI(obj).replace('&','%26'));
    path.unshift(base);
  }
  
  path.pop();
  return post_str.join('&');
}