home *** CD-ROM | disk | FTP | other *** search
/ PC User 2004 November / PCU1104CD2.iso / interfce / interfce.js < prev    next >
Encoding:
JavaScript  |  2004-09-10  |  7.0 KB  |  212 lines

  1. //FRAME DIRECTOR
  2. function setFrames(menubar,something) {parent.contents.document.location.href= something;
  3.                                   document.location.href = menubar;
  4.                                  }
  5.  
  6. function setFrames2(menubar,something) {parent.contents.document.location.href= something;
  7.                                   parent.menubar.document.location.href = menubar;
  8.                                  }
  9.  
  10. // ROTATING ADS
  11.  
  12. //Laurence Kwek - last modified 25 September 2001
  13.  
  14. //User defined variables - change these variables to alter the behaviour of the script
  15. var ImageFolder = "ads/images/"; //Folder name containing the images for product page
  16. var ImageFolderindex = "ads/images/"; //Folder name containing the images for main page
  17. var ImageFileNames = new Array('pcuser.swf','LG.gif' ); //List of images to use
  18. var ImageURLs = new Array('../interfce/frmesublg.htm'); //List of hyperlinks associated with the list of images
  19. var ImageURLsindex = new Array('interfce/frmesublg.htm'); //List of hyperlinks associated with the list of images
  20. var DefaultURL = 'default.htm'; //Default hyperlink for the Banner Ad
  21. var DisplayInterval = 5; //Number of seconds to wait before the next image is displayed
  22. var TargetFrame = "parent"; //Name of the frame to open the hyperlink into
  23.  
  24. //Internal variables (do not change these unless you know what you are doing)
  25. var IsValidBrowser = false;
  26. var BannerAdCode = 0;
  27. var BannerAdImages = new Array(NumberOfImages);
  28. var DisplayInterval = DisplayInterval * 2000;
  29. var NumberOfImages = ImageFileNames.length;
  30. var isFlashFile = false;
  31.  
  32.  
  33. //Check for flash files
  34. function isFlash() {
  35.     var checkletter = "";
  36.         checkletter = ImageFileNames[BannerAdCode].substr((ImageFileNames[BannerAdCode].length - 3), 1);
  37.         if (checkletter =="s") { 
  38.          isFlashFile = true; 
  39.         
  40.         }
  41.  
  42.  
  43. }
  44.  
  45.  
  46.  
  47. //Add a trailing forward slash to the ImageFolder variable if it does not already have one
  48. if (ImageFolder.substr(ImageFolder.length - 1, ImageFolder.length) != "/" && ImageFolder != "") { 
  49. ImageFolder += "/";
  50. }
  51.  
  52. if (TargetFrame == '') {
  53. var FramesObject = null;
  54. } else {
  55. var FramesObject = eval('parent.' + TargetFrame);
  56. }
  57.  
  58. //Function runs when this page has been loaded and does the following:
  59. //1. Determine the browser name and version  (since the script will only work on Netscape 3+ and Internet Explorer 4+).
  60. //2. Start the timer object that will periodically change the image displayed by the Banner Ad.
  61. //3. Preload the images used by the Banner Ad rotator script
  62.  
  63. //Banner ads display for product page
  64. function InitialiseBannerAdRotator() {
  65.  
  66. //Determine the browser name and version
  67. //The script will only work on Netscape 3+ and Internet Explorer 4+
  68. var BrowserType = navigator.appName;
  69. var BrowserVersion = parseInt(navigator.appVersion);
  70.  
  71. if (BrowserType == "Netscape" && (BrowserVersion >= 3)) {
  72. IsValidBrowser = true;
  73. }
  74.  
  75. if (BrowserType == "Microsoft Internet Explorer" && (BrowserVersion >= 4)) {
  76. IsValidBrowser = true;
  77. }
  78.  
  79. if (IsValidBrowser) {
  80. TimerObject = setTimeout("ChangeImage()", DisplayInterval);
  81. BannerAdCode = 0;
  82.  
  83. for (i = 0; i < NumberOfImages; i++) {
  84. BannerAdImages[i] = new Image();
  85. BannerAdImages[i].src = ' ' + ImageFolder + ImageFileNames[i];
  86. }
  87. }
  88. }
  89.  
  90. //Banner ads display for main page
  91. function InitialiseBannerAdindex() {
  92.  
  93. //Determine the browser name and version
  94. //The script will only work on Netscape 3+ and Internet Explorer 4+
  95. var BrowserType = navigator.appName;
  96. var BrowserVersion = parseInt(navigator.appVersion);
  97.  
  98. if (BrowserType == "Netscape" && (BrowserVersion >= 3)) {
  99. IsValidBrowser = true;
  100. }
  101.  
  102. if (BrowserType == "Microsoft Internet Explorer" && (BrowserVersion >= 4)) {
  103. IsValidBrowser = true;
  104. }
  105.  
  106. if (IsValidBrowser) {
  107. TimerObject = setTimeout("ChangeImage()", DisplayInterval);
  108. BannerAdCode = 0;
  109.  
  110. for (i = 0; i < NumberOfImages; i++) {
  111. BannerAdImages[i] = new Image();
  112. BannerAdImages[i].src = ' ' + ImageFolderindex + ImageFileNames[i];
  113. }
  114.  
  115. }
  116.  
  117. }
  118. //Function to change the src of the Banner Ad image
  119. function ChangeImage() {
  120.  
  121. if (IsValidBrowser) {
  122. BannerAdCode = BannerAdCode + 1;
  123.  
  124.     if (BannerAdCode == NumberOfImages) {
  125.         BannerAdCode = 0;}
  126. isFlash(BannerAdImages[BannerAdCode]);
  127.  
  128.     if(isFlashFile==true) {
  129.         document.getElementById('first').innerHTML='<embed src="ads/images/pcuser.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="468" height="60"></embed></object>'
  130.         isFlashFile = false;
  131.         TimerObject = setTimeout("ChangeImage()", DisplayInterval);
  132.  
  133.  
  134.     } else if(isFlashFile==false){
  135.         document.getElementById('first').innerHTML='<a href="javascript:ChangePageindex()" target="_parent"><img src="dummy.JPG" alt="Banner Advertisement" border="0" hspace="0" name="bannerad" width="468" height="60"> </img></a>'
  136.         window.document.bannerad.src = BannerAdImages[BannerAdCode].src;
  137.         TimerObject = setTimeout("ChangeImage()", DisplayInterval);}
  138. }
  139. }
  140.  
  141. //Function to redirect the browser window/frame to a new location,
  142. //depending on which image is currently being displayed by the Banner Ad.
  143. //If Banner Ad is being displayed on an old browser then the DefaultURL is displayed
  144.  
  145. //changepage for product page
  146. function ChangePage() {
  147.  
  148. if (IsValidBrowser) {
  149.  
  150. if (TargetFrame != '' && (FramesObject)) {
  151. FramesObject.location.href = ImageURLs[BannerAdCode];
  152. } else {
  153. document.location = ImageURLs[BannerAdCode];
  154. }
  155.  
  156. } else if (!IsValidBrowser) {
  157. document.location = DefaultURL;
  158. }
  159. }
  160.  
  161.  
  162. function ChangePageindex() {
  163.  
  164. if (IsValidBrowser) {
  165.  
  166. if (TargetFrame != '' && (FramesObject)) {
  167. FramesObject.location.href = ImageURLsindex[BannerAdCode];
  168. } else {
  169. document.location = ImageURLsindex[BannerAdCode];
  170. }
  171.  
  172. } else if (!IsValidBrowser) {
  173. document.location = DefaultURL;
  174. }
  175. }
  176.  
  177. //changepage for main
  178. /*function ChangePageindex() {
  179.         if (IsValidBrowser) {
  180.             if (TargetFrame != '' && (FramesObject)) {window.open(ImageURLsindex[BannerAdCode]);}
  181.             else {window.open(ImageURLsindex[BannerAdCode]);}
  182.         }
  183. else if (!IsValidBrowser) {window.open(DefaultURL);
  184. }
  185. }*/
  186.  
  187.  
  188. // ROLLOVER FUNCTIONS
  189. function MM_swapImgRestore() { //v3.0
  190.   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  191. }
  192.  
  193. function MM_preloadImages() { //v3.0
  194.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  195.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  196.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  197. }
  198.  
  199. function MM_findObj(n, d) { //v4.0
  200.   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  201.     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  202.   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  203.   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  204.   if(!x && document.getElementById) x=document.getElementById(n); return x;
  205. }
  206.  
  207. function MM_swapImage() { //v3.0
  208.   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  209.    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  210. }
  211.  
  212.