

//Tab JS begins

function ddtabcontent(tabinterfaceid){

	this.tabinterfaceid=tabinterfaceid 

	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") 

	this.enabletabpersistence=true

	this.hottabspositions=[] 

	this.currentTabIndex=0 

	this.subcontentids=[] 

	this.revcontentids=[] 

	this.selectedClassTarget="link" 

}



ddtabcontent.getCookie=function(Name){ 

	var re=new RegExp(Name+"=[^;]+", "i"); 

	if (document.cookie.match(re)) 

		return document.cookie.match(re)[0].split("=")[1] 

	return ""

}



ddtabcontent.setCookie=function(name, value){

	document.cookie = name+"="+value+";path=/" 

}



ddtabcontent.prototype={



	expandit:function(tabid_or_position){ 

		this.cancelautorun() 

		var tabref=""

		try{

			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) 

				tabref=document.getElementById(tabid_or_position)

			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel"))

				tabref=this.tabs[tabid_or_position]

		}

		catch(err){alert("Invalid Tab ID or position entered!")}

		if (tabref!="") 

			this.expandtab(tabref) 

	},



	cycleit:function(dir, autorun){ 

		if (dir=="next"){

			var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0

		}

		else if (dir=="prev"){

			var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1

		}

		if (typeof autorun=="undefined") 

			this.cancelautorun() 

		this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])

	},



	setpersist:function(bool){ 

			this.enabletabpersistence=bool

	},



	setselectedClassTarget:function(objstr){ 

		this.selectedClassTarget=objstr || "link"

	},



	getselectedClassTarget:function(tabref){ 

		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref

	},



	urlparamselect:function(tabinterfaceid){

		var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i")) 

		return (result==null)? null : parseInt(RegExp.$1) 

	},



	expandtab:function(tabref){

		var subcontentid=tabref.getAttribute("rel")

		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""

		this.expandsubcontent(subcontentid)

		this.expandrevcontent(associatedrevids)

		for (var i=0; i<this.tabs.length; i++){ 

			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""

		}

		if (this.enabletabpersistence)

			ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)

		this.setcurrenttabindex(tabref.tabposition) 

	},



	expandsubcontent:function(subcontentid){

		for (var i=0; i<this.subcontentids.length; i++){

			var subcontent=document.getElementById(this.subcontentids[i]) 

			subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" 

		}

	},



	expandrevcontent:function(associatedrevids){

		var allrevids=this.revcontentids

		for (var i=0; i<allrevids.length; i++){ 

			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"

		}

	},



	setcurrenttabindex:function(tabposition){ 

		for (var i=0; i<this.hottabspositions.length; i++){

			if (tabposition==this.hottabspositions[i]){

				this.currentTabIndex=i

				break

			}

		}

	},



	autorun:function(){ 

		this.cycleit('next', true)

	},



	cancelautorun:function(){

		if (typeof this.autoruntimer!="undefined")

			clearInterval(this.autoruntimer)

	},



	init:function(automodeperiod){

		var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid) 

		var selectedtab=-1 

		var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) 

		this.automodeperiod=automodeperiod || 0

		for (var i=0; i<this.tabs.length; i++){

			this.tabs[i].tabposition=i 

			if (this.tabs[i].getAttribute("rel")){

				var tabinstance=this

				this.hottabspositions[this.hottabspositions.length]=i 

				this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel") 

				this.tabs[i].onclick=function(){

					tabinstance.expandtab(this)

					tabinstance.cancelautorun() 

					return false

				}

				if (this.tabs[i].getAttribute("rev")){ 

					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))

				}

				if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){

					selectedtab=i 

				}

			}

		} 

		if (selectedtab!=-1) 

			this.expandtab(this.tabs[selectedtab]) 

		else 

			this.expandtab(this.tabs[this.hottabspositions[0]]) 

		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){

			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)

		}

	} 

} 

//Tab JS Ends



//dropdownmenu begins

var cssdropdown={

disappeardelay: 250, 

disablemenuclick: true,

enableswipe: 1, 

enableiframeshim: 1, 

dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,



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;

},



swipeeffect:function(){

if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){

this.bottomclip+=10+(this.bottomclip/10) //unclip drop down menu visibility gradually

this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"

}

else

return

this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 10)

},



showhide:function(obj, e){

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 (this.enableswipe==1){

if (typeof this.swipetimer!="undefined")

clearTimeout(this.swipetimer)

obj.clip="rect(0 auto 0 0)" //hide menu via clipping

this.bottomclip=0

this.swipeeffect()

}

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.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15

this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth

if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  

edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth

}

else{

var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset

var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18

this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight

if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ 

edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight

if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) 

edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge

}

}

return edgeoffset

},



dropit:function(obj, e, dropmenuID){

if (this.dropmenuobj!=null) 

this.dropmenuobj.style.visibility="hidden" 

this.clearhidemenu()

if (this.ie||this.firefox){

obj.onmouseout=function(){cssdropdown.delayhidemenu()}

obj.onclick=function(){return !cssdropdown.disablemenuclick} 

this.dropmenuobj=document.getElementById(dropmenuID)

this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}

this.dropmenuobj.onmouseout=function(e){cssdropdown.dynamichide(e)}

this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}

this.showhide(this.dropmenuobj.style, e)

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.positionshim() 

}

},



positionshim: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'

},



contains_firefox:function(a, b) {

while (b.parentNode)

if ((b = b.parentNode) == a)

return true;

return false;

},



dynamichide:function(e){

var evtobj=window.event? window.event : e

if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))

this.delayhidemenu()

else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))

this.delayhidemenu()

},



delayhidemenu:function(){

this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'; cssdropdown.hideshim()",this.disappeardelay) //hide menu

},



clearhidemenu:function(){

if (this.delayhide!="undefined")

clearTimeout(this.delayhide)

},



startchrome:function(){

for (var ids=0; ids<arguments.length; ids++){

var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")

for (var i=0; i<menuitems.length; i++){

if (menuitems[i].getAttribute("rel")){

var relvalue=menuitems[i].getAttribute("rel")

menuitems[i].onmouseover=function(e){

var event=typeof e!="undefined"? e : window.event

cssdropdown.dropit(this,event,this.getAttribute("rel"))

}

}

}

}

if (window.createPopup && !window.XmlHttpRequest){ 

document.write('<IFRAME id="iframeshim"  src="" style="display: none; left: 0; top: 0; z-index: 90; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')

this.shimobject=document.getElementById("iframeshim")

}

}



}

//dropdownmenu ends



// Ajax JS begins

var loadedobjects=""

var rootdomain="http://"+window.location.hostname



function ajaxpage(url, containerid){

var page_request = false

if (window.XMLHttpRequest) 

page_request = new XMLHttpRequest()

else if (window.ActiveXObject){ 

try {

page_request = new ActiveXObject("Msxml2.XMLHTTP")

} 

catch (e){

try{

page_request = new ActiveXObject("Microsoft.XMLHTTP")

}

catch (e){}

}

}

else

return false

page_request.onreadystatechange=function(){

loadpage(page_request, containerid)

}

page_request.open('GET', url, true)

page_request.send(null)

}



function loadpage(page_request, containerid){

if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))

document.getElementById(containerid).innerHTML=page_request.responseText

}



function loadobjs(){

if (!document.getElementById)

return

for (i=0; i<arguments.length; i++){

var file=arguments[i]

var fileref=""

if (loadedobjects.indexOf(file)==-1){ 

if (file.indexOf(".js")!=-1){ 

fileref=document.createElement('script')

fileref.setAttribute("type","text/javascript");

fileref.setAttribute("src", file);

}

else if (file.indexOf(".css")!=-1){ 

fileref=document.createElement("link")

fileref.setAttribute("rel", "stylesheet");

fileref.setAttribute("type", "text/css");

fileref.setAttribute("href", file);

}

}

if (fileref!=""){

document.getElementsByTagName("head").item(0).appendChild(fileref)

loadedobjects+=file+" " 

}

}

}



var rightpanel1obj=document.getElementById("rightpanel1")

function ietruebody(){

return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body

}

document.getElementById("rightpanel1").onmouseover=function(){ 

}

document.getElementById("rightpanel1").onmouseout=function(){ 

}



//  Ajax JS ends



// Mouse Hover JS begins



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}





// Mouse Hover JS ends

//search Functions Start
function checkvalid() {
   mpcode = trim(document.getElementById("prod_code").value);
   mpname = trim(document.getElementById("prod_name").value);
   if(mpcode=="" && mpname=="") {
      alert('Please Enter Product Code or Product Name');
      return false;
   }
   if(document.getElementById("searchtype").value=="pcode" && mpcode=="") {
      alert('Please Enter Product Code ');
      return false;
   }
   if(document.getElementById("searchtype").value=="pname" && mpname=="") {
      alert('Please Enter Product Name');
      return false;mpname
   }
   if(mpcode=="") {
     document.getElementById("searchval").value = mpname; 
   } else {
     document.getElementById("searchval").value = mpcode;  
   }
   
   return true;
}

function moveval(mval) {
   document.getElementById("searchtype").value=mval;
   if(mval=="pcode") document.getElementById("prod_name").value="";
   if(mval=="pname") document.getElementById("prod_code").value="";
}

function trim(str) {
   while(str.substring(0,1) == ' '){
      str = str.substring(1);
   }
   while(str.substring(str.length-1,str.length) == ' '){
      str = str.substring(0,str.length-1);
   }
   return str;
}
//search Functions end





