var boxopened = false;
var loadingimagerunned = false;
function hidepanels() {

$('#leftbar').css('overflow','hidden');
$('#rightbar').css('overflow','hidden');

$('.bigbox').css('margin-top', '20px')

$('#leftbar').animate({ height: "0" }, 1000);
$('#rightbar').animate({ height: "0" }, 1000);
$('#headbar').animate({ height: "1" }, 1000);


}



function showpanels() {


    $(document).find('[class*=NF]').each(function() { this.className = '' });
    $('.bigbox').animate({ opacity: "0" }, 50);

    $('#leftbar').css('overflow', 'hidden');
    $('#rightbar').css('overflow', 'hidden');

    $('.bigbox').css('margin-top', '0')

    $('#leftbar').animate({ height: "480" }, 1000);
    $('#rightbar').animate({ height: "487" }, 1000);
    $('#headbar').animate({ height: "15" }, 1000);

    $('.bigbox').css('display', 'none')
    $('.bigbox').animate({ opacity: '0' }, function () {

        $('#pagecontent').text('');    
    });

}

function signup() {
    hidepanels();

setTimeout('signup2()',1000);


}


function signup2() {
    doajax('signup.aspx', '', 'pagecontent');
	//loadpage('SignUp/SignUp.aspx','','','','pagecontent');
}

function doajax(url, vars, updatepanel) {

    if (updatepanel == 'pagecontent') {
        $('.bigbox').css('display', 'block')
        $('.bigbox').animate({ opacity: '1' });

    }
    showdarklayer();
    $.post(url, vars, function(data) {
        hidedarklayer();
        clearTimeout(animchartime);
        setTimeout(function() { $('#' + updatepanel).html(data); $('.bigbox').animate({ opacity: "100" }, 200); runscript(data); }, 500);

    });
 

}


function doajaxpart(url, vars, updatepanel,msg) {
    $('#' + updatepanel).text(msg);
    
    
    $.post(url, vars, function(data) {
        
        setTimeout(function() { $('#' + updatepanel).html(data);runscript(data); }, 10);

    });


}



function el(str) {
    return document.getElementById(str);
}


function clearListBox(listboxID) {
    // returns 1 if all items are sucessfully removed
    // otherwise returns zero.
    var mylistbox = document.getElementById(listboxID);
    if (mylistbox == null)
        return 1;
    while (mylistbox.length > 0) {
        mylistbox.remove(0);
    }
    return 1;
}



function addtolistall(srcstr, str) {
    clearListBox(str);
    var srcList = document.getElementById(str);
    len = el(srcstr).length;
    len2 = srcList.length;
    for (var i = 0; i <= (len - 1); i++) {
        srcList.options[len2] = new Option(el(srcstr).options[i].text, el(srcstr).options[i].value);

        len2++;


    }


}



function elcsel(str, str2) {
    for (i = 0; i < el(str).options.length; i++) {
        if (el(str).options[i].value == str2) {
            el(str).options[i].selected = true;
        } else {
            el(str).options[i].selected = false;
        }

    }
}



function runscript(data) {
    if (jQuery.browser.mozilla == 'undefined') {
        return;
    }
    var myregexp2 = new RegExp("<[\\s\\/]*script\\b[^>]*>([^>]*)<\\/script>");
    var match2 = myregexp2.exec(data.substr(data.indexOf('<script'), data.indexOf('</script>') - data.indexOf('<script') + 10));
    if (match2 != null && match2.length > 1) {        
        eval(match2[1]);
    }
}

function showdarklayer() {


    $('#darklayer3').css('display', 'block');

    $(document).validationEngine('hide');
    var newdiv = $('#darklayer');
    newdiv.css("background-color", "#000000");
    newdiv.css("opacity", "0.5");
    newdiv.css("position", "absolute");
    newdiv.css("height", "0px");
    newdiv.css("top", $('#footer').position().top + 70 + "px");
    newdiv.css("left", "0px");
    newdiv.css("width", "100%");
    newdiv.css("z-index", "1300");
    newdiv.animate({ height: $('#footer').position().top - 190, top: 271 }, 'slow', 'backout');

    var newdiv2 = $('#darklayer2');
    newdiv2.css("background-color", "#000000");
    newdiv2.css("opacity", "0.5");
    newdiv2.css("position", "absolute");
    newdiv2.css("height", "0px");
    newdiv2.css("top", "0px");
    newdiv2.css("left", "0px");
    newdiv2.css("width", "100%");
    newdiv2.css("z-index", "1300");
    newdiv2.animate({ height: 200 }, 'slow', 'backout', function() {


        $('#loimg1').css("position", "absolute");
        $('#loimg2').css("position", "absolute");
        $('#loimg3').css("position", "absolute");
        $('#loimg4').css("position", "absolute");
        $('#loimg1').css("top", "0px");
        $('#loimg2').css("top", "0px");
        $('#loimg3').css("top", "0px");
        $('#loimg4').css("top", "0px");








        var newdiv3 = $('#darklayer3');
        newdiv3.css("background-color", "#FFFFFF");
        newdiv3.css("opacity", "0");
        newdiv3.css("position", "absolute");
        newdiv3.css("height", "71px");
        newdiv3.css("top", "200px");
        newdiv3.css("text-align", "center");
        newdiv3.css("left", "0px");
        newdiv3.css("width", "100%");
        newdiv3.css("z-index", "1300");
        newdiv3.animate({ opacity: 0.8 }, 'slow', 'backout');


        $('#loimg1').css("left", parseInt($('#loadingbg').offset().left) + "px");
        $('#loimg2').css("left", parseInt($('#loadingbg').offset().left) + "px");
        $('#loimg3').css("left", parseInt($('#loadingbg').offset().left) + "px");
        $('#loimg4').css("left", parseInt($('#loadingbg').offset().left) + "px");

        //setInterval("changeloadingimage()",300);
        if (!loadingimagerunned) {
            changeloadingimage2()
            loadingimagerunned = true;
        }


    });



   

}

var limgcount=1;
function changeloadingimage() {
	var i = 0;
	for (i=0;i<=4;i++) {
		if (i == limgcount) {
			$('#loimg' + i).css('display',"block");
		}else{
			$('#loimg' + i).css('display',"none");
		
		}
	}
	if (limgcount == 4) {
		limgcount = 1;
	}else{
		limgcount += 1;
	}

}



function changeloadingimage2() {

    $('#loimg1').animate({ opacity: 0 }, 'fast');
    $('#loimg2').animate({ opacity: 1 }, 'fast', function() {

        $('#loimg2').animate({ opacity: 0 }, 'fast');
        $('#loimg3').animate({ opacity: 1 }, 'fast', function() {
            $('#loimg3').animate({ opacity: 0 }, 'fast');

            $('#loimg4').animate({ opacity: 1 }, 'fast', function() {

                $('#loimg4').animate({ opacity: 0 }, 'fast');
                $('#loimg3').animate({ opacity: 1 }, 'fast', function() {
                    $('#loimg3').animate({ opacity: 0 }, 'fast');
                    $('#loimg2').animate({ opacity: 1 }, 'fast', function() {
                        $('#loimg2').animate({ opacity: 0 }, 'fast');
                        $('#loimg1').animate({ opacity: 1 }, 'fast', function() {
                            changeloadingimage2();
                        });

                    });
                });



            });

        });

    });

}





function hidedarklayer() {

    var newdiv3 = $('#darklayer3');
    newdiv3.dequeue();
    newdiv3.animate({ opacity: 0 }, 'slow');

    var newdiv = $('#darklayer');
    newdiv.animate({ height: 0, top: $('#footer').position().top + 70 }, 'slow', 'backout');

    var newdiv2 = $('#darklayer2');

    newdiv2.animate({ height: 0 }, 'slow', 'backout', function() {

        var newdiv3 = $('#darklayer3');
        newdiv3.dequeue();
        newdiv3.animate({ opacity: 0 }, 'slow');

    });


    $('#darklayer3').css('display','none');

}


function checkdomain(dtype,dname) {
    

    if (dtype == 2) {
        doajax('core.aspx?action=choosedomain&subname=' + dname, '', 'pagecontent');

    }



}


function chooseplan() {

    $('form1').getElements('input[ID^=P]').each(function(element) {
        if (element.checked == true) {
            loadpage('SignUp/core.aspx?action=chooseplan&planid=' + element.value, '', '', '', 'step1');
        }
    })

}



function CallVerify() {

    doajax('core.aspx?action=callverify', '','verifydiv');
}

function backVerify() {

    doajax('userdetail.aspx', '','pagecontent');
}

function phoneverify() {


    $('#vtelentered').addClass("validate[required,custom[onlyNumberSp]] text-input");
    if ($("#phoneverifyform").validationEngine('validateField', "#vtelentered") == true) {

        $('#vtelentered').blur(function () {
            $("#phoneverifyform").validationEngine('validateField', "#vtelentered");
        });
        return;
    }

    


    doajax('core.aspx?action=phoneverify&digit='+$('#vtelentered').attr('value'), '','pagecontent');
}


function confirmMail(el){
    if (el.value != $('usr_Email').value) {
        el.errors.push("Email And Confirm Email Must Be Same!");
        return false;
    } else {
        return true;
    }
}


function confirmPass(el){
    if (el.value != $('usr_Password').value) {
        el.errors.push("Password And Confirm Password Must Be Same!");
        return false;
    } else {
        return true;
    }
}


function adduser(bk) {

    var errorstr = "";
str = "";
	if (bk==0) {
	 




		$('#usr_Email').addClass("validate[required,custom[email]] text-input");
		if ($("#userdetailform").validationEngine('validateField', "#usr_Email") == true) {

		    $('#usr_Email').blur(function() {
		        $("#userdetailform").validationEngine('validateField', "#usr_Email");
		    });
		    return;
		}



		$('#usr_CEmail').addClass("validate[required,custom[email],equals[usr_Email]] text-input");
		$('#usr_CEmail').attr('value', $('#usr_CEmail').attr('value').toLowerCase());
		$('#usr_Email').attr('value', $('#usr_Email').attr('value').toLowerCase());
		if ($("#userdetailform").validationEngine('validateField', "#usr_CEmail") == true) {

		    $('#usr_CEmail').blur(function() {
		        $("#userdetailform").validationEngine('validateField', "#usr_CEmail");
		    });
		    return;
		}



		$('#usr_Password').addClass("validate[required,minSize[6]] text-input");
		if ($("#userdetailform").validationEngine('validateField', "#usr_Password") == true) {

		    $('#usr_Password').blur(function() {
		        $("#userdetailform").validationEngine('validateField', "#usr_Password");
		    });
		    return;
		}


		$('#usr_CPassword').addClass("validate[required,minSize[6],equals[usr_Password]] text-input");
		if ($("#userdetailform").validationEngine('validateField', "#usr_CPassword") == true) {

		    $('#usr_CPassword').blur(function() {
		        $("#userdetailform").validationEngine('validateField', "#usr_CPassword");
		    });
		    return;
		}

		$('#usr_FirstName').addClass("validate[required] text-input");
		if ($("#userdetailform").validationEngine('validateField', "#usr_FirstName") == true) {

		    $('#usr_FirstName').blur(function() {
		        $("#userdetailform").validationEngine('validateField', "#usr_FirstName");
		    });
		    return;
		}



		$('#usr_LastName').addClass("validate[required] text-input");
		if ($("#userdetailform").validationEngine('validateField', "#usr_LastName") == true) {

		    $('#usr_LastName').blur(function() {
		        $("#userdetailform").validationEngine('validateField', "#usr_LastName");
		    });
		    return;
		}

		$('#usr_City').addClass("validate[required] text-input");
		if ($("#userdetailform").validationEngine('validateField', "#usr_City") == true) {

		    $('#usr_City').blur(function() {
		        $("#userdetailform").validationEngine('validateField', "#usr_City");
		    });
		    return;
		}


		$('#usr_Zip').addClass("validate[required] text-input");
		if ($("#userdetailform").validationEngine('validateField', "#usr_Zip") == true) {

		    $('#usr_Zip').blur(function() {
		        $("#userdetailform").validationEngine('validateField', "#usr_Zip");
		    });
		    return;
		}

		$('#usr_Address').addClass("validate[required] text-input");
		if ($("#userdetailform").validationEngine('validateField', "#usr_Address") == true) {

		    $('#usr_Address').blur(function() {
		        $("#userdetailform").validationEngine('validateField', "#usr_Address");
		    });
		    return;
		}




		if ($('#usr_Phone').attr('value')[0] == '0') { $('#usr_Phone').attr('value')[0] = $('#usr_Phone').attr('value').substring(1, $('#usr_Phone').attr('value').length) };

		$('#usr_Phone').addClass("validate[required,custom[onlyNumberSp]] text-input");
		if ($("#userdetailform").validationEngine('validateField', "#usr_Phone") == true) {

		    $('#usr_Phone').blur(function() {
		        $("#userdetailform").validationEngine('validateField', "#usr_Phone");
		    });
		    return;
		}



		$('#usr_agreement').addClass("validate[required] checkbox");
		if ($("#userdetailform").validationEngine('validateField', "#usr_agreement") == true && !($('#accepttermDIV').find('img')[0].className == 'NFCheck NFh')) {

		    $('#usr_agreement').blur(function () {
		        $("#userdetailform").validationEngine('validateField', "#usr_agreement");
		    });
		    return;
		}







}else{

errorstr ="";
};



str = "";
$('#userdetailform').find('input[ID^="usr_"]').each(function() {
    if (this.type == 'text' || this.type == 'password') {


        str += '&' + this.id + '=' + this.value;






    }


})


    $('#userdetailform').find('select[ID^="usr_"]').each(function() {
        str += '&' + this.id + '=' + this.value;


})






        if (errorstr != '') {
            //alert(errorstr);
} else {
if (bk==1) {
    doajax('core.aspx?back=' + bk + '&action=userdetail' + str, '', 'pagecontent');
} else {

    showdarklayer();
    $.post("core.aspx?action=checkuser&email=" + $('#usr_Email').attr('value') + "&phone=" + $('#usr_AreaCodeList').attr('value') + $('#usr_Phone').attr('value') + str , '', function (data) {
        eval(data);

    });

}


}

   

}


var jj;



function sendabuse() {

    
		$('#ab_FirstName').addClass("validate[required] text-input");
		if ($("#abuseform").validationEngine('validateField', "#ab_FirstName") == true) {
			
			$('#ab_FirstName').blur(function() {
				$("#abuseform").validationEngine('validateField', "#ab_FirstName");
            });
            return;
		}

        $('#ab_LastName').addClass("validate[required] text-input");
        if ($("#abuseform").validationEngine('validateField', "#ab_LastName") == true) {

            $('#ab_LastName').blur(function () {
                $("#abuseform").validationEngine('validateField', "#ab_LastName");
            });
            return;
        }

        $('#ab_Email').addClass("validate[required,custom[email]] text-input");
        if ($("#abuseform").validationEngine('validateField', "#ab_Email") == true) {

            $('#ab_Email').blur(function () {
                $("#abuseform").validationEngine('validateField', "#ab_Email");
            });
            return;
        }

        $('#ab_Phone').addClass("validate[required,custom[phone]] text-input");
        if ($("#abuseform").validationEngine('validateField', "#ab_Phone") == true) {

            $('#ab_Phone').blur(function () {
                $("#abuseform").validationEngine('validateField', "#ab_Phone");
            });
            return;
        }

        $('#ab_AbuseType').addClass("validate[required] text-input");
        if ($("#abuseform").validationEngine('validateField', "#ab_AbuseType") == true) {

            $('#ab_AbuseType').blur(function () {
                $("#abuseform").validationEngine('validateField', "#ab_AbuseType");
            });
            return;
        }



        $('#ab_Domain').addClass("validate[required,custom[domain]] text-input");
        if ($("#abuseform").validationEngine('validateField', "#ab_Domain") == true) {

            $('#ab_Domain').blur(function () {
                $("#abuseform").validationEngine('validateField', "#ab_Domain");
            });
            return;
        }



        $('#ab_Comment').addClass("validate[required] text-input");
        if ($("#abuseform").validationEngine('validateField', "#ab_Comment") == true) {

            $('#ab_Comment').blur(function () {
                $("#abuseform").validationEngine('validateField', "#ab_Comment");
            });
            return;
        }



        str = "id=ss";
        $('#abusecontactform').find('[id*=ab_]').each(function() {
            if (this.type == 'text' || this.type == 'password' || this.type == 'hidden' || this.type == 'textarea' || this.id == 'ab_Comment') {
                str += '&' + this.id + "=" + this.value ;
            }


        })


        doajax('Core.aspx?action=sendabuse', str, 'abusediv'); 
        //loadpage('SignUp/Core.aspx?action=sendabuse', str, '', '', 'pagecontent');


}






function privacy(elem) {
	
	hidepanels();
	document.title = document.domain.replace('www.','').toUpperCase() + ' - Privacy Policy';
	//loadpage('privacy.aspx','','','','pagecontent');
	setTimeout(function() { doajax('privacy.aspx', '', 'pagecontent') }, 1500);		

}




function terms(elem) {
	
	hidepanels();
	document.title = document.domain.replace('www.','').toUpperCase() + ' - Terms of Service';
//	loadpage('terms.aspx','','','','pagecontent');
	setTimeout(function() { doajax('terms.aspx', '', 'pagecontent') }, 1500);

}


function abuse(elem) {
	
	hidepanels();
	document.title = document.domain.replace('www.','').toUpperCase() + ' - Report Abuse';
	//	loadpage('SignUp/Abuse.aspx','','','','pagecontent');
	setTimeout(function() {	doajax('Abuse.aspx','','pagecontent') },1500);	

}


function homepage(elem) {

    showpanels();
	document.title = document.domain.replace('www.','').toUpperCase() + ' - Free Web Services';
	//setTimeout(function() { doajax('home.aspx', '', 'pagecontent');}, 1500);	

}


function login() {
	
	hidepanels();
	document.title = document.domain.replace('www.','').toUpperCase() + ' - Sign in';
	//	loadpage('SignUp/Login.aspx','','','','pagecontent');
	setTimeout(function() { doajax('signin.aspx', '', 'pagecontent') }, 1500);	

}


function dologin() {




    $('#log_Username').addClass("validate[required,custom[domain]] text-input");
    if ($("#loginform").validationEngine('validateField', "#log_Username") == true) {

        $('#log_Username').blur(function() {
		        $("#loginform").validationEngine('validateField', "#log_Username");
		    });
		    return false;
		}
		



		$('#log_Password').addClass("validate[required] text-input");
		if ($("#loginform").validationEngine('validateField', "#log_Password") == true) {

		    $('#log_Password').blur(function() {
		        $("#loginform").validationEngine('validateField', "#log_Password");
		    });
		    return false;
		}



	
	return true;

}



function forgotpassword3() {
	
		$('fg_Username').addClass("validate['required',custom[email]]");
		jj = new FormCheck('loginform', {
     			  alerts: {
			             required: 'Please Enter Your UserName!'           
		          }
		    });
		
		if (!jj.validate($('fg_Username'))) {
			jj.addError($('fg_Username'));
			return;
		}




		doajax('Core.aspx?action=forgotpassword','username='+$('#fg_Username').attr('value'),'','','forgotdiv');

	
	return true;

}




function forgotpassword() {


    $('#fg_Username').addClass("validate[required,custom[domain]] text-input");
    if ($("#forgotform").validationEngine('validateField', "#fg_Username") == true) {

        $('#fg_Username').blur(function() {
            $("#forgotform").validationEngine('validateField', "#fg_Username");
        });
        return;
    }


    doajax('Core.aspx?action=forgotpassword', 'username=' + $('#fg_Username').attr('value') + '&fg_captchavalue=' + $('#ab_captchavalue').attr('value'), 'forgotresult');

	
	return true;

}



function forgotform() {

    if (boxopened) {
        return;
    }
    boxopened = true;
    showdarklayer();


    $(document).validationEngine('hide');
    Boxy.load("ForgotPassword.aspx", { modal: true, afterShow: function() { popupafter(); } });
}


function showtermspop() {

    if (boxopened) {
        return;
    }
    boxopened = true;
    showdarklayer();


    $(document).validationEngine('hide');
    Boxy.load('terms2.aspx', { modal: true, afterShow: function () { popupafter(); } });
}



function popupafter() {
    hidedarklayer();
    NFInit(); 
    boxopened = false;
}

function showabuseform() {
    if (boxopened) {
        return;
    }
    boxopened = true;
    showdarklayer();
    
    $(document).validationEngine('hide');

    Boxy.load("AbuseForm.aspx", { modal: true, afterShow: function() { popupafter(); } });
}



function whois() {

	hidepanels();
	document.title = document.domain.replace('www.','').toUpperCase() + ' - Whois';
	setTimeout(function() { doajax('whois.aspx', '', 'pagecontent') }, 1500);
	

}


function getwhois() {


    $('#wh_subname').addClass("validate[required,minSize[4],maxSize[20],custom[onlyLetterNumber]]");
    if ($("#whoisform").validationEngine('validateField', "#wh_subname") == true) {

        $('#wh_subname').blur(function() {
            $("#whoisform").validationEngine('validateField', "#wh_subname");
        });
        return;
    }


    
$('[name=subgrp]').each(function() {
    this.className = 'NFhidden validate[minCheckbox[1]]';
})


    if ($("#whoisform").validationEngine('validateField', "#wh_dom_x7_com") == true) {

        $('#wh_subname').blur(function() {
            $("#whoisform").validationEngine('validateField', "#wh_dom_x7_com");
        });
        return;
    }





	var subext="";
	$('#whoisform').find('[type=checkbox]').each(function() {

	    if (this.checked == true) {
	        if (subext == '') {
	            subext += this.value;
	        } else {
	            subext += ',' + this.value;
	        }
	    }
	});

	doajax('Core.aspx?action=whois', 'subname=' + $('#wh_subname').attr('value') + '&subext=' + subext, 'whoisresult');

//	loadpage('SignUp/Core.aspx?action=whois','subname='+$('wh_subname').value +'&subext=' + subext,'','','whoisresult');
	
}


function getsubdomain(str) {

    checkdomain(2, str);
}

function whoisdetail(str) {

    if (boxopened) {
        return;
    }
    boxopened = true;
    showdarklayer();


    $(document).validationEngine('hide');

    Boxy.load('WhoisDetail.aspx?subname='+str,{ modal: true, afterShow: function() { popupafter(); } });

}

function whoisdetailcaptcha(str, capvalue) {
    doajax('WhoisDetail.aspx?subname=' + str + '&wh_captchavalue=' + capvalue, '', 'whoisdetailresult');


}

var checkedall = false;
function checkall(el) {



    if (checkedall == false) {
        $('#checkallbtn').className = 'NFCheck NFh';
        $('#' + el).find('[type=checkbox]').each(function() {
            this.checked = true;

        });

        $('#' + el).find('[class*=NFCheck]').each(function() {
            this.className = 'NFCheck NFh';
        });
        checkedall = true;
    } else {
    $('#checkallbtn').className = 'NFCheck';
    $('#' + el).find('[type=checkbox]').each(function() {
        this.checked = false;

    });

    $('#' + el).find('[class*=NFCheck]').each(function() {
        this.className = 'NFCheck';
    });
    checkedall = false;
    



    }
    
}


var livecheckingtime;
function livechecking(e) {
    $('#choosedomainbtn').animate({ opacity: "0.5" }, 500);
    $('#choosedomainbtn').css({ cursor: '' });
    $('#choosedomainbtn').unbind('click');
    $('#checkeddomain').attr('value', '');

    var key;

    if (e != null && e != undefined) {

        if (window.event)
            key = window.event.keyCode; //IE
        else
            key = e.which; //firefox

        if (key == 13) return false;

    }

    timecounter = 0;
    clearInterval(livecheckingtime);
    $('#choosedomainbtn').animate({ opacity: "0.5" }, 500);
    $('#choosedomainbtn').css({ cursor: '' });
    $('#choosedomainbtn').unbind('click');
    $('#checkeddomain').attr('value', '')
    
    
    try {
        $(document).validationEngine('hide');
        $(document).validationEngine('detach');
        
    } catch (e) {
    }

    livecheckingtime = setInterval(function() {
        timecounter++;
        if (timecounter == 2) {
            $('#freesubtext').removeClass();

            

            $.validationEngineLanguage.allRules['ajaxDomain'].extraData = $('#subdomainlist option:selected').val();
            $('#freesubtext').addClass("validate[required,minSize[4],maxSize[20],custom[onlyLetterNumber]]");
            if ($("#getstart1").validationEngine('validateField', "#freesubtext") == true) {


            } else {

                $('#freesubtext').removeClass();

                $('#freesubtext').addClass("validate[required,minSize[4],maxSize[20],custom[onlyLetterNumber],ajax[ajaxDomain]]");
                if ($("#getstart1").validationEngine('validateField', "#freesubtext") == true) {


                }
            }

            clearInterval(livecheckingtime);
        }
    }, 600);

}


function activechoosedomainbtn() {
    $('#choosedomainbtn').animate({ opacity: "1" }, 500);
    $('#choosedomainbtn').css({ cursor: 'pointer' });
    $('#choosedomainbtn').bind('click', function() { choosedomain(); });
    $('#checkeddomain').attr('value', $('#freesubtext').attr('value') + '.' + $('#subdomainlist').attr('value'))


}


function choosedomain() {

    if ($('#checkeddomain').attr('value') != '' && $('#checkeddomain').attr('value') == $('#freesubtext').attr('value') + '.' + $('#subdomainlist').attr('value')) {

        checkdomain(2, $('#checkeddomain').attr('value'));
    } else {
        livechecking();
    }

}


function telenterenter(e) {

    var key;
    if (window.event)
        key = window.event.keyCode; //IE
    else
        key = e.which; //firefox


    if (key == 13) phoneverify();

    return (key != 13);

}

function forgotpasswordenter(e) {

    var key;
    if (window.event)
        key = window.event.keyCode; //IE
    else
        key = e.which; //firefox


    if (key == 13) forgotpassword();
    
    return (key != 13);


}

var checkedemail = "";
var checkedphone = "";
function useremailchecked() {
    checkedemail = $('#usr_Email').attr('value');
    if (checkedphone != "") {
        $('button [value=Next]').attr('value', 'Next');
    }
}

function userphonechecked() {

    checkedphone = $('#usr_AreaCodeList').attr('value') + $('#usr_Phone').attr('value');

    if (checkedemail != "") {
        $('button [value=Next]').attr('value','Next');
    }
}



var animchartime;
function animatechar(el, prestr, str, maxchar, start) {
    if (start > maxchar) {
        start = 1;
    }
    res = "";
    for (i=0;i<=start;i++) {
        res += str;
    }

    $('#' + el).text(prestr + res);
    animchartime = setTimeout(function () { animatechar(el, prestr, str, 8, start + 1); }, 500);
}



function ind_subs_active_anim(str,str2) {

    $('#' + str).animate({ width: '0' }, function () { $('#' + str).css({ 'background-image': 'url(images/choosedomain_sub_active.jpg)' }); $('#' + str).text(str2); $('#' + str).animate({ width: '157' }, function () { $('[src=images/choose_sub_' + str.substring(str.length - 6) + '.jpg]').css({ 'opacity': '1', 'cursor': 'pointer' }); $('[src=images/choose_sub_' + str.substring(str.length - 6) + '.jpg]').bind('click', function () { hidepanels();getsubdomain(str2 + '.' + str.substring(str.length - 6).replace('_', '.')); }); }); })
}

function ind_subs_deactive_anim(str,str2) {

    $('#' + str).animate({ width: '0' }, function () { $('#' + str).css({ 'background-image': 'url(images/choosedomain_subtext.jpg)' }); $('#' + str).text(str2); $('#' + str).animate({ width: '157' }, function () { $('[src=images/choose_sub_' + str.substring(str.length - 6) + '.jpg]').css({ 'opacity': '0.5', 'cursor': 'normal' }); $('[src=images/choose_sub_' + str.substring(str.length - 6) + '.jpg]').unbind('click'); }); })
}


var ind_livecheckingtime;
function ind_livechecking(e) {

    var key;
    if (window.event)
        key = window.event.keyCode; //IE
    else
        key = e.which; //firefox

    if (key == 13) return false;

    var pattern = new RegExp(/^[0-9a-zA-Z]+$/);
   // alert(key);

   var mykey =  String.fromCharCode(key);

   if ($('#ind_freesubtext').attr('value').length >= 20) {
       return;
   } 


   if (key == 8) {
        mykey ='';
    }


    $('[class=ind_choose_subitem_btn]').each(function () { $(this).unbind('click') });

    if (pattern.test($('#ind_freesubtext').attr('value') + String.fromCharCode(key)) || (key == 8 && pattern.test($('#ind_freesubtext').attr('value')))) {
          $('#leftcontent').find('[id^=ind_sub_]').each(function () { this.innerHTML = $('#ind_freesubtext').attr('value') + mykey ; });

      }
                


   

    timecounter = 0;
    clearInterval(ind_livecheckingtime);
    
    
    try {
        $(document).validationEngine('hide');
        $(document).validationEngine('detach');

    } catch (e) {
    }

    ind_livecheckingtime = setInterval(function () {
        timecounter++;
        if (timecounter == 2) {
            $('#ind_freesubtext').removeClass();



            $.validationEngineLanguage.allRules['ajaxDomainIndex'].extraData = $('#ind_freesubtext').attr('value');
            $('#ind_freesubtext').addClass("validate[required,minSize[4],maxSize[20],custom[onlyLetterNumber]]");
            if ($("#leftcontent").validationEngine('validateField', "#ind_freesubtext") == true) {


            } else {

                $('#ind_freesubtext').removeClass();

                $('#ind_freesubtext').addClass("validate[required,minSize[4],maxSize[20],custom[onlyLetterNumber],ajax[ajaxDomainIndex]]");
                if ($("#leftcontent").validationEngine('validateField', "#ind_freesubtext") == true) {


                }
            }

            clearInterval(ind_livecheckingtime);
        }
    }, 600);

}


function getfreesubs() {
    $('#leftcontent').find('[id^=ind_sub_]').each(function () {
        this.innerHTML = 'Checking....';
        
  
     });

    $.post('core.aspx?action=indexchecksubs&subname=' + $('#ind_freesubtext').attr('value'), '', function (data) {
        runscript(data);

    });

}


function showfeatures() {

    if (boxopened) {
        return;
    }
    boxopened = true;
    showdarklayer();


    $(document).validationEngine('hide');
    Boxy.load("features.aspx", { modal: true, afterShow: function () { popupafter(); } });
}



function newsadd() {
    showdarklayer();
    doajax('Core.aspx?action=addnews', 'subject=' + $('#nw_title').attr('value') + '&shortnews=' + $('#nw_short').attr('value') + '&fullnews=' + $('#nw_full').html(), 'newsaddresult');

}

function newsupdate() {
    showdarklayer();
    doajax('Core.aspx?action=updatenews', 'subject=' + $('#nw_title').attr('value') + '&shortnews=' + $('#nw_short').attr('value') + '&fullnews=' + $('#nw_full').html() + '&newsid=' + $('#nw_id').attr('value'), 'newsaddresult');

}


function opennewseditor(str) {
    if (boxopened) {
        return;
    }
    boxopened = true;
    showdarklayer();


    $(document).validationEngine('hide');
    Boxy.load("news_edit.aspx?ID=" + str, { modal: true, afterShow: function () { popupeditorafter(); } });

}



function opennewsadder() {
    if (boxopened) {
        return;
    }
    boxopened = true;
    showdarklayer();


    $(document).validationEngine('hide');
    Boxy.load("news_add.aspx", { modal: true, afterShow: function () { popupeditorafter(); } });
   
}


function viewnews(str) {
    if (boxopened) {
        return;
    }
    boxopened = true;
    showdarklayer();


    $(document).validationEngine('hide');
    Boxy.load("news.aspx?ID=" + str, { modal: true, afterShow: function () { popupafter(); } });

}



function popupeditorafter() {
    hidedarklayer();
    $('textarea.tinymce').tinymce({
        // Location of TinyMCE script
        script_url: 'js/tiny_mce/tiny_mce.js',

        // General options
        theme: "advanced",
        plugins: "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

        // Theme options
        theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,preview,|,forecolor,backcolor",
        theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
        theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_resizing: true,

        // Example content CSS (should be your site CSS)
        content_css: "css/content.css",

        // Drop lists for link/image/media/template dialogs
        template_external_list_url: "lists/template_list.js",
        external_link_list_url: "lists/link_list.js",
        external_image_list_url: "lists/image_list.js",
        media_external_list_url: "lists/media_list.js",

        // Replace values for the template plugin
        template_replace_values: {
            username: "Some User",
            staffid: "991234"
        }
    });



}




$(document).ready(function () {
    if (window.location.hash == '#SignIn') {
        login();
    }

    if (window.location.hash == '#SignUp') {
        signup();
    }

    if (window.location.hash == '#Whois') {
        whois();
    }

    if (window.location.hash == '#Terms') {
        terms(null);
    }

    if (window.location.hash == '#Privacy') {
        privacy(null);
    }

    if (window.location.hash == '#Abuse') {
        abuse(null);
    }
});

