function grabobj(objname) // v1.0
{
	return $(objname);
}

function inputFocus(obj,defText) {
	if (obj.value==defText) {
		obj.value="";
	}
} 
function inputBlur(obj,defText) {
	if (obj.value=="") {
		obj.value=defText;
	}
} 
function $(objname)
{
	if (document.getElementById) return document.getElementById(objname);
	if (document.all) return document.all[objname];
	if (document.layers) return document.layers[objname];
}
function menuInit ()
{
	var i=1;
	while ($('menu_'+i))
	{
		$('menu_'+i).onmouseover=function(){ displayMenu(this);}
		$('menu_'+i).onmouseout=function(){ hideMenu(this);}
		i++;
	}
	i=1;
	while ($('menu_'+i+'_content'))
	{
		$('menu_'+i+'_content').onmouseover=function(){ clearMenuTimer(); }
		$('menu_'+i+'_content').onmouseout=function(){ menuTimer=window.setTimeout("closeMenus()",300);  }
		i++;
	}


}
function inputFocus(obj,defText) {
	if (obj.value==defText) {
		obj.value="";
	}
} 
function inputBlur(obj,defText) {
	if (obj.value=="") {
		obj.value=defText;
	}
} 

function displayMenu (obj)
{	
	clearTimeout(menuTimer);
	var i=1;
	while ($('menu_'+i+'_content'))
	{
		//$('menu_'+i).style.background='';
		$('menu_'+i+'_content').style.display='none';
		i++;
	}
	var id=obj.id.split('_')[1];
	$('menu_'+id+'_content').style.display='block';
	$('menu_'+id+'_content').style.top='206px';



	var popupWidth=$('menu_'+id+'_content').offsetWidth;
	var tabWidth=$('menu_'+id).offsetWidth;




/*	if ((findPos(obj)[0]+popupWidth)>1000)
	{
	 	var newLeft=(findPos(obj)[0]-findPos($('wrapper'))[0])-popupWidth+tabWidth;
		if (newLeft>0)
		{
			$('menu_'+id+'_content').style.left=newLeft+'px';
		} else {
			var bWidth=(findPos($('wrapper'))[0]*2)+1000;
			
			$('menu_'+id+'_content').style.left=((bWidth/2)-(popupWidth/2)-findPos($('wrapper'))[0])+'px';
		}
	} else {
*/		$('menu_'+id+'_content').style.left=(findPos(obj)[0]-findPos($('wrapper'))[0])+'px';
//	}
	menuDropShadow($('menu_'+id+'_content'));

}
//		javascript: menuDropShadow()
function menuDropShadow(menuObj) {
/*	This is designed to only work with IE as other browsers have drop-box-shadow in the css	*/
	if (navigator.appVersion.indexOf("MSIE")==-1) return;
	dropShadow	=	$('menuDropShadow');
	dropShadow.style.display	=	'block';
	dropShadow.style.height		=	(menuObj.offsetHeight-16)+'px';
	dropShadow.style.width		=	menuObj.offsetWidth+'px';
	dropShadow.style.top		=	(19+menuObj.offsetTop)+'px';
	dropShadow.style.left		=	(3+menuObj.offsetLeft)+'px';
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}
var menuTimer;
function hideMenu (id)
{
	menuTimer=window.setTimeout("closeMenus()",300);
}
function closeMenus ()
{
	var i=1;
	while ($('menu_'+i+'_content'))
	{
		//$('menu_'+i).style.background='';
		$('menu_'+i+'_content').style.display='none';
		i++;
	}
	$('menuDropShadow').style.display	=	'none';
}
function clearMenuTimer ()
{
	clearTimeout(menuTimer);
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}
function prodImageSwap (opt,obj)
{
  if (obj)
  {
	obj=grabobj(obj);
	if (obj)
	{
	
	 if (opt==1)
	 {
	  obj.src=obj.src.replace('/products/opt3/medium/','/products/medium/');
	  obj.src=obj.src.replace('/products/opt2/medium/','/products/medium/');
	 } else {

	  obj.src=obj.src.replace('/products/opt3/medium/','/products/opt'+opt+'/medium/');
	  obj.src=obj.src.replace('/products/opt2/medium/','/products/opt'+opt+'/medium/');
	  obj.src=obj.src.replace('/products/medium/','/products/opt'+opt+'/medium/');
	 }
	}

  }
}
function viewLarge(ref,opt)
{
	html="<div style=\"width:400px;\">";
	html+="<iframe src=\"/csp/dm/readeroffers/view.csp?id="+ref+"\" style=\"width:400px;height:430px;border:0px;\" scrolling=\"no\" frameborder=\"0\"></iframe>";

	html+="<div align=\"center\"><input type=\"button\" style=\"font-weight:bold;font-size:13px;\" onclick=\"clearItem('bigimg');\" value=\"Close Viewport\"></div>";
	html+="</div>";
	displayBox('bigimg',html);


}

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }



















function ajaxObject(url, callbackFunction)
{

  var that=this;      
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  this.update = function(passData,postMethod) { 
    if (that.updating) { return false; }
    that.AJAX = null;                          
    if (window.XMLHttpRequest) {              
      that.AJAX=new XMLHttpRequest();              
    } else {                                  
      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }                                             
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
        if (that.AJAX.readyState==4) {             
          that.updating=false;
          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date();        
	  
	  if ($('ajaxcall')) $('ajaxcall').innerHTML=new Date();
      if (/post/i.test(postMethod)) {
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.send(passData);
      } else {
        var uri=urlCall+'?'+passData+'&stamp='+(that.updating.getTime()); 
        that.AJAX.open("GET", uri, true);                             
        that.AJAX.send(null);                                         
      }              
      return true;                                             
    }
  }
  var urlCall = url;
  this.callback = callbackFunction || function () { };
}
function evalAjax (t,s)
{	
	eval(t);	
}
function toggleLine (id)
{
	var i=1;
	while ($('optionsline'+i))
	{
		if (id!=100) if (i!=id) $('optionsline'+i).style.display='none';
		if (id!=100) if (i!=id) $('headline'+i).style.display='none';
		i++;	
	}
	$('optionsline'+id).style.display='inline'
}

var openpromo=false;
function enterPromo (ref)
{
	clearItem('promo');
	if (!openpromo)
	{
		var ajax = new ajaxObject('/ajaxDrop/',evalAjax);
		ajax.update('ref='+ref,'POST');
	}
	//openpromo=true;
}
function promofocus ()
{
 if ($('promoCodeSect').style.display!="none")
 {
	$('PromotionCode').focus();
	$('PromotionCode').select();
 }
}
function ajaxCmd (page,dat)
{
	var ajax = new ajaxObject(page,evalAjax);
	ajax.update(dat,'POST');
}
function popUpSafe(obj) {
	iFrameSrc	=	obj.href+'&iFrame=1';
	html		=	'<iframe id="popUpSafeIFrame" src="'+iFrameSrc+'" border="0" frameborder="0"></iframe><a onclick="clearItem(\'popUpSafe\');" href="javascript: void(0);" class="closeMsgBox">X</a>';
	displayBox('popUpSafe',html);
	return false;
}
function parentResize(topDocId) {
	top.$(topDocId).style.height = document.body.offsetHeight+"px";
}