/*
------------------------------------------
Functions to change the background color on mouse click.
------------------------------------------
*/
function changeBgColor(item, newColor){
	document.getElementById(item).style.backgroundColor=newColor;
}
/*
------------------------------------------
Function to Show / Hide CSS based dialog box
------------------------------------------
*/
		var IE = document.all;
		function showHideDialog(dialogName) {
		var defaultWidth=300;
		var defaultHeight=80;
		var CFD_Layer = document.getElementById(dialogName).style;
		v_status = CFD_Layer.visibility;
		var l_width = CFD_Layer.width.slice(0,-2);	// Remove px from width
		var l_height = CFD_Layer.hight.slice(0,-2);	// Remove px from height
		if (!l_width)
			l_width=defaultWidth;
		if (!l_height)
			l_height=defaultHeight;
		// Capture browser window size
		if (IE) {
			screenWidth = (document.body.clientWidth + 20);
//			screenWidth = (top.document.all.mainFrame.width);
			screenHeight = (top.document.all.mainFrame.height);
		} else {
			screenWidth = self.innerWidth;
			screenHeight= self.innerHeight;
		}

			// Evaluate left position for the current browser width
			leftPos = (screenWidth/2) -  (l_width/2);
			topPos  = (screenHeight/2) - (l_height/2);
			// Show/Hide layer
			if ((v_status=="hidden") || (v_status==""))
			{
				CFD_Layer.visibility = "visible";
				// Assign new layer position
				CFD_Layer.left = leftPos+'px';
				CFD_Layer.top = (topPos-50)+'px';
			} else {
				CFD_Layer.visibility = "hidden";
			}
		}

		function showHideMenu2(menuName, leftPos, topPos){
		var _menu = document.getElementById(menuName).style;
		var _status = _menu.visibility;
			if ((_status=="hidden") || (_status=="")){
				_menu.left=leftPos+'px';
				_menu.top=topPos+'px';
				_menu.visibility = "visible";
			}else{
				_menu.visibility = "hidden";
			}
		}

		function showHideMenu3(menuName, leftPos, topPos, file){
		var _menu = document.getElementById(menuName).style;
		var _status = _menu.visibility;
			if ((_status=="hidden") || (_status=="")){
				_menu.left=leftPos;
				_menu.top=topPos;
				_menu.visibility = "visible";
				if (file!='')
				self.location.href="popup_add_shortcut.html"
			}else{
				_menu.visibility = "hidden";
			}
		}

		function toggle_submenu(menuName, action){
				document.getElementById(menuName).style.display = action;
		}
		
/*
------------------------------------------
Function to Show / Hide CSS based file/folder menu
------------------------------------------
*/

		var posX;
		var posY;
		function showHideMenu(linkId,menuName,folderid,level,parentid,utyp,fid,cid) {
		var CFD_Layer = document.getElementById(menuName).style;

		var v_status = CFD_Layer.visibility;
			if (IE){
				posX=event.clientX;
				posY=event.clientY;
			}else{
				window.captureEvents(Event.CLICK);
				document.captureEvents(Event.CLICK);
				document.getElementById(linkId).onclick=pos;
			}
                //      setFolder1(folderid,level,parentid,utyp,fid,cid);
//			alert(posX)
		// Capture browser window size
		if (IE) {
			screenHeight = (top.document.all.mainFrame.height);
		} else {
			screenHeight= self.innerHeight;
		}

			// Evaluate left position for the current browser width
			leftPos = posX - 4;
//			alert(screenHeight-posY)
			posYY = screenHeight-posY;
			menuHeight=275;
			if (posYY <= menuHeight)	// Menu height is 240 points
				topPos  = menuHeight-posYY;
			else
				topPos  = posY-4;
//alert(topPos)
			// Show/Hide layer
			if ((v_status=="hidden") || (v_status==""))
			{
				CFD_Layer.visibility = "visible";
				// Assign new layer position
				CFD_Layer.left = leftPos+'px';
				CFD_Layer.top = topPos+'px';
			} else {
				CFD_Layer.visibility = "hidden";
			}


		}
/*
------------------------------------------
Functions to capture mouse click position
------------------------------------------
*/

	  function pos(e){
			posX=e.pageX;
			posY=e.pageY;
		return true;
		}

/*
------------------------------------------
Functions to capture and save Cookies
------------------------------------------
*/

function getexpirydate( nodays){
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
}

function getcookie(cookiename){
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") return "";
		var index2=cookiestring.indexOf(';',index1);
	if (index2==-1) index2=cookiestring.length;
		return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}

function setcookie(name,value,duration){
	cookiestring=name+"="+escape(value); //;+"EXPIRES="+getexpirydate(duration);
	document.cookie=cookiestring;
	if(!getcookie(name)){
		return false;
	}
	else{
		return true;
	}
}

/*
------------------------------------------
Functions to change page/url in the main frame.
------------------------------------------
*/

function changeURL(URL){
	top.mainFrame.location=URL;
}
/*
------------------------------------------
Functions to change page/url in the same frame as the link
------------------------------------------
*/


function goTo(page){
	self.location=page;
}




         
        
        


function openPopup(varFilename, leftPos, topPos, intWidth, intHeight, binScroll) {

     winParams = " toolbar=no"         // Icon bar
               + ",location=no"      // Location bar
               + ",directories=no"   //
               + ",status=no"       //Status Bar at bottom of window.
               + ",menubar=no"       //Menubar at top of window.
               + ",resizeable=yes"    //Allow resizing by dragging. (Yes - Does not work with Netscape or IE)
               + ",scrollbars="+binScroll   //Displays scrollbars is document is larger than window.
               + ",titlebar=no"     //Enable/Disable titlebar resize capability.
               + ",left="+leftPos             //Offset of windows left edge from screen.
               + ",top="+topPos              //Offset of windows top edge from screen.
               + ",width="+intWidth    //Standard 640,800/788, 800/788
               + ",height="+intHeight  //Standard 480,600/541, 600/566
               + ";"

 		 		 var popwin;
				 popWindow = window.open(varFilename,popwin,winParams)
}




function openCSSPopup(fileName, fwidth, fheight){
	var _pLayer=document.getElementById('popupWin').style;
	var _pFrame=document.getElementById('frmPopup');
	var _pStatus=_pLayer.visibility;
		// Capture browser window size
		if (IE) {
			screenWidth = (document.body.clientWidth + 20);
//			screenWidth = (top.document.all.mainFrame.width);
			screenHeight = (top.document.all.mainFrame.height);
		} else {
			screenWidth = self.innerWidth;
			screenHeight= self.innerHeight;
		}

			// Evaluate left position for the current browser width
			leftPos = (screenWidth/2) -  (fwidth/2);
			topPos  = (screenHeight/2) - (fheight/2)-30; //30 value draws the display up

		if (_pStatus=="hidden") {
			if(IE)
			document.getElementById('container').style.filter="Alpha(Opacity=40)";
			else
			document.getElementById('container').setAttribute("style","-moz-opacity:.4;");
			_pLayer.left=leftPos+'px';
			_pLayer.top=topPos+'px';
			_pFrame.src=fileName;
			_pFrame.width=fwidth;
			_pFrame.height=fheight;
			_pLayer.visibility="visible";
		}else{
			if(IE)
			document.getElementById('container').style.filter="Alpha(Opacity=100)";
			else
			document.getElementById('container').setAttribute("style","-moz-opacity:1;");
			_pLayer.visibility="hidden";
		}
}




/*  CSS windoow and iframe to be used in pages for the popup window*/
cHTML='<div id="popupWin" style="position: absolute; visibility: hidden; background-color: #ffffff; z-index: 200;">\
	<div style="text-align: right;"> \
		<a href="javascript://" onClick="javascript:openCSSPopup(1,1,1);">Close</a>\
	</div>\
	<iframe name="frmPopup" id="frmPopup" frameborder="0" src="">Please wait...</iframe><br>\
	<div style="text-align: right;"> \
		<a href="javascript://" onClick="javascript:openCSSPopup(1,1,1);">Close</a>\
	</div>\
</div>'
document.write(cHTML)

// Create DIVs for each level of CSS POP-UP Window
document.write('<div id="jsHTML0"></div>')
document.write('<div id="jsHTML1"></div>')
document.write('<div id="jsHTML2"></div>')
document.write('<div id="jsHTML3"></div>')
document.write('<div id="jsHTML4"></div>')



//-------------------------------------------created by vivek sisoida with jquery----------------------------------

//alert("hi")
var x;
var y;
var pleft;
var ptop;
var pheight;
var pwidth;
var framheight;

cHTML='<div id="jsDiv" class="jsDiv" style="position: absolute; border: 2px double #4c5f65; display: none; background-color: #ffffff; z-index:2000;">\
	<div style="background-color: #4c5f65; text-align: right;"><a href="javascript://" onclick="closeCSSPopupByvivek();" ><img src="../images/cancel.gif" /></a></div>\
	<iframe name="jsFrame" id="jsFrame" frameborder="0" src="" scrolling="auto">Please wait...</iframe><br>\
	<div style="text-align: right;background-color: #4c5f65;color: #fff;font-family:Arial;"> \
		<a  href="javascript://" onclick="closeCSSPopupByvivek();" style="color:#FFF;" >Close this window</a>\
	</div>\
</div>'
document.write(cHTML)
cHTML='<div class="jsDiv1" style="position: absolute; border: 2px double #4c5f65; display: none; background-color: #ffffff; z-index:2000;">\
	<div style="background-color: #4c5f65; text-align: right;"><a href="javascript://" onclick="closeCSSPopupByvivek1();" ><img src="../images/cancel.gif" /></a></div>\
	<iframe name="jsFrame1" id="jsFrame1" frameborder="0" src="" scrolling="auto">Please wait...</iframe><br>\
	<div style="text-align: right;background-color: #4c5f65;color: #fff;font-family:Arial;"> \
		<a  href="javascript://" onclick="closeCSSPopupByvivek1();" style="color:#FFF;" >Close this window</a>\
	</div>\
</div>'
document.write(cHTML)

function openCSSPopupByName(fileName, fLeft, fTop, fwidth, fheight, wName, depth){
	x=0;
  y=0;
  pleft=fLeft;
  ptop=fTop;
  pheight=fheight;
  pwidth=fwidth;
  framheight=parseInt(fheight)-40;
  
  var screenWidth,leftPos,topPos,screenHeight;
  if (IE) {
			screenWidth = (document.body.clientWidth + 20);
			screenHeight = (document.body.clientHeight);
		} else {
			screenWidth = self.innerWidth;
			screenHeight= self.innerHeight;
		}
//  $('div#container').fadeTo('slow',0.4);

if(IE)
			{
				document.getElementById('container').style.filter="Alpha(Opacity=30)";
			}else{
				document.getElementById('container').setAttribute("style","-moz-opacity:.3;"); 
			}


  document.bgColor="#1b0022";
 leftPos = (screenWidth/2) -  (fwidth/2);
  y=0;
  pleft=fLeft;
  ptop=fTop;
  pheight=fheight;
  pwidth=fwidth;
  framheight=parseInt(fheight)-30;
  //alert("hi")
  
			if (fLeft != 0) {
				leftPos = fLeft;
			} else {
				leftPos = ((screenWidth/2) -  (fwidth/2));
			}
			if (fTop != 0) {
				topPos = fTop;
			} else {
				topPos  = ((screenHeight/2) - (fheight/2)-30); //30 value draws the display up
			}

 y=topPos;
  x=leftPos; 
  if(y<200)
{
  y=200;
}


if(document.getElementById("jsDiv").style.display=="none")
{

  var divname=document.getElementById("jsFrame");
 
  divname.src=fileName;
 //var jsdivname=document.getElementById("jsDiv");
 //alert(pheight);
 //alert(framheight);
 $('div.jsDiv').css({left:x,width:pwidth,height:pheight});
  $('iframe#jsFrame').css({width:pwidth,height:framheight});
//  $('iframe#jsFrame').animate({height: framheight}, 'slow')
//.animate({width: pwidth}, 'slow');
  $('div.jsDiv').stop(true, true).animate({opacity: "show", top:y}, "slow");  
  $('div.jsDiv').animate({left: x }, 'slow')
.animate({height: pheight}, 'slow')
.animate({width: pwidth}, 'slow')
.show('slow');
 

}
else
{
 var divname1=document.getElementById("jsFrame1");
 
  divname1.src=fileName;
 //var jsdivname=document.getElementById("jsDiv");
 //alert(pwidth);
 //alert(framheight);
 //alert(pheight);
 $('div.jsDiv1').css({left:x,width:pwidth,height:pheight});
  $('iframe#jsFrame1').css({width:pwidth,height:framheight});
//  $('iframe#jsFrame').animate({height: framheight}, 'slow')
//.animate({width: pwidth}, 'slow');
  $('div.jsDiv1').stop(true, true).animate({opacity: "show", top:y}, "slow");
  
  $('div.jsDiv1').animate({left: x }, 'slow')
.animate({height: pheight}, 'slow')
.animate({width: pwidth}, 'slow')
.show('slow');
}
}

function closeCSSPopupByvivek()
{
 var divname=document.getElementById("jsFrame");
  divname.src=""; 
  $('div.jsDiv').animate({opacity: "hide", top: "-70"}, "fast");
 
 if(IE)
			{
				document.getElementById('container').style.filter="Alpha(Opacity=100)";
			}else{
				document.getElementById('container').setAttribute("style","-moz-opacity:1;"); 
			}
 
 // $('div#container').fadeTo('slow',1);
  //document.bgColor="#ffffff";
}
function closeCSSPopupByvivek1()
{
 var divname1=document.getElementById("jsFrame1");
  divname1.src=""; 
  $('div.jsDiv1').animate({opacity: "hide", top: "-70"}, "fast");
 

}







function openCSSPopupByName1(e,fileName, fLeft, fTop, fwidth, fheight, wName, depth){

 
  
     /* ----Reading the co-oridinate--------------- */
      if (window.ActiveXObject)
       {

         e = window.event; // works on IE, but not NS (we rely on NS passing us the event)
      }
     if (e)
      { 
        if (e.pageX || e.pageY)
            {  // this doesn't work on IE6!! (works on FF,Moz,Opera7)
               x = e.pageX;
               y = e.pageY;
               algor = '[e.pageX]';
               if (e.clientX || e.clientY) 
                   algor += ' [e.clientX] '
            }
        else if (e.clientX || e.clientY)
          { 
            // works on IE6,FF,Moz,Opera7
              x = e.clientX + document.body.scrollLeft;
              y = e.clientY + document.documentElement.scrollTop;
          } 
     } 
 
     //y=y-280;
     //x=x-150;
    
     //alert("the position of y="+y); 
     //fLeft =x+12;
     fTop = y + 20;
     





x=0;
  y=0;
  pleft=fLeft;
  ptop=fTop;
  pheight=fheight;
  pwidth=fwidth;
  framheight=parseInt(fheight)-40;
  
  var screenWidth,leftPos,topPos,screenHeight;
  if (IE) {
			screenWidth = (document.body.clientWidth + 20);
			screenHeight = (document.body.clientHeight);
		} else {
			screenWidth = self.innerWidth;
			screenHeight= self.innerHeight;
		}
//  $('div#container').fadeTo('slow',0.4);

if(IE)
			{
				document.getElementById('container').style.filter="Alpha(Opacity=30)";
			}else{
				document.getElementById('container').setAttribute("style","-moz-opacity:.3;"); 
			}


 // document.bgColor="#1b0022";
 leftPos = (screenWidth/2) -  (fwidth/2);
  y=0;
  pleft=fLeft;
  ptop=fTop;
  pheight=fheight;
  pwidth=fwidth;
  framheight=parseInt(fheight)-30;
  //alert("hi")
  
			if (fLeft != 0) {
				leftPos = fLeft;
			} else {
				leftPos = ((screenWidth/2) -  (fwidth/2));
			}
			if (fTop != 0) {
				topPos = fTop;
			} else {
				topPos  = ((screenHeight/2) - (fheight/2)-30); //30 value draws the display up
			}

 y=topPos;
  x=leftPos; 
//  if(y<200)
//{
//  y=200;
//}


if(document.getElementById("jsDiv").style.display=="none")
{

  var divname=document.getElementById("jsFrame");
 
  divname.src=fileName;
 //var jsdivname=document.getElementById("jsDiv");
 //alert(pheight);
 //alert(framheight);
 $('div.jsDiv').css({left:x,width:pwidth,height:pheight});
  $('iframe#jsFrame').css({width:pwidth,height:framheight});
//  $('iframe#jsFrame').animate({height: framheight}, 'slow')
//.animate({width: pwidth}, 'slow');
  $('div.jsDiv').stop(true, true).animate({opacity: "show", top:y}, "slow");  
  $('div.jsDiv').animate({left: x }, 'slow')
.animate({height: pheight}, 'slow')
.animate({width: pwidth}, 'slow')
.show('slow');
 

}
else
{
 var divname1=document.getElementById("jsFrame1");
 
  divname1.src=fileName;
 //var jsdivname=document.getElementById("jsDiv");
 //alert(pwidth);
 //alert(framheight);
 //alert(pheight);
 $('div.jsDiv1').css({left:x,width:pwidth,height:pheight});
  $('iframe#jsFrame1').css({width:pwidth,height:framheight});
//  $('iframe#jsFrame').animate({height: framheight}, 'slow')
//.animate({width: pwidth}, 'slow');
  $('div.jsDiv1').stop(true, true).animate({opacity: "show", top:y}, "slow");
  
  $('div.jsDiv1').animate({left: x }, 'slow')
.animate({height: pheight}, 'slow')
.animate({width: pwidth}, 'slow')
.show('slow');
}
}

function closeCSSPopupByvivek()
{
 var divname=document.getElementById("jsFrame");
  divname.src=""; 
  $('div.jsDiv').animate({opacity: "hide", top: "-70"}, "fast");
 
 if(IE)
			{
				document.getElementById('container').style.filter="Alpha(Opacity=100)";
			}else{
				document.getElementById('container').setAttribute("style","-moz-opacity:1;"); 
			}



}

















//-----------------------------End opening css window when open the window---------------


function createPopUpDiv(jsDiv, jsFrame, divName, depth, fName) {
	if (fName != "1"){   // File Name MUST be 1 to close the CSS Window 
	popupHTML='<div id="' + jsDiv + '" style="position: absolute; border: 4px double #3c99d4; display: none; background-color: #ffffff; z-index:190;"> \
		<div style="background-color: #3c99d4; text-align: right;"><a href=javascript:openCSSPopupByName(1,1,1,1,1,"'+ divName +'",'+ depth +');><img src="../images/cancel.gif" /></a></div>\
		<iframe name="' + jsFrame + '" id="' + jsFrame + '" frameborder="0" src="">Please wait...</iframe><br>\
		<div style="background-color: #3c99d4; text-align: right;"><a href=javascript:openCSSPopupByName(1,1,1,1,1,"'+ divName +'",'+ depth +'); style="color: #fff;">Close this Window</a></div>\
		</div>'
	document.getElementById('jsHTML'+depth).innerHTML = popupHTML;
	}
}


function validateRemove(){
        return confirm("REMOVE!\n\nPlease confirm")
    }



var xmlHttp


        function GetXmlHttpObject()
                {
                      var xmlHttp=null;
                      try
                        {
                            // Firefox, Opera 8.0+, Safari
                            xmlHttp=new XMLHttpRequest();
                        }
                      catch (e)
                         {
                             // Internet Explorer
                            try
                             {
                                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                              }
                           catch (e)
                              {
                                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                               }
                   }
             return xmlHttp;
   }
    
   
 function closePopWindow(url)
  {
       var x= confirm ("Do you want to continue");
         if (x)
          {
            //alert("You have choosed" +x); 
            openCSSPopupByName(url, 0, 0, 300, 200,"checkoutwarninh",2);
          }
          else
           {
              //alert ("you have choose" +x); 
           }
      
  }
  
function ShowHistory()
  {
     var minus=document.getElementById("minus");
     minus.style.display="block";
     document.getElementById("plus").style.display="none";
     var hist= document.getElementById("history");
     hist.style.display="block";
  }
function HideHistory()
  {
     var minus=document.getElementById("minus");
     minus.style.display="none";
     document.getElementById("plus").style.display="block";
     var hist= document.getElementById("history");
     hist.style.display="none";
  }
function ChangeAccess(controld,value,newrdo)
{
   //alert("contolid=" + controld+" and value=" +value);
   if (parseInt(value)==0)
   {
     ddl=document.getElementById(controld);
     ddl.options[0].selected=true;
      
   }
   else
   {
      //alert("newRdo=" +newrdo );
      rdo=document.getElementById(controld);
      rdo.checked=false;
      rdo1=document.getElementById(newrdo);
      rdo1.checked=true;
      //alert("dropdownlist"); 
   }
   
} 
























