function headerInvoked(url) 
{     
    var dyniframe = document.getElementById("centerFrame");  
    dyniframe.src = url; 
}
function confirmSubmit(url,message){ 
	question = confirm(message)
	if (question != "0")
	{
	   formSubmit(url)
	}	
}

function formSubmit(val){  

    var oldactionvalue = window.document.forms[0].action; 
	var actionvalue = oldactionvalue.split("/");    
	
	if(actionvalue[1] == 'muecard'){
		if (actionvalue[1] != null)	{  
	        //alert("/" + actionvalue[1] + val);
			window.document.forms[0].action = "/" + actionvalue[1] + val;
			window.document.forms[0].submit();
		}else{ 
	        alert("The request path is error!");
		}
	}else{
	    //If we are user the ROOT directory,do not add any prefix
		window.document.forms[0].action = val;
		window.document.forms[0].submit();
	}
}

function getFullPath(url){ 
    var oldactionvalue = window.document.forms[0].action; 
	var actionvalue = oldactionvalue.split("/");   
 
	if(actionvalue[1] == 'muecard'){ 
		return "/" + actionvalue[1] + url;
	}else{
		return url;
	}
}

	
	

function formSubmitNoPre(url){
		window.document.forms[0].action="/Struts2Cares" + url; 
        alert(window.document.forms[0].action);
		window.document.forms[0].submit(); 
}


function multiFormSubmit(url,no){ 
	var oldactionvalue=window.document.forms[no].action;  
	var actionvalue=oldactionvalue.split("/"); 
	
	//question = confirm("Are you really want to execute?")
	if (actionvalue[1]!=null)	{
		window.document.forms[no].action="/"+actionvalue[1]+url; 
		window.document.forms[no].submit();
	}	
} 
function pageSubmit(type)
{ 
	if(type==4 && document.forms[0].allPageNo.value==1){
		return;
	}
	document.forms[0].operateType.value = type; 
	document.forms[0].submit();
}
function isChecked(boxname){
	
	var boxs = document.getElementsByName(boxname);
	for(var i=0;i<boxs.length;i++){
		if(boxs[i].checked) return true;
	}
	return false;
}

function stringToDate(dateString){ 
    //month must minus 1,08->AUG
	var arrays = dateString.split("-"); 
	var date = new Date(arrays[0],arrays[1]-1,arrays[2]); 
	return date;
}
function compareDate(date1,date2){
    if (stringToDate(date2) < stringToDate(date1))
        return false;
    return true;
}
function formatDateString(date){  
    //2006-1-1 to 2006-01-01
	var dates = date.split("-"); 
	if(dates[1].length == 1) dates[1] = "0" + dates[1];
	if(dates[2].length == 1) dates[2] = "0" + dates[2];
	var s = dates[0] + "-" + dates[1] + "-" + dates[2];
	return s;
}

function convertDateToString(date){ 
    return formatDateString(date.getYear() + "-" + date.getMonth() + "-" + date.getDate()); 
}

function getNextDaysDateString(dayNumber){ 
    //get the next dayNumber days Date String format ""2007-01-01" 
	var today = new Date();	
	today.setDate(today.getDate() + dayNumber);
	
	var month = today.getMonth();
	if(month == 11)
		month = 12; 
	else
		month ++;
    return formatDateString(today.getYear() + "-" + month + "-" + today.getDate()); 
}


function toUCase(obj){ 
	obj.value = obj.value.toUpperCase(); 
}
function toLCase(obj){ 
	obj.value = obj.value.toLowerCase(); 
}

 /**
  * gets the contents of the form as a URL encoded String
  * suitable for appending to a url
  * @param formName to encode
  * @return string with encoded form values , beings with &
  */ 
 function getFormAsString(formName){ 	
 	//Setup the return String
 	returnString =""; 	
  	//Get the form values
 	formElements=document.forms[formName].elements;
 	
 	//loop through the array , building up the url
 	//in the form /strutsaction.do&name=value 	
 	for ( var i=formElements.length-1; i>=0; --i ){
 		//we escape (encode) each value
 		returnString=returnString+"&"+escape(formElements[i].name)+"="+escape(formElements[i].value);
 	} 	
 	//return the values
 	return returnString; 
 }
 
function EnterforNumber ()
{ 
    if (!(window.event.keyCode >= 48 && window.event.keyCode <= 57))
    	window.event.keyCode = 0;
}

function OrtOpenCenterWindow (URL, Name, Features)
{
    var nWidth;
    var nHeight;
    var nLeft;
    var nTop;
    var strVal;
    var nPos;
    var strComb;
    var i;
    var chVal;
    nLeft = 0;
    nTop = 0;
    if (Features == null)
        return (window.open (URL, Name, Features));
    strVal = Features.toUpperCase ();
    if (strVal.indexOf ("LEFT", 0) >= 0 || strVal.indexOf ("TOP", 0) >= 0)
        return (window.open (URL, Name, Features));
    if ((nPos = strVal.indexOf ("WIDTH", 0)) < 0)
        return (window.open (URL, Name, Features));
    if ((nPos = strVal.indexOf ("=", nPos)) < 0)
        return (window.open (URL, Name, Features));
    strComb = "";
    for (i = nPos + 1; i < Features.length; i ++)
    {
        chVal = Features.charAt (i);
        if (chVal == " " || (chVal >= "0" && chVal <= "9"))
            strComb += chVal;
        else
            break;
    }
    if ((nWidth = eval (TrimString (strComb))) <= 0)
        return (window.open (URL, Name, Features));
    if ((nPos = strVal.indexOf ("HEIGHT", 0)) < 0)
        return (window.open (URL, Name, Features));
    if ((nPos = strVal.indexOf ("=", nPos)) < 0)
        return (window.open (URL, Name, Features));
    strComb = "";
    for (i = nPos + 1; i < Features.length; i ++)
    {
        chVal = Features.charAt (i);
        if (chVal == " " || (chVal >= "0" && chVal <= "9"))
            strComb += chVal;
        else
            break;
    }
    if ((nHeight = eval (TrimString (strComb))) <= 0)
        return (window.open (URL, Name, Features));
    nLeft = (window.screen.width - nWidth) / 2;
    nTop = (window.screen.height - nHeight) / 2;
    Features += ",left=" + nLeft + ",top=" + nTop;
    return (window.open (URL, Name, Features));
}
function OrtCloseWindow (wShow)
{
    try
    {
        wShow.close ();
    }
    catch (e)
    {}
}
