function getCookie(c_name){
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
	{
	c_start=c_start + c_name.length+1;
	c_end=document.cookie.indexOf(";",c_start);
	if (c_end==-1) c_end=document.cookie.length;
	return unescape(document.cookie.substring(c_start,c_end));
	}
  }
return "";
}
function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

/*
	Filen loades i ordre step 1, og i step 4

	<script language="javascript" src="/ubivox/jquery-1.4.2.min.js"></script>
	<script language="javascript" src="/ubivox/call.js"></script>
*/

$(document).ready(function(){

	if	(location.href.indexOf('/order1.html') != -1){
		
		$('#ShopMainLayOutTable .SubmitButton_Orderstep1_Position').click(function() {
			
			CNName = $('#ShopMainLayOutTable .CustomerData_Orderstep1_TBL #name').val();
			CNadress = $('#ShopMainLayOutTable .CustomerData_Orderstep1_TBL #email').val();
			
			if ($('#ShopMainLayOutTable .CustomerData_Orderstep1_TBL table:first input:checked').eq(0).val() == 'ON' && CNadress.length >= 1){
				setCookie('Ubivox-Name',CNName,365);
				setCookie('Ubivox-Mail',CNadress,365);
			}else{
				setCookie('Ubivox-Name','',-1);
				setCookie('Ubivox-Mail','',-1);
			}
		
		
	if	(location.href.indexOf('?cn') != -1){
	
//	old_alert('('+ CNName +')('+ CNadress +')');
	
	}
		
		
		});

	}

	if	(location.href.indexOf('/order4.html') != -1){
		
		if (getCookie('Ubivox-Mail') != ''){
			//	/ubivox/communicate.asp?mail=MAIL&list=1543&fields=Navn:CN;
			$('body').append('<iframe src="/ubivox/communicate.asp?mail='+ getCookie('Ubivox-Mail') +'&list=1543&fields=Navn:'+ getCookie('Ubivox-Name') +';" width="1" height="1" frameborder="0"></iframe>');
//			$.get('/ubivox/communicate.asp?mail='+ getCookie('Ubivox-Mail') +'&list=1543&fields=Navn:'+ getCookie('Ubivox-Name') +';');
		}

	}

});
