<!--
/************************************************/
/* skScript.js                       	       	*/
/* Seeto Kui Online javascript functions       	*/
/* Developed by Andrew Douglas for      	   	*/
/* Seeto Kui 2006				      			*/
/************************************************/

//Variables
var whichflash
var intro
var advert
var negOffset
var posOffset
var browser
var locationStr
var domainroot="www.seetokui.com.pg" //variable used for google search
locationStr=location.pathname.toLowerCase()
browser=navigator.appName.toLowerCase()
//function ypSlideOutMenu(id, dir, left, top, width, height)
//default top is set to 175px for IE, changes to 148px if broswer is Mozilla/Netscape
var menu1 = new ypSlideOutMenu("menu1", "down", 115, 175, 187, 149)
var menu2 = new ypSlideOutMenu("menu2", "down", 230, 175, 126, 64)
var menu3 = new ypSlideOutMenu("menu3", "down", 360, 175, 126, 106)
var menu4 = new ypSlideOutMenu("menu4", "down", 488, 175, 130, 106)
var menu5 = new ypSlideOutMenu("menu5", "down", 614, 175, 126, 106)
var menu6 = new ypSlideOutMenu("menu6", "down", 739, 175, 130, 64)

//Array for scroller content on index.htm
var pausecontent=new Array()
pausecontent[0]='<font style="text-align:center" color="#FF0000"/>Seeto Kui is a leading distributor of grocery & merchandise products.<br />Among our agencies are some of the best known companies, brands, and products. Most of the brands that Papua New Guineans ....</font /><p /><a href="Seetokui/profile.htm" />Find out more...<img src="images/index/scrollimg1.jpg" /></a /></p />';
pausecontent[1]='<font style="text-align:center" color="#B9B900"/>Mainland Plumbing &amp; Hardware Supplies has operations in both Lae and Port Moresby. As the name says it, we are involved in the retailing of plumbing and hardware supplies. We stock leading brands in hardware and plumbing supplies including Caroma, British Paints...<p /><a style="color:#B9B900" href="Mainland/profile.htm" /><br />Find out more...<img src="images/index/scrollimg1_2.jpg" /></a /></font /></p />';
pausecontent[2]='<font style="text-align:center" color="#000000"/>Bowmans – Lae specialises in a wide variety of hardware, timber, electrical, stationery and furniture supplies. We retail a variety of brands such as British Paints, Dulux, Solahart, PNG Forest Products, Prima Cement and Tasman Insulation...</font /><p /><a style="color:#000000" href="Bowmans/profile.htm" />Find out more...<img src="images/index/scrollimg1_3.jpg" /></a /></p />';


//redirects browser location to selected value from combo box
function gogo(){
 location=document.combo.go.options[document.combo.go.selectedIndex].value
}//end gogo()

//Opens up image in a seperate windown
function openImage(page,w,h){
 window.open(page, 'Image','width='+w+',height='+h)
}//end openImage()

//Opens another window with set width and height
function openWindow(page){
 window.open(page, 'Win','width=550,height=400,scrollbars')
}//end openWindow()

// Google Internal Site Search script- By JavaScriptKit.com (http://www.javascriptkit.com)
function Gsitesearch(curobj){
 curobj.q.value="site:"+domainroot+" "+curobj.qfront.value
}//end Gsitesearch()

//Initialising slideShow, setting the height of content for browser, and initialising negOffset & posOffset vars for slideOutMenus
function iniSlide(){
 if (browser=="microsoft internet explorer"){
  document.getElementById("content").style.height=560
  negOffset=375.5
  posOffset=121.5
 }

 if (browser=="netscape"){
  document.getElementById("content").style.minHeight=600
  negOffset=396
  posOffset=100.5
 }
 //slideShow(div id, image path, # of images, transition speed, index)
 if (locationStr == "/" || locationStr == "/index.htm"){
  intro = new slideShow("intro", "images/index/", 18, 9000, 2)	
  intro.slideit()
 }

 advert = new slideShow("slideAd", "images/products/", 40, 2000, 1)
 advert.slideit()
}//end iniSlide()

function runSlide(obj){
 //Check who is calling runSlide if more than one slideShow by checking id paramter.
 if(obj == 1)
  advert.slideit()

 if(obj == 2)
  intro.slideit()
}//end runSlide()

//Fading slideshow
function slideShow(id, path, length, speed, index){
 this.id = index//this is created for the sole purpose of passing through function runSlide()
 this.slidespeed = speed
 this.slideimages = newSlideImages(path, length) //variable used to load and store images associcated with the sekected slideshow
 this.whichimage=0//random variable used to select pic in array
 this.imgobj=document.getElementById(id) //access img obj
 this.filtersupport=this.imgobj.filters //check for support for filters
 this.blenddelay=(this.filtersupport)? this.imgobj.filters[0].duration*3000 : 0
 this.imageholder=newImageHolder(this.slideimages)
 this.slideit=slideit
}//end slideShow()

function newSlideImages(path, length){
 endPath = ".jpg"
 slideimages = new Array()
 //checking location pathname so that the images are referenced correctly from each page...ie use "../" or not
 if (locationStr == "/" || locationStr== "/thanks.htm" || locationStr == "/catalogue.asp" || locationStr == "/index.htm" || locationStr == "/search.asp"){
  for(x=0; x<length; x++){
   slideimages[x]=path+x+endPath;
  }
 }
 else{
  pathImg = "../"+path
  for(x=0; x<length; x++){
   slideimages[x]=pathImg+x+endPath;
  }
 }		 
 return slideimages
}//end newSlideImages()

function newImageHolder(slideimages){
 imageholder=new Array()
 for (i=0;i<slideimages.length;i++){	//preload images
 imageholder[i]=new Image()
 imageholder[i].src=slideimages[i]}
 return (imageholder)
}//end newImageHolder()

function slideit(){
 if (this.whichimage==(tempindex=Math.floor(Math.random()*(this.imageholder.length)))){
  //?: is a conditional operator
  //ie. (condition)? iftrue : iffalse
  this.whichimage= this.whichimage==0? 1 : this.whichimage-1
 }
 else
  this.whichimage=tempindex
 if (this.filtersupport)
  this.imgobj.filters[0].apply()
  this.imgobj.src=this.imageholder[this.whichimage].src
	
 if (this.filtersupport)
  this.imgobj.filters[0].play()
	
 str="runSlide("+this.id+")"

 //Pass through id to runslide to determine which one (if more than one slideshow) to transition	
 setTimeout(str, this.slidespeed+this.blenddelay)
}//end slideit()

//trims string passed through
function trimString(sString){
 while (sString.substring(0,1) == ' '){
  sString = sString.substring(1, sString.length)
 }
 while (sString.substring(sString.length-1, sString.length) == ' '){
  sString = sString.substring(0,sString.length-1)
 }
 f=1
 l=2
 tempString =sString.substring(0,1) 
 spaces = false
 prev = true
 while (f<sString.length){
  if(sString.substring(f,l) != ' '){
   tempString = tempString + sString.substring(f,l)
   prev=false
   spaces=false
  }else{
   spaces=true
  }
 
  if ((spaces) && (!prev)){
   tempString=tempString+" "
   prev=true
   spaces=false
  }
  f=f+1
  l=l+1 
 }
 return tempString;
}//end trimString()

//Check the form for null value before submitting
function CheckForm(form) {
 //trim search word
 tString = trimString(document.frmSearch.qfront.value)
 //Check for a word to search
 if (tString==""){
  alert("Please enter at least one keyword to search")
  document.frmSearch.qfront.focus()
  return false
 }else{
  document.frmSearch.qfront.value=tString
  Gsitesearch(form)
  return true
  }
}//end CheckForm()

//Checks if email is in correct format ie. karma23@gmail.com
function validateEmail(){
 checkEmail = document.frmContact.email.value
 if (((checkEmail.indexOf('@') <= 0) ||  (checkEmail.indexOf('@')==checkEmail.indexOf('.')-1))|| ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))){
  alert("You have entered an invalid email address. Please try again.")
  document.frmContact.email.select()
  return false
 }
 else {
  return true
 }
}//end validateEmail()

//Checks contact form null values within
//the fullname, email and message fields
//and also calls the validateEmail function.
function CheckContactForm() {
 //trim search word
 strName = trimString(document.frmContact.fullname.value)
 strEmail = trimString(document.frmContact.email.value)
 strMsg = trimString(document.frmContact.message.value)

 if (strName==""){
  alert("Please enter your name")
  document.frmContact.fullname.focus()
  return false}
 else if (strEmail==""){
  alert("Please enter your email address")
  document.frmContact.email.focus()
  return false}
 else if (strMsg==""){
  alert("Please enter your message")
  document.frmContact.message.focus()
  return false}
 else{
  return validateEmail()}
}//end CheckContactForm()

//function to choose randomly a flashmovie to display
//all flash movies are located within the root folder
function randomFlash(){
 var flash = document.getElementById("flash")
 if (whichflash==(tempflash=Math.floor(Math.random()*(7)))){
 //?: is a conditional operator
 //ie. (condition)? iftrue : iffalse
 whichflash= whichflash==0? 1 : whichflash-1
 }
 else
 whichflash=tempflash
 var pathFlash
 if (locationStr == "/" || locationStr == "/thanks.htm" || locationStr == "/catalogue.asp" || locationStr == "/index.htm" || locationStr == "/search.asp"){
  pathFlash = "images/index/"
 }
 else{
  pathFlash = "../images/index/"
 }
 
 if (locationStr == "/bowmans/profile.htm"){
	 whichflash=5
	 }
 if (locationStr == "/foodmart/profile.htm"){
	 whichflash=6
	 }
 if (locationStr == "/seetokui/profile.htm"){
	 whichflash=2
	 }
 if (locationStr == "/skholdings/profile.htm"){
	 whichflash=1
	 }
 if (locationStr == "/mainland/profile.htm"){
	 whichflash=3
	 }	 
	 
 var content = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="211" height="266" align="middle">\n'
	 	  	 + '<param name="movie" value="'+pathFlash+ whichflash +'.swf">\n'
			 + '<param name=quality value=high>\n'
			 + '<param name="SCALE" value="noborder">\n'
			 + '<param name="Menu" value="0">\n'			 
			 + '<embed src="'+pathFlash+ whichflash +'.swf" menu=false align="middle" width="211" height="266" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" scale="noborder"></embed>\n'
			 + '</object>\n'
 flash.innerHTML=content
}//end randomFlash()

//MouseOverImage swap functions
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;
}//end MM_swapImgRestore()

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];}}
}//end MM_preloadImages()

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;
}//end MM_findObj()

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];}//end MM_swapImage()
}

//menu toggle functions from http://www.ku.co.nz
var imgMenu = new Array("","");
imgMenu[0] = "../images/menuExpand.gif";
imgMenu[1] = "../images/menuCollapse.gif";
//set menuState='collapse'||'expand'
if(document.getElementsByName) {
//better to use personalised values from session object
//Menu state vars for SiteMap
 menuStateAbout='collapse';
 menuStateBowmans='collapse';
 menuStateMainland='collapse';
 menuStateAssociates='collapse';
 menuStateSK='collapse';
 menuStateSKHoldings='collapse';
//Menu state vars for Agency pages on SK, MPS & BMS
 menuStateAlsynite='collapse';
 menuStateBrasshards='collapse';
 menuStateBurns='collapse';
 menuStateCaroma='collapse';
 menuStateEnware='collapse';
 menuStateGameco='collapse';
 menuStateIcon='collapse';
 menuStateIrwin='collapse';
 menuStateITW='collapse';
 menuStateJames='collapse';
 menuStateKaba='collapse';
 menuStateAcorn='collapse';
 menuStateMakita='collapse';
 menuStateOriental='collapse';
 menuStatePacific='collapse';
 menuStatePluspoint='collapse';
 menuStatePryda='collapse';
 menuStateRondo='collapse';
 menuStateSaint='collapse';
 menuStateSanyo='collapse';
 menuStateSolahart='collapse';
 menuStateStanley='collapse';
 menuStateTasman='collapse';
 menuStateTropex='collapse';
 menuStateTyco='collapse';
 menuStateCordage='collapse';
 menuStateGillette='collapse';
 menuStateKing='collapse';
 menuStateKees='collapse';
 menuStateOrientalFood='collapse';
 menuStateRhino='collapse';
 menuStateSanMiguel='collapse';
 menuStateURC='collapse';
 menuStateRFM='collapse';
 menuStatePN='collapse';
 menuStateCapilano='collapse';
 menuStateUIC='collapse';
 menuStateCountry='collapse';
 menuStatePringles='collapse';
 menuStateKraft='collapse';
 menuStateDunlop='collapse';
 menuStateSanford='collapse';
 menuStateHeinz='collapse';
 menuStatePantene='collapse';
 menuStateBritish='collapse';
 menuStateBilda='collapse';
 menuStateClark='collapse';
 menuStateDulux='collapse';
 menuStateFullmark='collapse';
 menuStateSelleys='collapse';
}
 else{
 //if browser cannot run menuToggle() 
 //then ensure user gets full menu
 menuStateAbout='expand';
 menuStateBowmans='expand';
 menuStateMainland='expand';
 menuStateAssociates='collapse';
 menuStateSK='expand';
 menuStateSKHoldings='expand';
 menuStateAlsynite='expand';
 menuStateBrasshards='expand';
 menuStateBurns='expand';
 menuStateCaroma='expand';
 menuStateEnware='expand';
 menuStateGameco='expand';
 menuStateIcon='expand';
 menuStateIrwin='expand';
 menuStateITW='expand';
 menuStateJames='expand';
 menuStateKaba='expand';
 menuStateAcorn='expand';
 menuStateMakita='expand';
 menuStateOriental='expand';
 menuStatePacific='expand';
 menuStatePluspoint='expand';
 menuStatePryda='expand';
 menuStateRondo='expand';
 menuStateSaint='expand';
 menuStateSanyo='expand';
 menuStateSolahart='expand';
 menuStateStanley='expand';
 menuStateTasman='expand';
 menuStateTropex='expand';
 menuStateTyco='expand';
 menuStateCordage='collapse';
 menuStateGillette='expand';
 menuStateKing='expand';
 menuStateKees='expand';
 menuStateOrientalFood='expand';
 menuStateRhino='expand';
 menuStateSanMiguel='expand';
 menuStateURC='expand';
 menuStateRFM='expand';
 menuStatePN='expand';
 menuStateCapilano='expand';
 menuStateUIC='expand';
 menuStateCountry='expand';
 menuStatePringles='collapse';
 menuStateKraft='expand';
 menuStateDunlop='expand';
 menuStateSanford='expand';
 menuStateHeinz='expand';
 menuStatePantene='collapse';
 menuStateBritish='expand';
 menuStateBilda='expand';
 menuStateClark='expand';
 menuStateDulux='expand';
 menuStateFullmark='expand';
 menuStateSelleys='expand';
}

function emptyToggle() {}//end emptyToggle()

function menuToggle(menu) {
 var list = null; 
 var button = null;
 if (document.getElementsByName) {
  list = document.getElementsByName(menu+"Body");
  //next line doesn't  work in IE6 so use eval()
  //button = document.getElementsByName(menu + "Button");
  button = eval('document.' + menu + 'Button');
  if(list) {	
   if(list[0].style.display == "none") {
    list[0].style.display = "block";
	button.src=imgMenu[1];
   } 
   else {
	list[0].style.display = "none";
	button.src=imgMenu[0];
   }
  }	
 }
 window.event.cancelBubble = true;
 return false;
}//end menuToggle()

function menuSet(menu, state) {
 //state="collapse"||state="expand"
 var list = null; 
 var button = null;
 if(document.getElementsByName) {
  list = document.getElementsByName(menu+"Body");
  button = eval('document.' + menu + 'Button');
  if(list) {	
   if (state=="expand") {
    list[0].style.display = "block";
    button.src=imgMenu[1];
   }
   if (state=="collapse") {
    list[0].style.display = "none";
	button.src=imgMenu[0];
   }
  }	
 }
 return false;
}//end menuSet()

//Functions to reposition slide down menus when window is resized
menu1.onactivate = function() {repositionMenu(menu1, -negOffset); }
menu2.onactivate = function() {repositionMenu(menu2, -negOffset+115); }
menu3.onactivate = function() {repositionMenu(menu3, -negOffset+244); }
menu4.onactivate = function() {repositionMenu(menu4, -negOffset+372); }
menu5.onactivate = function() {repositionMenu(menu5, posOffset); }
menu6.onactivate = function() {repositionMenu(menu6, posOffset+126); }

// this function repositions a menu to the speicified offset from center
function repositionMenu(menu, offset) {
 // the new left position should be the center of the window + the offset
 var newLeft = getWindowWidth() / 2 + offset;
 // setting the left position in netscape is a little different than IE
 menu.container.style ? menu.container.style.left = newLeft + "px" : menu.container.left = newLeft;
}//end repositionMenu()

// this function calculates the window's width - different for IE and netscape
function getWindowWidth() {
 var winWidth
 winWidth = window.innerWidth ? window.innerWidth : document.body.offsetWidth
 if (browser=="netscape"){
  if(winWidth<867)
   winWidth=840
 }

 return winWidth
}//end getWindowWidth()

 menuStateAbout='expand';
 menuStateBowmans='expand';
 menuStateMainland='expand';
 menuStateAssociates='collapse';
 menuStateSK='expand';
 menuStateSKHoldings='expand';
 menuStateAlsynite='collapse';
 menuStateBrasshards='collapse';
 menuStateBurns='collapse';
 menuStateCaroma='collapse';
 menuStateEnware='collapse';
 menuStateGameco='collapse';
 menuStateIcon='collapse';
 menuStateIrwin='collapse';
 menuStateITW='collapse';
 menuStateJames='collapse';
 menuStateKaba='collapse';
 menuStateAcorn='collapse';
 menuStateMakita='collapse';
 menuStateOriental='collapse';
 menuStatePacific='collapse';
 menuStatePluspoint='collapse';
 menuStatePryda='collapse';
 menuStateRondo='collapse';
 menuStateSaint='collapse';
 menuStateSanyo='collapse';
 menuStateSolahart='collapse';
 menuStateStanley='collapse';
 menuStateTasman='collapse';
 menuStateTropex='collapse';
 menuStateTyco='collapse';
 menuStateCordage='collapse';
 menuStateGillette='collapse';
 menuStateKing='collapse';
 menuStateKees='collapse';
 menuStateOrientalFood='collapse';
 menuStateRhino='collapse';
 menuStateSanMiguel='collapse';
 menuStateURC='collapse';
 menuStateRFM='collapse';
 menuStatePN='collapse';
 menuStateCapilano='collapse';
 menuStateUIC='collapse';
 menuStateCountry='collapse';
 menuStatePringles='collapse';
 menuStateKraft='collapse';
 menuStateDunlop='collapse';
 menuStateSanford='collapse';
 menuStateHeinz='collapse';
 menuStatePantene='collapse';
 menuStateBritish='collapse';
 menuStateBilda='collapse';
 menuStateClark='collapse';
 menuStateDulux='collapse';
 menuStateFullmark='collapse';
 menuStateSelleys='collapse';
-->