isIE = false;
navVer = navigator.appVersion;
ver = parseFloat(navVer);
IEPos = navVer.indexOf('MSIE');
if (IEPos !=-1) {
  isIE = true;
  ver = parseFloat(navVer.substring(IEPos+5,navVer.indexOf(';',IEPos)));
}

if (window.navigator.userAgent.indexOf('Opera')>=0)
	br='opera';
else if (window.navigator.userAgent.indexOf('Netscape')>=0)
	br='ns';
else if (window.navigator.userAgent.indexOf('AOL')>=0)
	br='aol'
else if (isIE && ver >= 5)
	br = 'ie';
else
	br=0;

CQoutURL = 'http://www.CQout.com/'; 
CQoutTitle = 'CQout Online Auctions';
function setNSHomepage(URL,Title) {  
	if (br=='ns') {	
	  var Text = '';
	  Text += 'Making "' + Title + '" your homepage, will show you a dialog with a warning.\n';
	  Text += 'If you do not wish to grant this site the access to your browser settings,';
	  Text += ' you can manually copy the current location and paste it in the location field in "Edit / Preferences / Navigator".';
	  if (confirm(Text)) {
	    netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
	    navigator.preference('browser.startup.homepage',URL);
	  }
      } else if (br=='opera') {
	  Text = 'Making "' + Title + '" your Home page.\n';
	  Text += 'You can manually copy the current location and paste it in the location field in "Navigation / Set home page...".';
   	  alert(Text);
	} else {
	  Text = 'Making "' + Title + '" your Home page.\n';
	  Text += 'You can manually copy the current location and paste it in your Home page.';
   	  alert(Text);
	}		
}
function addtofav(linkUrl, Title){
       if (br=='ie') {
		window.external.AddFavorite(linkUrl,Title);
	} else if (br=='ns') {
	      alert('Please hit Ctrl-d to bookmark "' + Title +'"');
      } else if (br=='opera') {
	  Text = 'Adding "' + Title + '" to your Bookmarks.\n';
	  Text += 'You can manually copy the current location and paste it in the location field in "Bookmarks / Add current document here...".';
   	  alert(Text);
      } else if (br=='aol') {
	  Text = 'Adding "' + Title + '" to your Bookmarks.\n';
	  Text += 'At our home page, click on the red heart at the top right of your browser, then Select Add to Favourites.\nTo return later, click on Favourites (folder with heart) from the toolbar at the top of the screen and click on "' + Title + '".';
	  window.location.href='index.asp' ;
   	  alert(Text);
	} else {
	  Text = 'Adding "' + Title + '" to your Bookmarks.\n';
	  Text += 'You can manually copy the current location and paste it in your Bookmarks.';
   	  alert(Text);
	}		
   return false;
}

// Check frames. If window has frames then open CQout frame on top location
function check_frames(frame_content){
	if (window.navigator.userAgent.indexOf('Netscape')>=0) {
		if (location.search.indexOf('sview=self')<0) {
			document.write("<FORM METHOD=GET TARGET=_top name=fredirect><input type=hidden name=sview value=self/></FORM>");
			document.fredirect.action=location.href;
			document.fredirect.submit();
		} else {}
	} else {
		if (top.frames.length>0) {
			top.location.href=this.location.href;
		} else {} 
	}
}	

function readRefUrl () {
	value = "";
	query=''+window.location.search;
	pos = query.indexOf("go=");
	if(pos==1) {
		value=query.substring(pos+3);
	}
	return value;
}	

function getDate_DDMMYYYY() {	
	var now = new Date();
	var value = "";
	value += (now.getDate()<10) ? '0' + now.getDate() : now.getDate()
	value += '-'
	value += (now.getMonth()+1<10) ? '0' + (now.getMonth()+1) : now.getMonth()+1
	Year = now.getYear()
	if (Year < 1999) Year += 1900;
	value += '-' + Year
	return value
}	

function showEmail (txt, style, pos1, pos2) {
	var wstyle;
	if (!(pos1)) pos1 = 8; //from end
	if (!(pos2)) pos2 = 3; //from end
	wstyle =  (style)? style : ""; 
	var addr = txt.substring(0,txt.length-pos1) + "@" + txt.substring(txt.length-pos1,txt.length-pos2) + "." + txt.substring(txt.length-pos2);
	document.write("<A h" + "ref" + "=\"ma" + "ilt" + "" + "o:" + addr + "\" " + wstyle + " >" + addr + "</a>");
}

function showEmailLink (txt, style, pos1,pos2) {
	if (!(pos1)) pos1 = 8; //from end
	if (!(pos2)) pos2 = 3; //from end
	if (txt.indexOf("?subject") > 0 ) {
		pos1 = pos1 + txt.length-txt.indexOf("?subject"); 
		pos2 = pos2 + txt.length-txt.indexOf("?subject"); 
	}

	wstyle =  (style)? style : ""; 
	var addr = txt.substring(0,txt.length-pos1) + "@" + txt.substring(txt.length-pos1,txt.length-pos2) + "." + txt.substring(txt.length-pos2);
	document.write("<a h" + "ref" + "=\"ma" + "ilt" + "" + "o:" + addr + "\" " + wstyle + " >");
}

function glPopUp(url, name, attr) {
	var newwindow=window.open(url,name,'toolbar=no,scrollbars=yes,resizable=yes,'+attr);
	if (window.focus) {newwindow.focus()}
	return false;
}

function ctrPopUponLoad(firstHIT) {
      window.cityBaloon=document.getElementById('cityBaloon');
      window.chooseCityBg=document.getElementById('chooseCityBg');
      window.chooseCitySelect=document.getElementById('chooseCitySelect');
      if (firstHIT != 'False' && firstHIT != 'false') { 
	      ctrPopUpOpen();
      }
}
function ctrPopUpOpen() {
     window.chooseCityBg.style.display=window.cityBaloon.style.display='block'; 
      return false;
}	
function ctrPopUpClose() {
      window.chooseCityBg.style.display=window.cityBaloon.style.display='';
      return false;
}
function remNonAlpha(val) {
	var text = val.value;
	var newtext = '';
	var valid_numbers = '0123456789';
	for (var i=0; i<text.length; i++) {
		if (valid_numbers.indexOf(text.charAt(i)) > -1)
			newtext+=text.charAt(i);
	}
	val.value = newtext;
	return newtext;
}

