/*** this file defines js functions the application
	 *** @modified: Friday, November 28th 2008
	 *** @author:   www.pixelsonpoint.com
	 --------------------------------------------------------------*/

	// shortcut for dom getelementbyid
	function get_id (str_el) { return document.getElementById(str_el); }
	
	// show element.. change display
	function show_element ( str_el ) {
		str_el	=	get_id(str_el);		
		if( str_el ) str_el.className = str_el.className.replace('hidden', '');;		
	}
	
	// hide element.. change display
	function hide_element ( str_el ) {
		str_el	=	get_id(str_el);
		str_el.className.replace('hidden', '');
		str_el.className = (str_el.className == '') ? 'hidden' : str_el.className+' hidden';		
	}
		
	// hide element.. change display
	function show_hide_element ( str_ell ) {
		str_el	=	get_id(str_ell);
		if (str_el.className.indexOf("hidden") != -1 ) {	// hidden
			show_element(str_ell);
		} else {
			hide_element(str_ell)
		}
	}
	
	function display_message ( str_msg, str_typ )	{
		msg_box	=	get_id('msg-box');
		msg_box.className = str_typ;
		msg_box.innerHTML = str_msg;
		show_element(get_id('msg-box'));
		clear_info_bar('');
	}
	
	// hide info bar if its being displayed
	function clear_info_bar(mode) {
		tmr_info = setTimeout("clear_info_bar('yes')", 5000)
		if (mode == 'yes') {
			if (get_id('msg-box').className != "hidden") {
				hide_element('msg-box');
				clearTimeout(tmr_info);
			}
		}
	}
	
	function confirm_action(msg, action) {
		if (confirm(msg)) {
			if (action != '') {
	  	location.href = action;
	  }else{
			return true;
		}
		} else {
			 return false;			
		}
	}
  
	function validate(str_els, display_where) {
		arr_els = str_els.split(",");
		for (i=0; i < arr_els.length; i++ ) {
			el = get_id(arr_els[i]);
			if (el.value == '') {
        		show_element(display_where);
				el.className = 'error';
				el.focus();
				return false;
			}
		} return true;
	}
	
    function do_toggling(el) {
        current = get_id('toggler');
        if (current.value != '') {
			el2 = current.value.replace("dv-","pdv-");
            hide_element(current.value);
			get_id(el2).className = get_id(el2).className.replace("minus","plus");
        }   show_element(el);
            current.value = el;
			el2 = el.replace("dv-","pdv-");
			get_id(el2).className = get_id(el2).className.replace("plus","minus");
    }
    
    function check_email(fld) {
        if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(get_id(fld).value)){
            return (true)
        }
        alert("Invalid E-mail Address! Please re-enter.")
        return (false)
    }
	
	function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
	}
    
    function bookmarksite(title,url){
	    if (window.sidebar) // firefox
	        window.sidebar.addPanel(title, url, "");
	    else if(window.opera && window.print){ // opera
	        var elem = document.createElement('a');
	        elem.setAttribute('href',url);
	        elem.setAttribute('title',title);
	        elem.setAttribute('rel','sidebar');
	        elem.click();
	    } 
	    else if(document.all) { // ie
	        window.external.AddFavorite(url, title);
	    }
	}
	
	function to_tabbing(el1, el2) {
		t1 = get_id('tab1');
		t2 = get_id('tab2');
		t3 = get_id('tab3');
		
		tc1 = get_id('tabc1');
		tc2 = get_id('tabc2');
		tc3 = get_id('tabc3');
		
		t1.className = t2.className = t3.className = "";
		tc1.className = tc2.className = tc3.className = "hidden";
		get_id(el1).className = "selected";
		show_element(el2);
	}
