﻿/*
 * Include File:js/common.js
 */
function OpenNotes(url)
{
    window.open(url);
}

function CheckSpecialChr(elementId) {
	var obj = document.getElementById(elementId);
	var password = obj.value;
	if (/^[^a-z0-9]/.test(password)) { // only a-z0-9 allowed as first character
		obj.value = '';
		return false;
	}
	return true;
}

function OpenPopUp(hyperlink, e)
{
    OpenDivPopup(hyperlink.href);
    return CancelEventBubble(e);
}
	function OpenPopup() {
			
			}
function ConfirmDelete()
{
    if(!confirm("Are you sure you want to delete?"))
    {
        return false;
    }
    //return true;
}

function CancelEventBubble(e)
{
    if(!e)
    {
        e = event;
    }
    e.cancelBubble = true;
    return false;
}

function AlertForLogin(msg, e)
{
    alert(msg);
    return CancelEventBubble(e);
}

function OpenDivPopup(url, width, height, windowName)
{
    width = SafeValue(width, 0); //default
    height = SafeValue(height, 0); //default
    //modal = showPopWin(url, width, height, windowName);
    
    if(width > 0 || height > 0)
    {
        win = window.open(url, windowName, 'width=' + width + 'px,height=' + height + 'px,scrollbars=yes');
    }
    else
    {
        win = window.open(url);
    }
    win.focus();
}

function SafeValue(value, defaultValue)
{
    var toReturn = value;
    if(toReturn == null || toReturn == 'undefined')
    {
        toReturn = defaultValue;
    }
    return toReturn;
}

function ReturnFloat(tb)
{
    if(isNaN(tb.value) || tb.value == null || tb.value.length == 0)
    {
        tb.value = 0;
    }
    return parseFloat(tb.value);
}

function ShowDiv(divname)
{
    var obj = document.getElementById(divname);
    obj.style.display = 'block';
}

function HideDiv(divname)
{
    var obj = document.getElementById(divname);
    obj.style.display = 'none';
}

function Round(MyVal, Length)
{
    toReturn = Math.round(MyVal * Math.pow(10, Length)) / Math.pow(10, Length);
    return parseFloat(toReturn);
}

function OpenInParent(url, closeSelf)
{
    //window.top.location.href = url; //For Virtual Popup using div
    window.opener.document.location.href = url;
    window.close();
}

function OpenClassicWindow(url, height, width)
{
	window.open(url, 'popupWindow', 'height=' + height + ',width=' + width + ',toolbar=no');
}


function CopyToParent(checkbox, parentControlId, value)
{
    parentControl = window.parent.document.getElementById(parentControlId);
    parentControl.value = value;
}

function CopyToParentMultiple(checkbox, parentControlId, value)
{
    parentControl = window.parent.document.getElementById(parentControlId);
    if(checkbox.checked)
        {
            if(parentControl.value != null && parentControl.value.length > 0)
                {
                    parentControl.value = parentControl.value + ',';
                }
            parentControl.value = parentControl.value + value;
        }
    else
        {
            if(parentControl.value != null && parentControl.value.length > 0)
                {
                    parentControl.value = parentControl.value.replace(',' + value, '') //First Try
                    parentControl.value = parentControl.value.replace(value + ',', '') //Second Try
                    parentControl.value = parentControl.value.replace(value, '') //Third Try
                }
        }
}

function PreviousPage()
{
    history.go(-1);
}

function PromptInput(description, errorMessage, fieldName, e)
{
    var value = prompt(description, '');
    
    if(value != null)
    {
        value = Trim(value);
    }
    
    if(value != null && value.length != 0)
    {
        //Setting value to the hidden field
        var obj = GetControlById(fieldName);
        if(obj != null)
        {
            obj.value = value;
        }
        return true;
    }
    else
    {
        alert(errorMessage);
        return CancelEventBubble(e);
    }
    return true;
}

var objClickEvent = null;
var arr = {};

//Uses ExtJS
function PromptInputNew(id, description, errorMessage, fieldName, e, obj, once)
{
    if(once)
    {
        var value = eval('arr.' + id);
        if(value)
        {
            return true;
        }
    }

    var canPostBack = false;
    var value = null;
    if(canPostBack == undefined || canPostBack == null)
    {
        canPostBack = false;
    }
    if(!canPostBack)
    {
        if(obj != null)
        {
            objClickEvent = obj;
        }
        Ext.Msg.prompt('?', description, function(btn, text) {
            if(btn == 'ok')
            {
                value = text;
                if(value != null)
                {
                    value = Trim(value);
                }
    
                if(value != null && value.length != 0)
                {
                    //Setting value to the hidden field
                    var obj = GetControlById(fieldName);
                    if(obj != null)
                    {
                        obj.value = value;
                        canPostBack = true;
                    }
                }
                
                if(!canPostBack)
                {
                    Ext.Msg.alert('Status', errorMessage);
                }
                if(canPostBack)
                {   
                    if(once)
                    {
                        eval("arr." + id + " = '0'");
                    }
                    window.location.href = objClickEvent.href;
                }
            }
        });
    }

    
    return canPostBack;
}

function GetControlById(controlId)
{
    return document.getElementById(controlId);
}

function SetSubscriptionPlan(obj)
{
    var control = GetControlById('tbSubscriptionPlanId');
    
    var arr = obj.value.split(',');
    
    control.value = arr[0];
    
    shipmentsControl = GetControlById('ctl00_uxContentPlaceHolder_ContentPanel1_uxCustomAmount');
    if(control.value != '5')
    {
        shipmentsControl.value = arr[1];
        shipmentsControl.disabled = true;
    }
    else
    {
        shipmentsControl.value = '0';
        shipmentsControl.disabled = false;
    }
}


function ValidateSubscriptionPlanSelection(paymentModeControlId, customShipmentControlId, subscriptionSelectionControlId, e)
{
    var paymentModeControl = GetControlById(paymentModeControlId);
    var customShipmentControl = GetControlById(customShipmentControlId);
    var subscriptionSelectionControl = GetControlById(subscriptionSelectionControlId);
    
    var paymentModeId = paymentModeControl.value;
    var customShipment = customShipmentControl.value;
    var subscriptionId = subscriptionSelectionControl.value;
    
    if(subscriptionId == 0)
    {
        alert('Select subscription plan');
        return CancelEventBubble(e);
    }
    
    if(paymentModeId == 0)
    {
        alert('Select payment mode to proceed');
        return CancelEventBubble(e);
    }
    
    if(subscriptionId == 5) //Customized
    {
//        if(paymentModeId != 1) //Not Credit Card
//        {
//            alert('Only credit card can be used to buy customized shipments');
//            return CancelEventBubble(e);
//        }
//        else
//        {
            var invValue = 0;
            if(customShipment.length > 0)
                invValue = parseInt(customShipment);
            if(invValue < 20000)
            {
                alert('You must enter 20000 or higher for this plan');
                customShipmentControl.focus();
                return CancelEventBubble(e);
            }
//        }
    }
    return true;
}

function Redirect(redirectUrl)
{
    setTimeout("document.location.href = '" + redirectUrl + "'", 3000);
}

function ToggleControls(divName, show, inline)
{
 var x = document.getElementById( divName );
 if(x == null || x == undefined)
 {
    return;
 }
 
 var z = x.getElementsByTagName('SPAN');
 
 if(!inline)
 {
    inline = false;
 }
 if(show == null || show == undefined)
 {
    show = x.style.display == "none";
 }
 
 if(z)
 {
     for(i=0; i< z.length; i++)
     {
      var webControl = z[i];
      // check if it is really a validator control
      if(webControl.id != null && webControl.id.indexOf("Validator") > -1)
      {
       ValidatorEnable(webControl, show);
      }
     }
 }
 
 if(show)
 {
    if(inline)
        x.style.display = "inline";
    else
        x.style.display = "block";
 }
 else
 {
  x.style.display = "none";
 }
}


function ToggleContent(elementId)
{
    ToggleControls(elementId);
}

function attachEnterKey(controlId, buttonId)
{
}

function ConvertUnits(qtyControlId, unitFromControlId, unitToControlId, resultControlId)
{
    qtyFrom = document.getElementById(qtyControlId);
    unitFromDropdown = document.getElementById(unitFromControlId);
    unitToDropdown = document.getElementById(unitToControlId);
    resultControl = document.getElementById(resultControlId);

    qty = parseFloat(qtyFrom.value);
    unitFrom = unitFromDropdown.options[unitFromDropdown.selectedIndex].value;
    unitTo = unitToDropdown.options[unitToDropdown.selectedIndex].value;

    if(unitFrom.indexOf("||") > -1)
    {
        i = unitFrom.indexOf("||");

        formula = unitFrom.substring(0, i-1);
        formula = formula.replace("{0}", qty);
        
        qty = eval(formula);
        
        i = unitTo.indexOf("||");
        formula = unitTo.substring(i+2);
        
        formula = formula.replace("{0}", qty);
        qty = eval(formula);
        
        resultControl.value = formatFloat(qty);
        
        return;
    }
    
    if(unitFrom.indexOf("{0}") > -1)
    {
        alert('need to evaluate expression');
        return;
    }
    
    unitFrom = parseFloat(eval(unitFrom));
    unitTo = parseFloat(eval(unitTo));
    
    resultControl.value = formatFloat(qty * (unitFrom / unitTo));
}

function formatFloat(number, X) {
// rounds number to X decimal places, default is 6
    X = (!X ? 6 : X);
    return Math.round(number * Math.pow(10,X)) / Math.pow(10,X);
}

function resetForm(containerId)
{
    container = document.getElementById(containerId);
    inputs = container.getElementsByTagName('input');
    selects = container.getElementsByTagName('select');
    textAreas = container.getElementsByTagName('textarea');
    
    nLen = inputs.length;
    for(i=0; i < nLen; i++)
    {
        inputType = inputs[i].type;
        if(inputType == "text")
        {
            inputs[i].value = "";
        }
    }
}

function Processing(searchBtnControlId)
{
    searchBtn = GetControlById(searchBtnControlId);
    if(searchBtn != null)
    {
        searchBtn.value = 'Searching....';
        searchBtn.style.display = 'none';
    }
    ToggleControls('Processing', true, false);
    //ToggleControls('SearchDiv', false, false);
}

function AddToParent(selectedValue, parentControlId)
{
    /* TODO: Need to work for firefox */
    var toAdd = true;
    
    parentControl = window.opener.document.getElementById(parentControlId);
    if(parentControl == null || selectedValue.length == 0)
    {
        return false;
    }
    
    selectedValue = Trim(selectedValue);
    
    if(parentControl.value.length > 0)
    {
        var tempString = ',' + parentControl.value + ',';
        if(tempString.indexOf(',' + selectedValue + ',') > -1)
        {
            toAdd = false;
        }
    }
    
    if(toAdd)
    {
        if(parentControl.value.length > 0)
        {
            parentControl.value = parentControl.value + ',';
        }
        parentControl.value = parentControl.value + selectedValue;
    }
    
    ObjAddedMsgDiv = document.getElementById('addedMsgDiv');
    if(ObjAddedMsgDiv != null)
    {
        ObjAddedMsgDiv.style.display = 'block';
        setTimeout("HideDiv('addedMsgDiv')",1000);
    }
    else
    {
        alert('Selected');
    }
}

function OpenShipmentLookup(lookupTypeId, controlId)
{
    OpenDivPopup('PickupList.aspx?LookupTypeId=' + lookupTypeId + '&ParentControlId=' + controlId, 550, 620, 'ShipmentPickup');
    return false;
}

function OpenHSCodeSelection()
{
    OpenDivPopup('../India-Trade-Data/HS-Locator/Default.aspx', 800, 800, 'HSCodePickup');
    return false;
}

function OpenBookmarksPopup(urlToOpen)
{
    OpenDivPopup(urlToOpen, 600, 600, 'AddBookmark');
    return false;
}

function Trim(str)
{  while(str.charAt(0) == (" ") )
  {  str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {  str = str.substring(0,str.length-1);
  }
  return str;
}

function CheckHSCode(sender, args)
{
    var hsCode = args.Value;
    
    var control = GetControlFromSender(sender);
    
    hsCode = '' + hsCode;
    hsCode = hsCode.replace('.','');
    hsCode = hsCode.replace(' ','');
    if(control != null)
    {
        control.value = hsCode;
    }

    args.IsValid = true;
}

function GetControlFromSender(sender)
{
    var controlHtml = sender.outerHTML;
    startIndex = controlHtml.indexOf('controltovalidate');
    endIndex = controlHtml.indexOf('errormessage');
    htmlLength = endIndex - startIndex;
    
    controlId = controlHtml.substr(startIndex + 19, htmlLength - 21);
    return control = GetControlById(controlId);
}

function CheckShipmentSearch(tbControl, ddlControl)
{
    //tbControl = GetControlById(tbControlId);
    //ddlControl = GetControlById(ddlControlId);
    if(tbControl.value.length > 0)
    {
        var hsCode = parseFloat(tbControl.value);
        if(hsCode > 0)
        {
            hsCode = tbControl.value;
            if(ddlControl != null)
            {
                if(ddlControl.value == 0)
                {
                    return false;
                }
            }
            else
            {
                hsCode = '' + hsCode;
                hsCode = hsCode.replace('.','');
                hsCode = hsCode.replace(' ','');
                tbControl.value = hsCode;
                if(hsCode.length != 2 & hsCode.length != 4 & hsCode.length != 6 & hsCode.length != 8 & hsCode.length != 10 & hsCode.length != 12)
                {
                    return false;
                }
            }
        }
    }
    return true;
}

function CheckSearchValue(sender, args)
{
    //Sender is the textbox
    objDropDown = GetControlById(GetSearchDropDownClientId());
    objTextBox = GetControlById(GetSearchTextBoxClientId());
    
    if(CheckShipmentSearch(objTextBox, objDropDown))
    {
        args.IsValid = true;
    }
    else
    {
        args.IsValid = false;
    }
}

function CheckBlur(sender, defaultText)
{
    if(Trim(sender.value).length == 0)
    {
        sender.value = defaultText;
    }
}

function CheckFocus(sender, defaultText)
{
    if(sender.value == defaultText)
    {
        sender.value = '';
    }
}

function AllowTextOnly(e)
{
    var keynum;
    
    if(window.event)
    {
        keynum = e.keyCode;
    }
    else if(e.which)
    {
        keynum = e.which;
    }

    if(keynum >= 48 && keynum <= 57) //Allow all except numbers
    {
        alert('Number input not allowed');
    
        //Cancel Input
        if(window.event)
        {
            e.returnValue = false;
        }
        else
        {
            e.preventDefault();
        }
    }
}

function AllowNumbersOnly(e)
{
    var keynum;
    
    if(window.event)
    {
        keynum = e.keyCode;
    }
    else if(e.which)
    {
        keynum = e.which;
    }
    
    if((keynum >= 48 && keynum <= 57) || (keynum == 44)) //Allowing comma
    {
        return;
    }
    
    alert('Text input not allowed');

    //Cancel Input
    if(window.event)
    {
        e.returnValue = false;
    }
    else
    {
        e.preventDefault();
    }
}

function DisablePaste(e)
{
    alert('Paste not allowed');
    CancelEvent(e);
}

function CancelEvent(e)
{
    //Cancel Input
    if(window.event)
    {
        e.returnValue = false;
    }
    else
    {
        e.preventDefault();
    }
}

function AddToParentAll(parentControlId, e)
{
    var frm = document.forms[0];
    var hasSelected = false;
    
    for(i=0;i<frm.elements.length;i++)
    {
        el = frm.elements[i];
        if(el.type == 'checkbox')
        {
            if(el.checked)
            {
                hasSelected = true;
                AddToParent(el.parentNode.title, parentControlId);
            }
        }
    }
    if(!hasSelected)
    {
        alert('Please select atleast one checkbox');
    }
    
    return false;
}

var GB_myShow = function(caption, url, /* optional */height, width, callback_fn) {
	var options = {		caption: caption,
		height: height || 500,
		width: width || 500,
		fullscreen: false,
		show_loading: false,
		callback_fn: callback_fn
	}
	var win = new GB_Window(options);
	return win.show(url);
}

function GetCheckedIds(fmobj) {
	var ids = '';
	for (var i = 0; i < fmobj.childNodes.length; i++) {
		var e = fmobj.childNodes[i];
		if ((e.name != 'allbox') && (e.type == 'checkbox') && (!e.disabled)) {
			if (e.checked) {
				var label = e.nextSibling;
				ids += ',' + label.innerHTML;
			}
		}
	}
	if (ids.length > 0) {
		ids = ids.substring(1, ids.length);
	}
	return ids;
}

/*
 * Include File:js/marquee.js
 */
/***********************************************
* Cross browser Marquee II- � Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee()
{
    if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
        cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
    else
        cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializeMarquee(containerHeight, contentHeight)
{
    cross_marquee=document.getElementById("vmarquee")
    marqueeheight=document.getElementById("marqueeContainer").offsetHeight
    if(marqueeheight == 0)
    {
        marqueeheight = containerHeight;
    }
    actualheight=cross_marquee.offsetHeight;
    if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1) //if Opera or Netscape 7x, add scrollbars to scroll and exit
    { 
        cross_marquee.style.height=marqueeheight+"px"
        cross_marquee.style.overflow="scroll"
        return
    }
    setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}

//if (window.addEventListener)
//    window.addEventListener("load", initializemarquee, false)
//else if (window.attachEvent)
//    window.attachEvent("onload", initializemarquee)
//else if (document.getElementById)
//    window.onload=initializemarquee



/*
 * Include File:js/dropdowntabs.js
 */
var tabdropdown={
	disappeardelay: 200, //set delay in miliseconds before menu disappears onmouseout
	disablemenuclick: false, //when user clicks on a menu item with a drop down menu, disable menu item's link?
	enableiframeshim: 1, //1 or 0, for true or false

	//No need to edit beyond here////////////////////////
	dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, previousmenuitem:null,
	currentpageurl: window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, ""), //get current page url (minus hostname, ie: 

	getposOffset:function(what, offsettype){
		var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
		var parentEl=what.offsetParent;
			while (parentEl!=null){
				totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
				parentEl=parentEl.offsetParent;
			}
		return totaloffset;
	},

	showhide:function(obj, e, obj2){ //obj refers to drop down menu, obj2 refers to tab menu item mouse is currently over
		if (this.ie || this.firefox)
			this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
		if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
			if (obj2.parentNode.className.indexOf("default")==-1) //if tab isn't a default selected one
				obj2.parentNode.className="selected"
			obj.visibility="visible"
			}
		else if (e.type=="click")
			obj.visibility="hidden"
	},

	iecompattest:function(){
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	},

	clearbrowseredge:function(obj, whichedge){
		var edgeoffset=0
		if (whichedge=="rightedge"){
			var windowedge=this.ie && !window.opera? this.standardbody.scrollLeft+this.standardbody.clientWidth-15 : window.pageXOffset+window.innerWidth-15
			this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
		if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
			edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
		}
		else{
			var topedge=this.ie && !window.opera? this.standardbody.scrollTop : window.pageYOffset
			var windowedge=this.ie && !window.opera? this.standardbody.scrollTop+this.standardbody.clientHeight-15 : window.pageYOffset+window.innerHeight-18
			this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
			if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
				edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
				if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
					edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
			}
			this.dropmenuobj.firstlink.style.borderTopWidth=(edgeoffset==0)? 0 : "1px" //Add 1px top border to menu if dropping up
		}
		return edgeoffset
	},

	dropit:function(obj, e, dropmenuID){
		if (this.dropmenuobj!=null){ //hide previous menu
			this.dropmenuobj.style.visibility="hidden" //hide menu
			if (this.previousmenuitem!=null && this.previousmenuitem!=obj){
				if (this.previousmenuitem.parentNode.className.indexOf("default")==-1) //If the tab isn't a default selected one
					this.previousmenuitem.parentNode.className=""
			}
		}
		this.clearhidemenu()
		if (this.ie||this.firefox){
			obj.onmouseout=function(){tabdropdown.delayhidemenu(obj)}
			obj.onclick=function(){return !tabdropdown.disablemenuclick} //disable main menu item link onclick?
			this.dropmenuobj=document.getElementById(dropmenuID)
			this.dropmenuobj.onmouseover=function(){tabdropdown.clearhidemenu()}
			this.dropmenuobj.onmouseout=function(e){tabdropdown.dynamichide(e, obj)}
			this.dropmenuobj.onclick=function(){tabdropdown.delayhidemenu(obj)}
			this.showhide(this.dropmenuobj.style, e, obj)
			this.dropmenuobj.x=this.getposOffset(obj, "left")
			this.dropmenuobj.y=this.getposOffset(obj, "top")
			this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
			this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
			this.previousmenuitem=obj //remember main menu item mouse moved out from (and into current menu item)
			this.positionshim() //call iframe shim function
		}
	},

	contains_firefox:function(a, b) {
		while (b.parentNode)
		if ((b = b.parentNode) == a)
			return true;
		return false;
	},

	dynamichide:function(e, obj2){ //obj2 refers to tab menu item mouse is currently over
		var evtobj=window.event? window.event : e
		if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
			this.delayhidemenu(obj2)
		else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
			this.delayhidemenu(obj2)
	},

	delayhidemenu:function(obj2){
		this.delayhide=setTimeout(function(){tabdropdown.dropmenuobj.style.visibility='hidden'; if (obj2.parentNode.className.indexOf('default')==-1) obj2.parentNode.className=''},this.disappeardelay) //hide menu
	},

	clearhidemenu:function(){
		if (this.delayhide!="undefined")
			clearTimeout(this.delayhide)
	},

	positionshim:function(){ //display iframe shim function
		if (this.enableiframeshim && typeof this.shimobject!="undefined"){
			if (this.dropmenuobj.style.visibility=="visible"){
				this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
				this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"
				this.shimobject.style.left=this.dropmenuobj.style.left
				this.shimobject.style.top=this.dropmenuobj.style.top
			}
		this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"
		}
	},

	hideshim:function(){
		if (this.enableiframeshim && typeof this.shimobject!="undefined")
			this.shimobject.style.display='none'
	},

isSelected:function(menuurl){
	var menuurl=menuurl.replace("http://"+menuurl.hostname, "").replace(/^\//, "")
	return (tabdropdown.currentpageurl==menuurl)
},

	init:function(menuid, dselected){
		this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
		var menuitems=document.getElementById(menuid).getElementsByTagName("a")
		for (var i=0; i<menuitems.length; i++){
			if (menuitems[i].getAttribute("rel")){
				var relvalue=menuitems[i].getAttribute("rel")
				document.getElementById(relvalue).firstlink=document.getElementById(relvalue).getElementsByTagName("a")[0]
				menuitems[i].onmouseover=function(e){
					var event=typeof e!="undefined"? e : window.event
					tabdropdown.dropit(this, event, this.getAttribute("rel"))
				}
			}
			if (dselected=="auto" && typeof setalready=="undefined" && this.isSelected(menuitems[i].href)){
				menuitems[i].parentNode.className+=" selected default"
				var setalready=true
			}
			else if (parseInt(dselected)==i)
				menuitems[i].parentNode.className+=" selected default"
		}
	}

}
/*
 * Include File:js/ActiveX_run.js
 */
// lo: source url
// w: source width
// h: source height
// t: wmode ("" none, transparent, opaque ...)
function view_flash(lo,w,h,t){
document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'" id="flashID">');
document.write ('<param name="movie" value="'+lo+'">');
document.write ('<param name="quality" value="high">');
document.write ('<param name="wmode" value="'+t+'">');
document.write ('<embed src="'+lo+'" quality="high" wmode="'+t+'" width="'+w+'" height="'+h+'" name="flashID" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ></embed>');
document.write ('</object>');
}
/*
 * Include File:js/navigation.js
 */
<!--//--><![CDATA[//><!--

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//--><!]]>
/*
 * Include File:js/tigra_hints.js
 */
// Title: Tigra Hints
// URL: http://www.softcomplex.com/products/tigra_hints/
// Version: 2.1
// Date: 04/23/2007
// Note: This script is free for any kind of applications
//	The development of this software is funded by your donations

function THints (a_items, a_cfg) {

	if (!a_items) a_items = [];
	if (!a_cfg) a_cfg = [];
	this.a_cfg = a_cfg;

	this.a_elements = [];
	this.a_hints = [];

	this.show  = f_hintShow;
	this.showD = f_hintShowNow;
	this.hide  = f_hintHide;
	this.hideD = f_hintHideNow;

	// register the object in global collection
	this.n_id = A_HINTS.length;
	A_HINTS[this.n_id] = this;
	
	if (!b_ie5 && !b_ie6)
		a_cfg.IEfix = false;

	// generate HTML
	for (var s_id in a_items) {
		s_id = String(s_id).replace(/\W/g,'');
		document.write(
			'<div style="position:absolute;left:0;top:0;visibility:hidden;z-index:',
			((a_cfg['z-index'] == null ? 2 : a_cfg['z-index']) + (a_cfg.IEfix ? 1 : 0)), ';',
			(a_cfg.IEtrans ? 'filter:' + a_cfg.IEtrans.join(' ') : '') ,
			(a_cfg.opacity ? ' alpha(opacity=' + a_cfg.opacity + '); -moz-opacity:' + (a_cfg.opacity / 100) + ';opacity:' + (a_cfg.opacity / 100) + '' : ''), '" id="h', this.n_id, '_', s_id,
			'" class="', (this.a_cfg.css ? this.a_cfg.css : 'tigraHint'),
			'" onmouseover="A_HINTS[', this.n_id + '].show(\'', s_id, '\')" onmouseout="A_HINTS[',
			this.n_id, '].hide(\'', s_id, '\')" onmousemove="f_onMouseMove(event)">',
			a_items[s_id], '</div>'
		);
		if (a_cfg.IEfix) document.write(
			'<iframe style="position:absolute;left:0;top:0;visibility:hidden;z-index:',
			(a_cfg['z-index'] == null ? 2 : a_cfg['z-index']), ';filter:alpha(opacity=0);" id="h',
			this.n_id, '_', s_id, '_if" frameborder="0" scrolling="No"></iframe>'
		);
	}
	// assign mouseover event	
	if (document.addEventListener) {
		document.addEventListener('mousemove', f_onMouseMove, false);
		window.addEventListener('scroll', f_onwindowChange, false);
		window.addEventListener('resize', f_onwindowChange, false);
	}
	if (window.attachEvent) {
		document.attachEvent('onmousemove', f_onMouseMove);
		window.attachEvent('onscroll', f_onwindowChange);
		window.attachEvent('onresize', f_onwindowChange);
	}
	else {
		document.onmousemove = f_onMouseMove;
		window.onscroll = f_onwindowChange;
		window.onresize = f_onwindowChange;
	}
}
var n_flag = false;

function f_hintShow(s_id, e_element) {

	// cancel previous delay
	if (this.e_timer) {
		clearTimeout(this.e_timer);
		this.e_timer = null;
	}

	var s_id = String(s_id).replace(/\W/g,'');
	if (!this.a_hints[s_id])
		this.a_hints[s_id] = getElement('h' + this.n_id + '_' + s_id);
	if (!this.a_hints[s_id])
		this.a_hints[s_id] = getElement(s_id);
	if (!this.a_hints[s_id])
		throw new Error('001', 'Can not find the hint with ID=' + s_id);

	this.a_elements[s_id] = e_element;

	var n_showDelay = this.a_cfg.show_delay == null ? 200 : this.a_cfg.show_delay;
	if (!n_showDelay)
		return this.showD(s_id, e_element);

	this.e_timer = setTimeout('A_HINTS[' + this.n_id + '].showD("' + s_id + '")', n_showDelay);
}

function f_hintShowNow(s_id, e_element) {
	if (s_id == this.o_lastHintID)
		return;

	if (e_element)
		this.a_elements[s_id] = e_element;
	if (this.o_lastHintID != null)
		this.hideD(this.o_lastHintID);

	this.o_lastIframe = getElement('h' + this.n_id + '_' + s_id + '_if');
	if (this.o_lastIframe)
		this.o_lastIframe.style.visibility = 'visible';
	
	// Transition in IE
	f_hintPosition(this.a_elements[s_id], this.a_hints[s_id], this.a_cfg);
	if (this.a_cfg.IEtrans && this.a_cfg.IEtrans[0]) {
		try {
			var e_currTrans = this.a_hints[s_id].filters.item(0);
			e_currTrans.apply();
			this.a_hints[s_id].style.visibility = 'visible';
			e_currTrans.play();
		} catch(e) {
			this.a_hints[s_id].style.visibility = 'visible';
		};
	}
	else
		this.a_hints[s_id].style.visibility = 'visible';

	this.o_lastHintID = s_id;
}

function f_hintHide(s_id) {

	if (this.e_timer) {
		clearTimeout(this.e_timer);
		this.e_timer = null;
	}

	if (s_id != null)
		s_id = String(s_id).replace(/\W/g,'');
	else if (this.o_lastHintID)
		s_id = this.o_lastHintID;
	else
		return;
	
	if (!this.a_hints[s_id])
		throw new Error('001', 'Can not find the hint with ID=' + s_id);

	var n_hideDelay = this.a_cfg.hide_delay == null ? 200 : this.a_cfg.hide_delay;
	if (!n_hideDelay)
		return this.hideD(s_id);

	this.e_timer = setTimeout('A_HINTS[' + this.n_id + '].hideD("' + s_id + '")', n_hideDelay);
}

function f_hintHideNow(s_id) {
	// Transition in IE
	if (this.a_cfg.IEtrans && this.a_cfg.IEtrans[1]) {
		try {
			var e_currTrans = this.a_hints[s_id].filters.item(this.a_cfg.IEtrans[0] ? 1 : 0);
			e_currTrans.apply();
			this.a_hints[s_id].style.visibility = 'hidden';
			e_currTrans.play();
		} catch(e) {
			this.a_hints[s_id].style.visibility = 'hidden';
		};
	}
	else
		this.a_hints[s_id].style.visibility = 'hidden';

	this.o_lastHintID = null;
	if (this.o_lastIframe) {
		this.o_lastIframe.style.visibility = 'hidden';
		this.o_lastIframe = null;
	}
}


function f_hintPosition (e_element, e_hint, a_params) {
	// validate params
	if (!e_hint) throw new Error('001', 'hint object reference is missing in parameters');
	if (!a_params) a_params = [];
	
	var a_ = {
		n_elementWidth: e_element ? e_element.offsetWidth : 0,
		n_elementHeight: e_element ? e_element.offsetHeight : 0,
		n_elementLeft: e_element ? f_getPosition(e_element, 'Left') : n_mouseX,
		n_elementTop: e_element ? f_getPosition(e_element, 'Top') : n_mouseY,
		n_hintWidth: e_hint.offsetWidth,
		n_hintHeight: e_hint.offsetHeight,
		n_hintLeft: 0,
		n_hintTop : 0,
		n_clientWidth: f_clientWidth(),
		n_clientHeight: f_clientHeight(),
		n_scrollTop: f_scrollTop(),
		n_scrollLeft: f_scrollLeft(),
		s_align: a_params.align ? a_params.align : 'tlbl',
		n_gap: a_params.gap == null ? 5 : a_params.gap,
		n_margin: a_params.margin == null ? 10 : a_params.margin
	};

	f_applyAlign(a_);
	if (a_.n_hintLeft == 0)
		a_.n_hintLeft = -10000;
	// smart positioning is on by default
	else if (a_params.smart || a_params.smart == null)
		f_checkFit(a_);

	e_hint.style.left = a_.n_hintLeft + 'px';
	e_hint.style.top = a_.n_hintTop + 'px';

	// synchronize iframe if exists	
	var e_iframe = getElement(e_hint.id + '_if');
	if (e_iframe) {
		e_iframe.style.left = a_.n_hintLeft + 'px';
		e_iframe.style.top = a_.n_hintTop + 'px';
		e_iframe.style.width = a_.n_hintWidth + 'px';
		e_iframe.style.height = a_.n_hintHeight + 'px';
	}
}

/* corrects hints positioning to maximize the visibility */			
function f_checkFit (a_) {

	// check if correction is required
	if (a_.n_spaceT >= 0 && a_.n_spaceR >= 0 && a_.n_spaceB >= 0 && a_.n_spaceL >= 0)
		return;

	// determine if hint clears element for horisontal shifting
	var b_horShift =
		(a_.n_hintTop + a_.n_hintHeight + a_.n_gap <= a_.n_elementTop) ||
		(a_.n_elementTop + a_.n_elementHeight + a_.n_gap <= a_.n_hintTop);
	
	// resolve by horizontal shifting
	if (b_horShift) {
		if (a_.n_spaceL < 0 || (a_.n_spaceL + a_.n_spaceR < 0))
			a_.n_hintLeft = a_.n_scrollLeft + a_.n_margin;
		else if (a_.n_spaceR < 0)
			a_.n_hintLeft = a_.n_scrollLeft + a_.n_clientWidth - a_.n_margin - a_.n_hintWidth;
	}
	// determine if hint clears element for vertical shifting
	var b_verShift =
		(a_.n_hintLeft + a_.n_hintWidth + a_.n_gap <= a_.n_elementLeft) ||
		(a_.n_elementLeft + a_.n_elementWidth + a_.n_gap <= a_.n_hintLeft);

	// resolve by vertical shifting
	if (b_verShift) {
		if (a_.n_spaceT < 0 || (a_.n_spaceT + a_.n_spaceB < 0))
			a_.n_hintTop = a_.n_scrollTop + a_.n_margin;
		else if (a_.n_spaceB < 0)
			a_.n_hintTop = a_.n_scrollTop + a_.n_clientHeight - a_.n_margin - a_.n_hintHeight;
	}

	// resolve horisontal collision by mirroring
	if (!b_horShift && (a_.n_spaceL < 0 || a_.n_spaceR < 0)) {
		// save current overlap
		var n_overlap  = a_.n_spaceL + a_.n_spaceR,
			n_hintLeft = a_.n_hintLeft,
			n_hintTop  = a_.n_hintTop;

		// mirror the align
		a_.s_align = a_.s_align.replace('r', '-');
		a_.s_align = a_.s_align.replace('l', 'r');
		a_.s_align = a_.s_align.replace('-', 'l');
		f_applyAlign(a_);

		// restore old coordinate if mirrored hint is less visible
		if (Math.min(a_.n_spaceL, a_.n_spaceR) < n_overlap)
			a_.n_hintLeft = n_hintLeft;
		a_.n_hintTop = n_hintTop;
	}
	// resolve vertical collision by mirroring
	if (!b_verShift && (a_.n_spaceT < 0 || a_.n_spaceB < 0)) {
		var n_overlap  = Math.min(a_.n_spaceT, a_.n_spaceB),
			n_hintLeft = a_.n_hintLeft,
			n_hintTop  = a_.n_hintTop;

		// mirror the align
		a_.s_align = a_.s_align.replace('t', '-');
		a_.s_align = a_.s_align.replace('b', 't');
		a_.s_align = a_.s_align.replace('-', 'b');
		f_applyAlign(a_);

		// restore old coordinate if mirrored hint is less visible
		if (Math.min(a_.n_spaceT, a_.n_spaceB) < n_overlap)
			a_.n_hintTop = n_hintTop;
		a_.n_hintLeft = n_hintLeft;
	}
}

/* decodes the align parameter and calculates the coordinates of the hint */
function f_applyAlign (a_) {

	if (!re_align.exec(a_.s_align))
		throw new Error('001', 'Invalid format of align parameter: ' + a_.s_align);
	
	// decode alignment
	var n_align = RegExp.$1,
		n_top = a_.n_elementTop;

	// element vertical align
	if (n_align == 'm')
		n_top += Math.round(a_.n_elementHeight / 2);
	else if (n_align == 'b')
		n_top += a_.n_elementHeight + a_.n_gap;
	else
		n_top -= a_.n_gap;

	// hint vertical align
	n_align = RegExp.$3;
	if (n_align == 'm')
		n_top -= Math.round(a_.n_hintHeight / 2);
	else if (n_align == 'b')
		n_top -= a_.n_hintHeight;
		
	// element horizontal align
	var n_left = a_.n_elementLeft;
	n_align = RegExp.$2;
	if (n_align == 'c')
		n_left += Math.round(a_.n_elementWidth / 2);
	else if (n_align == 'r')
		n_left += a_.n_elementWidth + a_.n_gap;
	else
		n_left -= a_.n_gap;

	// hint horisontal align
	n_align = RegExp.$4;
	if (n_align == 'c')
		n_left -= Math.round(a_.n_hintWidth / 2);
	else if (n_align == 'r')
		n_left -= a_.n_hintWidth;

	a_.n_spaceT = n_top - a_.n_scrollTop - a_.n_margin,
	a_.n_spaceB = a_.n_clientHeight + a_.n_scrollTop - a_.n_margin - n_top - a_.n_hintHeight,
	a_.n_spaceL = n_left - a_.n_scrollLeft - a_.n_margin,
	a_.n_spaceR = a_.n_clientWidth + a_.n_scrollLeft - a_.n_margin - n_left - a_.n_hintWidth;

	a_.n_hintLeft = n_left;
	a_.n_hintTop  = n_top;
}

function f_onMouseMove(e_event) {
	if (!e_event && window.event)
		e_event = window.event;
	if (!e_event)
		return true;
	n_mouseX = e_event.pageX ? e_event.pageX : e_event.clientX + f_scrollLeft();
	n_mouseY = e_event.pageY ? e_event.pageY + 2 : e_event.clientY + f_scrollTop();
	return f_onwindowChange();
}

function f_onwindowChange() {
	var o_hint;
	for (var i = 0; i < A_HINTS.length; i++) {
		o_hint = A_HINTS[i];
		if (o_hint.a_cfg.follow && o_hint.o_lastHintID)
			f_hintPosition(o_hint.a_elements[o_hint.o_lastHintID], o_hint.a_hints[o_hint.o_lastHintID], o_hint.a_cfg);
	}
	return true;
}

/* browser abstraction layer */
function f_getPosition (e_elemRef, s_coord) {
	var n_pos = 0, n_offset,
		e_elem = e_elemRef;

	while (e_elem) {
		n_offset = e_elem["offset" + s_coord];
		n_pos += n_offset;
		e_elem = e_elem.offsetParent;
	}
	// margin correction in some browsers
	if (b_ieMac)
		n_pos += parseInt(document.body[s_coord.toLowerCase() + 'Margin']);
	else if (b_safari && (!this.o_block.b_relative || this.n_depth))
		n_pos -= n_offset;
	
	e_elem = e_elemRef;
	while (e_elem != document.body) {
		n_offset = e_elem["scroll" + s_coord];
		if (n_offset && e_elem.style.overflow == 'scroll')
			n_pos -= n_offset;
		e_elem = e_elem.parentNode;
	}
	return n_pos;
}

function f_clientWidth() {
	if (typeof(window.innerWidth) == 'number')
		return window.innerWidth;
	if (document.documentElement && document.documentElement.clientWidth)
		return document.documentElement.clientWidth;
	if (document.body && document.body.clientWidth)
		return document.body.clientWidth;
	return null;
}
function f_clientHeight() {
	if (typeof(window.innerHeight) == 'number')
		return window.innerHeight;
	if (document.documentElement && document.documentElement.clientHeight)
		return document.documentElement.clientHeight;
	if (document.body && document.body.clientHeight)
		return document.body.clientHeight;
	return null;
}
function f_scrollLeft() {
	if (typeof(window.pageXOffset) == 'number')
		return window.pageXOffset;
	if (document.body && document.body.scrollLeft)
		return document.body.scrollLeft;
	if (document.documentElement && document.documentElement.scrollLeft)
		return document.documentElement.scrollLeft;
	return 0;
}
function f_scrollTop() {
	if (typeof(window.pageYOffset) == 'number')
		return window.pageYOffset;
	if (document.body && document.body.scrollTop)
		return document.body.scrollTop;
	if (document.documentElement && document.documentElement.scrollTop)
		return document.documentElement.scrollTop;
	return 0;
}

getElement = document.all ?
	function (s_id) { return document.all[s_id] } :
	function (s_id) { return document.getElementById(s_id) };

// global variables
var A_HINTS = [],
	n_mouseX = 0,
	n_mouseY = 0,
	s_userAgent = navigator.userAgent.toLowerCase(),
	re_align = /^([tmb])([lcr])([tmb])([lcr])$/;

var b_mac = s_userAgent.indexOf('mac') != -1,
	b_ie5    = s_userAgent.indexOf('msie 5') != -1,
	b_ie6    = s_userAgent.indexOf('msie 6') != -1 && s_userAgent.indexOf('opera') == -1,
	b_ieMac  = b_mac && b_ie5,
	b_safari = b_mac && s_userAgent.indexOf('safari') != -1,
	b_opera6 = s_userAgent.indexOf('opera 6') != -1;


/***********************************************
* Bookmark site script- © 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
***********************************************/

function bookmark() {
	title = document.title;
	url = document.location.href;
	if (window.sidebar) { //firefox bookmark functionality
		window.sidebar.addPanel(title, url, "");
	} else if (window.external) { //ie favorite functionality
		window.external.AddFavorite(url, title);
	} else if (window.opera) {//opera virtual sidebar link
		a = document.createElement("A");
		a.rel = "sidebar";
		a.target = "_search";
		a.title = title;
		a.href = url;
		a.click();
	}
}

function bookmarklink() {
	if (window.sidebar || window.external || window.opera) { //we build link for only supported browsers
		document.write('<a href = "javascript:bookmark()");">Add to Favorites</a>');
	}
}
