//$(document).ready(function() {
$(window).load(function() {
    $('#UserName').each(function() {
        var default_value = this.value;
        $(this).focus(function() {
            if (this.value == default_value) {
                this.value = '';
            }
        });
        $(this).blur(function() {
            if (this.value == '') {
                this.value = default_value;
            }
        });
    });
    $('#Password_Clear').show();
    $('#Password').hide();

    $('#Password_Clear').focus(function() {
        $('#Password_Clear').hide();
        $('#Password').show();
        $('#Password').focus();
    });
    $('#Password').blur(function() {
        if ($('#Password').val() == '') {
            $('#Password_Clear').show();
            $('#Password').hide();
        }
    });
    //keywords
    $("#keywords").keyup(getKeywords);

    //coupon page
    $(".coupon_text").hide();
    $('a.coupon_title').click(function() {
        var id = $(this).attr('id');
        id = id.replace("link_", "");
        $('#coupon_' + id).slideToggle('fast');
        // alert(id);
        return false;
    });

    //   $('.coupon_title').click(function() {
    //     $(this).next('.coupon_text').slideToggle('fast');
    // });
    /*$(".coupon_title").click(function() {
    $(this).next(".coupon_text").slideToggle('fast');
    });*/
    $(".hide_coupon").click(function() {
        $(".coupon_text").hide();
        return true;
    });
    $("#company_select").change(getCompanyMsgStats);
    //alert lists
    $("#save_contacts").click(saveListContacts);
    //new ads
    $("#keywords").keyup(getKeywords);
    $("#p_line_code").blur(check_phone_number);
    $("#email_address").blur(check_email_address);
    $("#user_name").blur(check_user_name);

});
function limitChars(text_area, limit, info) {
    var text = $('#' + text_area).val();
    var text_length = text.length;
    if (text_length > limit) {
        $('#' + info).html('You cannot write more then <strong>' + limit + '</strong>characters.');
        return true;
    } else {
        $('#' + info).html('You have <strong>' + (limit - text_length) + '</strong> characters left.');
        return true;  
    }   
}
function getKeywords(){
 //remove all the class add the messagebox classes and start fading
 //$("#msg_display").removeClass().addClass('msg').text('Checking...').fadeIn("slow");
	$.ajax({
		type:"POST",
		url: "/includes/ajax/check_keywords.asp",
		dataType: "application/x-www-form-urlencoded",
		data: "Val=" + $("#keywords").val(),
		async: false,
		success: function(msg){
			if($("#keywords").val() == ''){ 
				$("#msg_display").removeClass().addClass('msg').text('');
			}else{
				if(msg>=1){
					$("#msg_display").removeClass().addClass('msg_deny').text('Keyword all ready in use.').fadeIn("slow");
				}else{
					$("#msg_display").removeClass().addClass('msg_approve').text('Keyword is ok.').fadeIn("slow");
				}
			}
		}

	 });
}
function saveListContacts(){
    var name = document.getElementsByName("name[]");
    
    var names="";
    for(var i=0;i<name.length;i++){
        if(name[i].value!=""){
            names += name[i].value;
            if((i+1)!=name.length){
                names += ",";
            }
         
        }
    }
    //alert(names);
    var email_address = document.getElementsByName("email_address[]");
    var emails="";
    for(var i=0;i<email_address.length;i++){
        if(email_address[i].value!=""){
            emails += email_address[i].value;
            if((i+1)!=email_address.length){
                emails+=",";
            }
        }                 
    }
    //alert(emails);
    var home_number = document.getElementsByName("home_number[]");
    var home_numbers="";
    for(var i=0;i<home_number.length;i++){
        if(home_number[i].value!=""){
            home_numbers += home_number[i].value;
            if((i+1)!=home_number.length){
                home_numbers +=",";
            }
        }
    }
    //alert(home_numbers);
    var wireless_number = document.getElementsByName("wireless_number[]");
    var wireless_numbers="";
    for(var i=0;i<wireless_number.length;i++){
        if(wireless_number[i].value!=""){
            wireless_numbers += wireless_number[i].value;
            if((i+1)!=wireless_number.length){
                wireless_numbers +=",";
            }
        }
    }
    var list_id = document.getElementsByName("list_id")
    var data = "names="+names+"&emails="+emails+"&home_numbers="+home_numbers+"&wireless_numbers="+wireless_numbers+"&list_id="+list_id[0].value;
    //alert(data);
    $.ajax({
        type: "POST",
        url: "/includes/ajax/alert_list.asp",
        dataType: "application/x-www-form-urlencoded",
        data: data,
        async: false,
        success:
        function(msg){
            if(msg){
                var html = "All contacts were added. &nbsp;<a href=\"/companyinfo.asp?i="+list_id[0].value+"&amp;task=manage_list&amp;msgCount=-1\">Manage list contacts</a> or <a href=\"/companyinfo.asp?i="+list_id[0].value+"&amp;task=add_list_contacts\">add more</a>.";
                $("#alert_contacts").removeClass().addClass('msg').html(html).fadeIn("fast");
            }else{
                
                $("#alert_contacts").removeClass().addClass('msg').html(msg).fadeIn("fast");
            }
        }
    })
}
function check_phone_number(){
		$.ajax({
		type:"POST",
		url: "/includes/ajax/check_phone_number.asp",
		dataType: "application/x-www-form-urlencoded",
		data: "area_code=" + $("#p_area_code").val()+"&prefix_code="+$("#p_prefix_code").val()+"&line_code="+$("#p_line_code").val(),
		async: false,
		success: function(msg){
			if($("#p_area_code").val()=='' || $("#p_prefix_code").val()=='' || $("#p_line_code").val()==''){
				$("#p_msg_display").text('Valid phone number is required.').fadeIn("fast");
			}else{			
				if(msg>=1){
					$("#p_msg_display").text('Phone number provided is all ready in use.').fadeIn("fast");
				}else{
					$("#p_msg_display").text('*').fadeIn("fast");
				}
			}
		
		}

	 });
	 
} 
function check_email_address(){
		$.ajax({
		type:"POST",
		url: "/includes/ajax/check_email_address.asp",
		dataType: "application/x-www-form-urlencoded",
		data: "email=" + $("#email_address").val(),
		async: false,
		success: function(msg){
			if($("#email").val()==' ' || $("#email").val()=='you@host.com'){
				$("#e_msg_display").html('Email address is required.').fadeIn("fast");
			}else{
			    //alert(msg);			
				if(msg>=1){
					$("#e_msg_display").html('Email address is all ready in use.').fadeIn("fast");
				}else{
					$("#e_msg_display").html('*');
				}
			}
		
		}

	 });
	 
} 
function check_user_name(){
		$.ajax({
		type:"POST",
		url: "/includes/ajax/check_user_name.asp",
		dataType: "application/x-www-form-urlencoded",
		data: "user=" + $("#user_name").val(),
		async: false,
		success: function(msg){
			if($("#user_name").val()==''){
				$("#u_msg_display").text('User name is required.').fadeIn("fast");
			}else{			
				if(msg>=1){
					$("#u_msg_display").text('User name is all ready in use.').fadeIn("fast");
				}else{
					$("#u_msg_display").text('*');
				}
			}
		
		}

	 });

}
  
function ShowProgress()
{
  strAppVersion = navigator.appVersion;
  if (document.MyForm.FILE1.value != "" || document.MyForm.FILE2.value != "" || document.MyForm.FILE3.value != "")
  {
    if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4)
    {
      winstyle = "dialogWidth=385px; dialogHeight:140px; center:yes";
      window.showModelessDialog('<% = barref %>&b=IE',null,winstyle);
    }
    else
    {
      window.open('<% = barref %>&b=NN','','width=375,height=115', true);
    }
  }
  return true;
}
function getCompanyMsgStats() {
    var selectBox = $("#company_select option:selected");
    var selectBoxValue = selectBox.val();
    var ajaxUrl = "/includes/ajax/company_msg_stats.asp";
    var ajaxData = "Val=" + selectBoxValue;
    $.ajax({
        type: "POST",
        url: ajaxUrl,
        dataType: "application/x-www-form-urlencoded",
        data: ajaxData,
        async: false,
        success: function(msg) {
            if (selectBoxValue != '') {
                $("#company_msg_stats").removeClass().addClass('msg').html(msg).fadeIn("fast");
            } else {
            $("#company_msg_stats").removeClass().addClass('msg').text('').fadeIn("fast");
            }
        }

    });
}
//recatpcha
var RecaptchaOptions = {
    theme: 'custom',
    lang: 'en',
    custom_theme_widget: 'recaptcha_widget'
};
//advertisers main page


function checkPurchaseForm()
{

	// set var radio_choice to false
	var radio_choice = false;

	// Loop from zero to the one minus the number of radio button selections
	for (var counter = 0; counter < document.getElementsByName("cat").length; counter++)
	{
		// If a radio button has been selected it will return true
	    // (If not it will return false)
		if (payService.cat[counter].checked)
		radio_choice = true; 
	}

	if (!radio_choice)
	{
		// If there were no selections made display an alert box 
		alert("Please select an Available Service.")
		return false;
	}

	radio_choice = false;

	// Loop from zero to the one minus the number of radio button selections
	for (var counter = 0; counter < document.getElementsByName("serviceoption").length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (payService.serviceoption[counter].checked)
		radio_choice = true; 
	}
	if (payService.serviceoption.checked)
		radio_choice = true; 

	if (!radio_choice)
	{
		// If there were no selections made display an alert box 
		alert("Please select a Service Option.")
		return false;
	}
	return true;
}

function applyoptions(catid){
	//catid = document.getElementById("cat").value;
	if(catid!=""){
		if(window.XMLHttpRequest)
			ajaxobj = new XMLHttpRequest();
		else
		ajaxobj = new ActiveXObject("MSXML2.XMLHTTP");
		ajaxobj.onreadystatechange =applyoptionscallback;
		document.getElementById("optionspan").innerHTML = "Applying...";
		ajaxobj.open("GET", "/includes/ajax/ajaxservices.asp?action=applycert&catid="+catid, true);
		ajaxobj.send(null);
		document.getElementById("controlBorder").style.visibility = 'visible';
	}
}


function applyoptionscallback() {
	if(ajaxobj.readyState==4){
		document.getElementById("optionspan").innerHTML = ajaxobj.responseText;
	}
}
var field_count=0;
function addFields(limit) {
    var element_id="list_contacts";
    if(field_count<limit){
        hasLoaded = true;
        field_count++;
        var tbl = document.getElementById(element_id);
        var lastRow = tbl.rows.length;
        var iteration = lastRow;
        var row = tbl.insertRow(lastRow);
        var cell0 = row.insertCell(0);
        var el = document.createElement('input');
        el.setAttribute("type","text");
        el.setAttribute("name","name[]");
        cell0.appendChild(el);
        var cell1 = row.insertCell(1);
        var el = document.createElement('input');
        el.setAttribute("type","text");
        el.setAttribute("name","wireless_number[]");
        el.setAttribute("maxlength","10");
        el.setAttribute("onkeydown","return checkKeys(event, this);");
        cell1.appendChild(el);
        var cell2 = row.insertCell(2);
        var el = document.createElement('input');
        el.setAttribute("type","text");
        el.setAttribute("name","home_number[]");
        el.setAttribute("maxlength","10");
        el.setAttribute("onkeydown","return checkKeys(event, this);");
        el.setAttribute("id","home_number_"+field_count);
        cell2.appendChild(el);
        var cell3 = row.insertCell(3);
        var el = document.createElement('input');
        el.setAttribute("type","text");
        el.setAttribute("name","email_address[]");
        cell3.appendChild(el);
        var cell4 = row.insertCell(4);
        var el = document.createElement("a")
        el.setAttribute("href","javascript:void(0);");
        el.setAttribute("onclick", "javascript:removeFields(this.parentNode.parentNode.rowIndex);");
        var linkText = document.createTextNode("Remove This");
        el.appendChild(linkText);
        cell4.appendChild(el);
    }else{
        alert("You can\'t add any more fields to this form.");
    }

}
function removeFields(i){
    field_count--;
    document.getElementById("list_contacts").deleteRow(i);
}

var validKey = false;
function checkKeys(e, whom, totalLen, nextid){

	if( !e ) {
	//if the browser did not pass the event information to the
	//function, we will have to obtain it from the event register
	if( window.event ) {
	  //Internet Explorer
	  e = window.event;
	} else {
	  //total failure, we have no way of referencing the event
	  return;
	}
  }
  if( typeof( e.keyCode ) == 'number'  ) {
	//DOM
	e = e.keyCode;
  } else if( typeof( e.which ) == 'number' ) {
	//NS 4 compatible
	e = e.which;
  } else if( typeof( e.charCode ) == 'number'  ) {
	//also NS 6+, Mozilla 0.9+
	e = e.charCode;
  } else {
	//total failure, we have no way of obtaining the key code
	e='';
	//return true;
  }
  
  key = e;
  validKey = false;
  
  //check number keys and NUM pad
  if( (key >= 48 && key<=57) || (key >= 96 && key<=105) ){
	validKey=true;
		return true;
	}
	
	if( key == 8 ) //delete allowed
		return true;
	
	if( key == 9 ) //tab allowed
		return true;
	
	return false;
}


function checkJump(whom, totalLen, nextid){
		if( validKey && whom.value.length >= totalLen){
			document.getElementById(nextid).focus();
			document.getElementById(nextid).select();
			validKey = false;
		}
}

//end checking functions
//pop up function
function popUp(URL,w,h) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width="+w+",height="+h+",left = 355,top = 195');");
}
function checkAll(name) {
    var checkBox = document.getElementsByName(name);
    var checkBoxCount = checkBox.length;
    for (var i = 0; i < checkBoxCount; i++) {
        checkBox[i].checked = true;
    }
}
function checkNone(name) {
    var checkBox = document.getElementsByName(name);
    var checkBoxCount = checkBox.length;
    for (var i = 0; i < checkBoxCount; i++) {
        checkBox[i].checked = false;
    }
}
function confirmAction(confirm_text, alert_text, form_name, check_box_name) {    
	var intCount=checkForm(check_box_name,form_name);
	
	if(intCount > 0){
		var agree=confirm(confirm_text);
		if (agree) {
		    document.forms[form_name].submit();
		}
	}else{
		alert(alert_text);
	}
}

function checkForm(check_box_name,form_name){
var checked = 0;
var checkBox = document.getElementsByName(check_box_name);
if (checkBox.length > 1) {
    for (var i = 0; i < checkBox.length; i++) {
        if (checkBox[i].checked) {
            checked += 1;
        }
    }
} else {
       if (checkBox.checked) {
            checked += 1;
       }
       
    
}   
	return checked;
}

function checkPassword()
{
	var newPassword, confirmPassword;
	newPassword = document.userinformation.new_password.value;
	confirmPassword = document.userinformation.confirm_new_password.value;
	
	
	if(newPassword!="" || confirmPassword!=""){
		if(newPassword == confirmPassword){
			var agree=confirm("Are you sure you want to change this users password?");
			if (agree)
				return true ;
			else
				return false ;			
		}else{
			alert("New password and password confirmation fields must match.");
			return false;			
		}

	}
}
/* Profile category selection*/
/*-----------------------------------------------------------+
| addLoadEvent: Add event handler to body when window loads |
+-----------------------------------------------------------*/
function addLoadEvent(func) {
    var oldonload = window.onload;

    if (typeof window.onload != "function") {
        window.onload = func;
    } else {

        window.onload = function() {
            oldonload();
            func();
        }
    }
}

/*------------------------------------+
| Functions to run when window loads |
+------------------------------------*/
addLoadEvent(function() {
    initChecklist();
});

/*----------------------------------------------------------+
| initChecklist: Add :hover functionality on labels for IE |
+----------------------------------------------------------*/
function initChecklist() {
    if (document.all && document.getElementById) {
        // Get all unordered lists
        var lists = document.getElementsByTagName("ul");

        for (i = 0; i < lists.length; i++) {
            var theList = lists[i];

            // Only work with those having the class "checklist"
            if (theList.className.indexOf("checklist") > -1) {
                var labels = theList.getElementsByTagName("label");

                // Assign event handlers to labels within
                for (var j = 0; j < labels.length; j++) {
                    var theLabel = labels[j];
                    theLabel.onmouseover = function() { this.className += " hover"; };
                    theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
                }
            }
        }
    }
}




function updateTotalCount(who, defauld, parentCat) {

    var totalAdsNow = 0;
    for (x = 0; x < 100; x++) {
        whom = document.getElementById('t' + x);
        if (whom) {
            var newVal = new Number(whom.value);
            if (newVal >= 0)
                totalAdsNow += newVal;
            else
                whom.value = defauld; //not a valid num reste to default
        } else {
            //alert( 'done at '+x );
            //					document.getElementById('totalAdsPerWeekCount').innerHTML = totalAdsNow;
            break;
        }
    }

    updateCategoryTotals();
}

function updateCategoryTotals() {
    for (x in catChildren) {
        var whom = document.getElementById('c' + x);
        var whomVal = document.getElementById('t' + catChildrenValues[x]);
        if (!whom || !catChildren[x]) continue;
        var total = new Number(whomVal.value);
        for (y = 0; y < catChildren[x].length; y++) {
            var swhom = document.getElementById('t' + catChildrenValues[catChildren[x][y]]);
            total += new Number(swhom.value);
            var subArr = catChildren[catChildren[x][y]];
            if (catChildren[catChildren[x][y]]) {
                subArr = catChildren[catChildren[x][y]]
                for (q = 0; q < subArr.length; q++) {
                    var whom2 = document.getElementById('t' + catChildrenValues[subArr[q]]);
                    total += new Number(whom2.value);
                }
            }
        }
        whom.innerHTML = total;
    }
}

var catChildren = new Array();
var catChildrenValues = new Array();
addLoadEvent(updateCategoryTotals);



function generateCode(){
	var widget_html_code;
	widget_html_code="<!--Begin Admobi.com Quick Alert Sign Up Code-->\n";
	widget_html_code+="<script language=\"javascript\" type=\"text/javascript\" src=\"http://www.admobi.com/includes/js/widget.js\"></script>\n";
	widget_html_code+="<form method=\"post\" target=\"_blank\" action=\"http://www.admobi.com/alert_signup.asp\" name=\"admobi_widget\" id=\"admobi_widget\">\n";
	widget_html_code+="<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"5\" id=\"admobi_alerts\">\n";
	widget_html_code+="<tr>\n";
	widget_html_code+="<td align=\"center\" colspan=\"2\">Sign up for wireless alerts &amp; coupons:</td>\n";
	widget_html_code+="</tr>\n";
	widget_html_code+="<tr>\n";
	widget_html_code+="<td align=\"center\" colspan=\"2\" style=\"font-size:smaller\">(Standard text messaging rates apply.)</td>\n";
	widget_html_code+="</tr>\n";
	widget_html_code+="<tr>\n";
	widget_html_code+="<td align=\"left\">Wireless Number:</td>\n";
	widget_html_code+="<td>(<input type=\"text\" name=\"admobi_wireless_area_code\" id=\"admobi_wireless_area_code\" onkeydown=\"return checkKeys(event, this);\"  onkeyup=\"checkJump(this, 3, 'admobi_wireless_prefix_code');\" size=\"2\" maxlength=\"3/\">) -";
	widget_html_code+="\n";
	widget_html_code+="<input type=\"text\" name=\"admobi_wireless_prefix_code\" id=\"admobi_wireless_prefix_code\" onkeydown=\"return checkKeys(event, this);\"  onkeyup=\"checkJump(this, 3, 'admobi_wireless_line_code');\" size=\"2\" maxlength=\"3/\"> - ";
	widget_html_code+="\n";
	widget_html_code+="<input type=\"text\" name=\"admobi_wireless_line_code\" id=\"admobi_wireless_line_code\" onkeydown=\"return checkKeys(event, this);\" size=\"2\" maxlength=\"4/\"></td>\n";
	widget_html_code+="</tr>\n";
	
		for(var i=0; i < document.widget_code_box.optional_fields.length; i++){
			if(document.widget_code_box.optional_fields[i].checked){
				if(document.widget_code_box.optional_fields[i].value=="home_number"){
					widget_html_code+="<tr>\n";
					widget_html_code+="<td align=\"left\">Home Number:</td>\n";
					widget_html_code+="<td>\n"
					widget_html_code+="(<input type=\"text\" name=\"admobi_home_area_code\" id=\"admobi_home_area_code\" onkeydown=\"return checkKeys(event, this);\"  onkeyup=\"checkJump(this, 3, 'admobi_home_prefix_code');\" size=\"2\" maxlength=\"3/\">) - ";
					widget_html_code+="\n";
					widget_html_code+="<input type=\"text\" name=\"admobi_home_prefix_code\" id=\"admobi_home_prefix_code\" onkeydown=\"return checkKeys(event, this);\"  onkeyup=\"checkJump(this, 3, 'admobi_home_line_code');\" size=\"2\" maxlength=\"3/\"> - ";
					widget_html_code+="\n";
					widget_html_code+="<input type=\"text\" name=\"admobi_home_line_code\" id=\"admobi_home_line_code\" onkeydown=\"return checkKeys(event, this);\" size=\"2\" maxlength=\"4/\">\n";
					widget_html_code+="</td>\n";
					widget_html_code+="</tr>\n";
				}
				if(document.widget_code_box.optional_fields[i].value=="person_name"){
					widget_html_code+="<tr>\n";
					widget_html_code+="<td align=\"left\">Name:</td>\n";
					widget_html_code+="<td><input type=\"text\" name=\"admobi_name\" id=\"admobi_name\" /></td>\n";
					widget_html_code+="</tr>\n";
				}				
				if(document.widget_code_box.optional_fields[i].value=="email_address"){
					widget_html_code+="<tr>\n";
					widget_html_code+="<td align=\"left\">Email Address:</td>\n";
					widget_html_code+="<td><input type=\"text\" name=\"admobi_email_address\" id=\"admobi_email_address\" /></td>\n";
					widget_html_code+="</tr>\n";
				}				
				
			}
		}
		widget_html_code+="\n";
		widget_html_code+="<input type=\"hidden\" name=\"admobi_list_id\" value=\"14\"/>\n";
		widget_html_code+="<input type=\"hidden\" name=\"admobi_alert_sign_up\" value=\"widget\" />\n";
		widget_html_code+="\n<tr>\n";
		widget_html_code+="<td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"admobi_submit\" value=\"Sign Me Up\" />\n";
		widget_html_code+="<input type=\"reset\" name=\"admobi_reset\" value=\"Reset Sign Up Form\" /></td>\n";
		widget_html_code+="</tr>\n";
		widget_html_code+="</table>\n";
		widget_html_code+="</form>\n";
		widget_html_code+="<!--End Admobi.com Quick Alert Sign Up Code-->\n";
		document.widget_code_box.widget_html.focus();
		document.widget_code_box.widget_html.value = widget_html_code;		
	
	
		
}
//Javascript for new message category select
		/*-----------------------------------------------------------+
		 | addLoadEvent: Add event handler to body when window loads |
		 +-----------------------------------------------------------*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	
	if (typeof window.onload != "function") {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}

/*------------------------------------+
 | Functions to run when window loads |
 +------------------------------------*/
addLoadEvent(function () {
	initChecklist();
});

/*----------------------------------------------------------+
 | initChecklist: Add :hover functionality on labels for IE |
 +----------------------------------------------------------*/
function initChecklist() {
	if (document.all && document.getElementById) {
		// Get all unordered lists
		var lists = document.getElementsByTagName("ul");
		
		for (i = 0; i < lists.length; i++) {
			var theList = lists[i];
			
			// Only work with those having the class "checklist"
			if (theList.className.indexOf("checklist") > -1) {
				var labels = theList.getElementsByTagName("label");
				
				// Assign event handlers to labels within
				for (var j = 0; j < labels.length; j++) {
					var theLabel = labels[j];
					theLabel.onmouseover = function() { this.className += " hover"; };
					theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
				}
			}
		}
	}
}

/*function limitChars(textarea, limit, infodiv) {
    //alert(textarea);				
		var text = textarea.value; 
		var textlength = text.length;
		var info = document.getElementById(infodiv);
		
		if(textlength > limit)
		{
			info.innerHTML = 'You cannot write more then '+limit+' characters!';
			textarea.value = text.substr(0,limit);
			return false;
		 }
		 else
		 {
			info.innerHTML = 'You have '+ (limit - textlength) +' characters left.';
			 return true;
		 }
}*/
