//Standard site functions
function setTitle()
{
	var url = unescape(document.location.href);
	var urlParts = url.split('/');
	var title = '|| Pinion Insurance Brokers';
	var i;
	
	for (i = 3; i < urlParts.length; i++)
	{
		title += ' || ' + urlParts[i];
	}
	
	document.title = title;
}

function fnShowSubMenu(obj){
	document.getElementById('subTools').style.display = 'none';
	document.getElementById('subContent').style.display = 'none';
	
	if (document.getElementById(obj).style.display != 'block'){
		document.getElementById(obj).style.display = 'block';
	}else{
		document.getElementById(obj).style.display = 'none';
	}
	//setTimeout("FadeOpacity('"+obj+"', 100, 0, 2000, 10);",2000);
}

function fnChangeImage(Obj, Img){
	Obj.src = '../images/'+Img;
}

function fnSubmitForm(Obj1, IPValue){
	Obj1.mode.value = IPValue;
	Obj1.submit();
}

function fnChangeStyle(obj, swap, style){
	if (swap == 1){
		document.getElementById(obj).className = style;
	}else{
		document.getElementById(obj).className = style;
	}
}

function fnLoadDetail(obj){
	window.open('oneonone-booking.asp?id='+obj,'Booking','width=450,height=450');
}

function fnSubmitItem(obj){
	var i
	for (i=0; i<document.all.item(obj).options.length; i++){
			document.all.item(obj).options[i].selected = true
	}
	
	return true;
}

function showStatus(sMsg) {
    window.status = sMsg ;
    return true ;
}

function fnProfileSubmitForm(IPValue){
		document.frmProfile.mode.value = IPValue;
		document.frmProfile.submit();
}

function fnLoadForgottenPassword(){
	document.getElementById('lightbox').style.display = 'none';
	document.getElementById('forgotten').style.display = 'block';
	document.getElementById('txtForgotten').focus();
}

function fnCheckKeyPress(Obj, Obj1, IPValue){
	if (Obj == 13){
		Obj1.mode.value = IPValue;
		Obj1.submit();
	}
}

function fnStatusChange(Obj){
	window.status = Obj
}

function fbreakout(obj){
	if (window.top!=window.self) 
	{
		window.top.location=obj
	}
}

function fnReloadLocation(obj){
	if (obj != ""){
		document.location = '/?Nedsec/17:0:'+obj+':0/OneOnOneBooking.html'
	}
}

function addCatItem(obj, obj1, obj2, obj3){
	var i
	
	for (i=0; i<document.all.item(obj1).options.length; i++){
		if (document.all.item(obj1).options[i].selected==true){
			addNewItem(obj, obj3, obj2, document.all.item(obj1).options[i].value, document.all.item(obj1).options[i].text)
		}
	}	
}

function fnPrintSchedule(obj){
	var obj1 = document.getElementById('printdate').value
	window.open('/bin/oneonone.asp?id='+obj+'&pid='+obj1+'','Schedule','width=700,height=500,menubar=1,resizable=1,scrollbars=1');
}

function fnBookingAlert(){
	alert("Please note:\r\n\nA booking has already been made by a representative of your company to attend this One-on-One.\r\nShould you wish, you are able to add yourself as an attendee at the One-on-One timeslot booked.\r\n\nThank you")
}

function fnTimeslotAlert(){
	alert("Please note:\r\n\nA booking has already been made by a representative of your company to attend a One-on-One over the chosen timeslot.\r\n\nThank you")
}

function fnPopupNews(obj){
	window.open('/popup-news.asp?Nedsec/2:0:0:'+obj+'/NewsSummary.html','News','width=450,height=380,scrollbars=0,resizable=0')
}

function fnOneonOneReport(obj){
	if (obj == 1){
		window.open('/bin/oneonone-report.asp','Reports','width=450,height=170,scrollbars=0,resizable=0')
	}else if (obj ==2){
		window.open('/bin/oneonone-report.asp?cid=999','Reports','width=450,height=170,scrollbars=0,resizable=0')
	}else{
		window.open('/bin/oneonone-report.asp?cid=998','Reports','width=450,height=170,scrollbars=0,resizable=0')
	}
}

function fnPopupContact(obj){
	window.open('/contact.asp?etid='+obj+'','Contact','width=450,height=380,scrollbars=0,resizable=0')
}

function fnRevertParent(obj){
	window.location = '/?Nedsec/2:0:0:'+obj+'/News.html';
	document.getElementById("newspopup").style.display = 'none';
}

function fnClose(obj){
	if (obj == 1){
		document.getElementById("newspopup").style.display = 'none';
	}else if (obj == 2){
		document.getElementById("peoplepopup").style.display = 'none';
	}else {
		document.getElementById("bookingpopup").style.display = 'none';
	}
}

function addNewItem(obj, obj1, obj2, id, name){
	var i
	addOption = true
	for (i=0; i<document.all.item(obj2).options.length; i++){
		if(document.all.item(obj2).options[i].value == id){
			addOption = false
		}
	}
	
	if (addOption == true){
		document.all.item(obj2).options[document.all.item(obj2).options.length] = new Option(name, id)

		if (obj == 'event' || obj == 'categories'){
			if (document.all.item(obj2).options.length == 1){
				document.all.item(obj1).value = id
			}else{
				document.all.item(obj1).value = document.all.item(obj1).value +','+id
			}
		}
	}
}

function removeCatItem(obj, obj1, obj2){
	var i
	var oElements
	var CatID
	var SelCat
	for (i=0; i<document.all.item(obj2).options.length; i++){
		if (document.all.item(obj2).options[i].selected==true){
			CatID = document.all.item(obj2).options[i].value
			document.all.item(obj2).options.remove(i)
		}
	}
	
	if (obj == 'event' || obj == 'categories'){
		for (i=0; i<document.all.item(obj2).options.length; i++){
			document.all.item(obj2).options[i].selected = true
		}
		
		oElements = document.all.item(obj2).value.split(",");
		document.all.item(obj1).value = "";
		for (i=0;i<oElements.length;i++){
			if (oElements.length == 1){
				document.all.item(obj1).value = oElements[i]
			}else{
				document.all.item(obj1).value = document.all.item(obj1).value +','+oElements[i]
			}
		}
	}
	
	if (obj == 'request'){
		document.location.replace("default.asp?cid=7&rid="+CatID)
	}
}

function fnLoadSheet(conf, obj, option){
	var oConf = conf.split(":");
		
	if (option == 1){
		for (i=0;i<oConf.length;i++){
			document.getElementById("div"+oConf[i]).style.display = 'none';
			document.getElementById("timediv"+oConf[i]).style.display = 'none';
		}
		
		document.getElementById("printdate").value = obj;
		if (obj == 1){
			document.getElementById("link1").className = 'oneonone-linkover';
			document.getElementById("link2").className = 'oneonone-link';
		}else{
			document.getElementById("link1").className = 'oneonone-link';
			document.getElementById("link2").className = 'oneonone-linkover';
		}
		
		document.getElementById("div"+obj).style.display = 'block';
		document.getElementById("timediv"+obj).style.display = 'block';
	}else{
		for (i=0;i<oConf.length;i++){
			document.getElementById("divprint"+oConf[i]).style.display = 'none';
			document.getElementById("timediv"+oConf[i]).style.display = 'none';
			document.getElementById("labeldiv"+oConf[i]).style.display = 'none';
		}
		
		document.getElementById("divprint"+obj).style.display = 'block';
		document.getElementById("timediv"+obj).style.display = 'block';
		document.getElementById("labeldiv"+obj).style.display = 'block';
	}
	
}

function fnLoadSchedule(obj){
	document.getElementById("div"+obj).style.display = 'block';
	document.getElementById("timediv"+obj).style.display = 'block';
	
	if (obj == 1){
		document.getElementById("link1").className = 'oneonone-linkover';
		document.getElementById("link2").className = 'oneonone-link';
	}else{
		document.getElementById("link1").className = 'oneonone-link';
		document.getElementById("link2").className = 'oneonone-linkover';
	}
}

function fnValidateBooking(){
	var bErr = false;
	
	if (document.getElementById('txtAttendee1').value == ""){
		alert("Please provide at least one attendee's details");
		document.getElementById('txtAttendee1').focus();
		return false;
	}
	
	for (i=1;i<=6;i++){
		var txtString = document.getElementById('txtAttendee'+i).value;
		var sArray = "1,2,3,4,5,6,7,8,9,0";
		var oArray = sArray.split(",");
		
		for (j=0;j<txtString.length;j++){
			for (k=0;k<oArray.length;k++){
				if (txtString.charAt(txtString[j]) == oArray[k]){
					alert("Please note: only alpha characters are permitted.\r\nPlease alter your attendee details and resubmit.");
					bErr = true;
					break;
				}
			}
			
			if (bErr){
				break;
			}
		}
		
		if (bErr){
			return false;
		}
	}
	
	return true;
}

function regEx(regString, regPattern, regFlag)
{
	if(regPattern.length>0){
		var regExp = new RegExp(regPattern,regFlag);
		regEx = regString.match(regExp);
	}
}

function fnValidateRequest(obj){
	if (document.getElementById('txtFirstName').value == ""){
		alert("Please provide a first name");
		document.getElementById('txtFirstName').focus();
		return false;
	}
	
	if (document.getElementById('txtLastName').value == ""){
		alert("Please provide a last name");
		document.getElementById('txtLastName').focus();
		return false;
	}
	
	if (document.getElementById('txtContactEmail').value == ""){
		alert("Please provide a contact email address");
		document.getElementById('txtContactEmail').focus();
		return false;
	}
	
	var addr = document.getElementById('txtContactEmail').value
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  alert('The email address contains invalid characters');
		  return false;
	   }
	}
	
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  alert("The email address contains non ascii characters.");
		  return false;
	   }
	}
	
	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   alert('The email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   alert('The email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   alert('The email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   alert('The email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   alert('The period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   alert('The period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	  alert('The two periods must not be adjacent in email address');
	   return false;
	}
	
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   alert('The primary domain in email address is invalid');
	   return false;
	}	
	
	if (document.getElementById('cboLocal').value == ""){
		alert("Please select your location");
		document.getElementById('cboLocal').focus();
		return false;
	}
	
	if (document.getElementById('cboProdSel').value == ""){
		alert("Please ensure that you have at least one product category you would be interested in.");
		document.getElementById('cboProdSel').focus();
		return false;
	}
}

function fnValidateEmail(){
	if (document.getElementById('txtForgotten').value == ""){
		alert("Please provide your registration email address.");
		document.getElementById('txtForgotten').focus();
		return false;
	}
	
	var addr = document.getElementById('txtForgotten').value
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  alert('The email address contains invalid characters.');
		  return false;
	   }
	}
	
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  alert("The email address contains non ascii characters.");
		  return false;
	   }
	}
	
	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   alert('The email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   alert('The email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   alert('The email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   alert('The email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   alert('The period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   alert('The period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	  alert('The two periods must not be adjacent in email address');
	   return false;
	}
	
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   alert('The primary domain in email address is invalid');
	   return false;
	}
	
	return true
}

function fnFPwdValidate(obj){
	if (document.getElementById('txtContactEmail').value == ""){
		alert("Please provide a contact email address");
		document.getElementById('txtContactEmail').focus();
		return false;
	}
	
	var addr = document.getElementById('txtContactEmail').value
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  alert('The email address contains invalid characters');
		  return false;
	   }
	}
	
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  alert("The email address contains non ascii characters.");
		  return false;
	   }
	}
	
	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   alert('The email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   alert('The email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   alert('The email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   alert('The email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   alert('The period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   alert('The period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	  alert('The two periods must not be adjacent in email address');
	   return false;
	}
	
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   alert('The primary domain in email address is invalid');
	   return false;
	}
}

function fnRegValidate(obj){
	if (document.getElementById('txtCompanyName').value == ""){
		alert("Please provide your company name");
		document.getElementById('txtCompanyName').focus();
		return false;
	}
	
	if (document.getElementById('txtContactPerson').value == ""){
		alert("Please provide a contact persons name");
		document.getElementById('txtContactPerson').focus();
		return false;
	}
	
	if (document.getElementById('txtContactNo').value == ""){
		alert("Please provide a contact persons number");
		document.getElementById('txtContactNo').focus();
		return false;
	}
	
	if (document.getElementById('txtContactEmail').value == ""){
		alert("Please provide a contact email address");
		document.getElementById('txtContactEmail').focus();
		return false;
	}
	
	var addr = document.getElementById('txtContactEmail').value
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  alert('The email address contains invalid characters');
		  return false;
	   }
	}
	
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  alert("The email address contains non ascii characters.");
		  return false;
	   }
	}
	
	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   alert('The email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   alert('The email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   alert('The email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   alert('The email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   alert('The period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   alert('The period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	  alert('The two periods must not be adjacent in email address');
	   return false;
	}
	
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   alert('The primary domain in email address is invalid');
	   return false;
	}	
}

function fnAddfavourite(){
   if (document.all){
      window.external.AddFavorite
      ("http://www.nedsec.co.za","Nedsec - Nedcor Securities")
   }
}

function fnPreload(){ 
  var args = fnPreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

function fnValidateRegistration(formVar){
	var ReqVar, VarLabel
	var ReqArray, FieldArray
	var bReq
	var telVar, telNo, oTel, bExist
	
	bReq = false;
	if (formVar == 1){
		ReqVar = "txtFirstName,txtLastName,txtCompanyName,txtAddress1,txtAddress2,txtEmail,txtWorkTel";
		FieldVar = "First Name:,Last Name:,Company Name:,Address:,Please Complete:,Email Address:,Work Telephone:";
	}else if (formVar == 2){
		ReqVar = "txtFirstName,txtLastName,txtCompanyName,txtAddress1,txtEmail,txtWorkTel,txtUserName,txtPassword";
		FieldVar = "First Name:,Last Name:,Company Name:,Address:,Please Complete:,Email Address:,Work Telephone:,Username:,Password:";
	}else if (formVar == 3){
		ReqVar = "txtEmail,txtSubject,txtComment";
		FieldVar = "Email Address:,Subject:,Comment:";
	}

	ReqArray = ReqVar.split(",");
	FieldArray = FieldVar.split(",");
	
	for (j=0;j<FieldArray.length;j++){
		for (i=0;i<ReqArray.length;i++){
			if (j == i){
					document.getElementById("label-"+ReqArray[i]).innerHTML = FieldArray[j].replace("Please Complete:","");
					break;
			}
		}
	}
	
	for (i=0;i<ReqArray.length;i++){
		if (document.getElementById(ReqArray[i]).value == ""){
			VarLabel = document.getElementById("label-"+ReqArray[i]).innerHTML;
			document.getElementById("label-"+ReqArray[i]).innerHTML = "<span style='color: #598787; font-weight: bold; text-decoration: none;'>"+VarLabel+"</span>";
			bReq = true;
		}
	}
	
	if (bReq){
		alert("- Please note -\r\n  The label(s) in bold text are mandatory fields.");
		
		for (i=0;i<=ReqArray.length;i++){
			if (document.getElementById(ReqArray[i]).value == ""){
				document.getElementById(ReqArray[i]).focus();
				break;
			}
		}
		return false;
	}
	
	var addr = document.getElementById('txtEmail').value
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  alert('The email address contains invalid characters');
		  return false;
	   }
	}
	
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  alert("The email address contains non ascii characters.");
		  return false;
	   }
	}
	
	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   alert('The email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   alert('The email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   alert('The email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   alert('The email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   alert('The period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   alert('The period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	  alert('The two periods must not be adjacent in email address');
	   return false;
	}
	
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   alert('The primary domain in email address is invalid');
	   return false;
	}
	
	
	if (formVar != 3){
		telVar = "(,),+,1,2,3,4,5,6,7,8,9,0"
		telNo = document.getElementById("txtWorkTel").value
		oTel = telVar.split(",")
		for (i=0;i<telNo.length;i++){
			bExist = false;
			for(j=0;j<oTel.length;j++){
				if (telNo.substring(i,i+1) == oTel[j]){
					bExist = true;
				}
			}
			
			if (!bExist){
				alert("Please ensure that you provide a valid telephone number removing all spaces.");
				document.getElementById("txtWorkTel").focus();
				break;
			}
		}
	}
	
	return true;
}


var minTxtSize = 20;
var maxTxtSize = 20;
var i=11;

function incSize(){
var num = i++;
var div = document.getElementById("contentbody").style.fontSize;
if(maxTxtSize != i){
document.getElementById("contentbody").style.fontSize = num + "px";
}else{
return;
} 
}

function decSize(){
var num = i--;
var div = document.getElementById("contentbody");
if(minTxtSize != i){
div.style.fontSize = num + "px";
}else{
return;
} 
}

function ShowHide(elementId)
{
	var element = document.getElementById(submenu1);
	if(element.style.display != "block")
	{
		element.style.display = "block";
	}
	else
	{
		element.style.display = "none";
	}
}

function UpdateText(submenu1)
{
	if(element.innerHTML.indexOf("Show") != -1)
	{
		element.innerHTML = "Hide Details";
	}
	else
	{
		element.innerHTML = "Show Details";
	}
}

function fnPopWindow()
{
	var width = 500;
	var height = 340;
	var left = (screen.width - width)/2;
	var top = (screen.height - height)/2;
	headlinewindow = window.open(
        '/inc/Headlinepopup.asp', 
        '_Blank',
        'width=500,height=340,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=0');
	headlinewindow.moveTo(left,top);
}

function fnNewsPopWindow()
{
	window.open(
        '/inc/Headline.asp', 
        '_Blank',
        'toolbar=0,location=1,directories=0,status=1,menubar=0,scrollbars=1,resizable=0');
}

function fnLoginfocus()
{
	document.getElementById('txtUID').focus();
		return false;
}

function fnLoginCookie(mode, days) {
	if (mode == "sign out"){
		if (document.getElementById("txtUID").value == ""){
			alert("Please provide a username");
			document.getElementById("txtUID").focus();
			return false;
		}
		
		if (document.getElementById("txtPWD").value == ""){
			alert("Please provide a password");
			document.getElementById("txtPWD").focus();
			return false;
		}
		
		if (document.getElementById("chkRemember").checked == true){
			cookie_name = "NKC";
			var UIDPWD, UID, PWD
			
			if(document.cookie != document.cookie){
				index = document.cookie.indexOf(cookie_name);
			}else{ 
				index = -1;
			}
			
			if (index == -1){
				UID = document.getElementById('txtUID').value
				PWD = document.getElementById('txtPWD').value
				UIDPWD = UID+':'+PWD
				
				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 = cookie_name+"="+UIDPWD+expires+"; path=/";
			}
		}else{
			var date = new Date();
			date.setTime(date.getTime()+(-1*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
			UIDPWD = '';
			
			document.cookie = cookie_name+"="+UIDPWD+expires+"; path=/";
		}
	}
}

function fnRetrieveCookie() {
	cookie_name = "NKC";
	var UID, PWD
	
	if(document.cookie){
		var ca = document.cookie.split(';');
		var nameEQ = cookie_name + "=";
		for(var i=0; i < ca.length; i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
			if (c.indexOf(nameEQ) == 0) {
				oCookie = c.substring(nameEQ.length, c.length).split(":");
				document.getElementById("txtUID").value = oCookie[0];
				document.getElementById("txtPWD").value = oCookie[1];
				
				document.getElementById("chkRemember").checked = true;
			}
		}
		return null;
	}else{
		document.getElementById('txtUID').focus();
	}
}

function toggle_visibility(id) {
		for(var i=1; i<17; i++){
			document.getElementById('Q'+i+'Answer').style.display = 'none';
		}
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
}

function toggle_claim(id) {
	for(var i=1; i<7; i++){
		document.getElementById(i).style.display = 'none';
	}
	document.getElementById(id).style.display = 'block';
}

function toggle_claimform(id) {
	for(var i=1; i<4; i++){
		document.getElementById(i).style.display = 'none';
	}
	document.getElementById(id).style.display = 'block';
}

function fnMotorAccident(){
	document.getElementById('ClaimTop').style.display = 'none'
	document.getElementById('MotorAccident').style.display = 'block'
	document.getElementById('MotorTheft').style.display = 'none'
	document.getElementById('BuildingClaims').style.display = 'none'
	document.getElementById('ContentClaims').style.display = 'none'
}

function fnMotorTheft(){
	document.getElementById('ClaimTop').style.display = 'none'
	document.getElementById('MotorAccident').style.display = 'none'
	document.getElementById('MotorTheft').style.display = 'block'
	document.getElementById('BuildingClaims').style.display = 'none'
	document.getElementById('ContentClaims').style.display = 'none'
}

function fnBuildingClaims(){
	document.getElementById('ClaimTop').style.display = 'none'
	document.getElementById('MotorAccident').style.display = 'none'
	document.getElementById('MotorTheft').style.display = 'none'
	document.getElementById('BuildingClaims').style.display = 'block'
	document.getElementById('ContentClaims').style.display = 'none'
}

function fnContentClaims(){
	document.getElementById('ClaimTop').style.display = 'none'
	document.getElementById('MotorAccident').style.display = 'none'
	document.getElementById('MotorTheft').style.display = 'none'
	document.getElementById('BuildingClaims').style.display = 'none'
	document.getElementById('ContentClaims').style.display = 'block'
}

function fnHowClaim(){
	document.getElementById('MotorAccident').style.display = 'none'
	document.getElementById('MotorTheft').style.display = 'none'
	document.getElementById('BuildingClaims').style.display = 'none'
	document.getElementById('ContentClaims').style.display = 'none'
}

function fnCapeTownBranch(){
	document.getElementById('CapeTownBranch').style.display = 'block'
	document.getElementById('DurbanBranch').style.display = 'none'
	document.getElementById('JohannesburgBranch').style.display = 'none'
	document.getElementById('PEBranch').style.display = 'none'
	document.getElementById('PretoriaBranch').style.display = 'none'
}

function fnDurbanBranch(){
	document.getElementById('CapeTownBranch').style.display = 'none'
	document.getElementById('DurbanBranch').style.display = 'block'
	document.getElementById('JohannesburgBranch').style.display = 'none'
	document.getElementById('PEBranch').style.display = 'none'
	document.getElementById('PretoriaBranch').style.display = 'none'
}

function fnJohannesburgBranch(){
	document.getElementById('CapeTownBranch').style.display = 'none'
	document.getElementById('DurbanBranch').style.display = 'none'
	document.getElementById('JohannesburgBranch').style.display = 'block'
	document.getElementById('PEBranch').style.display = 'none'
	document.getElementById('PretoriaBranch').style.display = 'none'
}

function fnPEBranch(){
	document.getElementById('CapeTownBranch').style.display = 'none'
	document.getElementById('DurbanBranch').style.display = 'none'
	document.getElementById('JohannesburgBranch').style.display = 'none'
	document.getElementById('PEBranch').style.display = 'block'
	document.getElementById('PretoriaBranch').style.display = 'none'
}

function fnPretoriaBranch(){
	document.getElementById('CapeTownBranch').style.display = 'none'
	document.getElementById('DurbanBranch').style.display = 'none'
	document.getElementById('JohannesburgBranch').style.display = 'none'
	document.getElementById('PEBranch').style.display = 'none'
	document.getElementById('PretoriaBranch').style.display = 'block'
}

function fnValidateQuote(){
	if (document.getElementById("txtName").value == ""){
		alert("Please provide a Name");
		document.getElementById("txtName").focus();
		return false;
	}
	
	if (document.getElementById("txtSurname").value == ""){
		alert("Please provide a Surname");
		document.getElementById("txtSurname").focus();
		return false;
	}
	
	if (document.getElementById("txtName").value == ""){
		alert("Please provide a Name");
		document.getElementById("txtName").focus();
		return false;
	}
	
	if (document.getElementById("txtEmail").value == ""){
		alert("Please provide a Email address");
		document.getElementById("txtEmail").focus();
		return false;
	}
	
	var addr = document.getElementById('txtEmail').value
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  alert('The email address contains invalid characters');
		  return false;
	   }
	}
	
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  alert("The email address contains non ascii characters.");
		  return false;
	   }
	}
	
	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   alert('The email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   alert('The email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   alert('The email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   alert('The email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   alert('The period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   alert('The period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	  alert('The two periods must not be adjacent in email address');
	   return false;
	}
	
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   alert('The primary domain in email address is invalid');
	   return false;
	}	
	
	if (document.getElementById("txtContact").value == ""){
		alert("Please provide a Contact");
		document.getElementById("txtContact").focus();
		return false;
	}
}

function fnSiteSearch(){
	var searchstring = document.getElementById('search').value;
	var url = "/Pinion/search.asp?search="+searchstring
	makeRequest(url)
}

function fnQuoteType(type){
	if (type = 'Business'){
	document.getElementById('BusinessQuote1').style.display = 'block';
	document.getElementById('BusinessQuote2').style.display = 'block';
	}else if(type = 'Private'){
	document.getElementById('BusinessQuote1').style.display = 'none';
	document.getElementById('BusinessQuote2').style.display = 'none';
	}else{
	}
}

function fnvalidateform(){
	if (document.getElementById("field2").value == ""){
		alert ('Please complete the First name field');
		document.getElementById('field2').focus();
		return true;
	}
else{
return true;
}
}


