//======================================================================================= /* Dynamic Script V.1 Creator: Paulo Corcino Functions: init, ajaxload,, isemail, allcampquery */ //======================================================================================= // JavaScript Document //--------------------------------------------------------------------------- //Previw Image - cod: previewImg documentall = document.all; //--------------------------------------------------------------------------- function ispocket(){ if(screen.width<640) return true; else return false; } //-------------------------------------------------------------------------- var IPocket = 0; if(ispocket()){ IPocket = 1; }else{ IPocket = 0; } //--------------------------------------------------------------------------- function listobjcols(t,c){ //AjaxLoad("fields.asp","table="+t,c); listcolsstat(t); } //--------------------------------------------------------------------------- function actioncol(obj,v){ obj.value = v; //alert(obj.value); } //--------------------------------------------------------------------------- function isIE(){ if(navigator.appName=='Microsoft Internet Explorer') return true; else return false; } //--------------------------------------------------------------------------- function data(){ var datas = new Date(); //document.write(datas.getHours()); return datas.getSeconds(); tId = setTimeout("data()",1000); } //--------------------------------------------------------------------------- function abrir(url){ if(ispocket()) parent._nome.location.href = url; else window.open(url,"_nome"); } //--------------------------------------------------------------------------- function WindowOpen(url){ if(ispocket()) window.location.href = url; else window.open(url,"_self"); } //--------------------------------------------------------------------------- function DeleteCookie (name) { var exp = new Date(); //var cval = GetCookie (name); document.cookie = name + "=off; expires=" + exp.toGMTString(); } //--------------------------------------------------------------------------- function getrandom(){ var ran_unrounded=Math.random()*9999999; var ran_number=Math.round(ran_unrounded); return ran_number; } //--------------------------------------------------------------------------- function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--------------------------------------------------------------------------- function MsgDia(){ var hora = new Date(); var Msg = ""; if(hora.getHours()>=18) Msg = "Boa Noite"; else if(hora.getHours()>=12) Msg = "Boa Tarde"; else Msg = "Bom Dia"; return Msg; } //--------------------------------------------------------------------------- function OpGerarSel(v) { if(v==0) { document.form.qtsPrint.value = ''; document.form.qtsPrint.disabled = true; } else { document.form.qtsPrint.disabled = false; document.form.qtsPrint.value = 0; } } //Request Camp - cod: allCampQuery //------------------------------------------------------------------------------- //--------------------------------------------------------------------------- function allCampQuery(n) { var nForms = document.forms.length - 1; var nForm; for(i=0; i<=nForms; i++){ //alert(document.forms[i].name) if(document.forms[i].name == n){ nForm = i; } } var nFormElements = document.forms[nForm].elements.length - 1; var nFormElement = document.forms[nForm].elements; var nQuery=''; for(i=0;i<=nFormElements;i++) { //analiza se o elemento é um checkbox ou um radio if(nFormElement[i].name.slice(0,3) != "chk" && nFormElement[i].name.slice(0,3) != "rdo") { //campos comuns if(i!=0) nQuery = nQuery + "&"+nFormElement[i].name+"="+escape(nFormElement[i].value); else nQuery = nFormElement[i].name+"="+escape(nFormElement[i].value); } else { //check box ou radio if(nFormElement[i].checked) { if(i!=0) nQuery = nQuery + "&"+nFormElement[i].name+"="+escape(nFormElement[i].value); else nQuery = nFormElement[i].name+"="+escape(nFormElement[i].value); } } } //alert(nQuery.substring(0,1)); if(nQuery.substring(0,1)=="&") { //alert(nQuery.substring(1,nQuery.length)); nQuery = nQuery.substring(1,nQuery.length); } return nQuery; } //Ajax Load - cod: AjaxLoad //------------------------------------------------------------------------------- //--------------------------------------------------------------------------- function AjaxLoad(pg,query,camada) { //-------------------------------- // Ajax - Paulo Corcino - 1.5 //-------------------------------- var http = null; //variavel //-------------------------------------------------------------- // Detecta o componentes XML //--------------------------------------------------------------- if (typeof XMLHttpRequest != "undefined") { http = new XMLHttpRequest(); }else if (window.ActiveXObject){ var aVersions = ["MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp","Microsoft.XMLHttp"]; for (var i = 0; i < aVersions.length; i++) { try{ var http = new ActiveXObject(aVersions[i]); } catch(oError){ //Do nothing } } } //----------------------------------------------------------------------- // Página do Post //----------------------------------------------------------------------- web = pg; //------------------------------------------------------------------------ // Envio dos Dados //------------------------------------------------------------------------ http.open('post', web, true); //document.getElementById(camada).innerHTML = '
Carregando....
'; http.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); // http.setRequestHeader("Connection", "close"); try{ http.setRequestHeader('Content-length', query.length ); } catch(oError){ http.setRequestHeader('Content-length', 24 ); } //----------------------------------------------------------------------- // Leitura de Dados //----------------------------------------------------------------------- http.onreadystatechange = function() { if(http.readyState == 4){ // if (http.status == 200) { document.getElementById(camada).innerHTML = unescape(http.responseText.replace(/\+/g,' ')); //}else{ // document.getElementById(camada).innerHTML = "
Erro na abertura da página: " + http.status + " - " + http.statusText + "
"; //} } }; //------------------------------------------------------------------------ // Captura a Pagina //------------------------------------------------------------------------ if(query!=''){ iTimeoutId = setTimeout(function(){http.send(query);},800); }else{ iTimeoutId = setTimeout(function() {http.send(null);},800); } } //Valid E-Mail - cod: isEmail //------------------------------------------------------------------------------- function isEmail(n){ var email = n; var emailsufix; //valida se contem o arroba if(email.lastIndexOf("@") > 0) { //verifica se o primeiro caracter é um @ if(email.slice(0,1)!="@") { //verfica se existe algo após o @ emailsufix = email.slice(email.lastIndexOf("@")+1,email.length); //dominio do e-mail if(emailsufix.length > 0) { //verifica a existencia de um . para deduzir que foi digitado o dominio if(emailsufix.lastIndexOf(".") > 0) { email = true; } else { email = false; } } else { email = false; } } else { email = false; } } else { email = false; } return email; } //---------------------------------------------------------