// a2kGlobal.js
isIE=(navigator.userAgent.toLowerCase().indexOf("msie") != -1);
isFF=(navigator.userAgent.toLowerCase().indexOf("firefox") != -1);
  
function getExt(flName){
  firstpos=flName.lastIndexOf('.');
  lastpos=flName.length;
  return flName.substring(firstpos,lastpos);
}

function a2kImgOver(img){
  var ext= getExt(img.src);
  img.oldSrc=img.src;

  var indx=img.src.lastIndexOf('-on');
  if(indx==-1)
    indx=img.src.lastIndexOf(ext);
  img.src=img.src.substring(0,indx)+"-over"+ext;
}
function a2kImgOn(img){
  var ext= getExt(img.src);
  var indx1=img.src.lastIndexOf('-');
  var indx2=img.src.lastIndexOf('/');
  var indx = -1;
  if(indx1 > indx2)
    indx=indx1;
  if(indx==-1)
    indx=img.src.lastIndexOf(ext);
  img.src=img.src.substring(0,indx)+"-on"+ext;
}
function a2kImgOut(img){
  img.src=img.oldSrc
  img.oldSrc=null;
}
function a2kImgOff(img){
  var ext= getExt(img.src);
  var indx1=img.src.lastIndexOf('-');
  var indx2=img.src.lastIndexOf('/');
  var indx = -1;
  if(indx1 > indx2)
    indx=indx1;
  if(indx==-1)
    indx=img.src.lastIndexOf(ext);
  img.src=img.src.substring(0,indx)+"-off"+ext;
}

function plainPopup(url) {
  plainPopup(url, '_blank');
}

function plainPopup(url, name) {
  popupWin = window.open(url, name, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=800, height=600');
  if (popupWin == null)
    alert('Please enable popups in your popup blocker for this site.');
  else
    popupWin.focus();
}


function getWait(url){
  var waitDiv = document.getElementById("loadingWait");
  if(waitDiv)
    waitDiv.style.display="block";    
  document.location.href=url;
}
function getWaitPopup(url) {
  if (navigator.appVersion.indexOf('Safari') == -1){
	  popupWin = window.open("", '_blank', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=800, height=600');
	  if (popupWin == null)
	    alert('Please enable popups in your popup blocker for this site.');
	  else {
	    popupWin.document.write('<html><head></head><body>');
	    popupWin.document.write('<div id="loadingWait" style="position:absolute;width:150px;height:150px;left:50%;top:200px;margin-left:-75px;display:none;z-index: 10000;background:transparent;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="150" height="150" id="waiting" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/a2kWeb/flash/waiting.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="/a2kWeb/flash/waiting.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="150" height="150" name="waiting" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></div>');
	    popupWin.document.write('</body></html>');
	    var waitDiv = popupWin.document.getElementById("loadingWait");
	    if(waitDiv)
	      waitDiv.style.display="block";    
	    popupWin.document.location.href=url;
	  }
  }
  else {
    popupWin = window.open(url, '_blank', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=800, height=600');
  }
}

function postWait(frm){
  var waitDiv = document.getElementById("loadingWait");
  if(waitDiv)
    waitDiv.style.display="block";    
  if(frm)
    frm.submit();
}

function waitWithoutSubmit(){
  var waitDiv = document.getElementById("loadingWait");
  if(waitDiv)
    waitDiv.style.display="block";  
}

function doubleConfirm(msg1, msg2){
	var result = false;
	if(confirm(msg1)){
		if(confirm(msg2)){
			result = true;
		}
	}	
	
	return result;
}


function promptPOC(msgText) {     
     if($.browser.msie && $.browser.version <= 6){
       var varText = 'We have noticed you have not viewed the Welcome to Amway Presentation.\nThis is a short presentation that you will find very valuable as you dive into your new business. \nPlease note you cannot order products until you view this presentation.';
       if (confirm(varText)){
       	 window.open('/Images/peckoncheek-html/index.html', 'POC', 'height=630,width=960,status=no,menubar=no,toolbar=no,location=no,scrollbars=no,resizable=no');
       	 return false;
       }else{
       	return false;
       }
     } else{    
	     $.alerts.okButton="View it now";
	     $.alerts.cancelButton="Ask me later";	
	     				
	   	 $.alerts.dialogClass = "pocReminder";  
		 jConfirm(msgText, 'Welcome to Amway Presentation Reminder', function(result) {
		    if (result == true){
				window.open('/Images/peckoncheek-html/index.html', 'POC', 'height=630,width=960,status=no,menubar=no,toolbar=no,location=no,scrollbars=no,resizable=no');
			}
		});
		return false;
	}	
} 

function processedPOCUpdate(data) {
	alert(data); 
	return false;
}