if (self != top) {
	top.location.replace(location.href);
}

function stopDefault( e ) {
	if ( e && e.preventDefault ) e.preventDefault();
	else window.event.returnValue = false;
	return false;
}

var isFirefox = navigator.userAgent.indexOf("Firefox") != -1;
var isIE = navigator.userAgent.indexOf("MSIE") != -1;
var isOpera = navigator.userAgent.indexOf("Opera") != -1;
var isSafari = navigator.userAgent.indexOf("AppleWebKit") != -1;

var regx = {
	'email' : /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
}

var Cookies={
    createCookie:function(cn,cv,d,dm){
          var now=new Date();
          var expire=new Date();
          if(d==null||d==0)d=1;
           
          expire.setTime(now.getTime()+3600000*24*d);
          document.cookie=cn+"="+escape(cv)+";expires="+expire.toGMTString()+";domain="+dm+"; path=/";
    },
    deleteCookie:function(cn,dm){
          if(this.readCookie(name)){
         document.cookie=cn+"="+((domain)?"; domain="+dm:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";
          }
    },
    readCookie:function(cn){
		var dc=document.cookie;
		var prefix=cn+"=";
		var begin=dc.indexOf("; "+prefix);
           
		if(begin==-1){
			begin=dc.indexOf(prefix);
			if(begin!=0)return null;
		} else {
			begin+=2;
		}
    
		var end=document.cookie.indexOf(";",begin);    
		if(end==-1){end=dc.length;}        
		return unescape(dc.substring(begin+prefix.length,end));
    }         
}

var isLoaded = function(url) {
	if(document.images) {
		var urls = url.split(',');
		for(var i=urls.length-1; i>=0; i--) {
			var img = new Image();
			img.src = urls[i];
			if (img.complete) {
				continue;
			}
		}
	} else {
		return false;
	}
}

function copystr(text2copy,hint){
	if (window.clipboardData) {   
		window.clipboardData.setData("Text",text2copy);
	} else {
		var flashcopier = 'flashcopier';
		if(!document.getElementById(flashcopier)) {
			var divholder = document.createElement('div');
			divholder.id = flashcopier;
			document.body.appendChild(divholder);
		}
		document.getElementById(flashcopier).innerHTML = '';
		var divinfo = '<embed src="jslibs/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		document.getElementById(flashcopier).innerHTML = divinfo;
	}
	if(hint){
		var msg = hint;
		alert(msg);
	}
}


var is_exist = function(selector) {
	return $(selector)&&$(selector).size()>0 ? $(selector) : false;
};

var zebra = function(el) {
	$(function(){
		$('table.nozebra:children table').each(function(){
			$(this).addClass('nozebra');
		});
		var tbl = $('table:not(.nozebra)>tbody>tr');
		//if(tbl.size() > 2) {
			tbl.bind('mouseenter', function(){$(this).addClass('mson')}).bind('mouseleave', function(){$(this).removeClass('mson')}).filter('tr:odd').addClass('zebra');
		//}
		
		
	});
}

/**
 * extend jQuery
*/
$.fn.disable = function(){
	return this.each(function(){
		if(typeof this.disabled != 'undefined') this.disabled = true;
	});
}

$.fn.enabled = function(){
	return this.each(function(){
		if(typeof this.disabled != 'undefined') this.disabled = '';
	});
}

function SelectDate(obj){
	new WdatePicker({el:obj});
}
