// JavaScript Document : Copyright Philton Nengobela,
//function onKeyPress () {
//var keycode;
//if (window.event) keycode = window.event.keyCode;
//else if (e) keycode = e.which;
//else return true;
//if (keycode == 13) {
//alert("Please Click on the Submit button to send this form");
//return false
//}
//return true 
//}
//document.onkeypress = onKeyPress;
function myad_op()
{
window.open('ad_dti.php','Advertinfo','width=790,height=400,scrolling=no');
}

function open_legis()
{
window.open('legislation/index.php','','width=790,height=400,scrolling=no');
}

function checkCheckBox(){
if (document.newmsgform.agree.checked == true )
{
document.newmsgform.formsend.disabled = false;
} else {
document.newmsgform.formsend.disabled = true;
}
}

//function checkCheckBoxT(f){
//if (f.agree.checked == false )
//{
//alert('Please check the Accept box to continue.');
//return false;
//}else
//return true;
//}

function chk_tomsg()
{
	missinginfo = "";
if (document.newmsgform.fullname.value == "") {
missinginfo += "\n     -  Name";
}

if ((document.newmsgform.mail.value == "") || 
 (document.newmsgform.mail.value.indexOf('@') == -1) || 
 (document.newmsgform.mail.value.indexOf('.') == -1)
) 
{
missinginfo += "\n     -  Mail (enter a valid e-mail address)";
}
//if ((document.newmsgform.web.value == "") || 
//(document.newmsgform.web.value.indexOf(".") == -1)) {
//missinginfo += "\n     -  Web site";
//}

if(document.newmsgform.contno.value == "") {
missinginfo += "\n     -  Contact number";
}
if(document.newmsgform.companyname.value == "") {
missinginfo += "\n     -  Company Name";
}
if(document.newmsgform.occupation.value == "") {
missinginfo += "\n     -  Position";
}
if(document.newmsgform.user.value == "") {
missinginfo += "\n     -  Username";
}
if(document.newmsgform.password.value == "") {
missinginfo += "\n     -  Password";
}
if(document.newmsgform.passwordsure.value == "") {
missinginfo += "\n     -  Confirm Password";
}
if((document.newmsgform.Q2basked.value == "")||
(document.newmsgform.Q2basked.value == "Type the question here")
)
 {
missinginfo += "\n     -  Question to be Asked";
}
if((document.newmsgform.answer.value == "")||
(document.newmsgform.answer.value == "Type the answer here")
)
 {
missinginfo += "\n     -  Answer to the question";
}
if(document.newmsgform.comp_reg.value == "") {
missinginfo += "\n     -  Company registration Number";
}
if(document.newmsgform.director.value == "") {
missinginfo += "\n     -  Company Directors";
}
if(document.newmsgform.employees.value == "") {
missinginfo += "\n     -  Number of Employees";
}
if(document.newmsgform.sector.value == "") {
missinginfo += "\n     -  Sector you service";
}

if (document.newmsgform.password.value!=document.newmsgform.passwordsure.value)
{ 
alert("The Password and Confirmation Password values are not the same");
document.newmsgform.password.focus();
return false
}

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}



else return true;
}


function showLines(max, text) {
max--;
text = "" + text;
var temp = "";
var chcount = 0; 
for (var i = 0; i < text.length; i++) // for each character ... 
{   
var ch = text.substring(i, i+1); // first character
var ch2 = text.substring(i+1, i+2); // next character
if (ch == '\n') // if character is a hard return
{  
temp += ch;
chcount = 1;
}
else
{
if (chcount == max) // line has max chacters on this line
{
temp += '\n' + ch; // go to next line
chcount = 1; // reset chcount
}
else  // Not a newline or max characters ...
{
temp += ch;
chcount++; // so add 1 to chcount
      }
   }
}
return (temp); // sends value of temp back
}


function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
// End -->


function GoUrl(Team)
  {
   	var d = Team.options[Team.selectedIndex].value;
	if (d=="") {alert("Please choose Industry");} else {
	window.location ="comp_data.php?type=" + d;
    }
  }
  
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null; 
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1]; 
}
j++;
}

// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
   }
}

function GoUrl(s)
  {	
	var d = s.options[s.selectedIndex].value
	if (d =="#") { alert("Choose Province"); return false;} 
	if (d !=="#")
	{
	parent.location =d;
	s.selectedIndex=0
	}
  }
  
//  End -->
