
lsjs.namespace('ti.lib');

ti.lib.win = function (url,x,y,name,isscrollbars) {
   var cx=screen.width / 2 - (x / 2);
   var cy=(screen.height/2 -(y / 2));
   isscrollbars=(isscrollbars=="no")?"no":"yes";
   window.open(url,name,"toolbar=no,status=no,directories=no,menubar=no,resizable=yes,width="+x+",height="+y+",scrollbars="+isscrollbars+",top="+cy+",left="+cx);

};

ti.lib.checkWin = function(obj) {
    ti.lib.win(obj.href, 780, 580, "");
    return false;
};

ti.lib.orderWin = function(obj) {
    ti.lib.win(obj.href, 1024, 768, "");
    return false;
};

ti.lib.bookmark = function(filterSet, prefix) {					    
	ti.lib.win(filterSet.getDataQuery(prefix+"/window/bookmark/?"),300,200,"","yes");
}


lsjs.namespace('ti.component.idSearch');

ti.component.idSearch.idSearchSubmit = function (form) {
    if(ti.component.idSearch.inputIdSearchClick(form.offerId)) {
    	ti.lib.win(form.action + '?uid=' + form.offerId.value, 800, 600);
    } else {
    	$('#search-id-help').overlay().show().centering(1,1);
    }
    return false;
};

ti.component.idSearch.btnIdSearchClick = function (form) {
    ti.component.idSearch.idSearchSubmit(form);
};

ti.component.idSearch.inputIdSearchClick = function (sender) {
    if(sender.value.length > 20 || sender.value.length==0 || !sender.value.match(/(^[0-9]{1,18}@[0-9]{3}$)|(^[0-9]{3,5}$)|(^[0-9]{1,2} [0-9]{3}$)/)) {
        sender.value = '';
        return false;
    }
    return true;
};

