//SHOW/HIDE
function showhide(div,openclose){
	thediv = document.getElementById(div);
	if(thediv.style.display == 'none' || openclose){
		thediv.style.display = 'inline';
	} else {
		thediv.style.display = 'none';
	}
	return true;
}
function showhideother(opendiv,closdiv){
	thediv = document.getElementById(opendiv);
	thediv.style.display = 'inline';
	
	var valueArray = closdiv.split(",");
	for(var i=0; i<valueArray.length; i++){
		thediv = document.getElementById(valueArray[i]);
		thediv.style.display = 'none';
	}
	return true;
}

//isNumeric
function isNumber(input){
   return (input - 0) == input && input.length > 0;
}

//TRIM
function trim(str) {
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}

//GET URL PARAM
function gup(name) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


//EVENTS
/*
function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
 	if(evType == 'beforeunload') var r = obj.attachEvent(evType, fn); 
 	else var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}
*/


//NEW WINDOW
rwin=null;
function openWindow(Path,FrameName,windwidth,windheight,windleft,windtop,menubar,scrollbars,resizable){
	rwin =  window.open(Path,FrameName,"menubar="+menubar+",scrollbars="+scrollbars+",resizable="+resizable+",width="+windwidth+",height="+windheight+",status=no,left="+windleft+",top="+windtop);
		if (rwin!= null){
			setTimeout ("rwin.focus();",200);
		}
	return true;
}

//FIELD NAMES
function markEmpty() {
	
	$('.mark_empty').each(function () { 
		var field_name = $(this).attr('rel');
		if ($(this).val() == '') { 
			$(this).val(field_name);
			$(this).addClass('highlight_empty');
		}
		else if ($(this).val() == field_name) {
			$(this).addClass('highlight_empty');
		}
	
		$(this).focus(function () {
			if ($(this).val() == field_name) {
				$(this).removeClass('highlight_empty');
				$(this).val('');
			}
		});
	
		$(this).blur(function () {
		if ($(this).val() == '') {
			$(this).val(field_name);
			$(this).addClass('highlight_empty');
		}
		});
	});
	
}

/* Jquery GET URL VAR*/
$.urlParam = function(name){
	var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
	if (!results) { return 0; }
	return results[1] || 0;
}


