// Note: Opera and WebTV spoof Navigator.  We do strict client detection.
// If you want to allow spoofing, take out the tests for opera and webtv.
var agt     = navigator.userAgent.toLowerCase();
var is_moz  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_ie   = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

function Redirect(url){
    window.location = url;
}


function HPopup (url,name,width,height,menubar,stats,toolbar,scrollbars,resizable){
    Popup(url,name,width,height,menubar,stats,toolbar,scrollbars,resizable)
}


function Popup(url,name,width,height,menubar,stats,toolbar,scrollbars,resizable){
   var DEF_MENUBAR   = 0;
   var DEF_STATUSBAR = 0;
   var DEF_TOOLBAR   = 0;
   var DEF_SCROLLS   = 1;
   var DEF_RESIZABLE = 1;

   if (typeof url == "undefined"){
      alert("Incorect use of Popup! url param must be suplied!\nPopup(url,name,width,height,menubar,stats,toolbar,scrollbars,resizable)");
      return;
   }

   if (typeof name == "undefined"){
      alert("Incorect use of Popup! name param must be suplied!\nPopup(url,name,width,height,menubar,stats,toolbar,scrollbars,resizable)");
      return;
   }

   if (typeof width == "undefined" || typeof height == "undefined"){
      alert("Incorect use of Popup! width and height params must be suplied!\nPopup(url,name,width,height,menubar,stats,toolbar,scrollbars,resizable)");
      return;
   }

   // define window params
   var win_menubar   = (menubar     || DEF_MENUBAR)     ? "yes" : "no";
   var win_status    = (stats       || DEF_STATUSBAR)   ? "yes" : "no";
   var win_toolbar   = (toolbar     || DEF_TOOLBAR)     ? "yes" : "no";
   var win_scrolls   = (scrollbars  || DEF_SCROLLS)     ? "yes" : "no";
   var win_resize    = (resizable   || DEF_RESIZABLE)   ? "yes" : "no";

   // form open string
   var win_str = "height=" + height + ",width=" + width + ",menubar=" + win_menubar + ",stats=" + win_status + ",toolbar=" + win_toolbar + ",scrollbars=" + win_scrolls + ",resizable=" + win_resize;

   // get client resolution and calc window position
   var scr_width  = screen.width;
   var scr_height = screen.height;

   var win_x = scr_width/2 - width/2;
   var win_y = scr_height/2 - height/2;

   var win = window.open(url, name, win_str);
   win.moveTo(win_x,win_y);
   win.focus();

   return win;
}



//Event - wrappers
var addEvent = function(el, event, handler) {
    if ( typeof document.attachEvent != 'undefined' ) {
        el.attachEvent("on" + event, handler);
    } else {
        el.addEventListener(event, handler, true);
    }
};

var removeEvent = function(el, event, handler) {
    if ( typeof document.attachEvent != 'undefined' ) {
        el.detachEvent("on" + event, handler);
    } else {
        el.removeEventListener(event, handler, true);
    }
};


function ShowISIS(){
    properties = 'history=no,toolbar=0,location=0,directories=0,scrollbars=yes,status=0,menubar=0,width=430,height=350,top='+ 100 +',left=' + 200 + '';
    Win = window.open('http://www.diamonds.uk.com/static/isis_popup.html','isis',properties) ;
}


/* Simple ajax wrapper
Usage (readyState 4 means request is complete):

xmlhttp = AjaxRequest();

xmlhttp.open("GET", "test.txt",true);

xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState==4) {
		alert(xmlhttp.responseText)
	}
}

xmlhttp.send(null);

*/
function AjaxRequest(){

	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}

	return xmlhttp;
}
