var hSelectedButton;

function setCookie( name, value, expiredays ) {
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString()+ "; "
}

function getCookie( name ) {
    var nameOfCookie = name + "=";
    var x = 0;
    
    while ( x <= document.cookie.length ) {
    	var y = (x+nameOfCookie.length);
    	if ( document.cookie.substring( x, y ) == nameOfCookie ) {
      		if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
        		endOfCookie = document.cookie.length;
      		return unescape( document.cookie.substring( y, endOfCookie ) );
    	}    	
    	x = document.cookie.indexOf( " ", x ) + 1;
    	if ( x == 0 )
      		break;
    }
    return "";
}

function np_SetImage() {
	if (getCookie("nprotect") == "none" ) {
	   	hSelectedButton = "off";
	} else { 
		hSelectedButton = "on"; 
	}
		Hack_off 	 = new Image(); 
		Hack_on  	 = new Image();
		Hack_off.src = "http://update.nprotect.net/nprotect2006/anyang/nprotect_off.gif";
		Hack_on.src  = "http://update.nprotect.net/nprotect2006/anyang/nprotect_on.gif";
}

function np_select(){
	np_SetImage();

	if ( hSelectedButton == "off"){

		setCookie("nprotect", "done", 100000);
		document.images['Hack1'].src = Hack_on.src;
		hSelectedButton   = "on";
		i_frame.location ="http://update.nprotect.net/nprotect2006/anyang/open_nprotect.html";
	} else {

		setCookie("nprotect" , "none", 100000);
		document.images['Hack1'].src = Hack_off.src;
		hSelectedButton = "off";
		i_frame.location="http://update.nprotect.net/nprotect2006/anyang/close_nprotect.html";
	}
}

function np_init(){

	var Hack2_off = new Image(); 
	var Hack2_on  = new Image();
	Hack2_off.src = "http://update.nprotect.net/nprotect2006/anyang/nprotect_off.gif";
	Hack2_on.src  = "http://update.nprotect.net/nprotect2006/anyang/nprotect_on.gif";

  setCookie("nprotect", "none", 100000);

	//document.images['Hack1'].src = Hack2_on.src;
	// i_frame.location="open_nprotect.html";

}
