function confirmDeleteOrder(func,confirmmsg)
{
	i=confirm( confirmmsg );

	if(i)
	{
		 return eval(func);
	}
	else
		return false;

}


function confirmCancelOrder(func,confirmmsg)
{
	i=confirm( confirmmsg );

	if(i)
	{
		 return eval(func);
	}
	else
		return false;

}


function viewOrderCallUrl(url)
{
    self.location.href=url+"&orderid="+document.MultiBtnForm.orderid.value+"&type="+document.MultiBtnForm.type.value;
    return true;
}

function submitForm(url,form)
{
      form.action=url;
      form.submit();
      return true;
}


function checkEmptyCheckbox(func,form,errmsg)
{
	var anychecked=false;
	for(i=1;i<=form.length;i++)
        {
	       if (form.elements[i-1].type == "checkbox")
               {
                   if (form.elements[i-1].checked)
		   {
			   anychecked=true;
			   //alert(func)
			   return eval(func);
		   }
               }
        }
	if (errmsg == null)
	{
		alert("No Items Selected. Please Select atleast ONE of them by checking the box next to it.");
	}
	else
	{
		alert(errmsg);
	}
	return false;
}



function loadUrl(url,form)
{
        //alert("URL "+url +" form "+form);
        var link=url;
  //      alert("No. of elements "+form.length);
        /* for(i=1;i<=form.length;i++)
        {
               //alert("Adding "+form.elements[i-1].name);
                //alert("Adding followed Value "+form.elements[i-1].value +" type "+form.elements[i-1].type);

               if (form.elements[i-1].type != "button")
               {
                    link = link+"&"+form.elements[i-1].name+"="+form.elements[i-1].value;
               }
        } */
        //alert("FINAL LINK "+link);
        //self.location.href=link;
        form.action = url;
        //alert(form.action);
        form.submit();

    //self.location.href=url;
        return true;
}


//opens a new window
function OpenInNewWindowMaximize(url)
{
	today = new Date()
	//window.open(url,"viewdetails"+today.getMilliseconds(),"maximize=yes,left=12,top=12,menubar=yes,status=yes,scrollbars=yes,resizable=yes")
	//width=770,height=450
	windowname =OpenInNewWindow(url);
	windowname.moveTo(0,0);
	windowname.resizeTo(screen.availWidth,screen.availHeight);
}

function OpenInNewWindow(url)
{
	//today = new Date()
	//window.open(url,"viewdetails"+today.getMilliseconds(),"maximize=yes,left=12,top=12,menubar=yes,status=yes,scrollbars=yes,resizable=yes")
	//width=770,height=450
	OpenInNewWindow(url,770,450);
}


//opens a new window
function OpenInNewWindow(url,width,height)
{
	today = new Date()
	return window.open(url,"viewdetails"+today.getMilliseconds(),"width="+width+",height="+height+",left=12,top=12,menubar=yes,status=yes,scrollbars=yes,resizable=yes")
}


//opens a new window
function loadUrlInNewWindow(url,form)
{
	today = new Date()
	 //alert("URL "+url +" form "+form);
        var link=url;
  //      alert("No. of elements "+form.length);
        for(i=1;i<=form.length;i++)
        {
               //alert("Adding "+form.elements[i-1].name);
                //alert("Adding followed Value "+form.elements[i-1].value +" type "+form.elements[i-1].type);

               if (form.elements[i-1].type != "button" && form.elements[i-1].type != "submit")
               {
					if(form.elements[i-1].type == "radio")
					{
						if(form.elements[i-1].checked == true)
							link = link+"&"+form.elements[i-1].name+"="+form.elements[i-1].value;
					}
					else
						link = link+"&"+form.elements[i-1].name+"="+form.elements[i-1].value;
               }
        }
		//url=link;
        //alert("FINAL LINK "+link);
        //self.location.href=link;
        //form.action = url;
        //alert(form.action);
       // form.submit();

    //self.location.href=url;
	window.open(link,"viewdetails"+today.getMilliseconds(),"width=770,height=500,left=150,top=100,menubar=yes,status=yes,scrollbars=yes,resizable=yes")
		return true;
}



function selectAllCheckBoxes(frm)
{
	//alert(frm.orderid.length)
	for(k=0; k < frm.orderid.length ; k++)
	{
		frm.orderid[k].checked = true
	}
}



//this will set the title of the current frame(page) to the main frame's title
//alert(parent.document.title);
//alert(self.document.title);
//parent.document.title=self.document.title;




//tooltip code starts here

var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
var style = ((NS4 && document.test) || IE4) ? 1 : 0;

var timerID = null;
var num = 1;

var padding = 3; // < 4 recommended
var bgcolor = "lightyellow";

var borWid = 1; // for no border, assign null
var borCol = "#000000";
var borSty = "outset";

var str = "<STYLE TYPE='text/css'>";
str += ".tooltip {";
str += "position: absolute;";
str += "visibility: hidden;";
str += "left: 0; top: 0;";
if (borWid > 0) { // if a border is specified
  str += "border-width: " + borWid + ";";
  str += "border-color: " + borCol + ";";
  str += "border-style: " + borSty + ";";
}
if (NS4) {
  if (borWid > 0 && padding <= 3) {
    str += "padding: 0;";
    str += "layer-background-color: " + bgcolor + ";";
  } else if (borWid > 0 && padding > 3) {
    str += "padding: " + (padding - 3) + ";";
    str += "background-color: " + bgcolor + ";";
  } else if (borWid == 0) {
    str += "padding: " + padding + ";";
    str += "layer-background-color: " + bgcolor + ";";
  }
} else {
  str += "padding: " + padding + ";";
  str += "background-color: " + bgcolor + ";";
}
str += "font-size:11px;font-family:Arial,Verdana,Helvetica;";
str += "}";
str += "</STYLE>";

if (style) {
  document.write(str);
  if (NS4) window.onload = init;
}

//makeEl("whatis_tip1", "You Brand Name is used whenever communicating with or displaying your name to an end-customer. This may not be the same as your company name and hence is required separately. For instance our Brand Name is Directi, while our Company Name is Direct Information Pvt Ltd. <I>nirvana</I>.",300);

function init() {
  setTimeout("window.onresize = redo", 1000);
}

function redo() {
  window.location.reload();
}


function makeEl(id, code,width) {
  if (!style) return;

  if(width == null)
  {
	width = 300;
  }

  var str = "<STYLE TYPE='text/css'>";
  str += "#" + id + " {";
  str += "width: " + width + ";";
  str += "}";
  str += "</STYLE>";
  str += "<DIV CLASS='tooltip' ID='" + id + "'>" + code + "</DIV>";
  //alert(str)
  document.write(str);
}

function displayEl(left, top, displayWidth) {
  if (NS4) document.releaseEvents(Event.MOUSEMOVE);
  document.onmousemove = null;
  var whichEl = (NS4) ? document[active] : document.all[active].style;
  whichEl.left = left;
  whichEl.top = top;
  whichEl.width = displayWidth;
  whichEl.visibility = (NS4) ? "show" : "visible";
}

function clearEl() {
  var whichEl = (NS4) ? document[active] : document.all[active].style;
  whichEl.visibility = (NS4) ? "hide" : "hidden";
  active = null;
  if (timerID) clearTimeout(timerID);
  if (NS4) document.releaseEvents(Event.MOUSEMOVE);
  document.onmousemove = null;
}

function activateEl(e) {
//alert("Inside activate with tooltip===="+this.tooltip)
  active = this.tooltip;
  if (NS4) document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove = checkEl;
  checkEl(e);
}

function checkEl(e) {
  if (timerID) clearTimeout(timerID);
	if(is.ns4 || is.ns6)
	{
		available_width = innerWidth;
		available_height = innerHeight;
	}
	else if(is.ie4 || is.ie5 || is.ie55 || is.ie6)
	{
		available_width=document.body.clientWidth;
		available_height=document.body.clientHeight;
	}
  var left = (NS4) ? e.pageX : event.clientX + document.body.scrollLeft;
  var top = (NS4) ? e.pageY + 20 : event.clientY + document.body.scrollTop + 20;
  var boxWidth = available_width - event.clientX
//alert("event.clientY="+event.clientY)
//alert("document.body.scrollTop="+document.body.scrollTop)
//alert("available_height="+available_height)
//alert("top="+top)

  //if((available_height-event.clientY) < 200)
  //	top = top - 200
  if(boxWidth > 300)
	boxWidth = 300
  if(boxWidth < 200)
 {
	left = left - 300
	boxWidth = 300
 }
  timerID = setTimeout("displayEl(" + left + ", " + top + ", " + boxWidth + ")", 300);
}

function showTooltip(id,e)
{
//alert(id)
        this.tooltip = id;
        this.onmouseover = activateEl;
        this.onmouseout = clearEl;
	  activateEl(e)
}


function Is() {
agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer')
== -1)
     && (agent.indexOf('compatible') ==  -1)));
this.ns2 = (this.ns && (this.major == 3));
this.ns3 = (this.ns && (this.major == 3));
this.ns4b = (this.ns && (this.major == 4) && (this.minor <= 4.03));
this.ns4 = (this.ns && (this.major == 4));
this.ns6 = (this.ns && (this.major >= 5));
this.ie = (agent.indexOf("msie") != -1);
this.ie3 = (this.ie && (this.major < 4));
this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0")
 == -1));
this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0")
 != -1));
this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5")
 != -1));
this.ie6 = (this.ie && (agent.indexOf("msie 6.0")!=-1) );
this.aol = (agent.indexOf("aol") != -1);
this.aol3 = (this.aol && this.ie3);
this.aol4 = (this.aol && this.ie4);
this.aol5 = (this.aol && this.ie5);
}
var is = new Is();

function winResize() {
if(is.ns4 ||is.ns6||is.ie4||is.ie5||is.ie55||is.ie6) {
history.go(0);
}
}


//tooltip code ends here



function checkPageNumber(num)
{
	//alert(parseInt(num));
	if (isNaN(parseInt(num)))
	{
		alert("Please put in the correct Page Number");
		return false;
	}
	return true;
}

function changeBrandingurl()
{
	if (document.BrandForm.brandingurl2.checked)
	{
		document.BrandForm.brandingurl2.value = document.BrandForm.otherbrandingurl.value;
	}
}

function CardCheck(ptr)
{
//	var ptr = document.mainForm.PAN ;
	Chk=parseInt(ptr.value.substring(0,1));
	Chk1=ptr.value.length;

	if((isNaN(ptr.value))||ptr.value.length==0)
	{
		alert('Please Enter a Numeric value in the Card Number');
		ptr.value='';
		ptr.focus();
		return false;
	}

	NumStr = parseInt(ptr.value).toString();
	NumLen = NumStr.length;
	if((Chk==3 && NumLen!=14 && Chk1!=NumLen)||(Chk!=3 && NumLen!=16 && Chk1!=NumLen))
	{
		alert('Please Enter a Numeric value in the Card Number');
		ptr.focus();
		ptr.value='';
		return false;
	}

	if((Chk==3 && Chk1!=14)||(Chk!=3 && Chk1<16)||(NumStr <0))
	{
		alert('Please enter the card number correctly');
		ptr.focus();
		ptr.value='';
		return false;
	}
}