function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
  return obj_window;
}

function help(fieldname,body) {
	pagename = '?q=help,'+fieldname+','+body+'';
	newWindow (pagename, 'help', 500, 100, 1, 0, 0, 0, 0, 0, 0);
}

function rhino_bookmark(){
  url = document.location;
  title = document.title;
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

function rhino_print () {
	var _url = document.location + "";
	var pos = _url.indexOf("?");
	if (pos >= 0) {
			url = document.location + '&print=1';		
	}
	else {
			url = document.location + '?print=1';
	}
	newWindow(url, 'Print', '800', '600', 1, 1, 1, 1, 1, 1, 0);
}

function rhino_tell () {
	var tellurl = 'modules/friend/';
	newWindow(tellurl, 'Print', '400', '300', 0, 0, 0, 0, 0, 0, 0);
}
function getInnerHtml(strURL, divid){ 
		
		document.getElementById(divid).innerHTML="<img src=\"upload/setup_files/loader.gif\" width=\"16\" height=\"16\" align=\"absmiddle\">&nbsp;Loading...";
		switch(divid){
			case 'divtable':
					EnableDisable2('divtablerow','show');
					break;
			case 'divprovinces':
					EnableDisable2('divprovincesrow','show');
					EnableDisable2('divcityrow','hide');
					EnableDisable2('divsuburbrow','hide');
					EnableDisable2('divtablerow','hide');
					break;
			case 'divcity':
					EnableDisable2('divcityrow','show');
					EnableDisable2('divsuburbrow','hide');
					EnableDisable2('divtablerow','hide');
					break;
			case 'divsuburb':
					EnableDisable2('divsuburbrow','show');
					EnableDisable2('divtablerow','hide');
					break;
		}
	var req = getXMLHTTP(); // fuction to get xmlhttp object
	 
	  if (req)
	 {
	 req.onreadystatechange = function()
	 
		 {	
			  if (req.readyState == 4) 
			  { //data is retrieved from server
				   if (req.status == 200) 
				   { // which reprents ok status                    
				     document.getElementById(divid).innerHTML=req.responseText;
				   }
				   else
				   { 
				   		alert(req.status);
				      //alert("There was a problem while using XMLHTTP:\n");
				   }
			  }            
		  }        
		req.open("GET", strURL, true); //open url using get method
		req.send(null);
	 }
}
function getXMLHTTP() 
	{ //fuction to return the xml http object
		var xmlhttp=false;
			
		try{xmlhttp=new XMLHttpRequest();}
		catch(e)	
		{		
			try{xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");}
			catch(e)
			{
				try{req = new ActiveXObject("Msxml2.XMLHTTP");}
				catch(e1){xmlhttp=false;}
			}
		}
		 	
		return xmlhttp;
	}
function EnableDisable2(id, status) {
     body=document.getElementById(id);
     if (body) {
       if (status == "show") {
         try {
           body.style.display='table-row';
         } catch(e) {
           body.style.display = 'block';
         }
       }
       else {
         body.style.display = 'none';
       }
     }
}
function Disable(id) {
	body=document.getElementById(id);
     if (body) {
     	body.style.display = 'none';
     }
}

function Enable(id) {
     body=document.getElementById(id);
     if (body) {
         try {
           body.style.display='table-row';
         } catch(e) {
           body.style.display = 'block';
         }
     }
}

function EnableDisable(id) {
     body=document.getElementById(id);
     if (body) {
       if (body.style.display == 'none') {
         try {
           body.style.display='table-row';
         } catch(e) {
           body.style.display = 'block';
         }
       }
       else {
         body.style.display = 'none';
       }
     }
}
function QuicklinckTrigger(Link){
	mytool_array = Link.split("*");
	var new_window = mytool_array[1];
	var link_url = mytool_array[0];
	if(link_url){
		if(new_window == 1){
			newWindow(link_url, "", "", "", 1, 1, 1, 1, 1, 1, 1)
		}else{
			window.location = link_url;
		}
	}
}
function checkEmails(form_id,email,email2) {
	var address = document.forms[form_id].elements[email].value;
   if(address){
	   	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   
	   if(reg.test(address) == false) {
	      alert('Error: Invalid Email Address');
		  document.forms[form_id].elements[email].value = "";
	      return false;
	   }
   }
   
}
