function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure ){ var cookie_string = name + "=" + escape ( value ); if (exp_y) { var expires = new Date ( exp_y, exp_m, exp_d ); cookie_string += "; expires=" + expires.toGMTString(); } if (path) cookie_string += "; path=" + escape ( path ); if (domain) cookie_string += "; domain=" + escape ( domain ); if (secure) cookie_string += "; secure"; document.cookie = cookie_string; } function get_cookie ( cookie_name ){ var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' ); if (results) return ( unescape ( results[2] ) ); else return null; } function delete_cookie ( cookie_name ){ var cookie_date = new Date ( ); // current date & time cookie_date.setTime ( cookie_date.getTime() - 1 ); document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString(); } function display_element(id,mode){ var target=document.getElementById(id); if(target.style.display==''){ target.style.display='none'; }else{ target.style.display=''; } return false; if(mode=='show'){ target.style.display=''; }else if(mode=="hide"){ target.style.display='none'; }else{ target.style.display='none'; } return false; } function confirm_delete(){ return window.confirm("Are you sure you want to delete this record?"); } function IsValidEmail(emailid){ var targt=document.getElementById(emailid); targt.focus(); var str = targt.value; var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,4})(\]?)$/; // valid if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid return true; }else{ alert("Please enter a valid Username!"); return false; } } function validate_User_form(nform){ if(!IsValidEmail('t_UserName')){ return false; } if(!nform.t_fname.value){ alert("Please enter your first name!"); nform.t_fname.focus(); return false; } if(!nform.t_lname.value){ alert("Please enter your last name!"); nform.t_lname.focus(); return false; } if(!nform.i_AccessLevel.value){ alert("Please select an access level!"); nform.i_AccessLevel.focus(); return false; } return true; } function display_hide_rows(row2showid,row2hideid){ var row2show = document.getElementById(row2showid); var row2hide = document.getElementById(row2hideid); row2show.style.display=''; row2hide.style.display='none'; return false; } function validate_books_caegory(nform){ if(!nform.t_Category_Name.value){ alert("Please enter category name!"); nform.t_Category_Name.focus(); return false; } /*if(!nform.i_CategoryParentID.value){ alert("Please select parent category!"); nform.i_CategoryParentID.focus(); return false; }*/ return true; } function validate_Publisher(nform){ if(!nform.publishername.value){ alert("Please enter Publisher name!"); nform.publishername.focus(); return false; } } function valdiate_book_author(nform){ if(!nform.t_AuhtorName.value){ alert("Please enter Author Name!"); nform.t_AuhtorName.focus(); return false; } if(!nform.author_image.value){ alert("Please add Author image!"); nform.author_image.focus(); return false; } if(nform.authorimages.value.trim()){ ar=nform.authorimages.value.split("."); ext=ar[ar.length-1].toLowerCase(); if(ext!='jpg' && ext!='jpeg' && ext!='gif'){ alert("Invalid File Type allowed: jpg,jpeg and gif"); return false; } } return true; } function valdiate_book_author_add(nform){ if(!nform.t_AuhtorName.value.trim()){ alert("Please enter Author Name!"); nform.t_AuhtorName.focus(); return false; } if(!nform.LangID.value.trim()){ alert("Please select Language!"); nform.LangID.focus(); return false; } if(nform.author_image1.value.trim()){ ar=nform.author_image1.value.split("."); ext=ar[ar.length-1].toLowerCase(); if(ext!='jpg' && ext!='jpeg' && ext!='gif'){ alert("Invalid File Type allowed: jpg,jpeg and gif"); return false; } } return true; } String.prototype.trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); } /* function validate_author(nform){ if(!nform.t_AuhtorName.value.trim()){ alert("Please enter author name!"); nform.t_AuhtorName.focus(); return false; } if(!nform.t_AuhtorName.value.trim()){ alert("Please enter author name!"); nform.t_AuhtorName.focus(); return false; } return true; }*/ function hide_unchecked(id,id2){ if(id.checked==true){ document.getElementById(id2).style.display=""; }else{ document.getElementById(id2).style.display="none"; } } function MessageLang() { alert("Comming Soon"); } function CheckValidEmail(NForm){ NForm.username.focus(); var str = NForm.username.value; var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,4})(\]?)$/; // valid if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid return true; }else{ alert("Please enter a valid Email!"); return false; } } function validate_register(rform){ var fname =document.getElementById("NewFirst").value; var lname =document.getElementById("NewLast").value; var pass =document.getElementById("Password").value; var confpass =document.getElementById("ConfPassword").value; if(fname==""){ alert("Please enter your First Name!"); return false; } if(lname==""){ alert("Please enter your Last Name!"); return false; } if((pass!="")&&(confpass=="")){ alert("Please enter a Confirmation Password!"); return false; } if(pass!=confpass){ alert("Password is not confirmed correctly!"); return false; } return true; } function validate_password(rform){ var passnew = rform.newpass.value; var passconf = rform.confpass.value; if(passnew.length==0){ alert("Please enter a new password!"); return false; } if(passconf.length==0){ alert("Please confirm your new password!"); return false; } if(passnew != passconf){ alert("Password is not confirmed correctly!"); return false; } return true; } function validate_contactUs(cform){ var fname=cform.fname.value; var comment= cform.comment.value; if(fname==""){ alert("Please enter your First Name!"); return false; } if(!CheckValidEmail(cform)){ return false; } if(comment==""){ alert("Please write a comment!"); cform.comment.focus(); return false; } if(document.getElementById("code").value==""){ alert("Please type in the characters!"); document.getElementById("code").focus(); return false; } return true; }