var mth_short = { 'Jan':'1', 'Feb':'2', 'Mar':'3', 'Apr':'4', 'May':'5', 'Jun':'6', 'Jul':'7', 'Aug':'8', 'Sep':'9', 'Oct':'10', 'Nov':'11', 'Dec':'12' };
function confirm_redirect( msg, location ) {
	if ( confirm( msg ) ) {
		window.location.href=location;
	} else {
		return false;
	}
}

function change_visDiv(div_id) {
        hza = document.getElementById(div_id);
        if (hza==undefined) return 0;
        state = hza.style.display;
        if (state=='block') {
        	hza.style.display = 'none';
        } else {
        	hza.style.display = 'block';
        }
}

function in_array(array, element) {
    if(array && element) {
        try {
            if(array.indexOf(element) == -1) {
                return false;
            } else {
                return true;
            }
        } catch(exception) {
            var z = array.length;
            while(z--) {
                if(array[z] == element) {
                    return true;
                }
            }
        }
    }
    return false;
}
function changeColor(elem) {

	if ( typeof( elem.oldcolor ) == 'undefined' ) {
		
		elem.className = "selected_row"; 
		elem.oldcolor=1;
	} else {
		elem.className = elem.oldclass; 
		elem.oldcolor = undefined;
	}
}

function overColor(elem) {
	if (!elem.oldcolor) {
		elem.oldclass = elem.className;
		elem.className = "over_selected_row"; 
	}
}

function outColor( elem ) {
	if (!elem.oldcolor) elem.className = elem.oldclass; 
}
function refreshParent() {
	
	window.opener.location.href = window.opener.location.href;
	if (window.opener.progressWindow) {
		window.opener.progressWindow.close()
	}
	window.close();
	
}
function print_r(x, name, separator) {

	l = 0;
	max = 2;
	sep = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	separator = separator || '<br/>';
	name = name || 'unknown';

	if (l > max) {
		return "[WARNING: Too much recursion]" +separator;
	}

	var
		i,
		r = '',
		t = typeof x,
		tab = '';

	if (x === null) {
		r += "(null)" +separator;
	} else if (t == 'object') {

		l++;

		for (i = 0; i < l; i++) {
			tab += sep;
		}

		if (x && x.length) {
			t = 'array';
		}

		r += name + ' (' + t + ") :" +separator;

		for (i in x) {
			try {
				r += tab + '[' + i + '] : ' + print_r(x[i], '' , separator);
			} catch(e) {
				return "[ERROR: " + e + "]" +separator;
			}
		}

	} else {

		if (t == 'string') {
			if (x == '') {
				x = '(empty)';
			}
		}

		r += '(' + t + ') ' + x + "" +separator;

	}

	return r;

};
function loadScript(scriptSrc, scriptOnload) {
	var headID = document.getElementsByTagName("head")[0];         
	var newScript = document.createElement('script');
	newScript.type = 'text/javascript';
	newScript.src = scriptSrc;
	if(scriptOnload) {
		var loaded = false;
		newScript.onload = newScript.onreadystatechange = function () {
			try{
	    		var rs = this.readyState;
	    	} catch(e) {
	    		var rs = null;
	    	}
		    if (rs && rs!='complete' && rs!='loaded') return;
		    if (loaded) return;
		    loaded = true;
		    scriptOnload();
		}
		
	}
	headID.appendChild(newScript);
}
function show_hide_video_related() {
	var el = document.getElementById('vp_page_videos');
	var el_but = document.getElementById('vp_page_videos_but');
	if ( ( el.style.display === 'none' ) ) {
		el.style.display = '';
		el_but.innerHTML = 'hide videos';
	} else {
		el.style.display = 'none';
		el_but.innerHTML = 'show videos';
	}
}

function show_hide_div( divid, butid, hidetxt, showtxt ) {
	var el = document.getElementById( divid );
	var el_but = document.getElementById( butid );
	if ( ( el.style.display === 'none' ) ) {
		el.style.display = '';
		el_but.innerHTML = hidetxt;
	} else {
		el.style.display = 'none';
		el_but.innerHTML = showtxt;
	}
}

function getUrlPublishID() {
	var url_amadeus = window.location.href;
	var r = new RegExp('#play:([^:]*)');
	var publish = r.exec(url_amadeus);
	if ( publish !== null ) {
		return publish[1];
	} else {
		return false;
	}
}