var ajax;

var site_url  = 'http://localhost/cake/blogtoprofit.com/';

function verify_complete(residing_url,code) {

	alert(code);

	ajax = new Ajax.Updater(

         'verify_complete_status',

         site_url+'scripts/verify_complete.php',

         {

        	method:'post',

			parameters:'residing_url='+residing_url+'&code='+code,

            onComplete: showResponse

         });

		function showResponse(req) {

			//$('verify_complete_status').innerHTML = '<a href="#" onclick="verify_complete(\''+residing_url+'\',\''+code+'\')" title="Verify that you have correctly posted the code on your blog.">verify</a>'+': '+req.responseText;

			$('verify_complete_status').innerHTML = req.responseText;



		}

}

function populateday(dayfield,monthfield,leap,day){
	day--
	var dayfield=document.getElementById(dayfield)
	if (dayfield.length>0){
		dayfield.remove(30);
		dayfield.remove(29);
		dayfield.remove(28);
	}
	if (document.getElementById(monthfield).value=="00"){
		if (dayfield.length>0){
			for (var i=0; i<31; i++)
				dayfield.remove(dayfield.length-1)
		}
	} else if (document.getElementById(monthfield).value=="2"){
		if (leap==0) {
			for (var i=0; i<28; i++){
				selected = false
				if (i==day) selected = true
				dayfield.options[i]=new Option(i+1, i+1,selected)
			}
		}else{
			for (var i=0; i<29; i++){
				selected = false
				if (i==day) selected = true
				dayfield.options[i]=new Option(i+1, i+1,selected)
			}
		}
	} else if (document.getElementById(monthfield).value=="4" || document.getElementById(monthfield).value=="6" || document.getElementById(monthfield).value=="9" || document.getElementById(monthfield).value=="11"){
		for (var i=0; i<30; i++){
				selected = false
				if (i==day) selected = true
			dayfield.options[i]=new Option(i+1, i+1,selected)
		}
	} else {
		for (var i=0; i<31; i++){
				selected = false
				if (i==day) selected = true
			dayfield.options[i]=new Option(i+1, i+1,selected)
		}
	}
	
	return false;
}

function markAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                    rows[i].className += ' marked';
                    marked_row[unique_id] = true;
                }
            }
        }
    }

    return true;
}

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 *
 * @param    container    DOM element
 */
function unMarkAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;
            rows[i].className = rows[i].className.replace(' marked', '');
            marked_row[unique_id] = false;
        }
    }

    return true;
}

