var _POPUP_FEATURES = 'location=1, statusbar=1, menubar=1, toolbar=1, scrollbars=1, resizable=1, width=1024, height=768';
var _LOGIN = 'location=0, statusbar=0, menubar=0, toolbar=0, scrollbars=1, resizable=1, width=1024, height=600';

function raw_popup(url, target, features) {
    if (isUndefined(features)) features = _POPUP_FEATURES;
    if (isUndefined(target  )) target   = '_blank';
    var theWindow = window.open(url, target, features);
    theWindow.focus();
    return theWindow;
}

function link_popup(src, features) {
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

function isUndefined(v) {
    var undef;
    return v===undef;
}

function doSubmit(frm) {
	if (tmt_validateForm(frm)) {
		frm.submit();
		return true;
   	}
	return false;
}


function getIndexValue(thisElement) {
	return document.getElementById(thisElement)[document.getElementById(thisElement).selectedIndex].value
}

/* 

	Blankwin function 
	written by Alen Grakalic, provided by Css Globe (cssglobe.com)
	please visit http://cssglobe.com/post/1281/open-external-links-in-new-window-automatically/ for more info
	
*/

this.blankwin = function(){
	var hostname = window.location.hostname;
	hostname = hostname.replace("www.","").toLowerCase();
	var a = document.getElementsByTagName("a");	
	this.check = function(obj){
		var href = obj.href.toLowerCase();
		return (href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? true : false;				
	};
	this.set = function(obj){
		obj.target = "_blank";
		obj.className = "external";
	};	
	for (var i=0;i<a.length;i++){
		if(check(a[i])) set(a[i]);
	};		
};

this.ieBorder = function(){
	var a = document.getElementsByTagName("img");	

	this.check = function(obj){
		var src = obj.src;
		return (src.indexOf("border")!=-1) ? true : false;				
	};
	this.set = function(obj){
		obj.src = "default/images/ie_border2.gif";
		obj.style.display = "block";
	};	
	for (var i=0;i<a.length;i++){
		if(check(a[i])) set(a[i]);
	};		
}


this.addEvent = function(obj,type,fn){
	if(obj.attachEvent){
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn](window.event );}
		obj.attachEvent('on'+type, obj[type+fn]);
	} else {
		obj.addEventListener(type,fn,false);
	};
};

addEvent(window,"load",blankwin);

/* show/hide layers */

	function HideContent(d) {
		if(d.length < 1) { return; }
		document.getElementById(d).style.display = "none";
	}
	function ShowContent(d) {
		if(d.length < 1) { return; }
		document.getElementById(d).style.display = "block";
	}
	function ReverseContentDisplay(d) {
		if(d.length < 1) { return; }
		if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
		else { document.getElementById(d).style.display = "none"; }
	}
