// JavaScript Document

function showQuickview(prodid) {
	document.getElementById(prodid).style.display = "block";	
}
function hideQuickview(prodid) {
	document.getElementById(prodid).style.display = "none";	
}

function NavbarOver(type) {
document.getElementById(type).className='selectedtab';
	}


function NavbarDone(type) {
document.getElementById(type).className='';
}



//Movable Div
/////////////////////////////////////////////////////////////////////////////////////

// Coded by Waseem Khan
// Developer at PakCoders
// Downloaded from http://www.Web-Tricks.info

function getID(id)
{
	return document.getElementById(id);
}

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    return;
  }

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    return;
  }
}
var browser = new Browser();


var dragObj = new Object();
function dragStart(event, id) {
  var x, y;
  dragObj.elNode = getID(id);
  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}

///////////////////////////////////////////////////////////////////////////////////////////////////////

function hideAllDivsFirst() {
		faqD = document.getElementsByTagName('div');
		for(var i=0;i<faqD.length;i++) {
			if(faqD[i].className=="faqTab") {
				faqD[i].style.display = "none";
			}
		}
	}
	function showFAQ(which) {
		hideAllDivsFirst();
		targetDivName = "faq_"+which;
		tabLiName = "tab_"+which;
		document.getElementById(targetDivName).style.display = "block";
	}
	function swapTopTab(whichID,onoff) {
		if(document.getElementById(whichID).className=="tab_sub") document.getElementById(whichID).className = "tab_sub_over";
		else if(document.getElementById(whichID).className=="tab_sub_over") document.getElementById(whichID).className = "tab_sub";
	}
	function hilite(tID) {
var Pathname2 = new String(document.location.href);

if (Pathname2.indexOf("p-") !=-1) {
		
		var allD = document.getElementsByTagName('li');
		for(var j=0;j<allD.length;j++) {
			if(allD[j].className=="tab_sub_selected") {
				allD[j].className = "tab_sub";
			}
		}
		var targetContentDiv = tID.split("_")[1];
		document.getElementById(tID).className = "tab_sub_selected";
		showFAQ(targetContentDiv);
	}


}
function viewall() {
var Pathname = new String(document.location.search+'');
var url = window.location.toString();
var anchor_index = url.indexOf('&DistID');



if (Pathname.indexOf("pagenum") !=-1) {
	var str2=location.search.match(/\bpagenum\= *([^\&]+)/);
	var varid5=str2[1];
	
	self.location=location.search.replace(varid5, "1")+'&pagesize=9999&sortEntity=0&SecID=0&DistID=0';
}

else if (Pathname.indexOf("pagesize=") !=-1) {
	var str=location.search.match(/\bpagesize\= *([^\&]+)/);
	var varid1=str[1];


self.location=location.search.replace(varid1, 9999);

}



else {
	self.location=location+'?pagesize=9999&sortEntity=0&SecID=0&DistID=0';
}

}
function appendsort(sortentity) {
var Pathname = new String(document.location.search+'');
var url = window.location.toString();
var anchor_index = url.indexOf('&sortEntity');

if (Pathname.indexOf("sortEntity=") !=-1) {
	var str=location.search.match(/\bsortEntity\= *([^\&]+)/);
	var varid4=str[1];
		self.location=location.search.replace(varid4, sortentity);

}
else if (Pathname.indexOf("pagenum") !=-1) {
	self.location=location+'&pagesize=0&sortEntity='+sortentity+'&SecID=0&DistID=0';
}

else {
	self.location=location+'?pagenum=1&pagesize=0&sortEntity='+sortentity+'&SecID=0&DistID=0';
}
}

function hideviewall() {
	var Pathname = new String(document.location.search+'');
	if (Pathname.indexOf("pagesize=9999") !=-1) {

	document.getElementById("viewall").style.display = "none";
	document.getElementById("viewall_bottom").style.display = "none";

}
	
}

/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


window.onload=function() {
	hideviewall();

}