﻿// JavaScript Document
function pop_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 pop_setCookie(name, value, expiredays) { 
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 

function pop_close(opt){
	var obj = document.getElementById(opt);
    if(obj.checked){
        if(arguments[1]){
            var num = arguments[1];
            pop_setCookie( "popClose" + num, "done" , 1); 
            self.close();
        }else{
            self.close();
        }
    }

	 
}

function open_pop(){
    var num = arguments[1];
	if(pop_getCookie("popClose" + num) != "done") {
		var pop_width = 300;
		var pop_height = 300;
		var pop_close_chk_opt = "0";
		var pop_location_opt = "0";
		var pop_location_opt_value1 = 0;
		var pop_location_opt_value2 = 0;
		var pop_resize_opt = "yes"
		if(arguments[0]){
			var pop_opt = arguments[0];
			var arr = pop_opt.split("|");
			if(arr.length == 7){
				pop_width = arr[0];
				pop_height = arr[1];
				pop_close_chk_opt = arr[2];
				pop_location_opt = arr[3];
				pop_location_opt_value1 = arr[4];
				pop_location_opt_value2 = arr[5];
				pop_resize_opt = arr[6];
				if(pop_resize_opt == "1") pop_resize_opt = "no";
				else {pop_resize_opt = "yes";}
				switch(pop_location_opt){
					case "0":
						var screen_w = window.screen.width;
						var screen_h = window.screen.height;
						pop_location_opt_value1 = (screen_h - Number(pop_height)) / 2;
						pop_location_opt_value2 = (screen_w - Number(pop_width)) / 2;
						break;
					case "1":
						pop_location_opt_value1 = "0";
						pop_location_opt_value2 = "0";
						break;
					default:
						break;
				}
				
				if(pop_close_chk_opt == "1"){
				    pop_height = Number(pop_height) + 27;
				}
			}
		}
		pop_width = Number(pop_width) - 10;
		pop_height = Number(pop_height) - 58;
		var spop = window.open("shrs_pop.aspx?num=" + arguments[1],"mainPop" + arguments[1] ,"width=" + (Number(pop_width) + 10) + ",height=" + (Number(pop_height) + 60) + ",status=no,toolbar=no,menubar=no,scrollbars=no,resizable=" + pop_resize_opt + ",left=" + pop_location_opt_value2 + ",top=" + pop_location_opt_value1);
		
		spop.focus();
	}

}