/* ----------------------------------- Alphabets Script ----------------------------------- */
function Browser() {



  this.isIE    = false;  // Internet Explorer
  this.isFF    = false;  // Firefox
  this.isSF    = false;  // Safari
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Firefox";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isFF = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
  
  s = "Safari";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isSF = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

function tab1612108977(tab_id, tabs_count,tabs_ref)
{
	var flag = false;
	for (var i=1; i <= tabs_count; i++)
	{
		if (tab_id == i)
			{
				flag = true;
				document.getElementById('hdnTabNo').value = tab_id;
				document.getElementById('tab1612108977_' + i).className = 'current';
				if (tabs_ref==1)
					document.Form1.submit();
			}
		else
			{
				document.getElementById('tab1612108977_' + i).className = '';
			}
	}
	
	// To select the All tab by default
	if (!flag)
		document.getElementById('tab1612108977_' + 1).className = 'current';		
}

/* ----------------------------------- Alphabets Script ----------------------------------- */


/* ----------------------------------- Quick Links ----------------------------------- */

//
// Helper functions for common components
// Kevin Roast 12-04-2005
//

// Menu component functions
var _lastMenu = null;

// toggle a dynamic menu dropping down
function _toggleMenu(e, menuId)
{
   // hide any open menu
   if (_lastMenu != null && _lastMenu != menuId)
   {
      document.getElementById(_lastMenu).style.display = 'none';
      _lastMenu = null;
   }
   
   // toggle visibility of the specified element id
   if (document.getElementById(menuId).style.display == 'none')
   {
      document.getElementById(menuId).style.display = 'block';
      
      _lastMenu = menuId;
      
      // set global onclick handler to hide menu
   	e.cancelBubble = true;
   	if (e.stopPropagation)
   	{
   	   e.stopPropagation();
   	}
      document.onclick = _hideLastMenu;
   }
   else
   {
      document.getElementById(menuId).style.display = 'none';
      document.onclick = null;
   }
}

// Hide the last opened menu
function _hideLastMenu()
{
   if (_lastMenu != null)
   {
      document.getElementById(_lastMenu).style.display = 'none';
      _lastMenu = null;
      document.onclick = null;
   }
}

/* ----------------------------------- Quick Links ----------------------------------- */


function OpenJobProof(JobID)
{
	if (JobID != "")
	{
		var url = "ProofResult.aspx?jobID="+ JobID + "&refresh=n";
		var popUp; 
		var winTitle = "Proof";
		
		if (JobID != "-1")
		{
			popUp=window.open (url, winTitle, "height=670,Width=645,top=0,scrollbars=yes,resizable=yes"); 				
		}
	}
}


function ShowErrorMessage(errMessage)
{
	alert(errMessage);
}



function openWindow(url) 
{
	popupWin=window.open(url,'remote','width=640,height=480,top=100,left=100');
}
	

function openSelectList(EId, OPId, OId, DeliveryId)
{
	if (EId != '')
		window.open('ViewSelectList.aspx?EId=' + EId + '&DeliverId=' + DeliveryId, 'ViewSampleList','width=770,height=580,left=100,top=100,status=no,resizable=yes');
	else
		window.open('ViewSelectList.aspx?OPId=' + OPId + '&OId=' + OId + '&DeliverId=' + DeliveryId, 'ViewSampleList','width=770,height=580,left=100,top=100,status=no,resizable=yes');
		
	return false;
}



/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
//document.write('<img id="dhtmlpointer" src="SiteBranding/DefaultTheme/Images/arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip


/* ----------------------------------- TOOL TIP ----------------------------------- */


/* ----------------------------------- Model Dialog ----------------------------------- */

function InitModelDialog()
{
	/*Start Modal Window Hide*/
	Hide();
		
		DOMManager.sweep();

	/*
		* Attach supporting css bind required
		* classes for transparency support in Opera.
		*/
	addExtensionsForOpera();
	attachOpacityCSS();

	/* Adjust height. */
	adjustHeight();
	
		/* Create the modal dialog */
	g_Modal=new ModalDialog("ModalBG","DialogWindow",
		"DialogContent","DialogActionBtn");
		/*End Modal Window Hide*/
	addEventToObject(window,'onload',rssFetchAndDisplay.Init); 
}

/* Model Window Script Start Here */
function mainshow(dialogID)
{
	var ajax = _.ajax();

	/*
	* Note that _.ajax(); is a shorthand notation 
	* for new XHRequest();
	* Visit http://sardalya.pbwiki.com/Shortcuts details.
	*/

	/* 
	* You can add as many fields as you like to the post data. 
	* Normally the server will use this data to create an
	* output that makes sense which may be an XML, a JSON String
	* or an HTML String.
	*/
	//alert('Test');
	ajax.removeAllFields();
	ajax.addField("name","John");
	ajax.addField("surname","Doe");
	//alert('main');
	ajax.oncomplete=ajax_complete;
	ajax.onerror=ajax_error;
	g_Modal.show("Getting Data");
	Showall(dialogID);
	ajax.get(document.getElementById('DialogWindow').style.display="inline");
	g_Modal.disableClose();
	/* Re-activate close button. */
	g_Modal.enableClose();

	return false;
}

function Showall(dialogID)
{
	document.getElementById('DialogActionBtn').style.display="inline";
	document.getElementById('MainDiv').style.display="inline";
	document.getElementById('ModalBG').style.display="inline";
	document.getElementById(dialogID).style.display="inline";
}

function main1()
{
	return false;
}

function adjustHeight()
{
	var intWindowHeight=WindowObject.getInnerDimension().getY();
	var dynModalBG=new DynamicLayer("ModalBG");
	var intModalHeight=dynModalBG.getHeight();
	//alert(intModalHeight);
	//alert(intWindowHeight);

	if(intModalHeight<intWindowHeight)
	{
		//alert(intWindowHeight);
		dynModalBG.setHeight(intWindowHeight);
	}
}

function addExtensionsForOpera()
{
	/* classes for opera */
	var ModalBG=new CBObject("ModalBG").getObject();
	if(typeof(window.opera)!="undefined")
	{
		ModalBG.className="modalOpera";
	}
}
function ajax_complete(strResponseText,objResponseXML)
{
	g_Modal.show(strResponseText);
	
	/* Re-activate close button. */
	g_Modal.enableClose();
}

/* Triggered when server generates an error. */
function ajax_error(intStatus,strStatusText)
{
	g_Modal.show("Error code: ["+ intStatus+ "] error message: [" + 
		strStatusText + "].");

	/* Re-activate close button. */
	g_Modal.enableClose();
}

function CloseButtonClick()
{
	//alert(document.getElementById('btn1').onclick);
	/*if(document.getElementById('btn1').onclick==null)
	{  */
	document.getElementById('DialogWindow').style.display="none";
	//alert(DialogWindow.disabled); 
	DialogWindow.disabled=false;
	//}
	DialogWindow.hideFocus;  
	document.getElementById('DialogActionBtn').style.display="none";
	document.getElementById('MainDiv').style.display="none";
	document.getElementById('ModalBG').style.display="none";
	document.getElementById('DialogContent1').style.display="none";

	return false;
}
function attachOpacityCSS()
{
	/*
		* CSS for opacity support
		* Note that this can be directly added to the body.
		* If you do not care about blindly adhering to standards
		* you can directly include the rules into Master.css
		*
		* Do I care? Yes and no.(visit http://www.sarmal.com/Exceptions.aspx
		* to learn how I feel about it).
		*/
	var opacityCSS = document.createElement("link");
	opacityCSS.type="text/css";
	opacityCSS.rel="stylesheet";
	opacityCSS.href="Opacity.css";
	document.getElementsByTagName("head")[0].appendChild(opacityCSS);
}

function SetDivHeight()
{
	document.getElementById('DialogWindow').offsetHeight=37;
	alert(document.getElementById('DialogWindow').offsetHeight);  
}

function window_resize(evt)
{
	adjustHeight();
}

function clone() 
{
	//alert('1');
					
	if(document.getElementById('DialogWindow').style.display="none")
	{ 
		alert(document.getElementById('DialogWindow').style.display="inline");
		document.getElementById('DialogWindow').style.display="inline";  
	}
	else
	{
	return false; 
	}
}
	
function Hide()
{
	document.getElementById('DialogWindow').style.display = "none";
}

/*Modal Window Script End Here*/


/* ----------------------------------- Model Dialog----------------------------------- */
