var valueProfileCompanyFocus;

 function addToFavorites(anchor)
 {
 if (window.external)
 {
 window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
 }
 } 

function foo(){
	        query = location.search;
		parties = query.split("?");
		partiess = parties[1].split("=");
		partiesss = partiess[1].split("&");
		numPage = partiesss[0];
		alert(numPage);
		//return numPage;
}


function updateLeftNavStyle(idPage){
	
//	alert("Updating element " + 'left_nav_p' + idPage);
	
	element = document.getElementById('left_nav_p' + idPage);

	element.className = "Selected";
	
	//element.setAttribute("class", "Selected");
	
	
}


function updateUpperNavStyle(id, way){
	
	element = document.getElementById(id);
	//alert('element');	
	//alert(id);
	if(way == 1){
	
		element.className = "DropdownTitleOver";
	}
	else{
		element.className = "DropdownTitle";
	}
	


}


function checkTel(elem)
{

	//alert(event.keyCode);
	/*
	if(elem.name == "tel_prefix" && elem.value.length == 4 && event.keyCode != 46 && event.keyCode != 16 && event.keyCode != 9)
	{
		document.getElementById('tel_zone').focus();
	}
	*/

	if(isNaN(elem.value))
	{
	 	elem.value = elem.value.substr(0,elem.value.length-1);
	 	return;
	}


}

// Function to clear content of search box on focus
function clearSearch() {
	document.frmSearch.elements['search'].value="";
}



function get_wnd(path)
{
	window.open(path,'','width=700,height=600,scrollbars=yes,resizable=yes,status=yes');
}

function get_wnd1(path)
{
	//path = "window.html?win="+path;
	path = "index.html?win="+path;
	window.open(path,'','width=780,height=650,scrollbars=yes,resizable=yes');
}

function pop_print(pg,lg,doc) {
	tmp="print.html?page="+pg+"&lang="+lg+"&doc="+doc;
	window.open(tmp,'','resizable=1,toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,width=750,height=650');
}

function launch_printer(path,hidden)
{
	var top = 0;
	var left = 0;
	var width = 750;
	var height = 550

	if(hidden)
	{
		left = "10000";
	}

	window.open(path,'','resizable=1,toolbar=no,status=no,scrollbars=yes,location=no,menubar=yes,width='+width+',height='+height+',top='+top+',left='+left);
}

function CheckEmail(elem,label)
{

	 var input =  document.getElementById(""+elem+"");
	 var label =  label;

	 if(input.value.length <= 0) return '     -The field "'+label+'" is mandatory.\n';

	 var check_email = emailCheck(input.value);

	 pos1=input.value.indexOf("@");
	 pos2=input.value.lastIndexOf(".");
	 pos = pos2 - pos1;

	 if(label.charAt(0) == '*') label = label.substring(1,label.length);
	 if(input.value.length <= 0) return '     -The field "'+label+'" is mandatory.\n';

	 //if ( (pos1==-1||pos1==0||pos1==input.value.length-1) || (pos2==-1||pos2==0||pos2==input.value.length-1) || (pos < 2)) return '     -Wrong e-mail format for "'+label+'" (ex: info@4your.net).\n';

	 if(!check_email) return '     -Wrong e-mail format for "'+label+'" (ex: myemail@domain.com).\n';

	 return '';
	}

/* - - - - - - - - - - - - - - - - - - - - - - -*/

	function emailCheck (emailStr)
	{
	/* The following pattern is used to check if the entered e-mail address
	   fits the user@domain format.  It also is used to separate the username
	   from the domain. */
	var emailPat=/^(.+)@(.+)$/
	/* The following string represents the pattern for matching all special
	   characters.  We don't want to allow special characters in the address.
	   These characters include ( ) < > @ , ; : \ " . [ ]    */
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	/* The following string represents the range of characters allowed in a
	   username or domainname.  It really states which chars aren't allowed. */
	var validChars="\[^\\s" + specialChars + "\]"
	/* The following pattern applies if the "user" is a quoted string (in
	   which case, there are no rules about which characters are allowed
	   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	   is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")"
	/* The following pattern applies for domains that are IP addresses,
	   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	   e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	/* The following string represents an atom (basically a series of
	   non-special characters.) */
	var atom=validChars + '+'
	/* The following string represents one word in the typical username.
	   For example, in john.doe@somewhere.com, john and doe are words.
	   Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")"
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	/* The following pattern describes the structure of a normal symbolic
	   domain, as opposed to ipDomainPat, shown above. */
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

	/* Finally, let's start trying to figure out if the supplied address is
	   valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	   different pieces that are easy to analyze. */
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
	  /* Too many/few @'s or something; basically, this address doesn't
		 even fit the general mould of a valid e-mail address. */
		alert("Wrong e-mail format (check @ and .'s)")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	// See if "user" is valid
	if (user.match(userPat)==null) {
		// user is not valid
		alert("TThe username doesn't seems to be valid.")
		return false
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	   host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		// this is an IP address
		  for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
			alert("Invalid destination IP address!")
			return false
			}
		}
		return true
	}

	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("Invalid domain name")
		return false
	}

	/* domain name seems valid, but now make sure that it ends in a
	   three-letter word (like com, edu, gov) or a two-letter word,
	   representing country (uk, nl), and that there's a hostname preceding
	   the domain or country. */

	/* Now we need to break up the domain to get a count of how many atoms
	   it consists of. */

	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length


	if (domArr[domArr.length-1].length<2 ||
		domArr[domArr.length-1].length>3) {
	   // the address must end in a two letter or three letter word.
	   alert("The e-mail address has an invalid domain extension.")
	   return false
	}

	// Make sure there's a host name preceding the domain.
	if (len<2) {
	   var errStr="Wrong domain name."
	   alert(errStr)
	   return false
	}

	// If we've gotten this far, everything's valid!
	return true;
}

/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  Permission granted to use this code 
  as long as this entire notice is included.
*************************************************************************/

function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 30 + "px";
  }
}

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}


function submitSearch() {}

/*
function submitSearch() {
	var code;


	var searched = document.getElementById('search').value;


	if(!searched){
		alert("EMPTY");
		return true;
	}

	
	e = window.event;

	if (!e) var e = window.event;

	if (e.keyCode) code = e.keyCode;

	else if (e.which) code = e.which;



	if(code == 13){
		
		document.location = 'index.html?page=109&search='+ searched;	
		
		return false;
	}

	return true;
}
*/


