function compopen(url, width, height) {
        var compcount1 = ggetCookie("compcount1");

        if(compcount1){
                compcount1++;
                gsetCookie('compcount1', compcount1, '', '/', gGetCookieDom());

                if(compcount1<30){
                        var Win2 = window.open(url,"displayWindow2",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no,status=no' );
                        Win2.focus();
                } else {
                        alert('You have exceeded the maximum number of comp images that may be downloaded during a day.  If you require more comp images, please contact us and we can help you with your requirements.');
                }
        } else {
                gsetCookie('compcount1', '0', '', '/', gGetCookieDom());

                var compcount1 = ggetCookie("compcount1");
                if(compcount1){
                        compcount1++;
                        gsetCookie('compcount1', compcount1, '', '/', gGetCookieDom());

                        if(compcount1<30){
                                var Win2 = window.open(url,"displayWindow2",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no,status=no' );
                                Win2.focus();
                        } else {
                                alert('You have downloaded more than 30 comps in this session. If you require more for legitimate usage, please contact us to obtain more comps.');
                        }
                } else {
                        alert('You must enable cookies to download Comps.  See your web browser preferences to enable cookies');
                }
        }
}


function license(id) {
                        top.location.replace('/bin/Cklb?atct=' + id + '&fmt=index&pi=1');
}

function maxscreen(){
        window.moveTo(0,0);
        window.resizeTo(screen.availWidth,screen.availHeight);
}

function smartsearch(qi){
        if(qi == 'EDM' || qi == 'edm' || qi == 'Edm'){qi='EDM*';}
	var ggsession = ggetCookie("gmpsess");
        var ggusert = ggetCookie("usert");
	gsetCookie("gwhichstartpage","", '', '/', gGetCookieDom());
        url='SwishSearch?Keywords=' + qi;
        url2='/bin/Cklb?Keywords=' + qi;
        url3='SwishSearch?Keywords=' + qi;
	

        if(parseInt(navigator.appVersion)>3 && browser != "Netscape Navigator"){

                url+='&max_res=200&supst=bkjs&glo=1';
                url2+='&max_res=200&supst=bkjs&glo=1';
                url3+='&max_res=200&supst=bkjs&glo=1';

        }

        if (ggsession && ggusert) {
                if (parent.frames['content'].frames['left']){
                        if (parent.frames['content'].frames['lb']){

		        parent.frames['content'].frames['left'].location= url3;
                        } else {
                        parent.frames['content'].location= url2;
                        }
                } else {
                        parent.frames['content'].location = url2;
                }
        } else {
                        top.location= url;
        }
}

function topsearchrefresh() {
        var ggsession = ggetCookie("gmpsess");
        var ggusert = ggetCookie("usert");
        url = '/user/search.shtml';
        if (ggsession && ggusert) {
               if (parent.frames['content'].frames['left']){
                        if (parent.frames['content'].frames['lb']){
                        parent.frames['content'].frames['left'].location= url;
                        } else {
                        parent.frames['content'].frames['left'].location= url;
                        }
                } else {
                        top.location= url;
                }
         } else {
                        top.location= url;
        }
}




function logout(){
	alert('logging you out');
	gsetCookie('username','', '', '/', gGetCookieDom());gsetCookie('gmpsess','', '', '/', gGetCookieDom());gsetCookie('gmpauth','', '', '/', gGetCookieDom());
	top.location.href='/index.shtml';
}

function gsetuser() {
	var gwhichuserset = ggetCookie("gwhichuser");
	if(gwhichuserset) {
		gsetCookie('username',gwhichuserset, '', '/', gGetCookieDom());
	} else {
		gsetCookie('username',document.l.username.value, '', '/', gGetCookieDom());
	}
}


function checkIt(string)
{
        place = detect.indexOf(string) + 1;
        thestring = string;
        return place;
}

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
        browser = "Konqueror";
        OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('firefox')) browser = "Firefox"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
        browser = "Netscape Navigator"
        version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
        if (checkIt('linux')) OS = "Linux";
        else if (checkIt('x11')) OS = "Unix";
        else if (checkIt('mac')) OS = "Mac"
        else if (checkIt('win')) OS = "Windows"
        else OS = "an unknown operating system";
}


var agt=navigator.userAgent
var yourOS="PC"
if (agt.indexOf("Mac")!=-1)
   {yourOS='Mac'}
var yourBrowse="IE"
if (navigator.appName == 'Netscape')
   {yourBrowse="NS"}
if (navigator.appVersion.substr(22,1) >= "5")
{ver5="Yes"}

if((yourOS=="Mac" && yourBrowse=="NS")||(yourOS=="Mac" && yourBrowse=="IE" && ver5 != "Yes")){
        document.write('<LINK rel="stylesheet" href="/css/mainMAC.css" type="text/css">')
}
else{
        document.write('<LINK rel="stylesheet" href="/css/main.css" type="text/css">')
}



function toplightboxrefresh() {
	if (top.frames[1]){
		top.frames[1].location = "/bin/Cklb?ref=/bin/Search?n~1^fmt~table";
	} else {
		top.location = "/bin/Cklb?ref=/bin/Search?n~1^fmt~table";
	}
}

function topcartrefresh() {
        if (parent == top){
                parent.frames[1].location = "/bin/Cklb?ref=/bin/Cart?op~view";
        } else {
                 parent.location = "/bin/Cklb?ref=/bin/Cart?op~view";
        }
}



function topsearchrefresh() {
	var ggsession = ggetCookie("gmpsess");
	var ggusert = ggetCookie("usert");

        if (ggsession && ggusert) {
		if (parent.frames['left']){
			parent.frames['left'].location = "/user/search.shtml";
		} else if(parent.frames['content'].frames['left']){
			parent.frames['content'].frames['left'].location = "/user/search.shtml";
		} else {
			parent.frames['content'].location = "/bin/Cklb?ref=/user/search.shtml";
		}
	} else {
			top.location = "/user/search.shtml";
        }
}







function topsearchrefreshpower() {
        if (parent == top){
                parent.frames[1].location = "/bin/Cklb?ref=/user/search_advanced.shtml";
        } else {
                parent.location = "/bin/Cklb?ref=/user/search_advanced.shtml";
        }
}

function topsearchconcept() {
        var ggsession = ggetCookie("gmpsess");
        var ggusert = ggetCookie("usert");
        url = '/search_concept.shtml';
        if (ggsession && ggusert) {
               if (parent.frames['content'].frames['left']){
                        parent.frames['content'].frames['left'].location= url;
                } else {
                        parent.frames['content'].location = url;
                }
         } else {
                        top.location= "" + url;
        }

}

function tload(dref)
{
        if(parent.thetop.href != dref){
                parent.thetop.location=dref;
        }
}

function siderefresh()
{
parent.left.location.replace('/bin/Search?n=1');

}

function csiderefresh(id)
{
        xcurrentdate = new Date();
  xcore = xcurrentdate.getSeconds();
  if (id){
  parent.left.location.replace('/bin/Cart?op=view&lc='+ id + '&random=' + xcore);
  }
  else {
  parent.left.location.replace('/bin/Cart?op=view' + '&random=' + xcore);
  }
}

function lccsiderefresh(id)
{
parent.left.location.replace('/bin/Cart?op=view&lc=1');
}


function VersionNavigateur(Netscape, Explorer) {
  if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||
      (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
    return true;
else return false;
}
function netie(net, ie) {
  if ((navigator.appVersion.substring(0,3) >= net && navigator.appName == 'Netscape' && net != -1) || (navigator.appVersion.substring(0,3) >= ie && navigator.appName.substring(0,9) == 'Microsoft' && ie != -1))
    return true;
else return false;
}

function cceditWindow()
{
  ccedit_window =
    window.open("https://argus.auroraquanta.com/bin/Profile?cc=1","ccedit","width=500,height=320,status=1");
}





// all new functions
function addlb(id) {
                if (parent.lb) {
                        var theurl= '/bin/ExLbAdd?id=' + id ;
                        parent.lb.location=theurl;
                } else {
                        var theurl= '/bin/Cklb?atlb=' + id;
                        self.location=theurl;
                }
}
function addcart2(id) {
                if (parent.lb) {
                        parent.lb.location = '/bin/Cart?op=add&id=' + id + '&fmt=index';
                        parent.com.location = '/user/cart_menu.shtml';

                } else {
                        var theurl= '/bin/Cklb?atct=' + id;
                        self.location=theurl;
                }
}



function gsetCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function gsetCookie2(name2,value2) {
        gsetCookie(name2, value2, '', '/', gGetCookieDom());
}


// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function ggetCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds

function gdeleteCookie(name, path, domain) {
  if (ggetCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function gfixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function gGetQV(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
  return false;
}

function checkRef() {
 var portal = getQV('portal');
 if (portal){
 var portalcookie = getCookie('portal');
  if (portalcookie != portal){
    setCookie('portal',portal,'','/');
  }
 }
}

function gGetCookieDom(){
var thisdomain = document.domain;
var domainparts = thisdomain.split(".");
var end = domainparts.length - 1;
var start = domainparts.length - 2;
var domainend = domainparts[end];
var domainstart = domainparts[start];
var setdom = "." + domainstart + "." + domainend;
return setdom;
}

function gSetBackpage() {
var thispage = location.href;
gsetCookie('backpage', thispage, '', '/', gGetCookieDom());
}

function mailit(){
	var address="imagery@t" + "ranstock.com"
	self.location="mailto:" + address;
}

function relatedkeywords (qq){
        self.location.href='SwishSearch?frmloc=detailjs&Keywords=' + qq;
}

