//(c) 2005-2011 by AD
function opw(p,n,w,h){
	var w=window.open(p,n,'toolbar=no,scrollbars=yes,width='+w+',height='+h+',resizable=yes',false);
	w.focus();
}
function opwns(p,n,w,h){
	var w=window.open(p,n,'toolbar=no,scrollbars=no,width='+w+',height='+h+',resizable=yes',false);
	w.focus();
}
function printo(obj){
	if (typeof(console)!='undefined' && console.debug) console.debug(obj);
}
function trim(s){
	if (typeof(s)!='string') s='';
	return s.replace(/^\s+|\s+$/g,'');
}
function chkemail(fld,msg){
	var r=/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@[a-zA-Z0-9]([a-zA-Z0-9_-])*(\.[a-zA-Z0-9_-]+)+$/;
	var str=trim(fld.value);
	if (r.test(str)) return true;
	else{alert(msg);fld.focus();return false;}
}
function chktxtfld(fld,msg1,msg2,len){
	var str=trim(fld.value);
	if (str.length==0){alert(msg1);fld.focus();return false;}
	else if (str.length>len){alert(msg2.replace(/\{0\}/,len));fld.focus();return false;}
	else return true;
}
function delegate(fnc,cntx,args){
	if (args==(void 0)) args=[];
	return function(){fnc.apply(cntx,args);};
}

if (typeof(MIV)=='undefined') MIV={};

//per i 'blocking scripts'
MIV.addScript = function(url, c, cb) {
	var g = document.createElement('script'),
		s = document.getElementsByTagName('script')[0];
	g.type = 'text/javascript';
	g.async = true;
	g.src = url;
	if (c) try {g.innerHTML = c;}catch(ex){}
	if (cb) {
		g.onload = cb;
		// IE 6 & 7
		g.onreadystatechange = function() { if (this.readyState == 'complete') cb(); }
	}
	s.parentNode.insertBefore(g, s);
};
