/************************************************************************************************
 * Common java script for the Quartzy.
 * @package    Quartzy 
 * @author     subbu
 * @date	   11-June-2007
 * @email      subedaryadav@greymatterindia.com 	
 ***************************************************************************************************/
// Removes leading whitespaces
function LTrim( value ) {
	
    var re = /\s*((\S+\s*)*)/;
    return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
    var re = /((\s*\S+)*)\s*/;
    return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
    return LTrim(RTrim(value));
	
}

/* Function for the E-mail validation*/
function echeck(str) {
    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    if (str.indexOf(at)==-1){
        return false
    }
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
        return false;
    }
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        return false;
    }
    if (str.indexOf(at,(lat+1))!=-1){
        return false
    }
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        return false;
    }
    if (str.indexOf(dot,(lat+2))==-1){
        return false;
    }
    if (str.indexOf(" ")!=-1){
        return false;
    }
    return true
}
function CheckEmail(emailStr)
{
    //Checking For valid email
    var emailPat=/^(.+)@(.+)$/
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
    var validChars="\[^\\s" + specialChars + "\]"
    var quotedUser="(\"[^\"]*\")"
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
    var atom=validChars + '+'
    var word="(" + atom + "|" + quotedUser + ")"
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
    var matchArray=emailStr.match(emailPat)
    if (matchArray==null){
        return false
    }
    var user=matchArray[1];
    var domain=matchArray[2];
    if (user.match(userPat)==null){
        return false;
    }
    var IPArray=domain.match(ipDomainPat)
    if (IPArray!=null)
    {
        for (var i=1;i<=4;i++)
        {
            if (IPArray[i]>255){
                return false;
            }
        }
    }
    var domainArray=domain.match(domainPat)
    if (domainArray==null)
    {
        return false
    }
    var atomPat=new RegExp(atom,"g");
    var domArr=domain.match(atomPat);
    var len=domArr.length;
    if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3){
        return false
    }
    if (len<2){
        return false;
    }
    return true
}

/*** Function for the cheking the intiger value **/
function isInteger(s)
{
    var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

/******* Function for the phone no validation **************************/
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-+ ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters;
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;
function stripCharsInBag(s, bag)
{
    var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function checkInternationalPhone(strPhone){
    s=stripCharsInBag(strPhone,validWorldPhoneChars);
    return (isInteger(s) && s.length <= minDigitsInIPhoneNumber);
}
/************** Function for hide/ show div *****************************/
function toggleVisible1(id)
{
    var item = $(id);
    var value = item.style.display ? '' : 'none';
    item.style.display = value;
}
/****************** Function for validate description field length *********************************/
function checkTextLength(obj,restrictLength,truncFlag)
{
    if(obj.value.length>restrictLength){
        if(truncFlag) obj.disabled = true;
        alert("Text should not be more than " + restrictLength + " characters");
        if(truncFlag) obj.disabled = false;
        obj.focus();
        if(truncFlag) obj.value = obj.value.substring(0,restrictLength);
        return false;
    }else{
        return true;
    }
}
/***************** Function for Confirmation ***************************************/
function confirmation(msg) {
    if(msg ==""){
        msg = 'Do you want to perform this Action?';
    }
    var answer = confirm(msg);
    if (answer){
        return true ;
    }else{
        return false;
    }
}
//This is function for the text counting 
function textCounter(message, countfield, maxlimit) 
{
    if(message.value.length > maxlimit) // if too long...trim it!
        message.value = message.value.substring(0, maxlimit);
    // otherwise, update 'characters left' counter
    else
    {
        var diff = (maxlimit - message.value.length);
        if(diff > 0)
        {
            countfield.style.color = "#000000";
        }
        countfield.value = diff;
        $('charCount').innerHTML=diff;
    }
} 
//Function unset the value of all div	
function unSetVal(fieldArray)
{		
    for(i=0;i < fieldArray.length;i++ )
    {
        fldname = fieldArray[i];
        if(document.getElementById(fldname))
        {
            document.getElementById(fldname).innerHTML='';
            document.getElementById(fldname).style.display='none';
        }
    }
}	
//Function for set the error value in the div
function setValue(id,msg)
{
    if(document.getElementById(id))
    {
        document.getElementById(id).innerHTML=msg;
        document.getElementById(id).style.display="block";
    }
}	
//Function unset the value of all fields	
function setArrCss(fieldArray,txtCss)
{		
    for(i=0;i < fieldArray.length;i++ )
    {
        fldname = fieldArray[i];
        $(fldname).setAttribute('class',txtCss);
        $(fldname).className=txtCss;
    }
}
//Function for set the error value in the div
function setCss(id,txtCss)	{
    if($(id)){
        $(id).className = txtCss;
    }
}
	
function RegsetCss(id,txtCss,text)	
{	
    $(id).className = txtCss;
    $(id).value = text;
		 
} 
		
//Function for checking file extension
function validateImage(imageFile){
    if(imageFile!=''){
        var temp = imageFile.split('.');
        var tempExt = temp[temp.length-1];
        if(tempExt!=='jpg' && tempExt!=='gif' && tempExt!=='png' && tempExt!=='JPG' && tempExt!=='GIF' && tempExt!=='PNG' && tempExt!='' && tempExt!=null)
            return 1;
        else
            return 0;
    }    
}
//function for the doc and pdf file
function validatedocpdf(imageFile){
    if(imageFile!=''){
        var temp = imageFile.split('.');
        var tempExt = temp[temp.length-1];
        if(tempExt!=='doc' && tempExt!=='DOC' && tempExt!=='pdf' && tempExt!=='PDF' && tempExt!='' && tempExt!=null && tempExt!=='jpg' && tempExt!=='gif' && tempExt!=='png' && tempExt!=='JPG' && tempExt!=='GIF'&& tempExt!=='ppt'&& tempExt!=='PPT')
            return 1;
        else
            return 0;
    }
}


function validateFileCustomDashboard(fileName, arrAllowedExt){
    var mozillaLatest = false;
    var validFile = true;
    var browserOS = '';
    if(navigator.userAgent.indexOf('Gecko')!=-1 && navigator.userAgent.indexOf('3.0')!=-1){
        mozillaLatest = true;
    }
    if(navigator.userAgent.indexOf('Gecko')!=-1 && navigator.userAgent.indexOf('3.')!=-1){
        mozillaLatest = true;
    }
    if(navigator.userAgent.indexOf('Safari')!=-1){
        mozillaLatest = true;
    }
    if(navigator.platform.indexOf('Linux')!=-1){
        browserOS = 'Linux';
    } else if(navigator.platform.indexOf('Mac')!=-1){
        browserOS = 'Mac';
    } else {
        browserOS = 'Windows';
    }
	
    if( browserOS=='Linux' ||  browserOS=='Windows' ){
		
    /*if( !mozillaLatest && fileName.indexOf('\\')==-1 ){
			validFile = false;
		}		*/
    } else {
    /*alert("else condition");
		if( !mozillaLatest && fileName.indexOf('/')==-1 ){
			validFile = false;
		}*/
    }
    if(fileName!='' && validFile){
        var temp = fileName.split('.');
        var tempExt = temp[temp.length-1];
        var extenMatch = false;
        for(i=0; i<arrAllowedExt.length; i++){
            if(arrAllowedExt[i].toLowerCase()==tempExt.toLowerCase()){
                extenMatch=true;
            }
        }
        return extenMatch;
    }
}


function validateFileCustom(fileName, arrAllowedExt){
    var mozillaLatest = false;
    var validFile = true;
    var browserOS = '';
    var extenMatch;
    if(navigator.userAgent.indexOf('Gecko')!=-1 && navigator.userAgent.indexOf('4.0')!=-1){
        mozillaLatest = true;
    }
    if(navigator.userAgent.indexOf('Gecko')!=-1 && navigator.userAgent.indexOf('4.')!=-1){
        mozillaLatest = true;
    }
    if(navigator.userAgent.indexOf('Safari')!=-1){
        mozillaLatest = true;
    }
    if(navigator.platform.indexOf('Linux')!=-1){
        browserOS = 'Linux';
    } else if(navigator.platform.indexOf('Mac')!=-1){
        browserOS = 'Mac';
    } else {
        browserOS = 'Windows';
    }    
    if(fileName!='' && validFile){
        var temp = fileName.split('.');
        var tempExt = temp[temp.length-1];
         extenMatch = false;
        for(i=0; i<arrAllowedExt.length; i++){
            if(arrAllowedExt[i].toLowerCase()==tempExt.toLowerCase()){
                extenMatch=true;
            }
        }
        return extenMatch;
    }
}

var characterNotAllow = " -/\_~";
// characters which are allowed in international phone numbers
function stripCatalog(s){ 
    var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (characterNotAllow.indexOf(c) != -1) return false;
    }
    return true;
}

function matchPassword(field1, field2, divError, divErrorValue)
{
    if(trim($(field1).value) != trim($(field2).value))
    {
        setValue(divError,divErrorValue);
        $(divError).style.display = 'block';
        window.scrollTo(0,120);
    }
    else
    {
        $(divError).style.display = 'none';
    }
	
}

/** function for testing the url validation
@param : url
@return: true/false
*/
function urlValidate(url) {
    url = trim(url);
    var v = new RegExp();
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.,=#]+$");
    if (!v.test(url)) {
        return false;
    }
    return true;
}

// Added by Sachin : function to check all/none by check main check box ////
function checkUncheckAll(mainCheck, subChecks, count){
	
    for (i=1; i<=count; i++){
        $(subChecks+i).checked = $(mainCheck).checked;
    }
}
function openPopUp(url_add){	
    window.open(url_add,'Quartzy', 'width=300, height=200, menubar=yes, status=yes, location=yes, toolbar=yes, scrollbars=yes');
}
function gotoURL(url_add){
    location.href=url_add;
}
function confirmRedirect(msg, redirectTrue, redirectFalse){
    if(msg ==""){
        msg = 'Are you sure you want to continue';
    }
    var confirmation = confirm(msg);
    if(confirmation){
        window.open(redirectTrue,'Quartzy', 'width=10, height=10, menubar=yes, status=yes, location=yes, toolbar=yes, scrollbars=yes');
    } else {
        window.open(redirectFalse,'Quartzy', 'width=10, height=10, menubar=yes, status=yes, location=yes, toolbar=yes, scrollbars=yes');
    }
}

// function for check the special charatcter
function checkSplChar(txtValue)
{
    var regex=/^[0-9A-Za-z\s]+$/;
    if(!regex.test(txtValue)){
        return false;
    }
    return true;
}

function showHideDivGen(divId){
    if(document.getElementById(divId).style.display =='none' ){
        document.getElementById(divId).style.display ='block';
    } else{
        document.getElementById(divId).style.display ='none';
    }
}
function swapIconGen(icon1, icon2, divId){
    if(document.getElementById(divId).src==icon1){
        document.getElementById(divId).src=icon2;
        document.getElementById(divId).title='Show Details';
    } else {
        document.getElementById(divId).src=icon1;
        document.getElementById(divId).title='Hide Details';
    }
}
	
function setElementValue(id, val){
    $(id).value = val;
}
function isNul(varChk){
    if(null === $(varChk)){
        return true;
    } else {
        return false;
    }
}
function trimSpaces(varRet){
    varRet = varRet.replace(/^\s+/,""); //Left trim
    varRet = varRet.replace(/\s+$/,""); //Right trim
    return varRet;
}
// BetterInnerHTML v1.15 - by Craig Buckler, http://www.optimalworks.net/
function BetterInnerHTML(_1,_2,_3){
    function Load(_4){
        var _5;
        if(typeof DOMParser!="undefined"){
            _5=(new DOMParser()).parseFromString(_4,"application/xml");
        }else{
            var _6=["MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"];
            for(var i=0;i<_6.length&&!_5;i++){
                try{
                    _5=new ActiveXObject(_6[i]);
                    _5.loadXML(_4);
                }catch(e){}
            }
            }
        return _5;
}
function Copy(_8,_9,_a){
    if(typeof _a=="undefined"){
        _a=1;
    }
    if(_a>1){
        if(_9.nodeType==1){
            var _b=document.createElement(_9.nodeName);
            for(var a=0,attr=_9.attributes.length;a<attr;a++){
                var _d=_9.attributes[a].name,aValue=_9.attributes[a].value,evt=(_d.substr(0,2)=="on");
                if(!evt){
                    switch(_d){
                        case "class":
                            _b.className=aValue;
                            break;
                        case "for":
                            _b.htmlFor=aValue;
                            break;
                        default:
                            _b.setAttribute(_d,aValue);
                    }
                }
            }
            _8=_8.appendChild(_b);
    if(evt){
        _8[_d]=function(){
            eval(aValue);
        };

}
}else{
    if(_9.nodeType==3){
        var _e=(_9.nodeValue?_9.nodeValue:"");
        var _f=_e.replace(/^\s*|\s*$/g,"");
        if(_f.length<7||(_f.indexOf("<!--")!=0&&_f.indexOf("-->")!=(_f.length-3))){
            _8.appendChild(document.createTextNode(_e));
        }
    }
}
}
for(var i=0,j=_9.childNodes.length;i<j;i++){
    Copy(_8,_9.childNodes[i],_a+1);
}
}
_2="<root>"+_2+"</root>";
var _11=Load(_2);
if(_1&&_11){
    if(_3!=false){
        while(_1.lastChild){
            _1.removeChild(_1.lastChild);
        }
    }
    Copy(_1,_11.documentElement);
}
}
	
//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
	
function ControlVersion()
{
    var version;
    var axo;
    var e;
    // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
    try {
        // version will be set for 7.X or greater players
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        version = axo.GetVariable("$version");
    } catch (e) {
    }
    if (!version)
    {
        try {
            // version will be set for 6.X players only
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
            // installed player is some revision of 6.0
            // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
            // so we have to be careful.
            // default to the first public version
            version = "WIN 6,0,21,0";
            // throws if AllowScripAccess does not exist (introduced in 6.0r47)
            axo.AllowScriptAccess = "always";
            // safe to call for 6.0r47 or greater
            version = axo.GetVariable("$version");
	
        } catch (e) {
        }
    }
    if (!version)
    {
        try {
            // version will be set for 4.X or 5.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }
    if (!version)
    {
        try {
            // version will be set for 3.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = "WIN 3,0,18,0";
        } catch (e) {
        }
    }
	
    if (!version)
    {
        try {
            // version will be set for 2.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11";
        } catch (e) {
            version = -1;
        }
    }
    return version;
}
// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
    // NS/Opera version >= 3 check for Flash plugin in plugin array
    var flashVer = -1;
		
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            var versionRevision = descArray[3];
            if (versionRevision == "") {
                versionRevision = descArray[4];
            }
            if (versionRevision[0] == "d") {
                versionRevision = versionRevision.substring(1);
            } else if (versionRevision[0] == "r") {
                versionRevision = versionRevision.substring(1);
                if (versionRevision.indexOf("d") > 0) {
                    versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                }
            }
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        }
    }
    // MSN/WebTV 2.6 supports Flash 4
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    // WebTV 2.5 supports Flash 3
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
    // older WebTV supports Flash 2
    else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
    else if ( isIE && isWin && !isOpera ) {
        flashVer = ControlVersion();
    }
    return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
    versionStr = GetSwfVer();
    if (versionStr == -1 ) {
        return false;
    } else if (versionStr != 0) {
        if(isIE && isWin && !isOpera) {
            // Given "WIN 2,0,0,11"
            tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
            tempString        = tempArray[1];			// "2,0,0,11"
            versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
        } else {
            versionArray      = versionStr.split(".");
        }
        var versionMajor      = versionArray[0];
        var versionMinor      = versionArray[1];
        var versionRevision   = versionArray[2];
	
        // is the major.revision >= requested major.revision AND the minor version >= requested minor
        if (versionMajor > parseFloat(reqMajorVer)) {
            return true;
        } else if (versionMajor == parseFloat(reqMajorVer)) {
            if (versionMinor > parseFloat(reqMinorVer))
                return true;
            else if (versionMinor == parseFloat(reqMinorVer)) {
                if (versionRevision >= parseFloat(reqRevision))
                    return true;
            }
        }
        return false;
    }
}	
function AC_AddExtension(src, ext)
{
    if (src.indexOf('?') != -1)
        return src.replace(/\?/, ext+'?');
    else
        return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
        str += '<object ';
        for (var i in objAttrs)
        {
            str += i + '="' + objAttrs[i] + '" ';
        }
        str += '>';
        for (var i in params)
        {
            str += '<param name="' + i + '" value="' + params[i] + '" /> ';
        }
        str += '</object>';
    }
    else
    {
        str += '<embed ';
        for (var i in embedAttrs)
        {
            str += i + '="' + embedAttrs[i] + '" ';
        }
        str += '> </embed>';
    }
    ///////// commented the below line and wrote the above one so that page doesn't redirect
    $('divVideo').innerHTML = str;
//document.write(str);
}	
function AC_FL_RunContent(){
    var ret =
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
        , "application/x-shockwave-flash"
        );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_SW_RunContent(){
    var ret =
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
        , null
        );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
    var ret = new Object();
    ret.embedAttrs = new Object();
    ret.params = new Object();
    ret.objAttrs = new Object();
    for (var i=0; i < args.length; i=i+2){
        var currArg = args[i].toLowerCase();
	
        switch (currArg){
            case "classid":
                break;
            case "pluginspage":
                ret.embedAttrs[args[i]] = args[i+1];
                break;
            case "src":
            case "movie":
                args[i+1] = AC_AddExtension(args[i+1], ext);
                ret.embedAttrs["src"] = args[i+1];
                ret.params[srcParamName] = args[i+1];
                break;
            case "onafterupdate":
            case "onbeforeupdate":
            case "onblur":
            case "oncellchange":
            case "onclick":
            case "ondblclick":
            case "ondrag":
            case "ondragend":
            case "ondragenter":
            case "ondragleave":
            case "ondragover":
            case "ondrop":
            case "onfinish":
            case "onfocus":
            case "onhelp":
            case "onmousedown":
            case "onmouseup":
            case "onmouseover":
            case "onmousemove":
            case "onmouseout":
            case "onkeypress":
            case "onkeydown":
            case "onkeyup":
            case "onload":
            case "onlosecapture":
            case "onpropertychange":
            case "onreadystatechange":
            case "onrowsdelete":
            case "onrowenter":
            case "onrowexit":
            case "onrowsinserted":
            case "onstart":
            case "onscroll":
            case "onbeforeeditfocus":
            case "onactivate":
            case "onbeforedeactivate":
            case "ondeactivate":
            case "type":
            case "codebase":
            case "id":
                ret.objAttrs[args[i]] = args[i+1];
                break;
            case "width":
            case "height":
            case "align":
            case "vspace":
            case "hspace":
            case "class":
            case "title":
            case "accesskey":
            case "name":
            case "tabindex":
                ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
                break;
            default:
                ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
        }
    }
    ret.objAttrs["classid"] = classid;
    if (mimeType) ret.embedAttrs["type"] = mimeType;
    return ret;
}
var popupDivId='';
var browseNodeId;
var innerDocWidth = 0, innerDocHeight = 0;	  
if( typeof( window.innerWidth ) == 'number' )
{
    //Non-IE
    innerDocWidth = window.innerWidth;
    innerDocHeight = window.innerHeight;
}
else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
{
    //IE 6+ in 'standards compliant mode'
    innerDocWidth = document.documentElement.clientWidth;
    innerDocHeight = document.documentElement.clientHeight;
}
else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
{
    //IE 4 compatible
    innerDocWidth = document.body.clientWidth;
    innerDocHeight = document.body.clientHeight;
} 
function showDivPopup(id)
{
    popupDivId = id;
    totalHeightWithScroll=document.body.scrollHeight;
    if(totalHeightWithScroll<innerDocHeight)
    {
        totalHeightWithScroll=innerDocHeight;
    }
    divHeight = document.getElementById(popupDivId).scrollHeight;
    divWidth = document.getElementById(popupDivId).scrollWidth;
    document.getElementById(popupDivId).style.top=currentDocHeight + innerDocHeight/2 - (divHeight/2) +"px";
    document.getElementById(popupDivId).style.left=currentDocWidth + innerDocWidth/2 - (divWidth/2) +"px";
    document.getElementById("blockSection").style.display='block';
    document.getElementById("blockSection").style.height=totalHeightWithScroll+"px";
    document.getElementById(popupDivId).style.display='block';
    document.getElementById(popupDivId).style.visibility='visible';
}	
function hideDivPopup(id)
{
    document.getElementById("blockSection").style.display='none';
    document.getElementById(id).style.visible='hidden';
    document.getElementById(id).style.display='none';
    popupDivId = 0;
}
function scrollDetector(){	 // detect scroll browser event and change position of loading banner
	
    if (navigator.appName == "Microsoft Internet Explorer"){
        currentDocHeight=document.documentElement.scrollTop;
        currentDocWidth=document.documentElement.scrollLeft;
    }
    else{
        currentDocHeight=window.pageYOffset
        currentDocWidth=window.pageXOffset
    }
    if(popupDivId!=0){
        divHeight = document.getElementById(popupDivId).scrollHeight;
        divWidth = document.getElementById(popupDivId).scrollWidth;
        document.getElementById(popupDivId).style.top=currentDocHeight + innerDocHeight/2 - (divHeight/2) +"px";
        document.getElementById(popupDivId).style.left=currentDocWidth + innerDocWidth/2 - (divWidth/2) +"px";
    }
} 
// set event to capture scrolling event
setInterval("scrollDetector()", 5);	
function goToPageNumber(elemName,strUrl,varExtra,indicator,totalPages,txtGoToPage)
{
    var txtGoPage = trim(document.getElementById(txtGoToPage).value);
    if(txtGoPage==""){
        alert('Please enter page number');
        document.getElementById(txtGoToPage).value = '';
        return false;
    }
    if(!isInteger(txtGoPage)){
        alert('Please enter numeric value');
        return false;
    }
    if(parseInt(txtGoPage) > parseInt(totalPages)){
        alert('Please enter page number less than total pages');
        return false;
    }
    var params = "?page="+txtGoPage+"&txtGoPage="+txtGoPage+varExtra;
    txtGoToPage = txtGoToPage.replace("Foot","");
    new Ajax.Updater(elemName, strUrl+params, {
        asynchronous:true,
        evalScripts:true,
        method:'get',
        onComplete:function(request, json){
            Element.hide(indicator);
            Element.show(elemName);
            window.location='#';
            document.getElementById(txtGoToPage).value=txtGoPage;
            if(document.getElementById(txtGoToPage+"Foot")){
                document.getElementById(txtGoToPage+"Foot").value=txtGoPage
                }
            },
    onLoading:function(request, json){
        Element.hide(elemName);
        Element.show(indicator);
    }
    });
;
return false;
}
	
function goToPageNumberCustom(elemName,strUrl,varExtra,indicator,totalPages,txtGoToPage,pageVar)
{
    var txtGoPage = trim(document.getElementById(txtGoToPage).value);
    if(txtGoPage==""){
        alert('Please enter page number');
        document.getElementById(txtGoToPage).value = '';
        return false;
    }
    if(!isInteger(txtGoPage)){
        alert('Please enter numeric value');
        return false;
    }
    if(parseInt(txtGoPage) > parseInt(totalPages)){
        alert('Please enter page number less than total pages');
        return false;
    }
    var params = "?"+pageVar+"="+txtGoPage+"&txtGoPage="+txtGoPage+varExtra;
    txtGoToPage = txtGoToPage.replace("Foot","");
    new Ajax.Updater(elemName, strUrl+params, {
        asynchronous:true,
        evalScripts:true,
        method:'get',
        onComplete:function(request, json){
            Element.hide(indicator);
            Element.show(elemName);
            window.location='#';
        },
        onLoading:function(request, json){
            Element.hide(elemName);
            Element.show(indicator);
        }
    });
;
return false;
}
	
function goToVendorPageNumber(strUrl,varExtra,totalPages,txtGoToPage,pageVar){
    var txtGoPage = trim(document.getElementById(txtGoToPage).value);
    if(txtGoPage=="") {
        alert('Please enter page number');
        document.getElementById(txtGoToPage).value = '';
        return false;
    }
    if(!isInteger(txtGoPage)){
        alert('Please enter numeric value');
        return false;
    }
    if(parseInt(txtGoPage) > parseInt(totalPages)){
        alert('Please enter page number less than total pages');
        return false;
    }
    var params = "?"+pageVar+"="+txtGoPage+"&txtGoPage="+txtGoPage+varExtra;
    txtGoToPage = txtGoToPage.replace("Foot","");
    window.location= strUrl+params;
}	
function showRecordsWithAjax(elemName,strUrl,varExtra,indicator,val,selectShow,pageVar){
    var params = "?"+pageVar+"=1"+varExtra+"&showRecords="+val;
    new Ajax.Updater(elemName, strUrl+params, {
        asynchronous:true,
        evalScripts:true,
        method:'get',
        onComplete:function(request, json){
            Element.hide(indicator);
            Element.show(elemName);
            window.location='#';
            document.getElementById(selectShow).value=val
        },
        onLoading:function(request, json){
            Element.hide(elemName);
            Element.show(indicator);
        }
    });
;
return false;
}	
function showRecords(strUrl,varExtra,val,selectShow,pageVar){
    var params = "?"+pageVar+"=1"+varExtra+"&showRecords="+val;
    window.location= strUrl+params;
}
function filterUnFilterWithSearch(id,elemName,strUrl,indicator)
{
   
	
	
	
   var chkType = '0';
    var params; 
    if(document.getElementById(id) && document.getElementById(id).checked)
    { 
        params = "?filter=0";
        if(trim($("txtSearch").value) != ''){
            params+="&txtSearch="+$("txtSearch").value+"&chkType="+chkType;
        }
        new Ajax.Updater(elemName, strUrl+params, {
            asynchronous:true,
            evalScripts:true,
            method:'get',
            onComplete:function(request, json){
               Element.hide(indicator);
                Element.show(elemName);
                window.location='#';
               // document.getElementById(selectShow).value=val
            },
            onLoading:function(request, json){
                Element.hide(elemName);
                Element.show(indicator);
            }
        });    
    return false;
}else{
     params = "?filter=1";
    if(trim($("txtSearch").value) != '') {
        params+="&txtSearch="+$("txtSearch").value+"&chkType="+chkType;
    }
    new Ajax.Updater(elemName, strUrl+params, {
        asynchronous:true,
        evalScripts:true,
        method:'get',
        onComplete:function(request, json){
            Element.hide(indicator);
            Element.show(elemName);
            window.location='#';
            //document.getElementById(selectShow).value=val
        },
        onLoading:function(request, json){
            Element.hide(elemName);
            Element.show(indicator);
        }
    });
;
return false;
}
}
	
function filterUnFilterWithSearchVendor(id,elemName,strUrl,indicator){
    if(document.getElementById(id) && document.getElementById(id).checked){
        var params = "?filter=0";
        if(trim($("txtSearch").value) != ''){
            params+="&txtApplySearch="+$("txtSearch").value;
        }
        new Ajax.Updater('mp-contentWrapper', strUrl+params, {
            asynchronous:true,
            evalScripts:true,
            method:'get',
            onComplete:function(request, json){
                Element.hide(indicator);
                Element.show(elemName);
                window.location='#';
                document.getElementById(selectShow).value=val
            },
            onLoading:function(request, json){
                Element.hide(elemName);
                Element.show(indicator);
            }
        });
    
    return false;
}else{
    var params = "?filter=1";
    if(trim($("txtSearch").value) != ''){
        params+="&txtApplySearch="+$("txtSearch").value;
    }
    new Ajax.Updater('mp-contentWrapper', strUrl+params, {
        asynchronous:true,
        evalScripts:true,
        method:'get',
        onComplete:function(request, json){
            Element.hide(indicator);
            Element.show(elemName);
            window.location='#';
            document.getElementById(selectShow).value=val
        },
        onLoading:function(request, json){
            Element.hide(elemName);
            Element.show(indicator);
        }
    });
;
return false;
}
}	
function filterUnFilterWithSearchOrder(id,elemName,strUrl,indicator,type,varextra)
{	
    if(document.getElementById(id) && document.getElementById(id).checked){
        var params = "?filter=0&type="+type;
        if(trim($("txtOrderSearch").value) != ''){
            params+="&txtApplySearch2="+$("txtOrderSearch").value;
        }
        new Ajax.Updater('mp-contentWrapper', strUrl+params+varextra, {
            asynchronous:true,
            evalScripts:true,
            method:'get',
            onComplete:function(request, json){
                Element.hide(indicator);
                Element.show(elemName);
                window.location='#';
                document.getElementById(selectShow).value=val
            },
            onLoading:function(request, json){
                Element.hide(elemName);
                Element.show(indicator);
            }
        });
    ;
    return false;
}else{
    var params = "?filter=1&type="+type;
    if(trim($("txtOrderSearch").value) != ''){
        params+="&txtApplySearch2="+$("txtOrderSearch").value;
    }
    new Ajax.Updater('mp-contentWrapper', strUrl+params+varextra, {
        asynchronous:true,
        evalScripts:true,
        method:'get',
        onComplete:function(request, json){
            Element.hide(indicator);
            Element.show(elemName);
            window.location='#';
            document.getElementById(selectShow).value=val
        },
        onLoading:function(request, json){
            Element.hide(elemName);
            Element.show(indicator);
        }
    });

return false;
}
}
	
function clearLabFilter(totType,totOwner,totContainer)
{		
    if(totType > 0)	{
        for(var i=0;i<totType;i++){
            if(document.getElementById("chkLabFilType"+i)){
                document.getElementById("chkLabFilType"+i).checked = false;
            }
        }
    }
    if(totOwner > 0){
        for(var j=0;j<totOwner;j++)	{
            if(document.getElementById("chkLabFilOwner"+j))	{
                document.getElementById("chkLabFilOwner"+j).checked = false;
            }
        }
    }
    if(totContainer > 0){
        for(var k=0;k<totContainer;k++){
            if(document.getElementById("chkLabFilContainer"+k)){
                document.getElementById("chkLabFilContainer"+k).checked = false;
            }
        }
    }
}
function clearPrivateFilter(totType,totContainer){
    if(totType > 0){
        for(var i=0;i<totType;i++){
            if(document.getElementById("chkPrivateFilType"+i)){
                document.getElementById("chkPrivateFilType"+i).checked = false;
            }
        }
    }
    if(totContainer > 0){
        for(var i=0;i<totContainer;i++){
            if(document.getElementById("chkPrivateFilContainer"+i)){
                document.getElementById("chkPrivateFilContainer"+i).checked = false;
            }
        }
    }
}
function clearOrderFilter(totVendor,totStatus,totSenRec,totGrant){
    if(confirm("Do you really want to clear the filter?")){
        if(totVendor > 0){
            for(var i=0;i<totVendor;i++){
                if(document.getElementById("chkOrderFilVen"+i))	{
                    document.getElementById("chkOrderFilVen"+i).checked = false;
                }
                if(document.getElementById("chkOrderFilVenSend"+i)){
                    document.getElementById("chkOrderFilVenSend"+i).checked = false;
                }
            }
        }
        if(totStatus > 0){
            for(var i=0;i<totStatus;i++){
                if(document.getElementById("chkOrderFilStatus"+i)){
                    document.getElementById("chkOrderFilStatus"+i).checked = false;
                }
                if(document.getElementById("chkOrderFilStatusSend"+i)){
                    document.getElementById("chkOrderFilStatusSend"+i).checked = false;
                }
            }
        }
			
        if(totSenRec > 0){
            for(var i=0;i<totSenRec;i++){
                if(document.getElementById("chkOrderFilSen"+i)){
                    document.getElementById("chkOrderFilSen"+i).checked = false;
                }
                if(document.getElementById("chkOrderFilSenSend"+i)){
                    document.getElementById("chkOrderFilSenSend"+i).checked = false;
                }
            }
        }
        if(totGrant > 0){
            for(var i=0;i<totGrant;i++){
                if(document.getElementById("chkOrderFilGrantId"+i)){
                    document.getElementById("chkOrderFilGrantId"+i).checked = false;
                }
                if(document.getElementById("chkOrderFilGrantIdSend"+i)){
                    document.getElementById("chkOrderFilGrantIdSend"+i).checked = false;
                }
            }
        }
    }
}
function hideShowSettings(id){
    if($("editPriviledgeId") && id=="editPriviledgeId"){
        if($('editPriviledgeId').style.display=="none"){
            $('editPriviledgeId').style.display = "";
            $('lieditPriviledgeId').className = "active w145 VA";
        }else{
            $('editPriviledgeId').style.display = "none";
            $('lieditPriviledgeId').className = "w145 VA";
        }
    }else if($("defaultViewId") && id=="defaultViewId"){
        if($('defaultViewId').style.display=="none"){
            $('defaultViewId').style.display = "";
            $('lidefaultViewId').className = "active";
        }else{
            $('defaultViewId').style.display = "none";
            $('lidefaultViewId').className = "";
        }
    }else if($("editInvBackupId") && id=="editInvBackupId"){
        if($('editInvBackupId').style.display=="none"){
            $('editInvBackupId').style.display = "";
            $('lieditInvBackupId').className = "active";
        }else{
            $('editInvBackupId').style.display = "none";
            $('lieditInvBackupId').className = "";
        }
    }
	else if($("purchaseorderdef") && id=="purchaseorderdef"){
        if($('purchaseorderdef').style.display=="none"){
            $('purchaseorderdef').style.display = "";
            $('lipurchaseorder').className = "active w145 VA";
        }else{
            $('purchaseorderdef').style.display = "none";
            $('lipurchaseorder').className = "";
        }
    }
		
    else if($("editInventoryCloumnId") && id=="editInventoryCloumnId"){
        if($('editInventoryCloumnId').style.display=="none"){
            $('editInventoryCloumnId').style.display = "";
            $('lieditInventoryCloumnId').className = "active";
			jQuery('#txtTypeLeft').trigger('change');
        }else{
            $('editInventoryCloumnId').style.display = "none";
            $('lieditInventoryCloumnId').className = "";
        }
    }
	
	else if($("editMigrateId") && id=="editMigrateId"){
        if($('editMigrateId').style.display=="none"){
            $('editMigrateId').style.display = "";
            $('liMigrateId').className = "active";
        }else{
            $('editMigrateId').style.display = "none";
            $('liMigrateId').className = "";
        }
	}
	
	else if($("copyInvId") && id=="copyInvId"){
        if($('copyInvId').style.display=="none"){
            $('copyInvId').style.display = "";
            $('liInvCopyId').className = "active";
        }else{
            $('copyInvId').style.display = "none";
            $('liInvCopyId').className = "";
        }
	}
}
function fnSaveTemplate(actionURL){
		var queryString = 'cmbDeptTemplate='+jQuery('#cmbDeptTemplate').val();
		jQuery.ajax({
						url:actionURL,
						data:queryString,
						type:'POST',
						cache:false,
						success:function(data){
							jQuery('#successMsgDiv').show();
						}	
		});	
}
function hideShowOrderPage(val,page,recCnt){
   
   
 // alert('Val is   '+val);
   // alert('Page is  '+page);
	if($("orderRequestTab")) {
        $("orderRequestTab").value= val;
    }
	if($("activeTab")) {
        $("activeTab").value= val;
    }
    if($("mainProfilePageContent"))
        //$("mainProfilePageContent").className = "PageCntReg";
    if($("typeReagentValue")){
        if(val!=$("typeReagentValue").value) {
            clearErrorSuccessMessages();
        }
    }
    if($("orderNote")){
        if(page=="Orders" && val=="Received"){
            $("orderNote").style.display = "";
        }else{
            $("orderNote").style.display = "none";
        }
    }
    if(page=="Requests"){
        if($("searchOrderNote1")){
            $("searchOrderNote1").style.display = "none";
            $("searchOrderNote2").style.display = "";
        }
    }else{
        if($("searchOrderNote1")){
            $("searchOrderNote1").style.display = "";
            $("searchOrderNote2").style.display = "none";
        }
    }
    if($("searchOrderTitle")){
        $("searchOrderTitle").innerHTML = "<b>Search "+page+"</b>";
    }
    if($("typeReagentValue")){
        $("typeReagentValue").value = val;
    }
    hideshowOrderFilter("1");
	if(val=="Received"){
		$("orderFiltersReceived").style.display = "";
		$("orderFiltersSent").style.display = "none";
      // alert('bababab');
            if($("ReceivedContentId"))
                $("ReceivedContentId").style.display = "";
				if($("SentContentId")){
              $("SentContentId").style.display = "none";
            if($("HistoryContentId"))
                $("HistoryContentId").style.display = "none";
            if($("PurchaseContentId"))
                $("PurchaseContentId").style.display = "none";
            if($("AddContentId"))
                $("AddContentId").style.display = "none";
            if($("PurchaseOrderContentId")) {
                $("PurchaseOrderContentId").style.display = "none";
            }
				
        }
		
		if(recCnt){	
			document.getElementById("orderInventory").innerHTML="Received ("+recCnt+")";
			setCss("liorderInventory",'active');
			setCss("liordersSent",'');
			setCss("lilLabOrders",'');
		}
		document.getElementById("SentTabId").innerHTML="Sent";
		
		
    }
    //else if(val=="Sent"){
	
	if(val=="Sent"){
		$("orderFiltersReceived").style.display = "none";
		$("orderFiltersSent").style.display = "";
	
		setCss("liorderInventory",'');
		setCss("liordersSent",'active');
		setCss("lilLabOrders",'');
		
        if($("SentContentId")){
            $("SentContentId").style.display = "";
            if($("ReceivedContentId"))
                $("ReceivedContentId").style.display = "none";
            if($("HistoryContentId"))
                $("HistoryContentId").style.display = "none";
            if($("PurchaseContentId"))
                $("PurchaseContentId").style.display = "none";
            if($("AddContentId"))
                $("AddContentId").style.display = "none";
            if($("PurchaseOrderContentId")) {
                $("PurchaseOrderContentId").style.display = "none";
            }
				
        }
		if($("ReceivedTabId"))
			document.getElementById("orderInventory").innerHTML="Received";
			if(recCnt){
				document.getElementById("SentTabId").innerHTML="Sent ("+recCnt+")";
				setCss("liorderInventory",'');
				setCss("liordersSent",'active');
				setCss("lilLabOrders",'');
			}
			
    }
	
	else if(val=="History"){
        if($("HistoryContentId")){
            $("HistoryContentId").style.display = "";
            if($("PurchaseContentId"))
                $("PurchaseContentId").style.display = "none";
            if($("ReceivedContentId"))
                $("ReceivedContentId").style.display = "none";
            if($("SentContentId"))
                $("SentContentId").style.display = "none";
            if($("AddContentId"))
                $("AddContentId").style.display = "none";
            if($("PurchaseOrderContentId")) {
                $("PurchaseOrderContentId").style.display = "none";
            }
				
        }
			
			
    }
    else if(val=="Purchase"){
        if($("PurchaseContentId")){
            $("PurchaseContentId").style.display = "";
            if($("HistoryContentId")) {
                $("HistoryContentId").style.display = "none";
            }
            if($("ReceivedContentId")) {
                $("ReceivedContentId").style.display = "none";
            }
            if($("SentContentId")) {
                $("SentContentId").style.display = "none";
            }
            if($("AddContentId")) {
                $("AddContentId").style.display = "none";
            }
				
        }
			
			
    }
    else if(val=="PurchaseOrder"){
        if($("PurchaseOrderTabId")){
            $("PurchaseOrderContentId").style.display = "";
            if($("HistoryContentId")) {
                $("HistoryContentId").style.display = "none";
            }
            if($("ReceivedContentId")) {
                $("ReceivedContentId").style.display = "none";
            }
            if($("SentContentId")) {
                $("SentContentId").style.display = "none";
            }
            if($("AddContentId")) {
                $("AddContentId").style.display = "none";
            }
				
        }
			
				
					
    }
		
    else if(val=="ReOrder"){
        if($("PurchaseOrderTabId")){
            $("PurchaseOrderContentId").style.display = "";
            if($("HistoryContentId")) {
                $("HistoryContentId").style.display = "none";
            }
            if($("ReceivedContentId")) {
                $("ReceivedContentId").style.display = "none";
            }
            if($("SentContentId")) {
                $("SentContentId").style.display = "none";
            }
            if($("AddContentId")) {
                $("AddContentId").style.display = "none";
            }
				
				
        }
			
			
    }
    else if(val=="SentsOrder"){
        if($("SentsOrderTabId")){
            $("SentsOrderContentId").style.display = "";
            if($("HistoryContentId")) {
                $("HistoryContentId").style.display = "none";
            }
            if($("ReceivedContentId")) {
                $("ReceivedContentId").style.display = "none";
            }
            if($("SentContentId")) {
                $("SentContentId").style.display = "none";
            }
            if($("AddContentId")) {
                $("AddContentId").style.display = "none";
            }
        }
			
				
					
    }
    else if(val=="Add"){
        if($("AddContentId")){
            $("AddContentId").style.display = "";
            if($("HistoryContentId"))
                $("HistoryContentId").style.display = "none";
            if($("ReceivedContentId"))
                $("ReceivedContentId").style.display = "none";
            if($("SentContentId"))
                $("SentContentId").style.display = "none";
            if($("PurchaseContentId"))
                $("PurchaseContentId").style.display = "none";
            if($("PurchaseOrderContentId")) {
                $("PurchaseOrderContentId").style.display = "none";
            }
				
				
        }
			
			
    }
    else{
        if($("SentContentId")){
            if($("HistoryContentId"))
                $("HistoryContentId").style.display = "none";
            $("SentContentId").style.display = "none";
            if($("ReceivedContentId"))
                $("ReceivedContentId").style.display = "";
            if($("AddContentId"))
                $("AddContentId").style.display = "none";
            if($("PurchaseOrderContentId")) {
                $("PurchaseOrderContentId").style.display = "none";
            }
            if($("SentsOrderContentId")) {
                $("SentsOrderContentId").style.display = "none";
            }
				
        }
        if($("sendFilterMsg")){
            $("sendFilterMsg").style.display = "none";
        }
    }
		

}

	
function callEnterFunction(event,frmName){
    if(event.keyCode=="13"){
		activeTab="";
		if($("activeTab")) {
			activeTab = document.getElementById('activeTab').value;		
		}
        if(valFrmReagentOrderSearch()){
            new Ajax.Updater('mp-contentWrapper', 'orders/reagentorderrequest?type=1&activeTab='+activeTab, {
                asynchronous:true,
                evalScripts:true,
                method:'get',
                onComplete:function(request, json){
                    Element.hide('indicator2');
                    Element.show('mp-contentWrapper');
                    showOrderSearch(val);
                    window.location='#';
                },
                onLoading:function(request, json){
                    Element.hide('mp-contentWrapper');
                    Element.show('indicator2');
                },
                onSuccess:function(request, json){
                    pageTracker._trackPageview("/orders/reagsearchorderrequest?type=1")
                    },
                parameters:Form.serialize(document.searchReagentOrderForm)
                });
        }
    }
}
	
function callLeftPanelOrder(val){
    if($("orderRequestLink")){
        $("orderRequestLink").value = val;
        new Ajax.Updater('leftPanel', 'profile/profileleftmenu?txtMenu=workspace', {
            asynchronous:true,
            evalScripts:true,
            method:'get',
            onComplete:function(request, json){
                topMenuActive('topWorkspace');
            },
            onLoading:function(request, json){}
        });
    return false;
}else{
    $("txtRedirectPageTo").value = val;
    document.redirectFrm.submit();
}
}

//added by atul
function orderReagentChecked(chkId){  
    if (document.getElementById('chkOnlyMyself').checked == true ){
        document.getElementById('chkLab').disabled = true;
    }else{
        document.getElementById('chkLab').disabled = false;
    }
} 
function orderReagentChecked2(chkId){ 
    if (document.getElementById('chkLab').checked == true){
        document.getElementById('chkOnlyMyself').disabled = true;
    }else{
        document.getElementById('chkOnlyMyself').disabled = false;
        document.getElementById('divReagEmail').style.display='none';
    }
}

//end added by atul
function callCommonLeftPanelPage(nextPage){		
    $("txtRedirectPageTo").value = nextPage;
    document.redirectFrm.submit();
}

function labmateNext(nextPage){		
      new Ajax.Updater('leftPanel', 'contacts/labmates', {
            asynchronous:true,
            evalScripts:true,
            onComplete:function(request, json){
                afterLoad();
            },
            onLoading:function(request, json){
                changeVideoClass();
                topMenuActive('topProtocols');
            }
        });
    ;
}
	
function callCommonLeftPanelPageDashboard(nextPage,status){	
    $("txtRedirectPageTo").value = nextPage;
    if(status == 'sent')
    {
        $("txtOrderRed").value = status;
    }
    document.redirectFrm.submit();
}

function callProtocolPage()	{	
    if($("orderRequestLink")){
        $("txtRedirectPageTo").value = "";
        new Ajax.Updater('leftPanel', 'profile/profileleftmenu?txtMenu=topprotocols', {
            asynchronous:true,
            evalScripts:true,
            onComplete:function(request, json){
                afterLoad();
            },
            onLoading:function(request, json){
                changeVideoClass();
                topMenuActive('topProtocols');
            }
        });
    ;
    return false;
}
}
function backToSearchFacility(){
    if($("txtFacilitySearch").value=="Search Facilities"){
        topMenuActive('topfacilities');
    }else{
        new Ajax.Updater('mp-contentWrapper', 'facility/searchFacility', {
            asynchronous:true,
            evalScripts:true,
            method:'GET',
            onComplete:function(request, json){
                setCloseImages();
                Element.hide('indicator2');
                Element.show('mp-contentWrapper');
                window.location='#';
            },
            onLoading:function(request, json){
                Element.hide('mp-contentWrapper');
                Element.show('indicator2');
                leftMenuFacility('')
                },
            parameters:Form.serialize(document.searchFacilityForm)
            });
    }
}
	
function callLeftPanelOrder(val){
    $("orderRequestLink").value = val;
    $("txtRedirectPageTo").value = val;
    document.redirectFrm.submit();
    new Ajax.Updater('leftPanel', 'profile/profileleftmenu?txtMenu=workspace', {
        asynchronous:true,
        evalScripts:true,
        method:'get',
        onComplete:function(request, json){
            topMenuActive('topWorkspace');
        },
        onLoading:function(request, json){}
    });
return false;
}
	
function callLeftPanelRequestOrder(val){
		
    $("orderRequestLink").value = val;
    $("txtRedirectPageTo").value = val;
    document.redirectFrm.submit();
    new Ajax.Updater('leftPanel', 'profile/profileleftmenu?txtMenu=Orders', {
        asynchronous:true,
        evalScripts:true,
        method:'get',
        onComplete:function(request, json){
            topMenuActive('topOrders');
        },
        onLoading:function(request, json){}
    });
return false;
}
	
function decreaseCont(){
    var val = parseInt($("totCont").value);
    var newVal = val-1;
    $("totCont").value = newVal;
    if(newVal==0){
        $("divViewLabmate_search").innerHTML='<div class="search-members-listing" style="width:570px;">No Contacts Found</div>';
    }
}
function decreaseLab(){
    var val = parseInt($("totLab").value);
    var newVal = val-1;
    $("totLab").value = newVal;
    if(newVal==0){
        $("divViewLabmate_search").innerHTML='<div class="search-members-listing" style="width:570px;">No LabMates Found</div>';
    }
}
function getSelectedVendorId(text, li){
    var vendorId = li.id;
    document.getElementById("txtHdnVendorId").value = vendorId;
    new Ajax.Updater("txtHdnCatalogCount", "reagent/catalogCount?vendorId="+vendorId, {
        asynchronous:true,
        evalScripts:true,
        method:'get',
        onComplete:function(request, json){
            hideshowcatalog();
        }
    });
}
	
function getSelectedLabVendorId(text, li){
    var vendorId = li.id;
    document.getElementById("txtLabHdnVendorId").value = vendorId;
    new Ajax.Updater("txtHdnCatalogCount", "reagent/catalogCount?vendorId="+vendorId, {
        asynchronous:true,
        evalScripts:true,
        method:'get',
        onComplete:function(request, json){
            hideshowcatalog();
        }
    });
}
	
function hideshowcatalog(){
    var countId = document.getElementById("txtHdnCatalogCount");
    var val = countId.innerHTML;
}
function setWinSizeCommon(){
    if($("dhtmltooltipQ")){
        $("dhtmltooltipQ").style.top = "0px";
    }
    if($("dhtmltooltipQ")){
        $("mp-contentWrapper").scrollTo();
    }
}

/** * Added By Mohan on 16Dec2009 starts. */ 
//downloadReagent('myReagentsForm','reagid[]','reagent/reagentdownload')
function downloadReagent(formName,checkedFieldName,url,type,search){
    var docName = document.forms[formName];
    var countVar = 0;
    var a = docName.elements.length;
		
    var selReagentIds='';
    for(i=0; i < docName.elements.length; i++){
        if(docName.elements[i].name==checkedFieldName){
            if( docName.elements[i].checked==true ){
                if (selReagentIds!='')
                    selReagentIds=selReagentIds+','+docName.elements[i].value;
                else
                    selReagentIds=selReagentIds+''+docName.elements[i].value;
            }
        }
    }
    //alert(selReagentIds);
		
    //if(selReagentIds == 0){
    /*setValue('div'+formName,'Please select at least one');
			$('div'+formName).scrollTo();
			return false;*/
    //}else{
    if(type=='private')	{
        if(document.getElementById('PrivateFilters').checked==true && selReagentIds=='' && document.getElementById('searchSessionPvt').value=='' ){
            setValue('divmyReagentsForm','No matching items to download.');
            return false;
        }
    }
    if(type=='lab'){
        if(document.getElementById('LabFilters').checked==true && selReagentIds=='' && document.getElementById('searchSessionLab').value==''){
            setValue('divlabmetReagentsForm','No matching items to download.');
            return false;
        }
    }
    if(!confirm('This will create an Excel download and may take a few minutes.  Would you like to proceed?')){
        return false;
    }
    if(formName == 'labmetReagentsForm')
    {
        DvLayerOpenSandBx('DvLayerSndLft_lab','DvLayerInvSandBx_lab','230','50%');

    }

                
    else if(formName == 'myReagentsForm')
    {
        DvLayerOpenSandBx('DvLayerSndLft','DvLayerInvSandBx','230','50%');
    }
		
    document.location.href=url+'?rtype='+type+'&regids='+selReagentIds;
//}
}
function downloadNoneSelectReagent(formName,checkedFieldName,url,type,search){
    var docName = document.forms[formName];
    var countVar = 0;
    var a = docName.elements.length;
		
    var selReagentIds='';
    for(i=0; i < docName.elements.length; i++){
        if(docName.elements[i].name==checkedFieldName){
            if( docName.elements[i].checked==true ){
                if (selReagentIds!='')
                    selReagentIds=selReagentIds+','+docName.elements[i].value;
                else
                    selReagentIds=selReagentIds+''+docName.elements[i].value;
            }
        }
    }
    //alert(selReagentIds);
		
    if(selReagentIds == 0){
        setValue('div'+formName,'No reagent for download.');
        $('div'+formName).scrollTo();
        return false;
    }else{
        if(type=='private')	{
            if(document.getElementById('PrivateFilters').checked==true && selReagentIds=='' && document.getElementById('searchSessionPvt').value=='' ){
                setValue('divmyReagentsForm','No matching items to download.');
                return false;
            }
        }
        if(type=='lab'){
            if(document.getElementById('LabFilters').checked==true && selReagentIds=='' && document.getElementById('searchSessionLab').value==''){
                setValue('divlabmetReagentsForm','No matching items to download.');
                return false;
            }
        }
        if(!confirm('This will create an Excel download and may take a few minutes.  Would you like to proceed?')){
            return false;
        }
        if(formName == 'labmetReagentsForm')
        {
            DvLayerOpenSandBx('DvLayerSndLft_lab','DvLayerInvSandBx_lab','230','50%');

        }

                
        else if(formName == 'myReagentsForm')
        {
            DvLayerOpenSandBx('DvLayerSndLft','DvLayerInvSandBx','230','50%');
        }
		
        document.location.href=url+'?rtype='+type+'&regids='+selReagentIds;
    }
}
function downloadEntireReagent(){
    DvLayerOpenSandBx('DvLayerSndLft','DvLayerInvSandBx','230','50%');
}
		
function getAllReagentIds(formName,checkedFieldName,url){
    var docName = document.forms[formName];
    var countVar = 0;
    var allReagentIds='';
    for(i=0; i < docName.elements.length; i++){
        if(docName.elements[i].name==checkedFieldName){
            if (allReagentIds!='')
                allReagentIds=allReagentIds+','+docName.elements[i].value;
            else
                allReagentIds=allReagentIds+''+docName.elements[i].value;
        }
    }
    return allReagentIds;
}
/** Added By Mohan on 16Dec2009 ends. */ 
function delOrderCheck(formName, elementName){ 	
    var docName = document.forms[formName];
    var countVar = 0;
    var tmpIndex = 1;
    for(i=0; i < docName.elements.length; i++){
        if(docName.elements[i].name==elementName){
            if(docName.elements[i].checked==true){
                countVar++;
            }
            tmpIndex++;
        }
    }
    if(countVar > 0){
        if(confirm('Are you sure?'))
            return true;
    }else {
        setValue('div'+formName,'Please select at least one');
        $('div'+formName).scrollTo();
        return false;
    }
}	

/*** Added By Mohan on 20Jan2010 starts.*/
function isConfirmChangeCatalog() {	  	
    try {
        var isConfirmed=false;
        var confirmMessage = 'You are attempting to edit a field that uniquely identifies this reagent. If you continue ratings and comments will be lost.';
        if (confirm(confirmMessage)){
            isConfirmed=true;
        }
        return isConfirmed;
    }
    catch(e){
        alert('Error >'+e)
        }
}
//COMMON FUNCTION FOR THE CHECKUNCHECKALL REAGENT 
function checkUncheckAllReg(formName, elementName){		
	
	var docName = document.forms[formName];
	
    var countVar = 0;
    for(i=0; i < docName.elements.length; i++){
        if(docName.elements[i].name==elementName){
            if(docName.chkAll.checked==true){
                docName.elements[i].checked=true;
				
            }else{
				
				 docName.elements[i].checked=false;
            }
        }
    }
}	
//END OF COMMON FUNCTION FOR THE  CHECKUNCHECKALL REAGENT  


//COMMON FUNCTION FOR THE CHECKUNCHECKALL REAGENT 
function checkUncheckAllInventory(formName, elementName){
	if(checkSelectionConflict(formName,elementName,"chkAll")){
		return;
	}
	toggleLocalVendorButton();	
	var docName = document.forms[formName];
	document.getElementById('txtInventoryStatus').value=elementName;
	/*****Uncheck all Checkbox Start*****/	
	for(i=0; i < docName.elements.length; i++){
		if(docName.elements[i].name !="chkAll"){
			docName.elements[i].checked=false;
			
		}
	}	
	/*****Uncheck all Checkbox End*****/	
    var countVar = 0;
    for(i=0; i < docName.elements.length; i++){
        if(docName.elements[i].name==elementName){
            if(docName.chkAll.checked==true){
                docName.elements[i].checked=true;
				
            }else{
				
				 docName.elements[i].checked=false;
            }
        }
    }
}	
//END OF COMMON FUNCTION FOR THE  CHECKUNCHECKALL REAGENT  


function checkUncheckAllRegent(formName, elementName,chkReagent){
	if(checkSelectionConflict(formName,elementName,chkReagent)){
		return;
	}
	toggleLocalVendorButton("LOCAL");
	var docName = document.forms[formName];
	var chkReagentBox = document.getElementById(chkReagent).checked;
	document.getElementById('txtInventoryStatus').value=elementName;	
	
	/*****Uncheck all Checkbox Start*****/		
	for(i=0; i < docName.elements.length; i++){
		if(docName.elements[i].name !=chkReagent){
			docName.elements[i].checked=false;
			
		}
	}
	/*****Uncheck all Checkbox End*****/	
	
	var countVar = 0;
    for(i=0; i < docName.elements.length; i++){
	    
		if(docName.elements[i].name==elementName){
		
			if(chkReagentBox==true){
				docName.elements[i].checked=true;
			}else{
				docName.elements[i].checked=false;
				
            }
        }
    }
}	
function checkEachRegent(formName, elementName){
	if(checkSelectionConflict(formName,elementName)){
		return;
	}
	
	toggleLocalVendorButton("LOCAL");
    var docName = document.forms[formName];
	document.getElementById('txtInventoryStatus').value=elementName;
	
	/*****Uncheck all Checkbox Start*****/	
	for(i=0; i < docName.elements.length; i++){
		if(docName.elements[i].name !=elementName){
			docName.elements[i].checked=false;
		}
	}
	/*****Uncheck all Checkbox End*****/		
    var flag = true;
    for(i=0; i < docName.elements.length; i++){
        if(docName.elements[i].name==elementName){
            if(docName.elements[i].checked==false){
                flag = false;
            }
        }
    }
    //docName.chkReagent.checked= flag;
}
function checkSelectionConflict(formName,elementName,chkReagent){
	var docName = document.forms[formName];	
	var conflictFound = false;	
	for(i=0; i < docName.elements.length; i++){
		if(chkReagent){
			if( docName.elements[i].name != chkReagent && docName.elements[i].name !=elementName && docName.elements[i].checked==true){			
				conflictFound = true;
			}
		}else{
			if(docName.elements[i].name !=elementName && docName.elements[i].checked==true){			
				conflictFound = true;
			}
		}		
	}
	if(conflictFound==true){
		var r=confirm("You have already selected record from another local vendor or vendor.\n\nAre you want to deselect those and select this ?");
		if(r==false){
			if(chkReagent){				
				document.getElementById(chkReagent).checked =false;
			}else{
				elmnt = document.getElementsByName(elementName);				
				for(i=0; i < elmnt.length; i++){
					elmnt[i].checked = false;
				}
			}
			return true;
		}
	}
	return false;
}
//COMMON FUNCTION FOR THE CHECK EACH CHECKBOX REAGENT 
function checkEachReg(formName, elementName){

    var docName = document.forms[formName];	
	
    var flag = true;
    for(i=0; i < docName.elements.length; i++){
        if(docName.elements[i].name==elementName){
            if(docName.elements[i].checked==false){
                flag = false;
            }
        }
    }
    docName.chkAll.checked= flag;
}	
//END OF COMMON FUNCTION FOR THE CHECK EACH CHECKBOX REAGENT

//COMMON FUNCTION FOR THE CHECK EACH CHECKBOX REAGENT 
function checkEachInventory(formName, elementName){
	if(checkSelectionConflict(formName,elementName)){
		return;
	}
	toggleLocalVendorButton();	
    var docName = document.forms[formName];	
	document.getElementById('txtInventoryStatus').value=elementName;
	/*****Uncheck all Checkbox Start*****/	
	for(i=0; i < docName.elements.length; i++){
		if(docName.elements[i].name !=elementName){
			docName.elements[i].checked=false;

		}
	}
	/*****Uncheck all Checkbox End*****/	
	
    var flag = true;
    for(i=0; i < docName.elements.length; i++){
        if(docName.elements[i].name==elementName){
            if(docName.elements[i].checked==false){
                flag = false;
            }
        }
    }
    docName.chkAll.checked= flag;
}	
//END OF COMMON FUNCTION FOR THE CHECK EACH CHECKBOX REAGENT 
/*** Added By Mohan on 20Jan2010 ends.*/	  
function test(id){
    var inlineEditBoxId='inlineEditBox_'+id;
    var isConfirmed=false;
    var confirmMessage = 'You are attempting to edit a field that uniquely identifies this reagent. If you continue ratings and comments will be lost.';
    if (confirm(confirmMessage)){
        isConfirmed=true;
        document.getElementById(inlineEditBoxId).style.display='';
    }
    return isConfirmed;
}
function callVendorPage(val)
{
    $("txtPageTo").value = val;
    document.redirectFrm.submit();
		
}
function validateSearch(){
		
    if(document.getElementById('txtSearch').value=='' || document.getElementById('txtSearch').value=='Search Reagents')	{
        alert('Please enter search text');
        document.getElementById('txtSearch').value='Search Reagents';
        return false;
    }
    return true;
}
function validateSearchReagent(){
    if(document.getElementById('txtSearch').value=='' || document.getElementById('txtSearch').value=='Search Inventory'){
        alert('Please enter search text');
        document.getElementById('txtSearch').value='Search Inventory';
        return false;
    }
    return true;
}
function clearVendorSearch(){		
    if(document.getElementById('txtSearch').value=='' || document.getElementById('txtSearch').value=='Search Reagents')	{
        document.getElementById('txtSearch').value='';
        document.getElementById('txtSearch').focus();
        return false;
    }
    document.getElementById('txtSearch').value='';
    document.getElementById('clrTag').value='1';
    document.searchVenReagentsForm.submit();
}
function clearSearchReagent(){		
    if(document.getElementById('txtSearch').value=='' || document.getElementById('txtSearch').value=='Search Inventory')	{
        document.getElementById('txtSearch').value='';
        document.getElementById('txtSearch').focus();
        return false;
    }
    document.getElementById('txtSearch').value='';
    document.getElementById('clrTag').value='1';
    document.searchVenReagentsForm.submit();
}
function clearVendorFilter(){	
    document.getElementById('clrVenFill').value='1';
    document.vendorForm.submit();
}	
function checkBoxClick(){	
    if(document.getElementById('PrivateFilters').checked==false){
        document.getElementById('clrVenFill').value='1';
        document.vendorForm.submit();
    }
}

function clearVendorFilterinside(){
    if(document.getElementById('PrivateFilters').checked==false){
        document.getElementById('clearVendorFilter').value='1';
    }
    document.vendorClrFilter.submit();
}

////// java script for home page images rotate tab/////////////////////

var index = 0;
function WindowLoaded(evt){
    document.body.onselectstart = function () {
        return false;
    };}
function Step(i) {
    GoTo(index + i)
}
function Step2(i){
    index = 0;
    GoTo(index + i)
}
function GoTo(newIndex){                
    document.getElementById("nextDivId1").style.display = "";
    document.getElementById("nextDivId2").style.display = "none";
    if(parseInt(newIndex) > 0){
        document.getElementById("nextDivId1").style.display = "none";
        document.getElementById("nextDivId2").style.display = "";
    }
    if(newIndex==0){
        document.getElementById("previousButton").style.display = "none";
    }else{
        document.getElementById("previousButton").style.display = "";
    }
    if(newIndex==6){
        document.getElementById("nextButton1").style.display = "none";
        document.getElementById("nextButton2").style.display = "none";
    }else{
        document.getElementById("nextButton1").style.display = "";
        document.getElementById("nextButton2").style.display = "";
    }
    if(newIndex >= 0 && newIndex < 7){
        index = newIndex;
        for(i=0;i<=6;i++){
            document.getElementById("Slideshow"+i).style.display = "none";
        }
        document.getElementById("Slideshow"+index).style.display = "";
    }
    return false;
}        
function HideShowIndx (num){			  
    if ( typeof HideShowIndx.counter == 'undefined' ){
        HideShowIndx.counter = 1;
    }
    document.getElementById('a' + HideShowIndx.counter).style.visibility = 'hidden';
    document.getElementById('ancho' + HideShowIndx.counter).className = 'innernav0'+ HideShowIndx.counter;
    HideShowIndx.counter = num;
    document.getElementById('a' + num).style.visibility = 'visible';
    document.getElementById('ancho' + num).className = 'innernav0'+ HideShowIndx.counter +'on';
}	
////// end of home page images rotate tab/////////////////////

/////Function used on header section////
function btnSearch(){
    var searchVal = document.getElementById("searchTxt").value;
    if(trim(searchVal) == "" || trim(searchVal) == "Search Scientists"){
        alert("Please enter the term you want to search");
        document.getElementById("searchTxt").focus();
        return(false);
    }
}	
function funCheckTimerWindow(Url)
{    
    flagLogout = false;
    if(typeof(timerPopupObj) == "undefined" ) {
        flagLogout = true;
    }else{
        if (timerPopupObj.closed){
            flagLogout = true;
        }else{
            if (confirm("You have one or more timers running. If you log-out the timer will continue running till you close the timer window. However, text-messages will not be sent. Log-out?")){
                flagLogout = true;
            }
        }
    }
    if(flagLogout){
        window.location = Url;
        return true;
    }
    return false;
}
	
function setWinSize(){
		
    var val = navigator.userAgent.toLowerCase();
    isSafari = false;
    if(val.indexOf("safari") > -1)
    {
        isSafari = true;
        innerDocWidth = window.innerWidth;
        innerDocHeight = window.innerHeight;
    }
    else if( typeof( window.innerWidth ) == "number" )
    {
        //Non-IE
        innerDocWidth = window.innerWidth;
        innerDocHeight = window.innerHeight;
    }
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {
        //IE 6+ in "standards compliant mode"
				
        innerDocWidth = document.documentElement.clientWidth;
        innerDocHeight = document.documentElement.clientHeight;
    }
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    {
        //IE 4 compatible
        innerDocWidth = document.body.clientWidth;
        innerDocHeight = document.body.clientHeight;
    }
			
    totalHeightWithScroll=document.body.scrollHeight;
    if(totalHeightWithScroll<innerDocHeight)
    {
        totalHeightWithScroll=innerDocHeight;
    }
			
    if(document.getElementById("DvLayer"))
	{
        document.getElementById("DvLayer").style.width = "100%";
		document.getElementById("DvLayer").style.height = "100%";
	}
    if(isSafari)
    {
        totalHeightWithScroll = document.getElementById("videoPanelID").offsetHeight;
        rightPanel = document.getElementById("reagentOrderRequestRightPDiv").offsetHeight;
				
        if(totalHeightWithScroll<rightPanel)
        {
            totalHeightWithScroll = rightPanel;
        }
        totalHeightWithScroll = totalHeightWithScroll + 520; // july02 297
        if(document.getElementById("DvLayer"))
            document.getElementById("DvLayer").style.height = totalHeightWithScroll+"px";
    }
    else{
        if(document.getElementById("DvLayer"))
            document.getElementById("DvLayer").style.height = totalHeightWithScroll+"px";
    }
			
}
/////Function used on header section////
////Home login validate//
function funSignUpValidate(){
    var isSignUpReturnFalse = true;
    var signUpEmailVar = document.getElementById('txtEmail2').value;
    var reTypeEmailVar = document.getElementById('txtRemail').value;
		
    if (( trim(signUpEmailVar) != 0 && trim(reTypeEmailVar) != 0 ) && ( trim(signUpEmailVar) != trim(reTypeEmailVar) ) ){
        setValue('divSignUpEmail','Email address mismatch.');
        document.getElementById('txtRemail').value='';
        isSignUpReturnFalse = false;
    }
    return isSignUpReturnFalse;
}
////Home login validate//

/**************** Show java script***********************************/
function IndTab(tb1,tb2,tb3,tb4,id1,id2,id3,id4) {			
    if(document.getElementById(tb1).className == "selected"){
        document.getElementById(tb1).className="";
        document.getElementById(tb2).className="";
        document.getElementById(tb3).className="";
        document.getElementById(tb4).className="";
        document.getElementById(id1).style.display="none";
    }else{
        document.getElementById(tb1).className="selected";
        document.getElementById(tb2).className="inact";
        document.getElementById(tb3).className="inact";
        document.getElementById(tb4).className="inact";
        document.getElementById(id1).style.display="block";
        document.getElementById(id2).style.display="none";
        document.getElementById(id3).style.display="none";
        document.getElementById(id4).style.display="none";
    }
    // in case no one is selected
    if(document.getElementById(id1).style.display=='none' && document.getElementById(id2).style.display=='none'){
        document.getElementById(id1).style.display = "block";
        document.getElementById(tb1).className="selected";
    }
}	
function callSuggession(copy,userid,TypeId){
	
    var txtTypeVal = $('txtType').value;
    if(TypeId > 0){
        txtTypeVal = TypeId;
    }
    new Ajax.Updater('dvSyssuggestfields', 'reagent/systemsuggestfields/rmprevious/1', {
        asynchronous:true,
        evalScripts:true,
        onComplete:function(request, json){
            Element.hide('indicatortype');
            Element.show('dvSyssuggestfields');
            $('txtType').disabled = true;
            ForShow('pub_T_81'), ForHide('pt_T_81')
            },
        onLoading:function(request, json){
            Element.hide('dvSyssuggestfields');
            Element.show('indicatortype');
        },
        onSuccess:function(request, json){
            pageTracker._trackPageview("/reagent/systemsuggestfields")
            },
        parameters:'txtType=' +txtTypeVal+'&reagid='+$('reagid').value+'&copy='+copy+'&usrid='+userid+''
        });
}
function callAdvanceSuggession(copy,userid,TypeId){
    //alert(copy);
    var txtTypeVal = $('txtType').value;
    if(TypeId > 0){
        txtTypeVal = TypeId;
    }
    new Ajax.Updater('dvSyssuggestfields', 'reagent/advsystemsuggestfields/rmprevious/1',
    {
        asynchronous:true,
        evalScripts:true,
        onComplete:function(request, json)
        {
            Element.hide('indicatortype');
            Element.show('dvSyssuggestfields');
            ForShow('pub_T_81'),
            ForHide('pt_T_81')
            },
        onLoading:function(request, json){
            Element.hide('dvSyssuggestfields');
            Element.show('indicatortype');
        },
        onSuccess:function(request, json){
            pageTracker._trackPageview("/reagent/advsystemsuggestfields")
            },
        parameters:'txtType=' +txtTypeVal+'&reagid='+$('reagid').value+'&copy='+copy+'&usrid='+userid+''
        });
}
	
function callAdvanceSuggessionLab(copy,userid,TypeId){
    //alert(copy);
    var txtTypeVal = $('txtLabType').value;
    if(TypeId > 0){
        txtTypeVal = TypeId;
    }
    new Ajax.Updater('dvSyssuggestfields2', 'reagent/advsystemsuggestfields/rmprevious/1',
    {
        asynchronous:true,
        evalScripts:true,
        onComplete:function(request, json)
        {
            Element.hide('indicatortype');
            Element.show('dvSyssuggestfields2');
            ForShow('pub_T_81'),
            ForHide('pt_T_81')
            },
        onLoading:function(request, json){
            Element.hide('dvSyssuggestfields2');
            Element.show('indicatortype');
        },
        onSuccess:function(request, json){
            pageTracker._trackPageview("/reagent/advsystemsuggestfields")
            },
        parameters:'txtType=' +txtTypeVal+'&reagid='+$('reagid').value+'&copy='+copy+'&usrid='+userid+''
        });
}
	
function ForShow(id){
    document.getElementById(id).style.display="block";
}
function ForHide(id){
    document.getElementById(id).style.display="none";
}	
var refer=true;
function showQue(QueCon){
    if (document.getElementById(QueCon).style.display=="none"){
        document.getElementById(QueCon).style.display="block";
        refer=false;
    } else{
        document.getElementById(QueCon).style.display="none";
        refer=true;
    }
}
/**************** Show java script***********************************/
/************ Detect swf *************/
// JavaScript Document
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
    if (!document.getElementById) {
        return;
    }
    this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
    this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
    this.params = new Object();
    this.variables = new Object();
    this.attributes = new Array();
    if(swf) {
        this.setAttribute('swf', swf);
    }
    if(id) {
        this.setAttribute('id', id);
    }
    if(w) {
        this.setAttribute('width', w);
    }
    if(h) {
        this.setAttribute('height', h);
    }
    if(ver) {
        this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split(".")));
    }
    this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
    if(c) {
        this.addParam('bgcolor', c);
    }
    var q = quality ? quality : 'high';
    this.addParam('quality', q);
    this.setAttribute('useExpressInstall', useExpressInstall);
    this.setAttribute('doExpressInstall', false);
    var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
    this.setAttribute('xiRedirectUrl', xir);
    this.setAttribute('redirectUrl', '');
    if(redirectUrl) {
        this.setAttribute('redirectUrl', redirectUrl);
    }
}
deconcept.SWFObject.prototype = {
    setAttribute: function(name, value){
        this.attributes[name] = value;
    },
    getAttribute: function(name){
        return this.attributes[name];
    },
    addParam: function(name, value){
        this.params[name] = value;
    },
    getParams: function(){
        return this.params;
    },
    addVariable: function(name, value){
        this.variables[name] = value;
    },
    getVariable: function(name){
        return this.variables[name];
    },
    getVariables: function(){
        return this.variables;
    },
    getVariablePairs: function(){
        var variablePairs = new Array();
        var key;
        var variables = this.getVariables();
        for(key in variables){
            variablePairs.push(key +"="+ variables[key]);
        }
        return variablePairs;
    },
    getSWFHTML: function() {
        var swfNode = "";
        if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
            if (this.getAttribute("doExpressInstall")) {
                this.addVariable("MMplayerType", "PlugIn");
            }
            swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" wmode="opaque" height="'+ this.getAttribute('height') +'"';
            swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
            var params = this.getParams();
            for(var key in params){
                swfNode += [key] +'="'+ params[key] +'" ';
            }
            var pairs = this.getVariablePairs().join("&");
            if (pairs.length > 0){
                swfNode += 'flashvars="'+ pairs +'"';
            }
            swfNode += '/>';
        } else { // PC IE
            if (this.getAttribute("doExpressInstall")) {
                this.addVariable("MMplayerType", "ActiveX");
            }
            swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
            swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
            swfNode += '<param name="wmode" value="opaque" />';
            var params = this.getParams();
            for(var key in params) {
                swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
            }
            var pairs = this.getVariablePairs().join("&");
            if(pairs.length > 0) {
                swfNode += '<param name="flashvars" value="'+ pairs +'" />';
            }
            swfNode += "</object>";
        }
        return swfNode;
    },
    write: function(elementId){
        if(this.getAttribute('useExpressInstall')) {
            // check to see if we need to do an express install
            var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
            if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
                this.setAttribute('doExpressInstall', true);
                this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
                document.title = document.title.slice(0, 47) + " - Flash Player Installation";
                this.addVariable("MMdoctitle", document.title);
            }
        }
        if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
            var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
            n.innerHTML = this.getSWFHTML();
            return true;
        }else{
            if(this.getAttribute('redirectUrl') != "") {
                document.location.replace(this.getAttribute('redirectUrl'));
            }
        }
        return false;
    }
}
	
/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
    var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
    if(navigator.plugins && navigator.mimeTypes.length){
        var x = navigator.plugins["Shockwave Flash"];
        if(x && x.description) {
            PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
        }
    }else{
        // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
        var axo;
        try{
             axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        }catch(e){
            try {
                 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
                axo.AllowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
            } catch(e) {
                if (PlayerVersion.major == 6) {
                    return PlayerVersion;
                }
            }
            try {
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            } catch(e) {}
        }
        if (axo != null) {
            PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
        }
    }
    return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
    this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
    this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
    this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
    if(this.major < fv.major) return false;
    if(this.major > fv.major) return true;
    if(this.minor < fv.minor) return false;
    if(this.minor > fv.minor) return true;
    if(this.rev < fv.rev) return false;
    return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
    getRequestParameter: function(param) {
        var q = document.location.search || document.location.hash;
        if(q) {
            var pairs = q.substring(1).split("&");
            for (var i=0; i < pairs.length; i++) {
                if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
                    return pairs[i].substring((pairs[i].indexOf("=")+1));
                }
            }
        }
        return "";
    }
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
    if (window.opera || !document.all) return;
    var objects = document.getElementsByTagName("OBJECT");
    for (var i=0; i < objects.length; i++) {
        objects[i].style.display = 'none';
        for (var x in objects[i]) {
            if (typeof objects[i][x] == 'function') {
                objects[i][x] = function(){};
            }
        }
    }
}
// fixes bug in fp9 see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
deconcept.SWFObjectUtil.prepUnload = function() {
    __flash_unloadHandler = function(){};
    __flash_savedUnloadHandler = function(){};
    if (typeof window.onunload == 'function') {
        var oldUnload = window.onunload;
        window.onunload = function() {
            deconcept.SWFObjectUtil.cleanupSWFs();
            oldUnload();
        }
    } else {
        window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
    }
}
if (typeof window.onbeforeunload == 'function') {
    var oldBeforeUnload = window.onbeforeunload;
    window.onbeforeunload = function() {
        deconcept.SWFObjectUtil.prepUnload();
        oldBeforeUnload();
    }
} else {
    window.onbeforeunload = deconcept.SWFObjectUtil.prepUnload;
}
/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) {
    Array.prototype.push = function(item) {
        this[this.length] = item;
        return this.length;
    }
    }
	
/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;
/************ Detect swf *************/

function clearFormVal(form) {
		
    var i, j;
    var frmObj;
    //frmObj = document.getElementById(form);
    frmObj = document.getElementById('myReagentsForm_history');
		 
	
    // go through the entire Form Object
    for (i = 0; i < frmObj.length; i++) {
        //alert('frmObj.elements[' + i + '] \n\n' + '<INPUT TYPE="' + frmObj.elements[i].type + '">'+' value '+frmObj.elements[i].name);

        if(frmObj.elements[i]) {
            // if the element isn't a button, hidden, submit, or reset then set the VALUE to ""
            if (frmObj.elements[i].type != 'button' && frmObj.elements[i].type != 'hidden' &&
                frmObj.elements[i].type != 'submit' && frmObj.elements[i].type != 'reset')
                frmObj.elements[i].value = "";

            // if the element is a radio button or a checkbox then uncheck the Object if it is checked
            if (frmObj.elements[i].type == 'radio' || frmObj.elements[i].type == 'checkbox')
                frmObj.elements[i].checked = false;

			   
            if (frmObj.elements[i].id == 'txtProductType_vendor' && frmObj.elements[i].type == 'radio')
                frmObj.elements[i].checked = true;
			 
            if (frmObj.elements[i].disabled == true) {
			   
                frmObj.elements[i].disabled = false;
            }
			
            // if the element is a select Object then assign it new text values
            if (frmObj.elements[i].type == 'select-one' || frmObj.elements[i].type == 'select-multiple') {
			   
                frmObj.elements[i].options[0].selected = true;
            }
        }
    }
}
	
/** Added By Mohan on 16Dec2009 ends. */ 
function selPurchaseOrderCheck(formName, elementName){ 	
    var docName = document.forms[formName];
    var countVar = 0;
    var tmpIndex = 1;
    for(i=0; i < docName.elements.length; i++){
        if(docName.elements[i].name==elementName){
            if(docName.elements[i].checked==true){
                countVar++;
            }
            tmpIndex++;
        }
    }
    if(countVar > 0 ){
        if(countVar > 20) {
            setValue('div'+formName,"You can not select more than 20");
            $('div'+formName).scrollTo();
            return false;
        }
        //if(confirm('Are you sure?'))
        return true;
    }else {
        setValue('div'+formName,'Please select at least one');
        $('div'+formName).scrollTo();
        return false;
    }
}
//
/*********************Department Step js*****************************/
function validateDepartmentForm(){	
    var isReturnFalse = true;
    var isReturnFalseTpe = true;
    divArray = new Array('divDeptname');
    unSetVal(divArray); // function for unset the div error
    if (trim($('cmbDeptTemplate').value)=='-1'){
        setValue('divDeptname','Please select form name.');
        return false;
				
    }else{
        return true;
    }
}	

//
function fnShowVideo(mainDiv,divId,siteURL){
	
    jQuery.ajax({
        url:siteURL,
        type:'POST',
        cache:false,
        success:function(data){
            document.getElementById(divId).innerHTML = data;
            DvLayerOpen(mainDiv,divId,'10','50%');
        }
    });
}


function showselectTypeDV()
{
    document.getElementById('typeDvShowHide').style.display="block";
}

function clearAdvSrcForm(frmName) {

    var elem = frmName.elements;
			
    for(var i=0; i<elem.length; i++) {
        //alert(elem[i].type);
		
        if(elem[i].type=="select-one") {
            elem[i].disabled = false;
            var mylen = elem[i].options.length;
            for (var x = 0; x < mylen; x++) {
                if (elem[i].options[x].value == '') {
                    elem[i].options[x].selected = true;
                }
            }
        }
        if(elem[i].type=="text") {
            elem[i].value = '';
        }
        if(elem[i].type=="checkbox") {
            elem[i].checked = false;
        }
    }
    //otherType();
    if($('dvSyssuggestfields'))
        $('dvSyssuggestfields').innerHTML = '';
    if($('ulSpecialontypechange'))
        $('ulSpecialontypechange').innerHTML = '';
		
	 document.getElementById('divSugested').style.display = 'none';
	 document.getElementById('divSpecFields').style.display = 'none';
}


function setSearchImg() {
    if($('advancedSeacrh') && $('advancedSeacrh').value == 'advSearch') {
        if($("closeimg1"))
        {
            $("closeimg1").src = "images/icnCloseRed.gif";
        }
        if($("advancedSrc")) {
            $("advancedSrc").style.display = 'none';
        }
        if($("advSrcContent")) {
            $("advSrcContent").style.display = 'block';
        }
    }
}
							
function unSetAdvSearch() {
	
    if($('advancedSeacrh')) {
        $('advancedSeacrh').value = '';
        if($("advancedSrc")) {
        //$("advancedSrc").style.display = 'block';
        }
        if($("advSrcContent")) {
        //$("advSrcContent").style.display = 'none';
        }
        if($("closeimg1"))
        {
            $("closeimg1").src = "images/icnClose.gif";
        }
    }
}

function validatePurchaseForm() {
    //alert('u r here'); return false;
    var iss = true;
	
    if(trim($("start_date5").value) == '') {
        $('errMsgDateDiv').innerHTML = "Please enter date";
        iss = false;
    } else {
        $('errMsgDateDiv').innerHTML = "";
    }
    if(trim($("txtRoom").value) == '') {
        $('errMsgRoomDiv').innerHTML = "Please enter room";
        iss = false;
    } else {
        $('errMsgRoomDiv').innerHTML = "";
    }
    if(trim($("txtVendor").value) == '') {
        $('errMsgVendorDiv').innerHTML = "Please enter vendor";
        iss = false;
    } else {
        $('errMsgVendorDiv').innerHTML = "";
    }
    if(trim($("txtPhone").value) != '') {
        if(!checkInternationalPhone($("txtPhone").value)) {
            $('errMsgPhoneDiv').innerHTML = "Please enter valid phone";
            iss = false;
        } else {
            $('errMsgPhoneDiv').innerHTML = "";
        }
    } else {
        $('errMsgPhoneDiv').innerHTML = "";
    }
    if(trim($("txtVendorPhone").value) != '') {
        if(!checkInternationalPhone($("txtVendorPhone").value)) {
            $('errMsgVendorPhoneDiv').innerHTML = "Please enter valid vendor phone";
            iss = false;
        } else {
            $('errMsgVendorPhoneDiv').innerHTML = "";
        }
    } else {
        $('errMsgVendorPhoneDiv').innerHTML = "";
    }
	
    var selectedValue = $('cmbCategory').value;
    if(selectedValue=='other'){
        if(trim($('txtOtherCategory').value) ==''){
            $('errMsgOtherCategoryDiv').innerHTML = 'Please enter other category';
            iss = false;
        }else{
            var productCatlog =  $('prdCatStr').value;
            var catArr = productCatlog.split(",");
            var catExist = false;
            if(catArr.length > 0){
                for(i=0; i< catArr.length; i++){
                    if($('txtOtherCategory').value == catArr[i]){
                        catExist = true;
                        break;
                    }
                }
            }
            if(catExist==true){
                $('errMsgOtherCategoryDiv').innerHTML = 'Category name already exist';
                iss = false;
            }else{
                $('errMsgOtherCategoryDiv').innerHTML = '';
            }
			
        }
    }else{
        $('errMsgOtherCategoryDiv').innerHTML = '';
    }
	
    if(iss == true) {
        $('errMsgRoomDiv').innerHTML = '';
        $('errMsgVendorDiv').innerHTML = '';
        $('errMsgPhoneDiv').innerHTML = '';
        $('errMsgVendorPhoneDiv').innerHTML = '';
        $('errMsgDateDiv').innerHTML = '';
        $('errMsgOtherCategoryDiv').innerHTML = '';
    }
    return iss;
}

function fnLoadPurchaseTemplate(actionUrl,updateDiv,processDiv){
	
    jQuery.ajax({
        url:actionUrl,
        type:'POST',
        cache:false,
        beforeSend:function(){
            jQuery('#'+processDiv).show();
        },
        success:function(data){
            jQuery('#'+processDiv).hide();
            jQuery('#'+updateDiv).html(data);
        }
    });
	
}

function fnLoadSentOrderTemplate(actionUrl,updateDiv,processDiv){
    jQuery.ajax({
        url:actionUrl,
        type:'POST',
        cache:false,
        beforeSend:function(){
            jQuery('#'+processDiv).show();
        },
        success:function(data){
            jQuery('#'+processDiv).hide();
            jQuery('#'+updateDiv).html(data);
        }
    });
	
}


/* created by kamlesh  08 march 2011 */



	
function hideshowPrivateFilter(val)
{
		
		
    var LabFilterDiv = $("privateFilterDiv");
    var LabFilterDivEdit = $("privateFilterDivEdit");
    if($("privateFilterDiv") && $("privateFilterDivEdit"))
    {
        if(val=="1")
        {
            LabFilterDiv.style.display = "none";
            LabFilterDivEdit.style.display = "";
				
            if($("private1Arrow"))
            {
                $("private1Arrow").style.display = "";
                $("private2Arrow").style.display = "none";
            }
            setCss("dvTitActFilterPrivate",'');
        }
        else{
            if(LabFilterDiv.style.display=="")
            {
                LabFilterDiv.style.display = "none";
                LabFilterDivEdit.style.display = "";
                if($("private1Arrow"))
                {
                    $("private1Arrow").style.display = "";
                    $("private2Arrow").style.display = "none";
                }
                setCss("dvTitActFilterPrivate",'');
            }
            else{
                LabFilterDiv.style.display = "";
                LabFilterDivEdit.style.display = "none";
					
                if($("private1Arrow"))
                {
                    $("private1Arrow").style.display = "none";
                    $("private2Arrow").style.display = "";
                }
                setCss("dvTitActFilterPrivate",'dvTitAct');
            }
        }
    }
}
	
/* Advance search function */
	
function hideshowAdvanceSearch(val)
{
		
		
		
    var LabFilterDiv = $("advanceSearchDiv");
    //	var LabFilterDivEdit = $("advanceSearchDivEdit");
		
    if($("advanceSearchDiv"))
    {
        if(val=="1")
        {
            LabFilterDiv.style.display = "none";
            //		LabFilterDivEdit.style.display = "";
				
            if($("advArrow"))
            {
                $("advArrow").style.display = "";
                $("adv2Arrow").style.display = "none";
            }
            setCss("dvTitActFilterPrivate5",'');
        }
        else{
				
			
				
            if(LabFilterDiv.style.display=="")
            {	//alert('none')
                LabFilterDiv.style.display = "none";
                //LabFilterDivEdit.style.display = "";
                if($("advArrow"))
                {
                    $("advArrow").style.display = "";
                    $("adv2Arrow").style.display = "none";
                }
                setCss("dvTitActFilterPrivate5",'');
            }
            else{
					
                LabFilterDiv.style.display = "";
                //LabFilterDivEdit.style.display = "none";
					
                if($("advArrow"))
                {
                    $("advArrow").style.display = "none";
                    $("adv2Arrow").style.display = "";
                }
					
					
                //alert('block')
                setCss("dvTitActFilterPrivate5",'dvTitAct2');
            }
        }
    }
}
	
	
/* Advance search function */
	

/* Advance search function */
	
function hideshowAdvanceLabSearch(val)
{
		
		
		
    var LabFilterDiv = $("advanceSearchLabDiv");
    //	var LabFilterDivEdit = $("advanceSearchDivEdit");
		
    if($("advanceSearchLabDiv"))
    {
        if(val=="1")
        {
            LabFilterDiv.style.display = "none";
            //		LabFilterDivEdit.style.display = "";
				
            if($("advArrow"))
            {
                $("advArrow").style.display = "";
                $("adv2Arrow").style.display = "none";
            }
            setCss("dvTitActFilterPrivate6",'');
        }
        else{
				
			
				
            if(LabFilterDiv.style.display=="")
            {	//alert('none')
                LabFilterDiv.style.display = "none";
                //LabFilterDivEdit.style.display = "";
                if($("advArrow"))
                {
                    $("advArrow").style.display = "";
                    $("adv2Arrow").style.display = "none";
                }
                setCss("dvTitActFilterPrivate6",'');
            }
            else{
					
                LabFilterDiv.style.display = "";
                //LabFilterDivEdit.style.display = "none";
					
                if($("advArrow"))
                {
                    $("advArrow").style.display = "none";
                    $("adv2Arrow").style.display = "";
                }
					
					
                //alert('block')
                setCss("dvTitActFilterPrivate6",'dvTitAct2');
            }
        }
    }
}
	
	
/* Advance search function */
		
		
		
function hideshowAdvancedSearch(val)
{
		
	var LabFilterDiv;
	if ($("txtShowInventory").value == "Private") {
		LabFilterDiv = $("advanceSearchDiv");
	}	
	else {
		LabFilterDiv = $("advanceSearchLabDiv");
	}
	
    if(val=="1")
        {
            LabFilterDiv.style.display = "none";
            //		LabFilterDivEdit.style.display = "";
				
            if($("lab1ArrowA"))
            {
                $("lab1ArrowA").style.display = "";
                $("lab2ArrowA").style.display = "none";
            }
            setCss("dvTitActFilterPrivate6",'');
        }
     else{
				
			
				
            if(LabFilterDiv.style.display=="")
            {	//alert('none')
                LabFilterDiv.style.display = "none";
                //LabFilterDivEdit.style.display = "";
                if($("lab1ArrowA"))
                {
                    $("lab1ArrowA").style.display = "";
                    $("lab2ArrowA").style.display = "none";
                }
                setCss("dvTitActFilterPrivate6",'');
            }
            else{
					
                LabFilterDiv.style.display = "";
                //LabFilterDivEdit.style.display = "none";
					
                if($("lab1ArrowA"))
                {
                    $("lab1ArrowA").style.display = "none";
                    $("lab2ArrowA").style.display = "";
                }
					
					
                //alert('block')
                setCss("dvTitActFilterPrivate6",'dvTitAct2');
            }
        }
		
}
	
	
		
/**/
	

	
function fnShowAddNewCategory(){
    var selectedValue = document.getElementById('cmbCategory').value;
    if(selectedValue=='other'){
        document.getElementById('otherVal').style.display='block';

        var element = document.createElement("input");
			 
        element.setAttribute("type", "text");
        element.setAttribute("value", "");
        element.setAttribute("name", "txtOtherCategory");
        element.setAttribute("id", "txtOtherCategory");
		    
        var otherCatTxtBoxDiv = document.getElementById("otherVal");
        otherCatTxtBoxDiv.appendChild(element);
			
    }else{
        document.getElementById('otherVal').style.display='none';
        document.getElementById('otherVal').innerHTML = '';
    }
}
	
function clearAdvSrcFormLab(frmName) {

    var elem = frmName.elements;
			
    for(var i=0; i<elem.length; i++) {
        //alert(elem[i].type);
		
        if(elem[i].type=="select-one") {
            elem[i].disabled = false;
            var mylen = elem[i].options.length;
            for (var x = 0; x < mylen; x++) {
                if (elem[i].options[x].value == '') {
                    elem[i].options[x].selected = true;
                }
            }
        }
        if(elem[i].type=="text") {
            elem[i].value = '';
        }
        if(elem[i].type=="checkbox") {
            elem[i].checked = false;
        }
		
    }
    if($('dvSyssuggestfields2'))
        $('dvSyssuggestfields2').innerHTML = '';
    if($('ulSpecialontypechangeLab'))
        $('ulSpecialontypechangeLab').innerHTML = '';
		
	 document.getElementById('divLabSugested').style.display = 'none';
	 document.getElementById('divLabSpecFields').style.display = 'none';
	
}

function clrGlbSrc() {

    if($('txtSearch')) {
        $('txtSearch').value = 'Search Inventory';
    }
}

function reagPecificDivTog ()
{
    $('divUpdateSpecificFirst').style.display = 'none';
    $('divUpdateSpecificSecond').style.display = '';
	
}
	
function checkInventoryColumn(){
		
    //if(document.frmInvColumn.chkName.checked == false && document.frmInvColumn.chkType.checked == false && document.frmInvColumn.chkOwner.checked == false && document.frmInvColumn.chkContainer.checked == false && document.frmInvColumn.chkBox.checked == false && document.frmInvColumn.chkVendor.checked == false && document.frmInvColumn.chkPrice.checked == false && document.frmInvColumn.chkUnitSize.checked == false && document.frmInvColumn.chkQuantity.checked == false && document.frmInvColumn.chkCAS.checked == false && document.frmInvColumn.chkUrl.checked == false && document.frmInvColumn.chkAttached.checked == false)	{
    if(document.frmInvColumn.chkName.checked == false)	{
        alert('Name column is mandatory');
        return false;
    }
    return true;
}
	
function functionDelSlotBooked(chkBoxList,slotId,requestUrl){
    var flag = confirm("Are you sure to delete slot?");
    if(flag == true)
    {
        var frmErr = true;
        var slotBgColor = '#fff';
        var totalCheckBox = chkBoxList.length;
        var facilityId = 0;
        for(i=0;i<totalCheckBox; i++){
            if(chkBoxList[i].checked == true){
                frmErr = false;
                facilityId = chkBoxList[i].value;
                break;
            }
        }
        if(frmErr){
            alert('Please select any facility');
            return false;
        }
        else{
			
		
            requestUrl = requestUrl+'?slotId='+slotId;
            for(i=0; i<96; i++){
				
                slotBgColor = '#f0f0f0';
                slotBgColor = '#fff';
                document.getElementById(i+'_'+facilityId+'_timeSlotDiv').style.backgroundColor=slotBgColor;
                document.getElementById(i+'_'+facilityId+'_facilitySlot').value = '';
				
                new Ajax.Updater('mp-contentWrapper', requestUrl, {
                    asynchronous:true,
                    evalScripts:true,
                    method:'get',
                    onComplete:function(request, json){
                        Element.hide('indicator2');
                        Element.show('mp-contentWrapper');
                        window.location='#';
                    },
                    onLoading:function(request, json){
                        Element.hide('mp-contentWrapper');
                        Element.show('indicator2');
                    }
                });
            
            return false;
				
            }
        return false;
    }
}
else
{
    return false;
}
}
	
/*function fnBookedGetSendMailConfirmation(choice, divId){
		
		alert(choice);
		alert(divId);
		document.getElementById('divShowProcess').style.display = 'none';
		document.getElementById('txtMsg').value = '';

		if(choice=='yes'){
			//DvLayerHide('DvLayerNfacility','divUpdateNotes');
			//DvLayerOpen('DvLayerNfacility','divBookedSendMail',-50,200);
			
			document.getElementById('divUpdateNotes').style.display = 'none';
			document.getElementById('divBookedSendMail').style.display = 'block';
			
		}else{
			
			DvLayerHide('DvLayerNfacility','divConfirmation');
			if(document.getElementById('txtChangeDivMod').value == '1'){
				DvLayerOpenRelativeClndr('DvLayerNfacility','DvLayerConnoteES',-200,100,divId);
			}else{
				DvLayerOpenRelativeClndr('DvLayerNfacility','DvLayerConnoteE',-200,100,divId);
			}	
		}	
	}*/
	
function funOpenEmailConf(choice, divId){
		
    if(choice=='yes'){
        document.getElementById('divUpdateNotes').style.display = 'none';
        document.getElementById('divSendEmail').style.display = 'block';
    }
		
}
	
function fnManageUserChoiceDiv(mainDiv, OpenDiv, CloseDiv){
    document.getElementById(mainDiv).style.display = 'none';
    document.getElementById(OpenDiv).style.display = 'block';
    document.getElementById(CloseDiv).style.display = 'none';
		
}
function removeSlotAct(actUser,divId,urlVal){
    var removeSlotUrl = siteUrl + 'facility/deleteSlotInfo'+urlVal;
    var pars = '';
    var myAjax ;
    if(actUser==1){
        removeSlotUrl = removeSlotUrl+'&deleteRange=1';
         myAjax = new Ajax.Request(removeSlotUrl, {
            method:'get',
            postBody:pars,
            onComplete:function(request, json){},
            onLoading:function(request, json){},
            onSuccess:function(t){
                $(divId).innerHTML = t.responseText
            },
            onFailure:function() { /*alert('Jay Ho');*/ }
        });
} else {
			
    removeSlotUrl = removeSlotUrl+'&deleteRange=0';
        myAjax = new Ajax.Request(removeSlotUrl, {
        method:'get',
        postBody:pars,
        onComplete:function(request, json){},
        onLoading:function(request, json){},
        onSuccess:function(t){
            $(divId).innerHTML = t.responseText
        },
        onFailure:function() { /*alert('faui');*/  }
    });
//new Ajax.Updater('mp-contentWrapper', removeSlotUrl, {asynchronous:true, evalScripts:true, method:'get', onComplete:function(request, json){Element.hide('indicator2');Element.show('mp-contentWrapper'); DvLayerHide('DvLayerSndLft_note','DvLayerInvSandBx_note'); window.location='#';  }, onLoading:function(request, json){Element.hide('mp-contentWrapper');Element.show('indicator2');}});; return false;
		
}
}
function fnValidateBookedMessage(nodeList,txtSubject,txtMsg){
		
    document.getElementById('divErrorSubject').style.display = 'none';
    document.getElementById('divErrorMessage').style.display = 'none';
    document.getElementById('divErrorTo').style.display = 'none';
		
    chk = nodeList.length;
    var errorForm = true;
    var fieldErr = true;
	
    if(chk){
        for(i=0; i<chk; i++)
        {
            if(nodeList[i].checked==true){
                errorForm = false;
                break;
            }
        }
			
    }
    else{
        if(document.getElementById('chkArr').checked==true){
            errorForm = false;
        }else{
            errorForm = true;
        }
    }
		
    if(errorForm == true){
        document.getElementById('divErrorTo').style.display = 'block';
        return false;
    }
		
    if(document.getElementById(txtSubject).value == ''){
        document.getElementById('divErrorSubject').style.display = 'block';
        return false;
    }
    if(document.getElementById(txtMsg).value == ''){
        document.getElementById('divErrorMessage').style.display = 'block';
        return false;
    }
    return true;
}
	
function funValidateSignUp()
{
	
    var err=0;
    var errStr = '';
    var flag = true;
    var regex=/^[A-Za-z\-\']+$/;
    if(trim(document.getElementById('txtFname').value)==''){
        document.getElementById('divFname').innerHTML='Please enter your first name.';
        flag = false;
    }else
    {
        document.getElementById('divFname').innerHTML='';
    }
	
    if(trim(document.getElementById('txtFname').value)!=''){
        if(trim(document.getElementById('txtFname').value).length > 50)
		{
            document.getElementById('divMaxFname').innerHTML='First name should be less than 50 characters.';
	        flag = false;
		}
    }else
    {
        document.getElementById('divMaxFname').innerHTML='';
    }
	
    if(trim(document.getElementById('txtFname').value)!=''){
        if(!regex.test(trim(document.getElementById('txtFname').value))){
            document.getElementById('divSpecFname').innerHTML='Special characters and middle spaces are not allowed.';
            flag = false;
        }
    }else{
        document.getElementById('divSpecFname').innerHTML='';
    }
	
    if(trim(document.getElementById('txtLname').value)==''){
        document.getElementById('divLname').innerHTML='Please enter your last name.';
        flag = false;
    }else
    {
        document.getElementById('divLname').innerHTML='';
    }
    if(trim(document.getElementById('txtLname').value)!=''){
        if (trim(document.getElementById('txtLname').value).length > 50)
		{
            document.getElementById('divMaxLname').innerHTML='Last name should be less than 50 characters.';
			flag = false;
		}
    }else
    {
        document.getElementById('divMaxLname').innerHTML='';
    }
    if(trim(document.getElementById('txtLname').value)!=''){
        if(!regex.test(trim(document.getElementById('txtLname').value))){
            document.getElementById('divSpecLname').innerHTML='Special characters and middle spaces are not allowed.';
            flag = false;
        }
    }
    else{
        document.getElementById('divSpecLname').innerHTML='';
    }
    if(trim(document.getElementById('txtEmail').value)==''){
        document.getElementById('divEmailAddr').innerHTML='Please enter your email address.';
        flag = false;
    }else
    {
        document.getElementById('divEmailAddr').innerHTML='';
    }
		
    if(trim(document.getElementById('txtEmail').value)!=''){
        if(!CheckEmail(trim(document.getElementById('txtEmail').value))){
            document.getElementById('divInvalidEmail').innerHTML='Invalid email address.';
            flag = false;
        } else{
			document.getElementById('divInvalidEmail').innerHTML='';
		}
		
    }
		
    if(trim(document.getElementById('txtPassword').value)==''){
        document.getElementById('divPassword').innerHTML='Please enter password.';
        flag = false;
    }else
    {
        document.getElementById('divPassword').innerHTML='';
    }
    if(trim(document.getElementById('txtPassword').value)!=''){
        if(trim(document.getElementById('txtPassword').value).length < 6 || trim(document.getElementById('txtPassword').value).length > 20 ){
            document.getElementById('divLenPassword').innerHTML='Must be 6-20 characters long.';
            flag = false;
        } else {
			document.getElementById('divLenPassword').innerHTML='';
		}
    }
    else
    {
        document.getElementById('divLenPassword').innerHTML='';
    }
	
    if(trim(document.getElementById('institution').value) <= 0){
		if(trim(document.getElementById('institution').value)== -1) {
			document.getElementById('divUniversity').innerHTML = '';
		} else if(trim(document.getElementById('institution').value)== 0) {
			document.getElementById('divUniversity').innerHTML = 'Please select Institution.';
			flag = false;
		}
       
    } else {
		document.getElementById('divUniversity').innerHTML='';
    }
	
	if( ! document.getElementById('chkTerm').checked )
	{
		document.getElementById('errAgreeTerms').innerHTML = 'Please Agree to terms to continue.';
		flag = false;
	}
	else {
		document.getElementById('errAgreeTerms').innerHTML = '';
	}

	return flag;
}


function txtDivShowRegistartion(dvId,field)
  {
	var institute = '';
	var dvIdVal  = '';
	if(document.getElementById(field)) {
		institute = document.getElementById(field).value;
	}
	if(document.getElementById(dvId)) {
		dvIdVal = document.getElementById(dvId).value;
	}
	if(institute == -1){
		document.getElementById(dvId).style.display = 'block';
	}else{
		document.getElementById(dvId).style.display = 'none';
		if(dvIdVal == 'dvTxtUni'){
			setCss('txtUniversity','txtField185 ');
		}
	}
	/*if($(field).value == '-1')
  		$(dvId).style.display='block';
  	else
  		$(dvId).style.display='none';
        if(dvId == 'dvTxtUni')
        {
          setCss('txtUniversity','txtField185 ')
        }*/
  }
  
function funMemberLoginValidate()
{
    var error=0;
    var errStr = '';
    var flag = true;
    if(trim(document.getElementById('txtSignEmail').value)==''){
        document.getElementById('divEmailSign').innerHTML='Please enter email address.';
        flag = false;
        error++;
    }else
    {
        document.getElementById('divEmailSign').innerHTML='';
    }
    if(trim(document.getElementById('txtSignEmail').value)!=''){
        if(!CheckEmail(trim(document.getElementById('txtSignEmail').value))){
            document.getElementById('divEmailSign').innerHTML='Invalid email address.';
            flag = false;
            error++;
        }else{
            document.getElementById('divEmailSign').innerHTML='';
        }
    }
    if(trim(document.getElementById('txtSignPassword').value)==''){
        document.getElementById('divPassSign').innerHTML='Please enter password.';
        flag = false;
        error++;
    }else
    {
        document.getElementById('divPassSign').innerHTML='';
    }
    if(error ==0){
        return true;
    }
    {
        return false;
    }
}
	
function showHideFields(showAllId,hideAllId,filedsDivId,showOrHide) {
	
    //alert('link id'+showHideLink+' fieldsId'+filedsDivId);
    //alert(document.getElementById(showHideLink).innerHTML);
    if(showOrHide == '1') {
        if($(showAllId))
            document.getElementById(showAllId).style.display = 'block';
        if($(hideAllId))
            document.getElementById(hideAllId).style.display = 'none';
        if($(filedsDivId))
            document.getElementById(filedsDivId).style.display = 'none';
    } else if(showOrHide == '0') {
        if($(showAllId))
            document.getElementById(showAllId).style.display = 'none';
        if($(hideAllId))
            document.getElementById(hideAllId).style.display = 'block';
        if($(filedsDivId))
            document.getElementById(filedsDivId).style.display = 'block';
    }
}
	
function chkChekBoxValue(reagId) { 
	
    if(document.getElementById('chkAcceptEmail'+reagId).checked == false){
        document.getElementById('sendAcceptEmail'+reagId).value = 'no';
    }else{
        document.getElementById('sendAcceptEmail'+reagId).value = 'yes';
    }
    if(document.getElementById('chkDenyEmail'+reagId).checked == false){
        document.getElementById('sendDenyEmail'+reagId).value = 'no';
    }else{
        document.getElementById('sendDenyEmail'+reagId).value = 'yes';
    }
		
    if(document.getElementById('chkCancelEmail'+reagId).checked == false){
        document.getElementById('sendCancelEmail'+reagId).value = 'no';
    }else{
        document.getElementById('sendCancelEmail'+reagId).value = 'yes';
    }
    if(document.getElementById('chkDeliverEmail'+reagId).checked == false){
        document.getElementById('sendDeliverEmail'+reagId).value = 'no';
    }else{
        document.getElementById('sendDeliverEmail'+reagId).value = 'yes';
    }
    if(document.getElementById('chkBackEmail'+reagId).checked == false){
        document.getElementById('sendBackEmail'+reagId).value = 'no';
    }else{
        document.getElementById('sendBackEmail'+reagId).value = 'yes';
    }
}
	
function showHideAddFacFields(attachDivId,attachNoteDivId) {
		
    if(document.getElementById(attachDivId).style.display == 'none') {
        document.getElementById(attachDivId).style.display = 'block';
        document.getElementById(attachNoteDivId).style.display = 'block';
    }
    else {
        document.getElementById(attachDivId).style.display = 'none';
        document.getElementById(attachNoteDivId).style.display = 'none';
    }
}
	
function advanceSearchImage() {

	if($("closeimg1")) {
        $("closeimg1").src = "images/icnCloseRed.gif";
    }
	if($("advancedSrc")) {
		$("advancedSrc").style.display = 'none';
	}
	if($("advSrcContent")) {
		$("advSrcContent").style.display = 'block';
	}
}
function toggleLocalVendorButton(localVendor){

	if(localVendor=="LOCAL"){
		jQuery("#localVendorViewButton").show();
		jQuery("#VendorViewButton").hide();
	}else{
		jQuery("#VendorViewButton").show();
		jQuery("#localVendorViewButton").hide();
	}
	
}

/* START Function for tracking vendor product click from vendor inventory Without Login*/
function vendorClickTracking(targetUrl) {
	new Ajax.Request(targetUrl, {
	  onSuccess: function(transport) {		  
	  }
	});
}
/* END Function for tracking vendor product click from vendor inventory Without Login*/

function checkMigrateReagent(){
	var error=0;
    var errStr = '';
    var flag = true;
    if(trim(document.getElementById('rdUserId').value)=='' || trim(document.getElementById('rdUserId').value)==0){
        document.getElementById('divlistLabmetForm').innerHTML='Please select labmate.';
        flag = false;
        error++;
    }else
    {
        document.getElementById('divlistLabmetForm').innerHTML='';
    }
    if(error ==0){
        return true;
    }
    {
        return false;
    }	
    
    
}

function checkCopyReagent(){
	var error=0;
    var errStr = '';
    var flag = true;
    if(trim(document.getElementById('selUsrLabmate').value)=='' || trim(document.getElementById('selUsrLabmate').value)==0){
        document.getElementById('divLabmateCopyError').innerHTML='Please select labmate.';
        flag = false;
        error++;
    }else
    {
        document.getElementById('divLabmateCopyError').innerHTML='';
    }
    if(error ==0){
        return true;
    }
    {
        return false;
    }	
}
function printForm(url) {
	window.open(url,"mywindow","scrollbars=1,width=900,height=550");
}


/******For Optimize Order Tab Start******/
function getStatus(reagId,id,old_order,currStatus,cnt,requestTypeId,fromUserName,pageNumber){
	targetUrl = 'orders/getStatus?reagId='+reagId+"&old_order="+old_order+"&currStatus="+currStatus+"&cnt="+cnt+"&requestTypeId="+requestTypeId+"&fromUserName="+fromUserName+"&pageNumber="+pageNumber;
	jQuery.ajax({
		url	 	: targetUrl,
		type	: 'POST',
		cache	: false,
		success	: function(data){
			jQuery("#"+id).html(data);
		}
	});
}
function loadOrderData(activeTab,targetUrl,divToUpdate,indicator){
	Element.hide("receiveOrderPlaceholder");
	Element.hide("sentOrderPlaceholder");
	
    if($("HistoryContentId"))
		$("HistoryContentId").style.display = "none";
	if($("PurchaseContentId"))
		$("PurchaseContentId").style.display = "none";
	if($("AddContentId"))
		$("AddContentId").style.display = "none";
	if($("PurchaseOrderContentId")) {
		$("PurchaseOrderContentId").style.display = "none";
	}			
	
	targetUrl=targetUrl+"&activeTab="+activeTab;
		
	new Ajax.Updater(divToUpdate, targetUrl, {
        asynchronous:true,
        evalScripts:true,
        method:'POST',
        onComplete:function(request, json){
            Element.hide(indicator);
            Element.show(divToUpdate);
            },
		onCreate:function(request, json){
			Element.show(indicator);
			Element.hide(divToUpdate);
		}
    });
	
}
/******For Optimize Order Tab End******/
function loadRightPanelOrderCount(path){
	Element.show("OrderStatusCountDivIndicator");
	Element.hide("OrderStatusCountDiv");
	targetUrl='default/rightpanelOrder';
	if(path){		
		targetUrl=path;
	}
	new Ajax.Updater("OrderStatusCountDiv", targetUrl, {
        asynchronous:true,
        evalScripts:true,
        method:'POST',
        onComplete:function(request, json){
            Element.hide("OrderStatusCountDivIndicator");
            Element.show("OrderStatusCountDiv");
            },
		onCreate:function(request, json){
			Element.show("OrderStatusCountDivIndicator");
			Element.hide("OrderStatusCountDiv");
		}
    });
}


function callAdvanceSuggessionLeft(copy,userid,TypeId){
    var txtTypeVal = $('txtTypeLeft').value;
    if(TypeId > 0){
        txtTypeVal = TypeId;
    }
    new Ajax.Updater('dvSyssuggestfieldsLeft', 'reagent/typeSystemsuggestfields/rmprevious/1',
    {
        asynchronous:true,
        evalScripts:true,
        onComplete:function(request, json)
        {
            Element.hide('indicatortypeLeft');
            Element.show('dvSyssuggestfieldsLeft');
            ForShow('pub_T_82'),
            ForHide('pt_T_82')
            },
        onLoading:function(request, json){
            Element.hide('dvSyssuggestfieldsLeft');
            Element.show('indicatortypeLeft');
        },
        onSuccess:function(request, json){
            pageTracker._trackPageview("/reagent/typeSystemsuggestfields")
            },
        parameters:'txtUserType=' +txtTypeVal+'&reagid='+$('reagid').value+'&copy='+copy+'&usrid='+userid+''
        });
}

function removeCustomColumnSelection(chkArr){
	var chkBoxLength = chkArr.length;
	var totalCheck = 0;
	for(i=0; i<chkBoxLength; i++){
		if(chkArr[i].checked){
		 totalCheck++;
		}
	} 
	if(totalCheck>1){
		jQuery("#txtTypeLeft").val('');
		jQuery('#txtTypeTextLeft').val('');
		hideShowSettings('editInventoryCloumnId');
	}
}
function fnDownloadReagentExcelSheet(formName,checkedFieldName,url,type,search){
    var docName = document.forms[formName];
    var countVar = 0;
    var a = docName.elements.length;
		
    var selReagentIds='';
    for(i=0; i < docName.elements.length; i++){
        if(docName.elements[i].name==checkedFieldName){
            if( docName.elements[i].checked==true ){
                if (selReagentIds!='')
                    selReagentIds=selReagentIds+','+docName.elements[i].value;
                else
                    selReagentIds=selReagentIds+''+docName.elements[i].value;
            }
        }
    }
  if(type=='private')	{
        if(document.getElementById('PrivateFilters').checked==true && selReagentIds=='' && document.getElementById('searchSessionPvt').value=='' ){
            setValue('divmyReagentsForm','No matching items to download.');
            return false;
        }
    }
    if(type=='lab'){
        if(document.getElementById('LabFilters').checked==true && selReagentIds=='' && document.getElementById('searchSessionLab').value==''){
            setValue('divlabmetReagentsForm','No matching items to download.');
            return false;
        }
    }
    DvLayerOpenSandBx2('DvLayerSndLft_state','DvLayerInvSandBx_state','230','50%');
	
	loadingData = "<div style='text-align:center;'>Loading..<br><img src='/images/indicator.gif'></div>";
	jQuery("#divUpdateExcel").html(loadingData);
   	
   		
	jQuery.ajax({
		url	 	: url,
		type	: 'POST',
		data    : "regids="+selReagentIds+"&rtype="+type,
		cache	: false,
		success	: function(data) {
			jQuery("#divUpdateExcel").html(data);
		}
	});
                
    

}
function sendInventoryEmail(sendUrl){
	
	
	jQuery("#dvSucessMessage").show();
	jQuery("#dvPageContents").hide();
	
	jQuery.ajax({
		url	 	: sendUrl,
		type	: 'POST',
		data    : "regids="+jQuery("#regids").val()+"&rtype="+jQuery("#rtype").val(),
		cache	: false,
		success	: function(data) {			
		}
	});
}

function openFacilityReportPopup(popID,fadeId){
	jQuery('#'+fadeId).css({'filter' : 'alpha(opacity=20)'}).fadeIn();			
	jQuery('#' + popID).fadeIn();
	
	var popMargTop = (jQuery('#' + popID).height() + 80) / 2;
	var popMargLeft = (jQuery('#' + popID).width() + 80) / 2;

	//Apply Margin to Popup
	jQuery('#' + popID).css({
		'margin-top' : -popMargTop,
		'margin-left' : -popMargLeft
	});	
}
function closeFacilityReportPopup(popID,fadeId){
	jQuery('#'+fadeId).fadeOut();
	jQuery('#'+popID).fadeOut();
	return false;
}
function validateFacilityReportDate(){
	fromDate = jQuery("#date_from").val();
	toDate = jQuery("#date_to").val();
	jQuery("#date_error").html("");		
	if(fromDate=="" || toDate==""){
		jQuery("#date_error").html("Please enter from and to date.");		
		return false;
	}
	var sarr = trim(fromDate).split('-');
	var earr = trim(toDate).split('-');	
	var sdate = new Date(sarr[0],sarr[1]-1,sarr[2],0,0,0);
	var edate = new Date(earr[0],earr[1]-1,earr[2],0,0,0);
	
	if(sdate > edate){
		jQuery("#date_error").html("From date can not greater than To date.");		
		return false;
	}			

}
function getSelectedVendorIdNew(vendorId){
    document.getElementById("txtHdnVendorId").value = vendorId;
    new Ajax.Updater("txtHdnCatalogCount", "reagent/catalogCount?vendorId="+vendorId, {
        asynchronous:true,
        evalScripts:true,
        method:'get',
        onComplete:function(request, json){
            hideshowcatalog();
        }
    });
}
