/* Disable Right Click */
document.oncontextmenu = new Function("return false;");

/* START:Flash Detect*/
var swf = false;
function hasFlash(ver) {
  if(!ver) ver = 0;
  var n = navigator;
  if(n.plugins && n.plugins.length > 0) {
    var m,t,d,v;
    m = n.mimeTypes;
    t = 'application/x-shockwave-flash';
    if(m && m[t] && m[t].enabledPlugin && m[t].enabledPlugin.description) {
      d = m[t].enabledPlugin.description;
      v = d.charAt(d.indexOf('.')-1);
      swf = (v >= ver) ? true : false;
    }
  } else if(n.appVersion.indexOf("Mac") == -1 && window.execScript) {
    for(var i=ver; i<=7&&i!=1&&swf!=true; i++) {
      execScript('on error resume next: swf=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash'+((i==0)?'':'.'+i)+'"))','VBScript');
    }
  } else {
    swf = false;
  }
  return swf;
}
/* END:Flash Detect*/


/* START:COMMON SCRIPT*/
function swapImg(imgid,id) {
  o = document.getElementById(imgid);
  o.src = o.src.replace(/_\d\./,'_'+id+'.');
}

/* OpenWindow
ACTION:
Open a new instance of browser
NOTES:
Multiple calls will re-use the same window;
Scrollable arg should be "scroll" or "no_scroll" for ease of reading(nothing cryptic)
*/
function OpenWindow(url,height,width,top,left,scrollable){
  var owcscroll = (scrollable=='scroll')?'yes':'no';
  cm_ow = window.open(url,'cm_ow','height='+height+',width='+width+',resizable=1,top='+ top +',left='+ left +',scrollbars='+owcscroll);
  cm_ow.focus();
}
/* END:COMMON SCRIPT*/



/* to avoid implementing section-based js files, include the js here. if it gets bulky separate it later */



/* START:INVESTOR SECTION JAVASCRIPT */
function ShowReport(ele){
  var val = ele.options[ele.selectedIndex].value;
  if(val!='') document.location.href=val;
}
//investor section also uses showNewsList() which is identical as in the news section

/* END:INVESTOR SECTION JAVASCRIPT*/


function selectList(ele) {
  var val = ele.options[ele.selectedIndex].value;
	if(document.location.toString().indexOf("abs_investorinformation")+1){
    val = '/abs_investorinformation/pressrelease/default.asp?'+val.split('?')[1];
  }
  if(val!='') document.location.href=val;
}



/* START:NEWS SECTION JAVASCRIPT */
function showNewsList(ele) { //also used in investor section
  var val = ele.options[ele.selectedIndex].value;
  if(val!='') document.location.href=val;
}
/* END:NEWS SECTION JAVASCRIPT*/

/* START: Force Numeric */
function ForceNumeric(field)
{
	var inputStr = field.value.toString();
	var strLength = inputStr.length;
	var newStr = "";
	for (var i = 0; i < strLength; i++) 
{
	var oneChar = inputStr.charAt(i); 
	if (!( isNaN(oneChar) || oneChar == ' ') || oneChar == '-' ) 
	{ 
		newStr = String(newStr) + String(field.value.substring(i,i+1));
	}
}
	if (newStr != field.value) 
	{
		field.value = newStr;
	}
}
function NumericKeyUp(fieldToEval,fieldToEvalLength,objToJumpTo) 
{
	ForceNumeric(fieldToEval);
	if ((fieldToEval.value.length == fieldToEvalLength)&& (fieldToEval.value != prevValue) && (objToJumpTo != null))
	{ 
		objToJumpTo.focus() 
	} 
		prevValue = fieldToEval.value;
}
/* END: Force Numeric */

/* START: Zip Code Validation */
function ValidateZip (sZip)
{
	var regZip = /(^\d{5}$)|(^\d{5}-\d{4}$)/;

	if (sZip == '')
	{
		alert('Please Enter Your Zip Code');
		return false;
	}
	else if (!regZip.test(sZip))
	{
		alert('The Zip Code Entered Is Not Valid');
		return false;
	}
	else return true;
}
/* END: Zip Code Validation */

/* START: Validate PSC and Weekly Ads Form */
function ValidatePSCAdsForm (formName, fieldName, type)
{		
	var field = eval("document." + formName + "." + fieldName + ".value");
	var validated
			
	if (field.length == 0)
	{
		alert("Please Enter " + type + " Email Address");
		validated = EmailValidation (field);
	}
	else
	{	
		validated = EmailValidation (field);
	}	
	
	if (validated)
	{
		return true;
	}
	else
	{
		return false;
	}
}
/* END: Validate PSC and Weekly Ads Form */

/* START: Email Validation */
function EmailValidation (Email)
{
	var regEmail = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
		
	if (!regEmail.test(Email))
	{
		alert('The Email Address Entered Is Not Valid');
		return false;
	}
	else return true;	
}
/* END: Email Validation */

/* START:To display message when the first option in is selected */

function selectOptionChange(selectObj,message)
        {
           if((selectObj.selectedIndex) == 0)
           alert(message);     
        else
                  document.forms[0].submit();
        }

 /* END:To display message when the first option is selected */
 
 /* to avoid implementing section-based js files, include the js here. if it gets bulky separate it later */
 /*Changes made by DPSDA2N(KEANE)*/
/*function to open a popup for careers*/    
  
  function thirdPartywindowpopup(promoURL,name,height,width){
    var w = 404;
    var h= 309;
       
        if (document.all) {
        w = document.body.clientWidth;
        h = document.body.clientHeight;
    }
    else if (document.layers) {
      w = window.innerWidth;
      h = window.innerHeight;
    }
    
                    
    var popW = 300, popH = 200;
    var leftPos = (w-popW)/2, topPos = (h-popH)/2;
    
    var popupwindow = window.open("","","width=405,height=319,top=" + topPos + ",left=" + leftPos + ",location=0,status=0,scrollbars=true,menubar=0,resizable=0")
    var popup = popupwindow.document;
    popup.write('<html><head><title>SUPERVALU :: Third Party Site Notification</title>');
    popup.write('<script language=\'javascript\'>');
    popup.write('function redirect(){ var OpenerWin = window.opener;');
    popup.write('OpenerWin.location="http://savealot.recruitmax.com/MAIN/careerportal/default.cfm?szUniqueCareerPortalID=1bdbd0fe-4a82-4a9b-bc31-3f6695904641";}');
    popup.write('</script>');
    popup.write('</head>');
    popup.write('<body background="/eCommerceWeb/images/divBrands/common/bg-3rdparty-notice.gif">');
    popup.write('<br><br><br><br><br><br>&nbsp;');
    popup.write('<table width=404 height=165 border=0>');
    popup.write('<tr><td align=left style="padding-top:60px;">');
    //popup.write('<input type="image" src="/eCommerceWeb/images/divBrands/common/button-3rdpartyok.gif" border="0"  onclick="javascript:target=parent;window.open(\''+promoURL+'\', \'' +name+'\',\'height='+height+',width='+width+',scrollbars='+1+'\');javascript:window.close()"> ');
	popup.write('<input type="image" src="/eCommerceWeb/images/divBrands/common/button-3rdpartyok.gif" border="0"  onclick="redirect();window.close();"> ');
    popup.write('&nbsp;&nbsp;&nbsp;');   
    popup.write('<input type="image" src="/eCommerceWeb/images/divBrands/common/button-3rdpartycancel.gif" border="0"  onclick="javascript:window.close()">.');
    popup.write('</td></tr>');
    popup.write('</table>');
    popup.write('</body></html>');
    popup.close();
 }
 
 /*function to open a popup*/    
  
  function thirdPartywindowpopupall(promoURL,name,height,width){
    var w = 404;
    var h= 309;
       
        if (document.all) {
        w = document.body.clientWidth;
        h = document.body.clientHeight;
    }
    else if (document.layers) {
      w = window.innerWidth;
      h = window.innerHeight;
    }
    
                    
    var popW = 300, popH = 200;
    var leftPos = (w-popW)/2, topPos = (h-popH)/2;
    var popupwindow = window.open("","","width=405,height=319,top=" + topPos + ",left=" + leftPos + ",location=0,status=0,scrollbars=true,menubar=0,resizable=0")
    var popup = popupwindow.document;
    popup.write('<html><head><title>SUPERVALU :: Third Party Site Notification</title>');
    popup.write('</head>');
    popup.write('<body background="/eCommerceWeb/images/divBrands/common/bg-3rdparty-notice.gif">');
    popup.write('<br><br><br><br><br><br>&nbsp;');
    popup.write('<table width=404 height=165 border=0>');
    popup.write('<tr><td align=left style="padding-top:60px;">');
    popup.write('<input type="image" src="/eCommerceWeb/images/divBrands/common/button-3rdpartyok.gif" border="0"  onclick="javascript:window.open(\''+promoURL+'\', \'' +name+'\',\'height='+height+',width='+width+',scrollbars='+1+'\');javascript:window.close()"> ');
	//popup.write('<input type="image" src="/eCommerceWeb/images/divBrands/common/button-3rdpartyok.gif" border="0"  onclick="redirect();window.close();"> ');
    popup.write('&nbsp;&nbsp;&nbsp;');   
    popup.write('<input type="image" src="/eCommerceWeb/images/divBrands/common/button-3rdpartycancel.gif" border="0"  onclick="javascript:window.close()">.');
    popup.write('</td></tr>');
    popup.write('</table>');
    popup.write('</body></html>');
    popup.close();
 }
 


 
 

