// Assign path  for images in ROL. site

//******************************************************************************
//
// Browser check for all versions of IE and NS
//
//******************************************************************************
// 02/06/2001 10:07AM. Nai add feature Cancel.
var agt = navigator.userAgent.toLowerCase(); 
var is_major = parseInt(navigator.appVersion); 
var is_minor = parseFloat(navigator.appVersion); 

// Just to be safe we can check for all versions of IE and NS

var is_nav  = ((agt.indexOf('mozilla')!=-1));
var is_nav2 = (is_nav && (is_major == 2)); 
var is_nav3 = (is_nav && (is_major == 3)); 
var is_nav4 = (is_nav && (is_major == 4)); 
var is_nav4up = (is_nav && (is_major >= 4)); 
var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) ); 
var is_nav5 = (is_nav && (is_major == 5)); 
var is_nav5up = (is_nav && (is_major >= 5)); 

var is_ie   = (agt.indexOf("msie") != -1); 
var is_ie3  = (is_ie && (is_major < 4)); 
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) ); 
var is_ie4up  = (is_ie  && (is_major >= 4)); 
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) ); 
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4); 

var random_text = new Array("0","1","2","3","4","5","6","7","8","9","0","a","b","c","d",
				"e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
				"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");

/*
if (is_ie4up) {
	document.write("<LINK rel='stylesheet' href='includes/globalstyle_ie.css' type='text/css'>");
}
else { 
	document.write("<LINK rel='stylesheet' href='includes/globalstyle_ns.css' type='text/css'>");
}
*/
document.write("<LINK rel='stylesheet' href='includes/global_style.css' type='text/css'>");
//******************************************************************************
//
// Show link description in the window status bar
//
//******************************************************************************
function showStatus(text) {
	window.status = text;
}

//******************************************************************************
//
// For pop up windows. Specifies html file, height and width within the string
//
//******************************************************************************
function openNewWindow(fileName,windowName,theWidth,theHeight) {
	window.open(fileName,windowName,"toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight)
}

function openNewDialog(fileName,windowName,theWidth,theHeight) {
	window.open(fileName,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+theWidth+",height="+theHeight)
}

//******************************************************************************
//
// Select All function for checkboxes
//
//******************************************************************************
function SelectAll_Mails(form){
	len = form.length;
	for (i=0;i<len;i++){
		if(form.elements[i].name == 'selectmail[]'){
			form.elements[i].checked = form.SelectAll.checked;
		}
	}
}

function alertTrash(theMessage) {
confirm (theMessage);
}


function switchImage(nameStr, sourceStr) {
	if (eval("document.images." + nameStr)) {
		eval( 'document.images.' + nameStr + '.src=' + sourceStr + '.src;' );
	}
}

function switchSection(nameStr) {
	if (document.images) {
		for(i=0;i<document.images.length;i++){
			if (document.images[i].name!=nameStr) {
				image_i_name = document.images[i].name;
				imgsrcStr = document.images[i].src;
				if (imgsrcStr.substring(imgsrcStr.length-9, imgsrcStr.length) == "_roll.gif") {		
					modifier = "_off";
					switchImage(image_i_name, image_i_name+modifier);
				} 
			}
		}
		if (eval("document.images." + nameStr)) {
			imgsrcStr = eval('document.images.'+nameStr+'.src');
			if (imgsrcStr.substring(imgsrcStr.length-9, imgsrcStr.length) == "_roll.gif") {		
				modifier = "_off";
				baseStr = imgsrcStr.substring(0, imgsrcStr.length - 9);
			} else {
				modifier = "_roll";
				baseStr = imgsrcStr.substring(0, imgsrcStr.length - 8);
			}
			switchImage(nameStr, nameStr+modifier);
		}
	}
}
function alert_signup(){
	window.open('alert_signup.php','alert_window','height=100,width=400,top=100,left=250,scrollbars=no,resizable=yes');
}

function cancel_confirm(reason){
	text = "Are you sure you would like to cancel "+reason;
	if(confirm(text)){
		window.close();
	}
}
function isUsing(string_id,sel_id){
	result = false;
	str_array=new Array();
	sel_array=new Array();
	str_array=string_id.split(',');
	sel_array=sel_id.split(',');
	for(i=0;i<str_array.length;i++){
		for(j=0;j<sel_array.length;j++){
			if(sel_array[j]==str_array[i]){
				result=true;
				j=sel_array.length;
				i=str_array.length;
			}
		}
	}
	return result;
}
function DeleteCheckedItems(form,chbx_name){
	var checked = false;
	var sel_id = '';
	for(i=0;i<form.elements.length;i++){
		if((form.elements[i].name==chbx_name)&&(form.elements[i].checked)){
			checked = true;
			if(form.usingid_text){
				if(sel_id=='')	sel_id = form.elements[i].value;
				else	sel_id += ','+form.elements[i].value;
			}
			else	i = form.elements.length;
		}
	}
	if(!checked){
		alert('Please make a selection.');
	}else{
		if(form.usingid_text){
			if(isUsing(form.usingid_text.value,sel_id))	{
				if((form.announce_id)||(form.name=='productlist_form')||(form.name=='receivablelist_form')){
					ok = false;
					alert(notice_word);
				}else if (form.data_sort){
					if((form.data_sort.value=='modify_categorynew_product')||(form.data_sort.value=='modify_categoryproductlist_form')){
						ok = false;
						alert(notice_word);
					}else	ok = confirm(notice_word);
				}else	ok = confirm(notice_word);
			
			}else	ok = confirm('Are you sure you want to delete the selected items?');
		}else ok = confirm('Are you sure you want to delete the selected items?');
		if(ok){
			form.submitType.value = 'Delete';
			form.submit();
		}
	}
}


function change_image(buttName,buttNew, clickFile){
	if(clickFile==1){
		document.images[buttName].src = imgBtns_select[buttNew].src;
	}else{
		document.images[buttName].src = imgBtns[buttNew].src;
	}
}

function SwapImgMain(push) {
	if(push)
		document.mainscn.src = imgMain[2].src;
	else
		document.mainscn.src = imgMain[1].src;
}

function SwapImgBack(push) {
	if(push)
		document.backbtn.src = imgBack[2].src;
	else
		document.backbtn.src = imgBack[1].src;
}

function RandomFunc(input){
	var to_text = '';
	len = random_text.length - 1;
	for(i=0;i<=9;i++){
		to_text += random_text[Math.round(len*Math.random())];
	}
	if(input == 'login') document.forms[0].f_name.value = to_text;
	else document.forms[0].f_password.value = to_text;
}

function CheckMonth(st_en){
	var form = document.forms[0];
	var day_ctl = eval('form.'+st_en+'_day');
	var month_ctl = eval('form.'+st_en+'_month');
	var year_ctl = eval('form.'+st_en+'_year');
	var sel_day = eval(day_ctl.options[day_ctl.selectedIndex].value);
	var sel_month = eval(month_ctl.options[month_ctl.selectedIndex].value);
	var sel_year = eval(year_ctl.options[year_ctl.selectedIndex].value);

	if(sel_month==2){
		if(sel_year%4==0)	enday_of_mon = 29;
		else				enday_of_mon = 28;
	}else if((sel_month==4)||(sel_month==6)||(sel_month==9)||(sel_month==11)){
		enday_of_mon = 30;
	}else{
		enday_of_mon = 31;
	}

	if((day_ctl.options.length>enday_of_mon)&&(sel_day>enday_of_mon)){
		while(day_ctl.options.length>enday_of_mon){
			ind = day_ctl.options.length-1;
			day_ctl.options[ind] = null;
		}
		if(day_ctl.options.length==enday_of_mon) day_ctl.selectedIndex=day_ctl.options.length-1;
		if(day_ctl.selectedIndex<1) day_ctl.selectedIndex=day_ctl.options.length-1;
	}
	else if(day_ctl.options.length<enday_of_mon){
		while(day_ctl.options.length<enday_of_mon){
			ind = day_ctl.options.length;
			val = ind +1;
			day_ctl.options[ind] = new Option(val,val,false,false);
		}
		if(sel_day<val) day_ctl.selectedIndex=sel_day-1;
		else            day_ctl.selectedIndex=val-1;  
	}
	else if(sel_day>day_ctl.options.length){
		day_ctl.selectedIndex = day_ctl.options.length-1;
	}
	
	if((sel_month==4)||(sel_month==6)||(sel_month==9)||(sel_month==11)||(sel_month==2)){
		while(day_ctl.options.length>enday_of_mon){
			ind = day_ctl.options.length-1;
			day_ctl.options[ind] = null;
		}
	}
	
}

function SelectAll(NameAll,form,NameElement){
	len = form.length;
	for (i=0;i<len;i++){
		if(form.elements[i].name == NameElement){
			form.elements[i].checked = NameAll.checked;
		}
	}
}
function RefreshAdminTopBottom(mn,p_id){
	var url='?p_id='+p_id+'&mn='+mn;
	switch(mn){
		case'admin':
			action_bottom='user_list.php';
		break;
		case 'game':
			action_bottom='game_list.php';
		break;
		case 'season':
			action_bottom='season_list.php';
		break;
		case 'sponsor':
			action_bottom='sponsor_list.php';
		break;
		case 'action':
			action_bottom='action_list.php';
		break;
		case 'product':
			action_bottom='product_list.php';
		break;
		case 'invoice':
			action_bottom='invoice_list.php';
		break;
	}
	this.location = 'main_admin_menu.php'+url;
	parent.main.location = action_bottom+url;
}
function RefreshAdminTopBottom2(mn,p_id,season_id){
	var url='?p_id='+p_id+'&mn='+mn+'&season_id='+season_id;
	switch(mn){
		case 'sponsor':
			action_bottom='sponsor_list.php';
		break;
		case 'product':
			action_bottom='product_list.php';
		break;
		case 'invoice':
			action_bottom='invoice_list.php';
		break;
		case 'receivable':
			action_bottom='receivable_main_list.php';
		break;
		case 'pa_listing':
			action_bottom='pa_list.php';
		break;
	}
	this.location = 'main_admin_menu.php'+url;
	parent.main.location = action_bottom+url;
}
function RefreshTopBottom(showtype_radio,mn,p_id,game_id,season_id){
	var url='?p_id='+p_id+'&mn='+mn+'&showtype_radio='+showtype_radio+'&game_id='+game_id+'&season_id='+season_id;
	switch(showtype_radio){
		case'game_script':
			action_bottom='gameday_list.php';
		break;
		case 'time_line':
			action_bottom='gameday_list.php';
		break;
		case 'timeline_quick':
			action_bottom='gameday_list.php';
		break;
		case 'summary_game':
			action_bottom='pregame_list.php';
		break;
		case 'announcements':
			action_bottom='announcement_list.php';
		break;
		case 'self_promotions':
			action_bottom='selfpromotion_list.php';
		break;
	}
	this.location = 'main_admin_menu.php'+url;
	parent.main.location = action_bottom+url;
}
function CheckTextInput(ctl,alert_text){
	var text_input = ctl.value;
	text_input = text_input.replace(/ /g,"");
	if(text_input==''){
		ctl.value = '';
		ctl.focus();
		alert(alert_text);
		return 0;
	}else return 1;
}
//******************************************************************************
//
// For checking the maximum limit of the characters length
//
//******************************************************************************
function checkMaxChar(ctl,max){
	var len = ctl.value.length;
	if(len>max){
		alert('You have reached '+max+' characters max.');
		ctl.value = ctl.value.substring(0,max);
	}
}

function isTextNotEmpty(text_obj,alert_word){
	var text = text_obj.value;
	text = text.replace(/ /g,"");
	if(text==''){
		 text_obj.value = '';
		 alert(alert_word);
		 text_obj.focus();
		return 0;
	}else return 1;
}
function isTextNotEmpty(text_obj,alert_word,nofocus){
	var text = text_obj.value;
	text = text.replace(/ /g,"");
	if(text==''){
		 if(!nofocus)	text_obj.value = '';
		 alert(alert_word);
		 if(!nofocus)	text_obj.focus();
		return 0;
	}else return 1;
}