//embed UK flash on alerts page
function flash1() {
document.write('<object width="525" height="250"><param name="movie" value="http://www.senedd.tv/main.swf?i=true&amp;tt=18300&amp;tv=en_100000_23_03_2010"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.senedd.tv/main.swf?i=true&amp;tt=18300&amp;tv=en_100000_23_03_2010" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="525" height="250"></embed></object>');   
}
//open blank
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 
//window.onload = externalLinks;
function onstart(objectID,state,control_offID,control_onID)
{
	externalLinks();
	openpopup();
	setVisibility(objectID,state,control_offID,control_onID);
}


function mailpage()
    {
    mail_str = "mailto:?subject=" + document.title;
    mail_str += "&body=Please help the animals by signing Ban Shock Collars Petition. ";
    mail_str += "You can view it at, " + location.href; 
    location.href = mail_str;
    }




//Pop up
var expDays = 1; // number of days the cookie should last

var page = "wait.html";
var w = 400;
var h = 400;
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);

var windowprops = "titlebar=0,toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, copyhistory=0, width="+w+",height="+h+",top="+top+",left="+left;

//var windowprops = "width=420,height=420,top=10,left=10,screenX=10,screenY=10,resizable=1,scrollbars=0,menubar=0";
function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if(i == 0) break;   
}  
return null;
}
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2]: null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure=(argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
   }
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function openpopup() {
var count = GetCookie('count');

if (count == null) {
count=1;
SetCookie('count', count, exp);

window.open(page, "popup", windowprops);

}
else {
count++;
SetCookie('count', count, exp);
   }
}
//Visibility functions
function setVisibility(objectID,state,control_offID,control_onID) {
var object = document.getElementById(objectID);
var off = document.getElementById(control_offID);
var on = document.getElementById(control_onID);
if(object != null) object.style.display = state;
if(state == 'none'){
	off.style.display = 'inline'
	on.style.display = 'none'}
}
function toggleVisibility(objectID,control_offID,control_onID) {
var object = document.getElementById(objectID);
var off = document.getElementById(control_offID);
var on = document.getElementById(control_onID);
if(object != null){
state = object.style.display;
if (state == 'block'){
object.style.display = 'none';
off.style.display = 'inline'
on.style.display = 'none'
}
else {
object.style.display = 'block';
off.style.display = 'none'
on.style.display = 'inline'
}
}
}


