function do_register()
{
    document.myform.action="domain.php?action=buy";
    document.myform.submit();
}
function log_out(item_count)
{
    ht = document.getElementsByTagName("html");
    ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
    if(item_count!=0)
    {
        var mess = document.getElementById('signout2').value;
    }
    else
    {
        var mess = document.getElementById('signout1').value;
    }
    if (confirm(mess))
    {
        return true;
    }
    else
    {
        ht[0].style.filter = "";
        return false;
    }
}
//Function to toggle Div, with Plus/Minus image
function togPlus(objDiv,objImg)
{
    if(document.getElementById(objDiv))
    {
        var myElement = document.getElementById(objDiv);
        if (myElement.style.display == "none")
        {
            myElement.style.display = "block";
            objImg.src = "getImage.php?src=collapse.gif";
        }
        else
        {
            myElement.style.display = "none";
            objImg.src = "getImage.php?src=expand.gif";
        }
    }
}

function tog(objDiv)
{
    if(document.getElementById(objDiv))
    {
        var myElement = document.getElementById(objDiv);
        if(myElement.style.display == "none")
        {
            myElement.style.display = "block";
        }
        else
        {
            myElement.style.display = "none";
        }
    }
}

function togLogin(status)
{
    if(document.getElementById('sidebar-login'))
    {
        var myElement = document.getElementById('sidebar-login');
        myElement.style.display = status;
    }
}

// toggle row bgcolors and set active row bgcolor
var activeRow = null;
	
function rowOver(thisRow) {
    if(thisRow.className=="row")
        thisRow.className = "row-over";
}

function rowOut(thisRow) {
    if(thisRow.className=="row-over")
        thisRow.className = "row";
}

var classtype;
classtype=null;
function carowOver(thisRow) {
    if(thisRow.className=="")
    {
        thisRow.className = "row-over";
        classtype="";
    }
    if(thisRow.className=="alt")
    {
        thisRow.className = "row-over";
        classtype="alt";
    }
}

function carowOut(thisRow) {
    if(thisRow.className=="row-over")
        thisRow.className = classtype;
}

function rowClick(thisRow) {
    if (thisRow.className=="row" || thisRow.className=="row-over")
        thisRow.className = "row-active";
    else
        thisRow.className = "row";
}
/////////////////
function Toggle(e)
{	
    var checkflag=false;
    var i,count;
    count=0;
    if (e.checked)
    {
        Highlight(e);
    }
    else
    {
        r = e.parentNode.parentNode;
        count=r.childNodes.length;
        i=0;
        while(i<count)
        {
            if(r.childNodes[i].nodeName=="TD")
            {
                if(r.childNodes[i].firstChild.type=="checkbox" && r.childNodes[i].firstChild.checked)
                {
                    checkflag=true;
                    break;
                }
            }
            i++;
        }
        if(checkflag==false)
            Unhighlight(e);
    }
}


function Highlight(e)
{
    var r = null;
    if (e.parentNode && e.parentNode.parentNode)
    {
        r = e.parentNode.parentNode;
    }
    else if (e.parentElement && e.parentElement.parentElement)
    {
        r = e.parentElement.parentElement;
    }
    if (r)
    {
        (r.className == "row")
        r.className = "row-active";
    }
}


function Unhighlight(e)
{
    var r = null;
    if (e.parentNode && e.parentNode.parentNode)
    {
        r = e.parentNode.parentNode;
    }
    else if (e.parentElement && e.parentElement.parentElement)
    {
        r = e.parentElement.parentElement;
    }

    if (r)
    {
        (r.className == "row-active")
        r.className = "row";
    }
}
/////////////////////////////////
function Highlight_addservice(e)
{
    var r = null;
    if (e.parentNode && e.parentNode.parentNode)
    {
        r = e.parentNode.parentNode;
    }
    else if (e.parentElement && e.parentElement.parentElement)
    {
        r = e.parentElement.parentElement;
    }
    if (r)
    {
        (r.className == "alt")
        r.className = "row-active";
    }
}
function UnHighlight_addservice(e)
{
    var r = null;
    if (e.parentNode && e.parentNode.parentNode)
    {
        r = e.parentNode.parentNode;
    }
    else if (e.parentElement && e.parentElement.parentElement)
    {
        r = e.parentElement.parentElement;
    }
    if (r)
    {
        (r.className == "row-active")
        r.className = "alt";
    }
}
///////////////////////////////////
var tempbutton=null;
function chk_selected(check_selected_err,butt)
{
    var domlength,i,temp,flag;
    domlength=document.myform.domval.length;
    flag=false;
    if(document.myform.domval.checked)
    {
        flag=true;
    }
    for(i=0 ; i<domlength ; i++)
    {
        if(document.myform.domval[i].checked)
        {
            flag=true;
            break;
        }
    }
    if(flag==false)
    {
        /*var check_selected_err = document.getElementById('chk_selected_error');*/
        check_selected_err.style.display = 'block';
        /*window.scrollTo(-100,-1000);*/
        return false;
    }
    if(butt.className=="frmButton-disable")
    {
        return false;
    }
    else
    {
        tempbutton=butt;
        //butt.value="   Processing...  ";
        butt.className="frmButton-disable";
        check_for_suggested_domain_names();
        animLoading();
        document.myform.action="domain.php?action=buy";
        document.myform.submit();
    }
}

var Cookies = {
	init: function () {
		var allCookies = document.cookie.split('; ');
		for (var i=0;i<allCookies.length;i++) {
			var cookiePair = allCookies[i].split('=');
			this[cookiePair[0]] = cookiePair[1];
		}
	},
	create: function (name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else {
			var expires = "";
		}
		document.cookie = name+"="+value+expires+"; path=/";
		this[name] = value;
	},
	erase: function (name) {
		this.create(name,'',-1);
		this[name] = undefined;
	}
};
Cookies.init();

function check_for_suggested_domain_names() {
    if(document.getElementById('suggestions') == null) {
        return;
    }

    var suggestions = document.getElementById('suggestions').getElementsByTagName('input');
    var domain_name = '';
    for(var i = 0 ; i < suggestions.length; i++) {
        if(suggestions[i].checked == true) {
            domain_name += ',' + suggestions[i].value;
        }
    }
    domain_name = domain_name.substr(1);
    if(Cookies['suggested_domain_name'] != undefined) {
        domain_name += ',' + Cookies['suggested_domain_name'];
        Cookies.erase('suggested_domain_name');
    }
    Cookies.create('suggested_domain_name', domain_name, '');
}

var step=1;
function animLoading()
{
    butt=tempbutton;
    step++;
    if (step == 9) step = 1;

    if (step == 1)
    {
        window.status = 'Processing.   ';
        butt.value = 'Processing.   ';
    }
    if (step == 2)
    {
        window.status = 'Processing.   ';
        butt.value = 'Processing.   ';
    }
    if (step == 3)
    {
        window.status = 'Processing..  ';
        butt.value= 'Processing..  ';
    }
    if (step == 4)
    {
        window.status = 'Processing..  ';
        butt.value = 'Processing..  ';
    }
    if (step == 5)
    {
        window.status = 'Processing... ';
        butt.value = 'Processing... ';
    }
    if (step == 6)
    {
        window.status = 'Processing... ';
        butt.value = 'Processing... ';
    }
    if (step == 7)
    {
        window.status = 'Processing....';
        butt.value = 'Processing....';
    }
    if (step == 8)
    {
        window.status = 'Processing....';
        butt.value = 'Processing....';
    }
    setTimeout("animLoading()", 200);
}

function round_decimals(original_number, decimals)
{
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function pad_with_zeros(rounded_value, decimal_places)
{

    // Convert the number to a string
    var value_string = rounded_value.toString()
		
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")
		
    // Is there a decimal point?
    if (decimal_location == -1)
    {
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0

        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else
    {
        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
	
    if (pad_total > 0)
    {
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++)
            value_string += "0"
    }
    return value_string
}
	
function chk_button(formname)
{
    var sub = document.getElementById('sub_button');
    if(formname.agree.checked)
    {
        sub.className='frmButton';
    }
    else
    {
        sub.className='frmButton-disable';
    }
}

function checkandsubmit(butt,formname)
{
    if(butt.className=="frmButton-disable")
    {
        return false;
    }
    else
    {
        //butt.value="   Processing...  ";
        butt.className="frmButton-disable";
        tempbutton=butt;
        animLoading();
        formname.submit();
    }
}

function on_mouse_over(butt)
{
    if(butt.className!="frmButton-disable")
        butt.className='frmButton-over';
}
function on_mouse_out(butt)
{
    if(butt.className!="frmButton-disable")
        butt.className='frmButton';
}

function on_mouse_over_secondary(butt)
{
    if(butt.className!="frmButton-disable")
        butt.className='frmButton-secondary-over';
}
function on_mouse_out_secondary(butt)
{
    if(butt.className!="frmButton-disable")
        butt.className='frmButton-secondary';
}


// The Yellow Fade Technique. codename:MisFX

var FadeInterval = 600;
var StartFadeAt = 7;
var FadeSteps = new Array();
FadeSteps[1] = "ff";
FadeSteps[2] = "ee";
FadeSteps[3] = "dd";
FadeSteps[4] = "cc";
FadeSteps[5] = "bb";
FadeSteps[6] = "aa";
FadeSteps[7] = "99";
function DoFade(colorId, targetId) {
    if (colorId >= 1) {
        document.getElementById(targetId).style.backgroundColor = "#ffff" + FadeSteps[colorId];
		
        // If it's the last color, set it to transparent
        if (colorId==1) {
            document.getElementById(targetId).style.backgroundColor = "transparent";
        }
        colorId--;
		
        // Wait a little bit and fade another shade
        setTimeout("DoFade("+colorId+",'"+targetId+"')", FadeInterval);
    }
}
function open_new_window(url)
{
    window.open(url,'','menubar=no,location=no,resizable=yes,scrollbars=yes,status=no');
}

// alternating TD-TR Without PHP 

function colorRows(tableid) {
    var myTR = tableid.getElementsByTagName('tr');
    for (var i=0;i<myTR.length;i++) {
        if (i%2) {
            myTR[i].className = 'alt';
        }
    }
}

// BETTER ALTERNATING COLORED ROWS

var elem = "TR";
function alternating () {
    if(document.getElementsByTagName) {
        var el = document.getElementsByTagName(elem);
        for(var i=0; i<el.length; i++) {
            if(el[i].childNodes[0].tagName != "TH"
                && el[i].parentNode.parentNode.className.indexOf("alternating") != -1) {
                if(i%2 == 1){
                    el[i].className = "alt";
                } else {
                    el[i].className = "";
                }
            }
        }
    }
}

function openPopUp(theURL,winName,features) {
    window.open(theURL,winName,features);
}

function htmlDecode(input){
    var e = document.createElement('div');
    e.innerHTML = input;
    return e.childNodes[0].nodeValue;
}

