var TLDs=new Array();var Domains=new Array();var numberOfSelectedDomains=0;function addElement(b,d,a){var c=document.getElementById("whois"+a+"ResultDiv");var f=document.createElement("div");var e="whois_res_"+b;f.setAttribute("id",e);f.innerHTML=d;c.appendChild(f);return e}function removeElement(c,b){var a="whois_res_"+c;var e=document.getElementById(a);var d=document.getElementById("whois"+b+"ResultDiv");d.removeChild(e)}function displayError(a,b,d){$("#loading").fadeOut("slow");try{if(b=="timeout"){alert("Κάποιο σφάλμα προέκυψε στη σύνδεση, παρακαλούμε προσπαθήστε πάλι.")}}catch(c){}}function addFavouriteDomain(b,c){var a=USER_ID;if(a==-1){alert("Η υπηρεσία είναι ενεργή σε εγγεγραμένους χρήστες.")}else{$.ajax({type:"POST",dataType:"json",timeout:10000,url:"include/ajax_php/manageDomainsAjax.php?skey="+SK_MANAGE_DOMAINS,data:"domain="+b+"&user_id="+USER_ID+"&action=add_domain_favourite",success:function(d){if(d=="0"){document.getElementById(c).innerHTML='<br>Το Domain προστέθηκε στα αγαπημένα σας. <br><a href="members/favourites.php">Θέλω να δω την λίστα των "Favourite Domains" μου</a> '}else{document.getElementById(c).innerHTML="Το Domain δεν προστέθηκε. Παρακαλώ δοκιμάστε πάλι."}},error:displayError})}}function makeCompactRequest(){document.getElementById("whoisResultDiv").innerHTML="";document.getElementById("whoisCompactResultDiv").style.display="block";d=0;var a=new Array();for(i=0;i<Domains.length;i++){for(j=0;j<TLDs.length;j++){a[d]=Domains[i]+"."+TLDs[j];d++}}var g=a.join(",");$("#submitDomainToRegister").fadeOut("slow");$("#showTabs").fadeOut("slow");$("#result_title").fadeIn("slow");var e=document.getElementById("whoisCompactResultDiv");e.innerHTML="";$("#myBox_search_div").block({message:null});var b=2;var f=a.length;var c=(f-(f%b))/b;if((f%b)>0){c=c+1}var d=0;for(i=0;i<c;i++){for(j=0;j<b;j++){if(d<a.length){domnain_underscore=a[d].replace(/\./g,"_");div_id="DomainToRegister_"+domnain_underscore;div_id_checkbox=domnain_underscore+"_checkbox";div_id_domain=domnain_underscore+"_domain";txtDomain=a[d];loading_txt='<div id="'+div_id+'_DIV" style="width:45%; float:left; cursor: pointer; margin-bottom: 5px; border: 1px dotted #DDDDDD; padding-left: 10px; padding-bottom: 10px; padding-top: 10px; margin-right: 2px; background-color: #f7f7f7;">';loading_txt+='<div id="'+div_id_checkbox+'" style="width:20px; float:left;">';loading_txt+='<img src="media/images/ajax_loading_13x13.gif" />';loading_txt+="</div>";loading_txt+='<div id="'+div_id_domain+'" style="float:left; margin-top: -2px">';loading_txt+=txtDomain;loading_txt+="</div>";loading_txt+='<input name="'+div_id+'" id="'+div_id+'" type="hidden" value="'+a[d]+'" disabled="true">';loading_txt+="</div>"}else{loading_txt='<div style="width:45%; float:left; margin-bottom: 5px; padding-left: 10px; padding-bottom: 10px; padding-top: 10px; margin-right: 2px; ">';loading_txt+="&nbsp;&nbsp;&nbsp;&nbsp;</div>"}addElement(d,loading_txt,"Compact");d++}}$.ajax({type:"POST",dataType:"json",timeout:100000,async:true,url:"include/ajax_php/whoisAjax.php?skey="+SK_WHOIS_DOMAIN,data:"domain="+g+"&action=check_domains",success:function(k){for(i=0;i<k.length;i++){var n=k[i].Domain.replace(/_/g,".");div_id="#DomainToRegister_"+k[i].Domain+"_DIV";div_id_2="DomainToRegister_"+k[i].Domain+"_DIV";div_id_checkbox="#"+k[i].Domain+"_checkbox";if(k[i].isFree=="1"){$(div_id).click(function(){c_id=$(this).attr("id").replace(/_DIV/g,"");addDomainToList(c_id,c_id)});$(div_id_checkbox).html('<img src="media/icons/checkbox.gif" title="Επιλογή Domain Name" id="DomainToRegister_'+k[i].Domain+'_CHECK" style="padding-right: 5px">')}else{$(div_id_checkbox).html('<img src="media/icons/checkbox_not_avail.gif" title="Το Domain δεν είναι διαθέσιμο" style="padding-right: 5px">');$(div_id).css({cursor:"default"})}if(k[i].isFree==1||k[i].isFree==0){var h=new Date();var o=h.getMonth()+1;var q=h.getDate();var p=h.getFullYear();var u=q+"/"+o+"/"+p;var l=n;var r=k[i].isFree+"|"+u;$.setSubCookie(whoisCookieName,l,r);var t=$.getCookie(whoisCookieName);d=0;var m;for(var s in t){if(t.hasOwnProperty(s)){if(d===0){m=s}d++}}if(d>maxWhoisCookieLength){delete t[m];$.setCookie(whoisCookieName,t)}}}$("#submitDomainToRegister").fadeIn("slow");$("#myBox_search_div").unblock();txtRes=""}});return true}function makeRequestWrapper(){getDomains();var a=getCheckedTLDs();if(a===0){alert("Πρέπει να επιλέξετε τουλάχιστον μια κατάληξη ονομάτων.");return false}if(!checkDomain_without_TLD("domain")){return false}var b=$("input[name=whois_type]:checked").val();if(b=="compactCheck"){return makeCompactRequest()}else{return makeRequest()}}function makeRequest(){document.getElementById("whoisCompactResultDiv").innerHTML="";document.getElementById("whoisResultDiv").style.display="block";$("#submitDomainToRegister").fadeOut("slow");$("#showTabs").fadeOut("slow");$("#result_title").fadeIn("slow");var b=document.getElementById("whoisResultDiv");b.innerHTML="";$("#myBox_search_div").block({message:null});var a=0;var c="";for(i=0;i<Domains.length;i++){c=trim11(Domains[i]);if(c!==""){for(j=0;j<TLDs.length;j++){loading_txt='<table height="75px"><tr><td><img src="media/images/loader.gif" alt="whois"></td><td><b>&nbsp;&nbsp;Αναζήτηση για '+c+"."+TLDs[j]+"</b></td></tr></table>";addElement(a,loading_txt,"");a++}}}a=0;for(i=0;i<Domains.length;i++){c=trim11(Domains[i]);for(j=0;j<TLDs.length;j++){$.ajax({type:"POST",dataType:"json",timeout:100000,async:true,url:"include/ajax_php/whoisAjax.php?skey="+SK_WHOIS_DOMAIN,data:"domain="+c+"&action=whois&tld="+TLDs[j]+"&count="+a,success:function(f){var k=f.Domain.replace(/_/g,".");var l=f.txtRes;var e=f.count;removeElement(e,"");if(f.isFree==1){addElement(a,l,"")}else{if(f.isFree==0){addElement(a,l,"")}else{if(f.isFree==-1){addElement(a,l,"")}}}if(f.isFree==1||f.isFree==0){var d=new Date();var m=d.getMonth()+1;var o=d.getDate();var n=d.getFullYear();var s=o+"/"+m+"/"+n;var g=k;var p=f.isFree+"|"+s;$.setSubCookie(whoisCookieName,g,p);var r=$.getCookie(whoisCookieName);a=0;var h;for(var q in r){if(r.hasOwnProperty(q)){if(a===0){h=q}a++}}if(a>maxWhoisCookieLength){delete r[h];$.setCookie(whoisCookieName,r)}}l=""}});a++}}$("#submitDomainToRegister").fadeIn("slow");$("#myBox_search_div").unblock();return true}function feelLucky(){$.ajax({type:"POST",dataType:"json",timeout:10000,url:"include/ajax_php/whoisAjax.php?skey="+SK_WHOIS_DOMAIN,data:"action=lucky",success:function(b){var c=b.word;var a=document.getElementById("domain");a.value=c;makeRequestWrapper()}})}function getCheckedTLDs(){var b="";var a=0;TLDs=[];if(document.getElementById("gr_tpl").checked==true){TLDs[a]="gr";a++}if(document.getElementById("net_gr_tpl").checked==true){TLDs[a]="net.gr";a++}if(document.getElementById("com_gr_tpl").checked==true){TLDs[a]="com.gr";a++}if(document.getElementById("org_gr_tpl").checked==true){TLDs[a]="org.gr";a++}if(document.getElementById("gov_gr_tpl").checked==true){TLDs[a]="gov.gr";a++}if(document.getElementById("edu_gr_tpl").checked==true){TLDs[a]="edu.gr";a++}if(document.getElementById("com_tpl").checked==true){TLDs[a]="com";a++}if(document.getElementById("org_tpl").checked==true){TLDs[a]="org";a++}if(document.getElementById("net_tpl").checked==true){TLDs[a]="net";a++}return a}function addDomainToList(b,c){var e=document.getElementById(b+"_DIV");var d=b+"_CHECK";var a=document.getElementById(d).src;if(a.search("checkbox_checked.gif")>0){document.getElementById(d).src="media/icons/checkbox.gif";numberOfSelectedDomains--;e.style.backgroundColor="#f7f7f7";e.style.border="1px dotted #DDDDDD";document.getElementById(b).disabled=true}else{document.getElementById(d).src="media/icons/checkbox_checked.gif";numberOfSelectedDomains++;e.style.backgroundColor="#deffd3";e.style.border="1px dotted #b9ffa1";document.getElementById(b).disabled=false}}function checkSelectedDomainsAndSubmit(){if(numberOfSelectedDomains<=0){alert("Πρέπει να επιλέξετε τουλάχιστον ένα ελέυθερο domain για να συνεχίσετε.");return false}myBlockTheUI();$("#formStartRegistration").submit();return true}Array.prototype.unique=function(){var d={},b,a=this.length,c=[];for(b=0;b<a;b+=1){d[this[b]]=this[b]}for(b in d){c.push(d[b])}return c};function getDomains(){var b=document.getElementById("domain").value;Domains=b.split(",");Domains=Domains.unique();new_domain_str="";var a="";for(i=0;i<Domains.length;i++){a=Domains[i].split(".");tld="NA";if(a.length==3){tld=a[1]+"_"+a[2]+"_tpl"}else{if(a.length==2){tld=a[1]+"_tpl"}}if(tld!=""){if(document.getElementById(tld)){document.getElementById(tld).checked=true}}Domains[i]=a[0];if(i!=0){new_domain_str=new_domain_str+","}new_domain_str=new_domain_str+a[0]}document.getElementById("domain").value=new_domain_str}function myBlockTheUI(){$.blockUI({message:'<p><img src="media/images/ajax-progress_bar.gif" width="220" height="19"/><br><br> <b>Παρακαλώ περιμένετε...</b></p>',css:{border:"none",padding:"15px",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px",opacity:0.7,color:"#fff"}})};
