function windowOpenn(url)
{
    window.open(url,'windowOpen',"resizable=0,scrollbars =1,menubar=0,width=520,height=600,top=50,left=100");
}
function OpenURL(address) {
    location.href=address;
}
function OpenNewURL(address) {
    window.open(address,"Location Map","toolbar=no,directories=no,menubar=no,scrollbars=yes,width=500,height=300");
}  ;
function OpenNewURL2(address,wwidth,wheight) {
    opts='toolbar=no,directories=no,menubar=no,scrollbars=yes,width='+wwidth+',height='+wheight;
    window.open(address,"Help",opts);
}


function ajaxGetCourseFiles(courseId) {

    var html = document.getElementById('crsFls' + courseId).innerHTML;

    if (html != '') {
        return;
    }

    ajax.requestFile        =       '/ajax/?ajax=getFiles&CourseDateId=' + courseId;
    ajax.onCompletion       =       courseFilesResult;
    ajax.runAJAX();
}

function courseFilesResult() {

    var req = ajax.requestFile;
    var courseIdPos = req.lastIndexOf('=') + 1;
    var courseId = req.substring(courseIdPos);

    document.getElementById('crsFls' + courseId).innerHTML =  ajax.response;

}

function search(formname) {
    var x=document.getElementById(formname);
    var url=x.href.value;
    var course_location=x.course_location.value;
    if(course_location == 0){
        return false;
    }
    address = url+course_location+"" ;
    location.href=address;
}


var ajax = new sack();
function form_search_check()
{
    if(document.form_search.course_type.value=='')
    {

}
}

//      For Select Titles On Type Change
function courseTitle()
{
    document.getElementById('course_title').options.length          =       1;
    document.getElementById('course_location').options.length       =       1;
    //document.getElementById('full_address').innerHTML                     =       '';

    ajax.requestFile        =       'ajax_user.php?type=title&type_id='+document.getElementById('course_type').value;
    ajax.onCompletion       =       courseTitleResult;
    ajax.runAJAX();
}
function courseTitleResult()
{
    document.getElementById('id_course_title').innerHTML    =       ajax.response;
    courseLocation();
}
function courseTitleResult_Old()
{
    var obj =       document.getElementById('course_title');
    values  =       ajax.response;
    eval(values);
    courseLocation();
}


//      For Select Location On Type Change Or Title Change
function courseLocation()
{
    document.getElementById('course_location').options.length       =       1;
    ajax.requestFile        =       'ajax_user.php?type=location&type_id='+document.getElementById('course_type').value+'&title_id='+document.getElementById('course_title').value;
    ajax.onCompletion       =       courseLocationResult;
    ajax.runAJAX();
}
function courseLocationResult()
{
    document.getElementById('id_course_location').innerHTML =       ajax.response;
}
function courseLocationResult_old()
{
    var obj = document.getElementById('course_location');
    eval(ajax.response);
}

//      For Display Full Address
function selectAddress(val)
{
    ajax.requestFile        =       'ajax_user.php?type=selectloc&location_id='+document.getElementById('course_location').value;
    ajax.onCompletion       =       selectAddressResult;
    ajax.runAJAX();
}
function selectAddressResult()
{
    //alert(ajax.response);
    values  =       ajax.response;

    document.getElementById('full_address').innerHTML       =       '';
    document.getElementById('full_address').innerHTML       =       values;
}

//      For Download Selected Courses
function downSelCsv()
{
    var ids,len;
    len     =       document.form_csv_check.detail_id.length;
    ids     =       '';
    for(i=0;i<len;i++)
    {
        if(document.form_csv_check.detail_id[i].checked)
        {
            if(ids!='')     ids     =       ids     +       ',';
            ids     =       ids     +       document.form_csv_check.detail_id[i].value
        }
    }
    if(ids=='')
    {
        alert("Please Select Any One Courses !!");
        return false;
    }
    else
    {
        document.form_csv.form_csv_ids.value    =       ids;
        document.form_csv.submit();
    }
}


//      For Show Hide Description
function viewHideCourseDescription(id)
{
    var hide = "document.getElementById('hideCd_"+id+"')";
    var view = "document.getElementById('viewCd_"+id+"')";
    var hide = eval(hide);
    var view = eval(view);

    if(hide.style.display=='')
    {
        view.style.display      =       '';
        hide.style.display      =       'none';
        ajaxGetCourseFiles(id);
    }
    else
    {
        view.style.display      =       'none';
        hide.style.display      =       '';
    }
}


//      For Show Hide
function viewHideCategories(relatedElement) {

    var hideTxt = "document.getElementById('hide_" + relatedElement + "')";
    var viewTxt = "document.getElementById('view_" + relatedElement + "')";
    var hide = eval(hideTxt);
    var view = eval(viewTxt);


    view.style.display      =       '';
    hide.style.display      =       'none';

}

function hideDivGroup(nameRoot) {

    var compare = "view_" + nameRoot;
    var rootLength = compare.length;

    var divs = document.getElementsByTagName("div");

    for(var i = 0; i < divs.length; i++){
        var divId = divs[i].id;
        var divIdRoot = divId.substring(0, rootLength);
        if ( (divIdRoot.length = rootLength) && (divIdRoot == compare) ) {
            divs[i].style.display      =       'none';
            unselectRadioButtons(divs[i]);
        }

    }

}


function unselectRadioButtons(divElement) {

    var inputFields = divElement.getElementsByTagName("input");

    for (var field in inputFields) {

        if (inputFields[field].type == 'radio') {
            inputFields[field].checked = false;
        }

    }

}


//      For Show Hide
function viewHide(id)
{
    var hide = "document.getElementById('hide_"+id+"')";
    var view = "document.getElementById('view_"+id+"')";
    var hide = eval(hide);
    var view = eval(view);

    if(hide.style.display=='')
    {
        view.style.display      =       '';
        hide.style.display      =       'none';
    }
    else
    {
        view.style.display      =       'none';
        hide.style.display      =       '';
    }
}


//      For Show & Hide Functions
function showDiv(id)
{
    var view = "document.getElementById(id)";
    var view = eval(view);
    view.style.display      =       '';
}

function hideDiv(id)
{
    var hide = "document.getElementById(id)";
    var hide = eval(hide);
    hide.style.display = 'none';
}



function uncheckall()
{
    var ins = document.getElementsByTagName('input');
    for (var i=0; i<ins.length; i++)
    {
        if (ins[i].getAttribute('type') == 'checkbox')
        {
            ins[i].checked = false;
        }

    }
}

function searchall()
{
    var ins = document.getElementsByTagName('input');
    var ok = 0;
    for (var i=0; i<ins.length; i++)
    {
        if (ins[i].getAttribute('type') == 'radio')
        {
            if(ins[i].checked == true && ins[i].name == 'CourseGroup') {
                ok = 1;
            }
        }

    }
    if(ok == 0) {
        alert (' Please make at least one selection. ');
        return false;
    }
    else {
        return true;
    }
}


function uncheckgroup(gid)
{
    var ins = document.getElementById('type3');
    ins.checked = false;
}


function pause(millis)
{
    var date = new Date();
    var curDate = null;

    do {
        curDate = new Date();
    }
    while(curDate-date < millis)
}


var isNS = navigator.appName.indexOf("Firefox") != -1
var isIE = 1 != -1


function show() {
    if (isNS) document.layers["d1"].visibility = "show";
    if (isIE) document.all.d1.style.visibility = "visible";
}
function hide() {
    if (isNS) document.layers["d1"].visibility = "hide";
    if (isIE) document.all.d1.style.visibility = "hidden";

}



/*
/******************************************************************************
/*   Copyright (C) 2006  INTERBERRY SOLUTIONS
/*   http://www.interberry.com
/*
/*   Date of creation		:  	21-Aug-2006
/*   Date last modified		:  	21-Aug-2006.
/*   Project				:  	INUNI
/*   Release				:  	1.0
/*   Comment				:  	<ajax>
/*   Author                 :   Santhosh.
/*
/******************************************************************************/

/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* �2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence,
   see documentation or authors website for more details */

function sack(file) {
    this.xmlhttp = null;

    this.resetData = function() {
        this.method = "POST";
        this.queryStringSeparator = "?";
        this.argumentSeparator = "&";
        this.URLString = "";
        this.encodeURIString = true;
        this.execute = false;
        this.element = null;
        this.elementObj = null;
        this.requestFile = file;
        this.vars = new Object();
        this.responseStatus = new Array(2);
    };

    this.resetFunctions = function() {
        this.onLoading = function() { };
        this.onLoaded = function() { };
        this.onInteractive = function() { };
        this.onCompletion = function() { };
        this.onError = function() { };
        this.onFail = function() { };
    };

    this.reset = function() {
        this.resetFunctions();
        this.resetData();
    };

    this.createAJAX = function() {
        try {
            this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e1) {
            try {
                this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e2) {
                this.xmlhttp = null;
            }
        }

        if (! this.xmlhttp) {
            if (typeof XMLHttpRequest != "undefined") {
                this.xmlhttp = new XMLHttpRequest();
            } else {
                this.failed = true;
            }
        }
    };

    this.setVar = function(name, value){
        this.vars[name] = Array(value, false);
    };

    this.encVar = function(name, value, returnvars) {
        if (true == returnvars) {
            return Array(encodeURIComponent(name), encodeURIComponent(value));
        } else {
            this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
        }
    }

    this.processURLString = function(string, encode) {
        encoded = encodeURIComponent(this.argumentSeparator);
        regexp = new RegExp(this.argumentSeparator + "|" + encoded);
        varArray = string.split(regexp);
        for (i = 0; i < varArray.length; i++){
            urlVars = varArray[i].split("=");
            if (true == encode){
                this.encVar(urlVars[0], urlVars[1]);
            } else {
                this.setVar(urlVars[0], urlVars[1]);
            }
        }
    }

    this.createURLString = function(urlstring) {
        if (this.encodeURIString && this.URLString.length) {
            this.processURLString(this.URLString, true);
        }

        if (urlstring) {
            if (this.URLString.length) {
                this.URLString += this.argumentSeparator + urlstring;
            } else {
                this.URLString = urlstring;
            }
        }

        // prevents caching of URLString
        this.setVar("rndval", new Date().getTime());

        urlstringtemp = new Array();
        for (key in this.vars) {
            if (false == this.vars[key][1] && true == this.encodeURIString) {
                encoded = this.encVar(key, this.vars[key][0], true);
                delete this.vars[key];
                this.vars[encoded[0]] = Array(encoded[1], true);
                key = encoded[0];
            }

            urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
        }
        if (urlstring){
            this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
        } else {
            this.URLString += urlstringtemp.join(this.argumentSeparator);
        }
    }

    this.runResponse = function() {
        eval(this.response);
    }

    this.runAJAX = function(urlstring) {
        if (this.failed) {
            this.onFail();
        } else {
            this.createURLString(urlstring);
            if (this.element) {
                this.elementObj = document.getElementById(this.element);
            }
            if (this.xmlhttp) {
                var self = this;
                if (this.method == "GET") {
                    totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
                    this.xmlhttp.open(this.method, totalurlstring, true);
                } else {
                    this.xmlhttp.open(this.method, this.requestFile, true);
                    try {
                        this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
                    } catch (e) { }
                }

                this.xmlhttp.onreadystatechange = function() {
                    switch (self.xmlhttp.readyState) {
                        case 1:
                            self.onLoading();
                            break;
                        case 2:
                            self.onLoaded();
                            break;
                        case 3:
                            self.onInteractive();
                            break;
                        case 4:
                            self.response = self.xmlhttp.responseText;
                            self.responseXML = self.xmlhttp.responseXML;
                            self.responseStatus[0] = self.xmlhttp.status;
                            self.responseStatus[1] = self.xmlhttp.statusText;

                            if (self.execute) {
                                self.runResponse();
                            }

                            if (self.elementObj) {
                                elemNodeName = self.elementObj.nodeName;
                                elemNodeName.toLowerCase();
                                if (elemNodeName == "input"
                                    || elemNodeName == "select"
                                    || elemNodeName == "option"
                                    || elemNodeName == "textarea") {
                                    self.elementObj.value = self.response;
                                } else {
                                    self.elementObj.innerHTML = self.response;
                                }
                            }
                            if (self.responseStatus[0] == "200") {
                                self.onCompletion();
                            } else {
                                self.onError();
                            }

                            self.URLString = "";
                            break;
                    }
                };

                this.xmlhttp.send(this.URLString);
            }
        }
    };

    this.reset();
    this.createAJAX();
}
/* Nifty Corners Cube - rounded corners with CSS and Javascript
Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

/* Nifty Corners Cube - rounded corners with CSS and Javascript
Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);
var niftyCss=false;

String.prototype.find=function(what){
    return(this.indexOf(what)>=0 ? true : false);
}

var oldonload=window.onload;
if(typeof(NiftyLoad)!='function') NiftyLoad=function(){};
if(typeof(oldonload)=='function')
    window.onload=function(){
        oldonload();
        AddCss();
        NiftyLoad()
    };
else window.onload=function(){
    AddCss();
    NiftyLoad()
};

function AddCss(){
    niftyCss=true;
    var l=CreateEl("link");
    l.setAttribute("type","text/css");
    l.setAttribute("rel","stylesheet");
    l.setAttribute("href","niftyCorners.css");
    l.setAttribute("media","screen");
    document.getElementsByTagName("head")[0].appendChild(l);
}

function Nifty(selector,options){
    if(niftyOk==false) return;
    if(niftyCss==false) AddCss();
    var i,v=selector.split(","),h=0;
    if(options==null) options="";
    if(options.find("fixed-height"))
        h=getElementsBySelector(v[0])[0].offsetHeight;
    for(i=0;i<v.length;i++)
        Rounded(v[i],options);
    if(options.find("height")) SameHeight(selector,h);
}

function Rounded(selector,options){
    var i,top="",bottom="",v=new Array();
    if(options!=""){
        options=options.replace("left","tl bl");
        options=options.replace("right","tr br");
        options=options.replace("top","tr tl");
        options=options.replace("bottom","br bl");
        options=options.replace("transparent","alias");
        if(options.find("tl")){
            top="both";
            if(!options.find("tr")) top="left";
        }
        else if(options.find("tr")) top="right";
        if(options.find("bl")){
            bottom="both";
            if(!options.find("br")) bottom="left";
        }
        else if(options.find("br")) bottom="right";
    }
    if(top=="" && bottom=="" && !options.find("none")){
        top="both";
        bottom="both";
    }
    v=getElementsBySelector(selector);
    for(i=0;i<v.length;i++){
        FixIE(v[i]);
        if(top!="") AddTop(v[i],top,options);
        if(bottom!="") AddBottom(v[i],bottom,options);
    }
}

function AddTop(el,side,options){
    var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
    d.style.marginLeft="-"+getPadding(el,"Left")+"px";
    d.style.marginRight="-"+getPadding(el,"Right")+"px";
    if(options.find("alias") || (color=getBk(el))=="transparent"){
        color="transparent";
        bk="transparent";
        border=getParentBk(el);
        btype="t";
    }
    else{
        bk=getParentBk(el);
        border=Mix(color,bk);
    }
    d.style.background=bk;
    d.className="niftycorners";
    p=getPadding(el,"Top");
    if(options.find("small")){
        d.style.marginBottom=(p-2)+"px";
        btype+="s";
        lim=2;
    }
    else if(options.find("big")){
        d.style.marginBottom=(p-10)+"px";
        btype+="b";
        lim=8;
    }
    else d.style.marginBottom=(p-5)+"px";
    for(i=1;i<=lim;i++)
        d.appendChild(CreateStrip(i,side,color,border,btype));
    el.style.paddingTop="0";
    el.insertBefore(d,el.firstChild);
}

function AddBottom(el,side,options){
    var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
    d.style.marginLeft="-"+getPadding(el,"Left")+"px";
    d.style.marginRight="-"+getPadding(el,"Right")+"px";
    if(options.find("alias") || (color=getBk(el))=="transparent"){
        color="transparent";
        bk="transparent";
        border=getParentBk(el);
        btype="t";
    }
    else{
        bk=getParentBk(el);
        border=Mix(color,bk);
    }
    d.style.background=bk;
    d.className="niftycorners";
    p=getPadding(el,"Bottom");
    if(options.find("small")){
        d.style.marginTop=(p-2)+"px";
        btype+="s";
        lim=2;
    }
    else if(options.find("big")){
        d.style.marginTop=(p-10)+"px";
        btype+="b";
        lim=8;
    }
    else d.style.marginTop=(p-5)+"px";
    for(i=lim;i>0;i--)
        d.appendChild(CreateStrip(i,side,color,border,btype));
    el.style.paddingBottom=0;
    el.appendChild(d);
}

function CreateStrip(index,side,color,border,btype){
    var x=CreateEl("b");
    x.className=btype+index;
    x.style.backgroundColor=color;
    x.style.borderColor=border;
    if(side=="left"){
        x.style.borderRightWidth="0";
        x.style.marginRight="0";
    }
    else if(side=="right"){
        x.style.borderLeftWidth="0";
        x.style.marginLeft="0";
    }
    return(x);
}

function CreateEl(x){
    return(document.createElement(x));
}

function FixIE(el){
    if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
        el.style.display="inline-block";
}

function SameHeight(selector,maxh){
    var i,v=selector.split(","),t,j,els=[],gap;
    for(i=0;i<v.length;i++){
        t=getElementsBySelector(v[i]);
        els=els.concat(t);
    }
    for(i=0;i<els.length;i++){
        if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
        els[i].style.height="auto";
    }
    for(i=0;i<els.length;i++){
        gap=maxh-els[i].offsetHeight;
        if(gap>0){
            t=CreateEl("b");
            t.className="niftyfill";
            t.style.height=gap+"px";
            nc=els[i].lastChild;
            if(nc.className=="niftycorners")
                els[i].insertBefore(t,nc);
            else els[i].appendChild(t);
        }
    }
}

function getElementsBySelector(selector){
    var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
    if(selector.find("#")){ //id selector like "tag#id"
        if(selector.find(" ")){  //descendant selector like "tag#id tag"
            s=selector.split(" ");
            var fs=s[0].split("#");
            if(fs.length==1) return(objlist);
            f=document.getElementById(fs[1]);
            if(f){
                v=f.getElementsByTagName(s[1]);
                for(i=0;i<v.length;i++) objlist.push(v[i]);
            }
            return(objlist);
        }
        else{
            s=selector.split("#");
            tag=s[0];
            selid=s[1];
            if(selid!=""){
                f=document.getElementById(selid);
                if(f) objlist.push(f);
                return(objlist);
            }
        }
    }
    if(selector.find(".")){      //class selector like "tag.class"
        s=selector.split(".");
        tag=s[0];
        selclass=s[1];
        if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
            s=selclass.split(" ");
            selclass=s[0];
            tag2=s[1];
        }
    }
    var v=document.getElementsByTagName(tag);  // tag selector like "tag"
    if(selclass==""){
        for(i=0;i<v.length;i++) objlist.push(v[i]);
        return(objlist);
    }
    for(i=0;i<v.length;i++){
        c=v[i].className.split(" ");
        for(j=0;j<c.length;j++){
            if(c[j]==selclass){
                if(tag2=="") objlist.push(v[i]);
                else{
                    v2=v[i].getElementsByTagName(tag2);
                    for(k=0;k<v2.length;k++) objlist.push(v2[k]);
                }
            }
        }
    }
    return(objlist);
}

function getParentBk(x){
    var el=x.parentNode,c;
    while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
        el=el.parentNode;
    if(c=="transparent") c="#FFFFFF";
    return(c);
}

function getBk(x){
    var c=getStyleProp(x,"backgroundColor");
    if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
        return("transparent");
    if(c.find("rgb")) c=rgb2hex(c);
    return(c);
}

function getPadding(x,side){
    var p=getStyleProp(x,"padding"+side);
    if(p==null || !p.find("px")) return(0);
    return(parseInt(p));
}

function getStyleProp(x,prop){
    if(x.currentStyle)
        return(x.currentStyle[prop]);
    if(document.defaultView.getComputedStyle)
        return(document.defaultView.getComputedStyle(x,'')[prop]);
    return(null);
}

function rgb2hex(value){
    var hex="",v,h,i;
    var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
    var h=regexp.exec(value);
    for(i=1;i<4;i++){
        v=parseInt(h[i]).toString(16);
        if(v.length==1) hex+="0"+v;
        else hex+=v;
    }
    return("#"+hex);
}

function Mix(c1,c2){
    var i,step1,step2,x,y,r=new Array(3);
    if(c1.length==4)step1=1;
    else step1=2;
    if(c2.length==4) step2=1;
    else step2=2;
    for(i=0;i<3;i++){
        x=parseInt(c1.substr(1+step1*i,step1),16);
        if(step1==1) x=16*x+x;
        y=parseInt(c2.substr(1+step2*i,step2),16);
        if(step2==1) y=16*y+y;
        r[i]=Math.floor((x*50+y*50)/100);
        r[i]=r[i].toString(16);
        if(r[i].length==1) r[i]="0"+r[i];
    }
    return("#"+r[0]+r[1]+r[2]);
}



