/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

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

function popUpWindow(theURL,winName,width,height) {
    window.open(theURL,winName,'height='+height+',width='+width+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
}

function modalPopUp(theURL,winName,width,height) {
    if (window.showHiddenDivModalDialog) {
        window.showHiddenDivModalDialog(theURL,winName,"dialogWidth:"+height+"px;dialogHeight:"+width+"px");
    } else {
        window.open(theURL,winName,'height='+height+',width='+width+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
    }
}

function windowOpenerRefresh(){
    window.opener.location.reload(true);
}

function gotoPage(url){
    window.location=url;
}

function closeWindow() { //v2.0
  window.close();
}

function showHiddenDiv(id){
    if (document.getElementById){
        obj = document.getElementById(id);
        if (obj.style.display == "none"){
            obj.style.display = "";
        } else {
            //obj.style.display = "none";
        }
    }
}

function hideDiv(id){
    if (document.getElementById){
        obj = document.getElementById(id);
        if (obj.style.display == "none"){
            //obj.style.display = "";
        } else {
            obj.style.display = "none";
        }
    }
}

function showHiddenDivhideDiv(id){
    if (document.getElementById){
        obj = document.getElementById(id);
        if (obj.style.display == "none"){
            obj.style.display = "";
        } else {
            obj.style.display = "none";
        }
    }
}

function textAreaFormat(str){
    var index = 0;
    var strFind="<br>";
    var strReplace="\r";
    var strOrg=str;
     while(strOrg.indexOf(strFind,index) != -1){
      strOrg = strOrg.replace(strFind,strReplace);
      index = strOrg.indexOf(strFind,index);
     }
     return strOrg

}

function textAreaFormatConvert(str){
    var index = 0;
    var strFind="\r";
    var strReplace="<br>";
    var strOrg=str;
     while(strOrg.indexOf(strFind,index) != -1){
      strOrg = strOrg.replace(strFind,strReplace);
      index = strOrg.indexOf(strFind,index);
     }
     return strOrg

}

function dateDiff(date1,date2){
    var dateValue=ConvertToDate(date1).getTime();
    var dateValue2=ConvertToDate(date2).getTime();
    return dateValue-dateValue2;
}

function ConvertToDate(strValue,strDateFormat) {
    if(typeof(strDateFormat)=="undefined"){strDateFormat="yyyy-mm-dd";}
    var strSeparator="";
    if(strDateFormat.indexOf("/", 0)>=0){
        strSeparator="/";
    }else{
        if(strDateFormat.indexOf("-", 0)>=0){
            strSeparator="-";
        }else{
            if(strDateFormat.indexOf(".", 0)>=0){
                strSeparator=".";
            }else{

            }
        }
    }
    var arrayDate = strValue.split(strSeparator);
    var arrayFormat=strDateFormat.split(strSeparator);

    var dtmDate;
    var dtmMonth;
    var dtmYear;
    for(var i=0;i<arrayFormat.length;i++){
        switch(arrayFormat[i].substr(0,1)){
            case "d":
                dtmDate=parseInt(arrayDate[i],10);
                break;
            case "M":
                dtmMonth=parseInt(arrayDate[i],10);
                break;
            case "y":
                dtmYear=parseInt(arrayDate[i],10);
                break
        }
    }    
    var newDate = new Date(dtmYear,dtmMonth-1,dtmDate)	;
    return newDate;
}

function getDateFormat(dateValue,dateFormat){
    var strSeparator="";
    if(dateFormat.indexOf("/", 0)>=0){
        strSeparator="/";
    }else{
        if(dateFormat.indexOf("-", 0)>=0){
            strSeparator="-";
        }else{
            if(dateFormat.indexOf(".", 0)>=0){
                strSeparator=".";
            }
        }
    }
    var arrayFormat=dateFormat.split(strSeparator);

    var newDateFormat="";
    var tempValue="";
    for(var i=0;i<arrayFormat.length;i++){
        switch(arrayFormat[i].substr(0,1)){
            case "d":
                tempValue=dateValue.getDate()+"";
                switch(arrayFormat[i].length){
                    case 2:
                        if(tempValue.length!=2){
                            tempValue="0"+tempValue+"";
                        }
                        break;    
                }
                newDateFormat+=tempValue;
                break;
            case "M":
                tempValue=dateValue.getMonth()+1+"";
                switch(arrayFormat[i].length){
                    case 2:
                        if(tempValue.length!=2){
                            tempValue="0"+tempValue+"";
                        }
                        break;
                }
                newDateFormat+=tempValue;
                break;
            case "y":
                newDateFormat+=dateValue.getYear();
                break;
        }
        if(i<arrayFormat.length-1){
            newDateFormat+=strSeparator;
        }
    }
    return newDateFormat;
}

function encodeString(str){
    var output=encodeURI(str);
    output= output.replace("+","%2B");
    return output;
}


//-->



