function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function checkEmail(the_email)
{
var the_at = the_email.indexOf("@");
var the_dot = the_email.lastIndexOf(".");
var a_space = the_email.indexOf (" ");
if ((the_at != -1) &&
   (the_at != 0) &&
   (the_dot != -1) &&
   (the_dot > the_at +1) &&
   (the_dot < the_email.length -1) &&
   (a_space == -1))
   { 
     return true;
   } else {
     alert("Sorry, your e-mail address appears to be invalid. Please double check that you have entered it correctly.");
     return false;
   }
}

function transition() { 
	var allcookies=document.cookie;
	var pos = allcookies.indexOf("SOK=");
	var myprot = location.protocol;
	var myref = location.href;
	var start=5;
	var end= myref.length;
	if ((pos != -1) && (myprot == "http:")) 
		document.location = "https:" + myref.substring(start,end);
}

// JK Pop up image viewer script- By JavaScriptKit.com
// Visit JavaScript Kit (http://javascriptkit.com)
// for free JavaScript tutorials and scripts
// This notice must stay intact for use

var popbackground="#e8e8e8" //specify backcolor or background image for pop window
var windowtitle="2008 Magic Winners"  //pop window title

function detectexist(obj){
return (typeof obj !="undefined")
}

function jkpopimage(imgpath, popwidth, popheight, textdescription){

function getpos(){
leftpos=(detectexist(window.screenLeft))? screenLeft+document.body.clientWidth/2-popwidth/2 : detectexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
toppos=(detectexist(window.screenTop))? screenTop+document.body.clientHeight/2-popheight/2 : detectexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
if (window.opera){
leftpos-=screenLeft
toppos-=screenTop
}
}

getpos()
var winattributes='width='+popwidth+',height='+popheight+',resizable=yes,left='+leftpos+',top='+toppos
var bodyattribute=(popbackground.indexOf(".")!=-1)? 'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"'
if (typeof jkpopwin=="undefined" || jkpopwin.closed)
jkpopwin=window.open("","",winattributes)
else{
//getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
//jkpopwin.moveTo(leftpos, toppos)
jkpopwin.resizeTo(popwidth, popheight+30)
}
jkpopwin.document.open()
jkpopwin.document.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>'+windowtitle+'</title></head><body '+bodyattribute+'><img src="'+imgpath+'" style="margin-bottom: 0.5em; border: 4px #9c4117 solid; margin-top: 0.5em; margin-left: 0.5em;" /><br />'+textdescription+'</body></html>')
jkpopwin.document.close()
jkpopwin.focus()
}
function MoveDiv(myDiv) {
  var posx = 0; var posy = 0; var e = window.event;
  if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; }
  else if (e.clientX || e.clientY) {
    posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
    posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
  }
  document.getElementById(myDiv).style.left = posx;
  document.getElementById(myDiv).style.top = posy;
}
function shareThis(site,thisTitle,thisDescription) {
    var thisURL = window.location.href;
    thisURL = thisURL.replace("#","");

/*  for tracking
    if (thisURL.indexOf("THEREF=") > 0) {
      thisURL = thisURL.replace("THEREF=","THEREF=HELLO&OLDREF=");
    } else if (thisURL.indexOf("?") > 0) {
      thisURL = thisURL + "&THEREF=HELLO";
    } else {
      thisURL = thisURL + "?THEREF=HELLO";
    }
*/
    var encodedURL = encodeURIComponent(thisURL);
    var encodedTitle = encodeURIComponent(thisTitle);
    var encodedDescription = encodeURIComponent(thisDescription);
    var targetURL;

    switch (site) {
      case "facebook":
        targetURL = "http://www.facebook.com/sharer.php?u="
           + encodedURL
           + "&t=" + encodedTitle;
      break;
      case "myspace":
        targetURL = "http://www.myspace.com/Modules/PostTo/Pages/?u="
           + encodedURL
           + "&t=" + encodedTitle
	   + "&c=" + encodedDescription;
      break;
      case "twitter":
        targetURL = "http://twitter.com/home?status="
           + encodedURL;
      break;
    }
    window.open(targetURL,"_blank");
}

function shareURL(site,thisURL,thisTitle,thisDescription) {
    thisURL = thisURL.replace("#","");

/*  for tracking
    if (thisURL.indexOf("THEREF=") > 0) {
      thisURL = thisURL.replace("THEREF=","THEREF=HELLO&OLDREF=");
    } else if (thisURL.indexOf("?") > 0) {
      thisURL = thisURL + "&THEREF=HELLO";
    } else {
      thisURL = thisURL + "?THEREF=HELLO";
    }
*/
    var encodedURL = encodeURIComponent(thisURL);
    var encodedTitle = encodeURIComponent(thisTitle);
    var encodedDescription = encodeURIComponent(thisDescription);
    var targetURL;

    switch (site) {
      case "facebook":
        targetURL = "http://www.facebook.com/sharer.php?u="
           + encodedURL
           + "&t=" + encodedTitle;
      break;
      case "myspace":
        targetURL = "http://www.myspace.com/Modules/PostTo/Pages/?u="
           + encodedURL
           + "&t=" + encodedTitle
	   + "&c=" + encodedDescription;
      break;
      case "twitter":
        targetURL = "http://twitter.com/home?status="
           + encodedURL;
      break;
    }
    window.open(targetURL,"_blank");
}

function get_cookie(cookie_name)
{
	var results = document.cookie.match( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
	if (results)
		return (unescape(results[2]));
	else
		return null;
}
function set_cookie(cookie_name,cookie_value)
{
	var newcookie = cookie_name+"="+cookie_value+"; path=/";
	document.cookie = newcookie;
	return true;
}
function realonly(field,event) {
	  if (window.event || event) key = window.event ? window.event.keyCode : event.which;
	    else return true;
	      if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27) ||
			          (("0123456789.").indexOf(String.fromCharCode(key)) > -1)) {
		              if (key == 46) {
				                if (field.value.indexOf('.') != (-1)) return false;
						        }
			        	return true;
					  }
	        return false;
}
function intonly(field,event) {
	  if (window.event || event) key = window.event ? window.event.keyCode : event.which;
	    else return true;
	      if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27) ||
			          (("0123456789").indexOf(String.fromCharCode(key)) > -1))
		        	return true;
	        return false;
}

function intonly1(field,event) {
	  if (window.event || event) key = window.event ? window.event.keyCode : event.which;
	    else return true;
	      if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 27) ||
			          (("0123456789").indexOf(String.fromCharCode(key)) > -1))
		        	return true;
	        return false;
}

function subonly(field,val) {
	if (field.value > val) {
		alert("You can not increase this value.");
		field.value = val;
	}
	return true;
}

function ynonly(field,event) {
	  if (window.event || event) key = window.event ? window.event.keyCode : event.which;
	    else return true;
	      if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27) ||
			          (("NYny").indexOf(String.fromCharCode(key)) > -1))
		        	return true;
	        return false;
}
function decimals(field,count) {
	  var dot=field.value.indexOf('.');
	      if (count && (dot != (-1)) && 
			            ((field.value.length - dot) > (count +1))) {
		      	var v = field.value;
				field.value=v.substring(0,dot+count+1);
				  }
	        return true;
}

var clickSubmitted = false;
function disableDblClick(obj)
{
	if (!clickSubmitted) {
		clickSubmitted = true;
		return true;
	}
	document.getElementById(obj).href='#';
	return false;
}


