var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};

var scroller = {
  init:   function() {

	//alert('hi');
    //collect the variables
    scroller.docH = document.getElementById("content").offsetHeight;
    scroller.contH = document.getElementById("container").offsetHeight;
    scroller.scrollAreaH = document.getElementById("scrollArea").offsetHeight;
      
    //calculate height of scroller and resize the scroller div
    //(however, we make sure that it isn't to small for long pages)
//scroller.scrollH = (scroller.contH * scroller.scrollAreaH) / scroller.docH;
  scroller.scrollH = 15;
    //if(scroller.scrollH < 15) scroller.scrollH = 15;
    document.getElementById("scroller").style.height = Math.round(scroller.scrollH) + "px";
    
    //what is the effective scroll distance once the scoller's height has been taken into account
    scroller.scrollDist = Math.round(scroller.scrollAreaH-scroller.scrollH);
    
    //make the scroller div draggable
    Drag.init(document.getElementById("scroller"),null,0,0,-1,scroller.scrollDist);
    
    //add ondrag function
    document.getElementById("scroller").onDrag = function (x,y) {
      var scrollY = parseInt(document.getElementById("scroller").style.top);
      var docY = 0 - (scrollY * (scroller.docH - scroller.contH) / scroller.scrollDist);
      document.getElementById("content").style.top = docY + "px";
    }
  }
}

onload = scroller.init;



////////////   CHANGE CONTENT IN DIV FOR ABOUT US PAGE    /////////////////////


function abtusContent()
{
	document.getElementById("abtus").href = '#';
	document.getElementById("abtus").style.color = '#000000';
	document.getElementById("abtus").style.cursor = 'default';
	
	document.getElementById("founder").href = 'javascript:founderContent();';
	document.getElementById("founder").style.color = '#FFFFFF';
	document.getElementById("founder").style.cursor = 'pointer';
	document.getElementById("founder").style.cursor = 'hand';
	
	document.getElementById("philosopy").href = 'javascript:philosophyContent();';
	document.getElementById("philosopy").style.color = '#FFFFFF';
	document.getElementById("philosopy").style.cursor = 'pointer';
	document.getElementById("philosopy").style.cursor = 'hand';
	
	document.getElementById("people").href = 'javascript:peopleContent();';
	document.getElementById("people").style.color = '#FFFFFF';
	document.getElementById("people").style.cursor = 'pointer';
	document.getElementById("people").style.cursor = 'hand';
	
	document.getElementById("futureplan").href = 'javascript:futurePlanContent();';
	document.getElementById("futureplan").style.color = '#FFFFFF';
	document.getElementById("futureplan").style.cursor = 'pointer';
	document.getElementById("futureplan").style.cursor = 'hand';
	
	
	document.getElementById("scrollArea").style.visibility = 'visible';
	document.getElementById("content").innerHTML='<strong>Two Decades of Delicious Business</strong><br><br>The story of Samrat Namkeen is sweet and simple.<br><br>It began as a small home-made eatables unit at Swaminarayan Temple, Narayan Ghat, Ahmedabad, Gujarat, INDIA in 1979.<br><br>Wafers, Sevs, Bhujias, Daals, Chavana, Cheevda . . .made in ancient gastronomic traditions of Gujarat.<br><br>The tastes were irresistible, the products are fresh, and the packing is hygenic.<br><br>Customers responded enthusiastically. And in the following years, the company evolved continuously, dictated by customer demands and market trends.<br><br>Today, Samrat is a snack foods conglomerate that manufactures 24 popular products. These products reach taste-lovers in every nook and corner of Gujarat.They are also exported quite successfully.<br><br>Today, Samrat is quoted as one of Gujarat`s most inspiring scratch-to-riches stories.<br><br>Not really surprising, as there was no way such good taste could lose.'
}

function founderContent()
{
	
	document.getElementById("abtus").href = 'javascript:abtusContent();';
	document.getElementById("abtus").style.color = '#FFFFFF';
	document.getElementById("abtus").style.cursor = 'pointer';
	document.getElementById("abtus").style.cursor = 'hand';
	
	document.getElementById("founder").href = '#';
	document.getElementById("founder").style.color = '#000000';
	document.getElementById("founder").style.cursor = 'default';
	
	document.getElementById("philosopy").href = 'javascript:philosophyContent();';
	document.getElementById("philosopy").style.color = '#FFFFFF';
	document.getElementById("philosopy").style.cursor = 'pointer';
	document.getElementById("philosopy").style.cursor = 'hand';
	
	document.getElementById("people").href = 'javascript:peopleContent();';
	document.getElementById("people").style.color = '#FFFFFF';
	document.getElementById("people").style.cursor = 'pointer';
	document.getElementById("people").style.cursor = 'hand';
	
	document.getElementById("futureplan").href = 'javascript:futurePlanContent();';
	document.getElementById("futureplan").style.color = '#FFFFFF';
	document.getElementById("futureplan").style.cursor = 'pointer';
	document.getElementById("futureplan").style.cursor = 'hand';
	
	document.getElementById("scrollArea").style.visibility = 'visible';
	document.getElementById("content").innerHTML='<strong>A Story of Guts &amp; Good Taste</strong><br><br>1979. Mr. Jayshankar S. Vaid was young, and his mind was brimming with ideas of enterprise.<br><br>Through the week, he scout around for an entrepreneurial break. He visited and studed various industries weigh pros and cons.<br><br>On weekends, Jayshankar indulge in what  most of his friends thought was an unusual hobby -- making Namkeens.<br><br>On those days, he had turned his kitchen into a virtual R&amp;D lab for his experiments in Namkeens. Later, he would relish these with his family and friends.<br><br>Then one day, in a moment dictated by destiny, the thought struck him : why not turn the hobby into a business? After all, everyone likes to eat good things.<br><br>Thus began Jayshankar`s life as a Namkeen manufacturer.<br><br>He was a modest man, but named his product `Samrat`, meaning `King / Emperor` , because he was confident of its taste value.<br><br>He himself prepared the Namkeens, pack them and supplied to homes nearby.<br><br>There was no way that such conviction could lose.<br><br>Today, he employs more than 210 people and more than 23 sumptuous food items are marketed under the Samrat brand.<br><br>Today, he has taste experts, foods scientists, management veterans, and a network of marketing channels, to take the Samrat brand far and wide.<br><br>But there is one aspect of his business that he still directly controls -- QUALITY.<br><br>And this is the reason why Samrat products still retain their home-like crunchy taste  and freshness.<br><br>And this is the reason of Jayshankar S. Vaid`s success.'
}

function philosophyContent()
{
	document.getElementById("abtus").href = 'javascript:abtusContent();';
	document.getElementById("abtus").style.color = '#FFFFFF';
	document.getElementById("abtus").style.cursor = 'pointer';
	document.getElementById("abtus").style.cursor = 'hand';
	
	document.getElementById("founder").href = 'javascript:founderContent();';
	document.getElementById("founder").style.color = '#FFFFFF';
	document.getElementById("founder").style.cursor = 'pointer';
	document.getElementById("founder").style.cursor = 'hand';
	
	document.getElementById("philosopy").href = '#';
	document.getElementById("philosopy").style.color = '#000000';
	document.getElementById("philosopy").style.cursor = 'default';
	
	document.getElementById("people").href = 'javascript:peopleContent();';
	document.getElementById("people").style.color = '#FFFFFF';
	document.getElementById("people").style.cursor = 'pointer';
	document.getElementById("people").style.cursor = 'hand';
	
	document.getElementById("futureplan").href = 'javascript:futurePlanContent();';
	document.getElementById("futureplan").style.color = '#FFFFFF';
	document.getElementById("futureplan").style.cursor = 'pointer';
	document.getElementById("futureplan").style.cursor = 'hand';
	
	document.getElementById("scrollArea").style.visibility = 'visible';
	document.getElementById("content").innerHTML='<strong>More Than Just Tastes : A Whole Tradition</strong><br><br>Give people good taste, and they will love it.<br><br>Give them a variety of good tastes, and they will love you. Give them freshness, hygiene and home-like quality, and they will make you part of their lives.<br><br>Give them new food products, new blends and new taste experiences and they will make you part of their culture.<br><br>That`s what we want to become. A part of Gujarat`s culture.<br><br>In the next decade, when people reminisce on life in Gujarat, we want the name of Samrat Namkeen to be mentioned as one of the most endearing aspects of that life.<br><br>Big aim, that. But we keep trying, because we belive that no defeat is final untill you stop trying.<br><br>And while we keep trying , you keep enjoying !'
}

function peopleContent()
{
	document.getElementById("abtus").href = 'javascript:abtusContent();';
	document.getElementById("abtus").style.color = '#FFFFFF';
	document.getElementById("abtus").style.cursor = 'pointer';
	document.getElementById("abtus").style.cursor = 'hand';
	
	document.getElementById("founder").href = 'javascript:founderContent();';
	document.getElementById("founder").style.color = '#FFFFFF';
	document.getElementById("founder").style.cursor = 'pointer';
	document.getElementById("founder").style.cursor = 'hand';
	
	document.getElementById("philosopy").href = 'javascript:philosophyContent();';
	document.getElementById("philosopy").style.color = '#FFFFFF';
	document.getElementById("philosopy").style.cursor = 'pointer';
	document.getElementById("philosopy").style.cursor = 'hand';
	
	document.getElementById("people").href = '#';
	document.getElementById("people").style.color = '#000000';
	document.getElementById("people").style.cursor = 'default';
	
	document.getElementById("futureplan").href = 'javascript:futurePlanContent();';
	document.getElementById("futureplan").style.color = '#FFFFFF';
	document.getElementById("futureplan").style.cursor = 'pointer';
	document.getElementById("futureplan").style.cursor = 'hand';
	
	document.getElementById("content").innerHTML='<strong>Bonded by Quality, Spurred by  Success</strong><br><br>What began modestly in 1979, with a single man functioning as proprietor, manufacturer and supplier, is today a large enterprise employing more than 225 people.<br><br>This proud workforce includes taste scientists, foodstuff industry veterans, management experts, experienced chefs and recipe-makers, and plant engineers.<br><br>All these people, from the Directors to the workpersons at the plant, are bonded by the Samrat brand of quality. It`s the guiding sprit that permeates all endeavours of the company.<br><br>The corporate culture at Samrat Namkeens prompts every one of these 225 people to contribute to the quality chain, at his / her individual level.<br><br>And together; they have realised founder Mr. Jayshankar`s quality-driven vision, beyond his wildest dreams.'
	document.getElementById("scrollArea").style.visibility = 'hidden';
}
function futurePlanContent()
{
	document.getElementById("abtus").href = 'javascript:abtusContent();';
	document.getElementById("abtus").style.color = '#FFFFFF';
	document.getElementById("abtus").style.cursor = 'pointer';
	document.getElementById("abtus").style.cursor = 'hand';
	
	document.getElementById("founder").href = 'javascript:founderContent();';
	document.getElementById("founder").style.color = '#FFFFFF';
	document.getElementById("founder").style.cursor = 'pointer';
	document.getElementById("founder").style.cursor = 'hand';
	
	document.getElementById("philosopy").href = 'javascript:philosophyContent();';
	document.getElementById("philosopy").style.color = '#FFFFFF';
	document.getElementById("philosopy").style.cursor = 'pointer';
	document.getElementById("philosopy").style.cursor = 'hand';
	
	document.getElementById("people").href = 'javascript:peopleContent();';
	document.getElementById("people").style.color = '#FFFFFF';
	document.getElementById("people").style.cursor = 'pointer';
	document.getElementById("people").style.cursor = 'hand';
	
	document.getElementById("futureplan").href = '#';
	document.getElementById("futureplan").style.color = '#000000';
	document.getElementById("futureplan").style.cursor = 'default';
	
	document.getElementById("scrollArea").style.visibility = 'visible';
	
	document.getElementById("content").innerHTML='<strong>Continuous Innovations, Continuing  Leadership</strong><br><br>In the future, we will bring more and more tastes into more and more homes around the world.<br><br>We will bring out more and more traditional food items of Gujarat in a modern packaged format, and offer them to taste-lovers everywhere.<br><br>We will experiment more and introduce more blend recipes that combine traditional Namkeens with popular food items from other States of India and with even Continental and European cuisines.<br><br>We will develop newer and newer methods of long-term storage and freshness retention.<br><br>We will set up more and more domestic and overseas distribution outlets to take the Samrat brand to more markets.<br><br>However there`s one thing about us that will never change -- that distinct home-made taste which has been the signature of our success.<br><br>Even in the new century, in every packet of Samrat Namkeen, you will find that special element of human care.<br><br>May the taste gods be with you !'
	//document.getElementById("scrollArea").style.visibility = 'hidden';
}


////////////   CHANGE CONTENT IN DIV FOR SALES & NETWORK PAGE    /////////////////////

function performanceContent()
{
	document.getElementById("performance").href = '#';
	document.getElementById("performance").style.color = '#000000';
	document.getElementById("performance").style.cursor = 'default';
	
	document.getElementById("network").href = 'javascript:networkContent();';
	document.getElementById("network").style.color = '#FFFFFF';
	document.getElementById("network").style.cursor = 'pointer';
	document.getElementById("network").style.cursor = 'hand';
	
	
	document.getElementById("content").innerHTML='<strong>Quantity Always Follows Quality</strong><br><br>Today, the domestic sales of Samrat Namkeens register a steady rise, year after year.<br><br>For instance, our turnover has risen eight-fold in the last five years (1992-1998) alone.<br><br>During this period, a total of 2,00,00,00 kg of Samrat Namkeens were consumed by taste-lovers around the world.<br><br>Today, the Samrat brand reaches the length and breadth of India. In fact, It`s today one of India`s best known snack foods brand, and the undoubted market leader in Western India.<br><br>And its export focus has been getting sharper and sharper. It is already a member of the Snack Foods Association, Virginia, USA.<br><br>To put it briefly, the world would hear more and more of us in the future.<br><br>Or rather, they would be devouring more and more of us in the future.'
}

function networkContent()
{

	document.getElementById("performance").href = 'javascript:performanceContent();';
	document.getElementById("performance").style.color = '#FFFFFF';
	document.getElementById("performance").style.cursor = 'pointer';
	document.getElementById("performance").style.cursor = 'hand';
	
	document.getElementById("network").href = '#';
	document.getElementById("network").style.color = '#000000';
	document.getElementById("network").style.cursor = 'default';
	
	
	document.getElementById("content").innerHTML='<strong>Success Through Smart Strategies and Sheer Taste</strong><br><br>Today, the Samrat brand posts a turnover of more than Rs. 15 crore, and reaches the length and breadth of India through a network of more than 200 Distributors and 35,000 Retailers.<br><br>Samrat was the first of its kind to receive official permission of the Indian Railways to supply its products inside railway stations -- opening up for the brand a gigantic marketplace.<br><br>Today, it is successfully exported to the US, the Middle East, South Africa and many other countries. It has obtained memberships of the Snack Foods Association, USA, Agricultural & Processed Food Products Export Development Authority (APEDA), India, Gujarat Chamber of Commerce & Industry (GCCI), Gujarat International Trade Promotion Council, Ahmedabad Mithai & Farsan Association, etc. It also has export approvals from the Reserve Bank of India, and the Import Export Code.<br><br>And the company`s future vision has laid much emphasis on export promotion.'
}