
//--------------------------------------------------------------
function awButtonSubmit(id1, event)
{
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (keyCode == 13 || keyCode == 3) 
    {
		event.returnValue=false;
		id1.returnValue=false;
	   	id1.click();
		if (document.all && document.getElementById)
		{
		}
	}
}  

//--------------------------------------------------------------
function awDualButtonSubmit(id1, id2, event)
{
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (keyCode == 13 || keyCode == 3) 
    {
		event.returnValue=false;
		if (id1 != undefined)
		{
			id1.returnValue=false;
	   		id1.click();
	   	}
	   	else if (id2 != undefined)
	   	{
			id2.returnValue=false;
	   		id2.click();
	   	}
	}
}  

//--------------------------------------------------------------
function SetQSBox(Obj, Val)
{
    obj.value = Val;
}  


var isInput;

//--------------------------------------------------------------
function IsInputSubmit()
{
	if (isInput)
	{
		return true;
	}
	else
	{
		return false;
	}
}  

var isQSInput;

//--------------------------------------------------------------
function awQSClick(rootpath, Keywords, InitialValue)
{

	if (isQSInput)
	{
		isQSInput=true;
		if (Keywords.value == InitialValue)
		{
			document.location = rootpath + "/Default.aspx?sID=5";
		}
		else
		{
		isInput = true;
		}
	}
	else
	{
		return false;
	}
	
}  

//--------------------------------------------------------------
function awPopUpWindow(url, target, features) {
	//"location=0,  statusbar=0,  menubar=0,  width=800,  height=300";
  	var theWindow =
    window.open(url, target, features);
 	theWindow.focus();
  	return theWindow;
}

//--------------------------------------------------------------	
function awOpenMailWin(x, y, params) 
{
	if (params =="")
		window.open(x,y,'status=no,scrollbars=no,resizable=no,width=400,height=425');
	else
		window.open(x, y, params);
}

/*Transputec site related functions*/


var popWin = null    // use this when referring to pop-up window

var winCount = 0

var winName = "popWin"

function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){

  var d_winLeft = 20  // default, pixels from screen left to window left

  var d_winTop = 20   // default, pixels from screen top to window top

  winName = "popWin" + winCount++ //unique name for each pop-up window

  closePopWin()           // close any previously opened pop-up window

  if (openPopWin.arguments.length >= 4)  // any additional features? 

            winFeatures = "," + winFeatures

  else 

            winFeatures = ""

  if (openPopWin.arguments.length == 6)  // location specified

            winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)

  else

            winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)

  popWin = window.open(winURL, winName, "width=" + winWidth 

                           + ",height=" + winHeight + winFeatures)

  }

function closePopWin(){    // close pop-up window if it is open

  if (navigator.appName != "Microsoft Internet Explorer" 

              || parseInt(navigator.appVersion) >=4) //do not close if early IE

            if(popWin != null) if(!popWin.closed) popWin.close()

  }

function getLocation(winWidth, winHeight, winLeft, winTop){

  return ""

  }

function getLocation(winWidth, winHeight, winLeft, winTop){

  var winLocation = ""

  if (winLeft < 0)

            winLeft = screen.width - winWidth + winLeft

  if (winTop < 0)

            winTop = screen.height - winHeight + winTop

  if (winTop == "cen")

            winTop = (screen.height - winHeight)/2 - 20

  if (winLeft == "cen")

            winLeft = (screen.width - winWidth)/2

  if (winLeft>0 & winTop>0)

            winLocation =  ",screenX=" + winLeft + ",left=" + winLeft

                                                + ",screenY=" + winTop + ",top=" + winTop

  else

            winLocation = ""

  return winLocation

  }




//--------------------------------------------------------------	
//Author: Brian Burke
//Function to overwrite an image with one from an array set up in the header.
function RandomImg(ImgId) 
{
		do 
		{								
			i=Math.floor(Math.random()*oIDArray.length); 
		}
			while(typeof(oIDArray[i])=="undefined");	
	//document.getElementById(ImgId).src= oIDArray[i];
	//document.getElementById(ImgId).alt= AltArray[i];
		document.write("<img src=" + oIDArray[i] + " alt='" + AltArray[i]> + "'");	
}

//--------------------------------------------------------------	
function randselect() 
{							
	do 
	{												
		i=Math.floor(Math.random()*Items.length); 
	}
	while(typeof(Items[i])=="undefined");	
	return i;								
}
//--------------------------------------------------------------
function awHomeRandomImage(ID, imgAlt, ImgID) 
{
	document.write("<img id='"+ ImgID +"' src='" + ID + "' alt='" + imgAlt + "' />");
}

function awRandomQuoteImageWithURL(Item, RootPath) 
{
	//Item is an array of field as follows
	// 0 = Id of Image
	// 1 = Image Alt Text
	// 2 = LanguageID
	// 3 = URL
	if (Item[3] != "")
		document.write("<a href='" + Item[3] + "'>" + "<img src='" + RootPath + "/fileserver.aspx?oID=" + Item[0] + "&amp;lID=" + Item[2] + "' alt='" + Item[1] + "' title='' /></a>");
	else
		document.write("<img src='" + RootPath + "/fileserver.aspx?oID=" + Item[0] + "&amp;lID=" + Item[2] + "' alt='" + Item[1] + "' title='' />");

}



function awRandomQuoteFlashWithURL(Item, RootPath) 
{
	//Item is an array of field as follows
	// 0 = Id of Image
	// 1 = Image Alt Text
	// 2 = LanguageID
	// 3 = URL
	if (Item[3] != "")
		document.write("<script type='text/javascript'>AC_FL_RunContent2( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','731','height','304','src','http://www.transputec.com/fileserver.aspx?oID=" + Item[0] + "','quality','high','menu','false','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','http://www.transputec.com/fileserver.aspx?oID=" + Item[0] + "' );</script><noscript><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='731' height='304'><param name='movie' value='http://www.transputec.com/fileserver.aspx?oID=" + Item[0] + "' /><param name='quality' value='high' /><param name='menu' value='false' /><embed src='http://www.transputec.com/fileserver.aspx?oID=" + Item[0] + "' quality='high' menu='false' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='731' height='304'></embed></object></noscript>");
	else
		document.write("<script type='text/javascript'>AC_FL_RunContent2( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','731','height','304','src','http://www.transputec.com/fileserver.aspx?oID=" + Item[0] + "','quality','high','menu','false','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','http://www.transputec.com/fileserver.aspx?oID=" + Item[0] + "' );</script><noscript><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='731' height='304'><param name='movie' value='http://www.transputec.com/fileserver.aspx?oID=" + Item[0] + "' /><param name='quality' value='high' /><param name='menu' value='false' /><embed src='http://www.transputec.com/fileserver.aspx?oID=" + Item[0] + "' quality='high' menu='false' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='731' height='304'></embed></object></noscript>");

}




//----------- scrolling big ad banners for the homepage ---------------------
function Banner(refreshTime, width, height, altText, start, random){
	this.objName = "bannerAd" + (Banner.count++);
	eval(this.objName + "=this");
	if (!refreshTime) this.refreshTime = 5000; else this.refreshTime = refreshTime*1000;
	if (!width) this.width = 460; else this.width = width;
	if (!height) this.height = 68; else this.height = height;
	if (random == null) this.random = 1; else this.random = random;
	this.altText = altText;
	this.ads = [];
	if (start) this.currentAd = start-1; else start = null;
	this.mySize = 0;

	this.Ad = function(src, href, target, mouseover) {
		var tempImage = new Image();
		tempImage.src = src;
		this.ads[this.mySize] = new Object();
		var ad = this.ads[this.mySize];
		ad.src = src;
		if (typeof(target) == "undefined" || target == null) ad.target = "_self"; else ad.target = target;
		ad.href = href;
		ad.mouseover = mouseover;
		this.mySize++;
	}

	this.link = function(){
		var	ad = this.ads[this.currentAd];
		if (ad.target == "_self"){
			location.href = ad.href;
		}
		else if (ad.target == "_blank" || ad.target == "_new"){
			open(ad.href,this.objName + "Win");
		}
		else top.frames[ad.target].location.href = ad.href;
	}

	this.showStatus = function(){
		var ad = this.ads[this.currentAd];
		if (ad.mouseover) status = ad.mouseover;
		else status = ad.href;
	}

	this.randomAd = function(){
		var n;
		do { n = Math.floor(Math.random() * (this.mySize)); } 
		while(n == this.currentAd);
		this.currentAd = n;
	}

	this.output = function(){
		var tempCode = "";
		if (this.mySize > 1){
			if (this.currentAd == null) this.randomAd();
			if (this.currentAd >= this.mySize) this.currentAd = this.mySize - 1;
			tempCode = '<a href="javascript:'+this.objName+'.link();"';
			tempCode += ' onMouseOver="' + this.objName + '.showStatus(); return true"';
			tempCode += ' onMouseOut="status=\'\';return true">';
			tempCode += '<img src="' + this.ads[this.currentAd].src + '" width="' + this.width;
			tempCode += '" name="' + this.objName + 'Img" height="' + this.height + '" ';
			if (this.altText) tempCode += 'alt="'+this.altText + '" ';
			tempCode += 'border="0" /></a>';
			document.write(tempCode);
			this.nextAd();
		} else document.write("Error: two banners must be defined for the script to work.");
	}

	this.newAd = function(){
		if (!this.random){	
			this.currentAd++;
			if (this.currentAd >= this.mySize)
			   this.currentAd = 0;
		}
		else {
			this.randomAd();
		}
		this.nextAd();
	}

	this.nextAd = function(){
		document.images[this.objName+ 'Img'].src = this.ads[this.currentAd].src;
		setTimeout(this.objName+'.newAd()',this.refreshTime)
	}
}
Banner.count = 0;



 function Mainsearch()
           {
              var Url = "http://195.224.200.136/ItdealerRetailer/default.aspx?Searchword=" + document.getElementById("proSearch").value ;
              window.open(Url,"IdealerEmbededEngine","width=950,height=450,scrollbars=auto");
             
          }

           

function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)  {
   var Url = "http://195.224.200.136/ItdealerRetailer/default.aspx?Searchword=" + document.getElementById("proSearch").value;

if(navigator.appVersion.indexOf("MSIE 17")>-1) {
var thewindow = window.showModelessDialog(Url,"IdealerEmbededEngine","dialogWidth:950px,dialogHeight:450px,scroll:no");
       thewindow.focus();

} else {

   var thewindow = window.open(Url,"IdealerEmbededEngine","width=950,height=450,scrollbars=auto");
       thewindow.focus();
      }          
          
   } else {
   return true;
}
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=1020,height=660,left = 130,top = 182');");
}

function popUpsmall(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=750,height=320,left = 130,top = 182');");
}


// to capture the key down event, so that form get submitted 
// when user presses enter key
// in the search text box

//document.onkeydown = keyDown
//if (document.layers) document.captureEvents(Event.KEYDOWN)
//function keyDown(KeyVal)
//{	
//	var keycode = (document.layers)?KeyVal.which:(event.keyCode);
//	bolSubmit = true
//			 
//	if (keycode == 13)
//	{
//		// checks if the input value is blank. 
//		//if so throw an error message.
//		var strUsername = document.frmlogin.Username.value;
//		var strPassword = document.frmlogin.Password.value;
//		if (strUsername == "Login ID")
//		{
//			alert("Please enter the User Name.");
//			document.frmlogin.Username.focus();
//			bolSubmit = false;
//			return(false);
//		}
//		if (strPassword == "")
//		{
//			alert("Please enter the Password.");
//			document.frmlogin.Password.focus();
//			bolSubmit = false;
//			return(false);
//		}
//		
//		if (bolSubmit == true)
//		{  
//			document.frmlogin.submit();
//		}
//	}
//}

function submitpage() 
{

	bolSubmit = true;
	var strUsername = document.Form1.Username.value;
	var strPassword = document.Form1.Password.value;
	
	if ((strUsername == "Login ID") || (strUsername == ""))
	{
		alert("Please enter a value for \"Username\".");
		document.Form1.Username.focus();
		bolSubmit = false;
	}
	if (bolSubmit == true) {
		if (strPassword == "")
		{
			alert("Please enter a value for \"Password\".");
			document.Form1.Password.focus();
			bolSubmit = false;
		}
	}
		
	if (bolSubmit == true)
	{  
		document.Form1.action = 'http://195.224.200.139/TopsUK/login_process.asp';
	document.Form1.target = '_blank';
		document.Form1.submit();
	}
}

function clearme() 
{
var strUsername = document.Form1.Username.value;
if (strUsername == "Login ID")
	{
	document.Form1.Username.value = "";
	}
}


