function PopupViewShipping(){PopupCreateModal('shipping');}
function PopupViewCompetitive(){PopupCreateModal('competitive');}
function PopupViewSatisfaction(){PopupCreateModal('satisfaction');}
function popupFreightExplained(type){PopupCreateModal(type);}

function PopupCreateModal(type)
{
	var opac=document.getElementById("modalBackgroundPopup").style.opacity;
	PopupChangeOpac(0,'modalBackgroundPopup');
	PopupChangeOpac(0,'modalWindowPopup');

	document.getElementById('modalWindowPopup').style.display='block';
	document.getElementById('modalBackgroundPopup').style.display='block';

	if(type=='shipping')
		{
			document.getElementById('PopupShippingView').style.display='block';
			document.getElementById('PopupShippingViewTop').style.display='inline';
		}

	if(type=='competitive')
		{
			document.getElementById('PopupCompetitive').style.display='block';
			document.getElementById('PopupCompetitiveTop').style.display='inline';
		}

	if(type=='satisfaction')
		{
			document.getElementById('PopupSatisfaction').style.display='block';
			document.getElementById('PopupSatisfactionTop').style.display='inline';
		}
  
  // Freight Rates
  if(type=='insurance')
		{
			document.getElementById('PopupFreightInsuranceView').style.display='block';
			document.getElementById('PopupFreightInsuranceTop').style.display='inline';
		}
    
  if(type=='glowe')
		{
			document.getElementById('PopupFreightGloweView').style.display='block';
			document.getElementById('PopupFreightGloweTop').style.display='inline';
		}
    
  if(type=='warranty')
		{
			document.getElementById('PopupFreightWarrantyView').style.display='block';
			document.getElementById('PopupFreightWarrantyTop').style.display='inline';
		}
  
  if(type=='expedited')
    {
      document.getElementById('PopupFreightExpeditedView').style.display='block';
      document.getElementById('PopupFreightExpeditedTop').style.display='inline';
    }

	onWindowResize();

	if(document.all)document.documentElement.onscroll=onWindowResize;

	PopupOpacity('modalBackgroundPopup',0,70,700);
	PopupOpacity('modalWindowPopup',0,100,800);
}

function PopupOpacity(id,opacStart,opacEnd,millisec)
{
	var speed=Math.round(millisec/100);
	var timer=0;
	if(opacStart>opacEnd)
		{
			for(i=opacStart;i>=opacEnd;i--)
				{
					setTimeout("PopupChangeOpac("+i+",'"+id+"')",(timer*speed));
					timer++;
				}
	}else if(opacStart<opacEnd)
		{
			for(i=opacStart;i<=opacEnd;i++)
				{
					setTimeout("PopupChangeOpac("+i+",'"+id+"')",(timer*speed));
					timer++;
				}
		}
	if(i==opacEnd);return true;
}

function PopupChangeOpac(opacity,id)
{
	var object=document.getElementById(id).style;object.opacity=(opacity/100);
	object.MozOpacity=(opacity/100);
	object.KhtmlOpacity=(opacity/100);
	object.filter="alpha(opacity="+opacity+")";
}


function PopupEraseModal(type)
{
	PopupOpacity('modalBackgroundPopup',70,0,700);

	if(PopupOpacity('modalWindowPopup',100,0,800))
	{
			setTimeout("document.getElementById('modalWindowPopup').style.display=document.getElementById('modalBackgroundPopup').style.display='none'",800);
		}else{	
			document.getElementById('modalWindowPopup').style.display=document.getElementById('modalBackgroundPopup').style.display='none';
		}
	if (type=='satisfaction')
	{
			document.getElementById('PopupSatisfaction').style.display='none';
			document.getElementById('PopupSatisfactionTop').style.display='none';

	}

	if (type=='shipping')
	{
			document.getElementById('PopupShippingView').style.display='none';
			document.getElementById('PopupShippingViewTop').style.display='none';
	}

	if (type=='competitive')
	{
			document.getElementById('PopupCompetitive').style.display='none';
			document.getElementById('PopupCompetitiveTop').style.display='none';
	}
  
  // Freight Rates
  if (type=='insurance')
	{
			document.getElementById('PopupFreightInsuranceView').style.display='none';
			document.getElementById('PopupFreightInsuranceTop').style.display='none';
	}
  
  if (type=='glowe')
	{
			document.getElementById('PopupFreightGloweView').style.display='none';
			document.getElementById('PopupFreightGloweTop').style.display='none';
	}
  
  if (type=='warranty')
	{
			document.getElementById('PopupFreightWarrantyView').style.display='none';
			document.getElementById('PopupFreightWarrantyTop').style.display='none';
	}
  
  if (type=='expedited')
  {
      document.getElementById('PopupFreightExpeditedView').style.display='none';
      document.getElementById('PopupFreightExpeditedTop').style.display='none';
  }
}



function onWindowResize()
{
	var left=window.XMLHttpRequest==null?document.documentElement.scrollLeft:0;
	var top=window.XMLHttpRequest==null?document.documentElement.scrollTop:0;
	var div=document.getElementById('modalWindowPopup');
	div.style.left=Math.max((left+(getWindowWidthPopup()-div.offsetWidth)/2),0)+'px';
	div.style.top=Math.max((top+(getWindowHeightPopup()-div.offsetHeight)/2),0)+'px';
}


function getWindowWidthPopup()
{
	var width=document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth||document.body&&document.body.parentNode&&document.body.parentNode.clientWidth||0;
	return width;
}
function getWindowHeightPopup()
{
	if(window.innerHeight)return window.innerHeight;
	else return document.documentElement.clientHeight;
}