function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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;
}
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"}

var now = new Date();
gfixDate(now);
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); 


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 (parent == top){
		parent.content.location = "/bin/Cklb?ref=/bin/Search?n~1^fmt~table^mr=all";
	} else {
		 parent.location = "/bin/Cklb?ref=/bin/Search?n~1^fmt~table^mr=all";
	}
}

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


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





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

function topsearchconcept() {
        if (ggsession && ggusert) {
                if (parent.frames[1].frames[1]){
                        if (parent.frames[1].frames[3]){
                        parent.frames[1].frames[1].location= "/user/search_concept.shtml";  
                        } else {
                        parent.frames[1].frames[0].location= "/user/search_concept.shtml";
                        }
                } else {
                        parent.frames[1].location = "/bin/Cklb?ref=/user/search_concept.shtml";
                }
        } else {
                        parent.frames[1].location= "/user/search_concept.shtml";
        }
}


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

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

}

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;
			//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 gsetuser() {
	var gwhichuserset = ggetCookie("gwhichuser");
	if(gwhichuserset) {
		gsetCookie('username','', '', '/', gGetCookieDom());
	} else {
		gsetCookie('username',document.l.username.value, '', '/', gGetCookieDom());
	}
}



// Search Field Validation
function checkSearch() {
 if (document.search_form.Keywords.value == "") {
  alert("Please enter keyword(s) to begin a search");
  } else {
  document.search_form.submit();
  }
}
// Login Validation
function checkLogin() {
 if (document.login_form.username.value == "" || document.login_form.password.value=="") {
  alert("Please enter a username and password.");
  } else {
  document.login_form.submit();
  }
}
// Detail image pop-up
function showDetail(id_images,action) {
	popWidth=690;
	popHeight=550;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
	queryString = 'detail.php?id_images=' + id_images + '&action=' + action;
	window.open(queryString,'','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=no,top='+popTop+',left='+popLeft);
}
// User logout
function userLogout() {
	popWidth=275;
	popHeight=150;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
	queryString = 'logout.php';
	window.open(queryString,'logout','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=no,top='+popTop+',left='+popLeft);
}
// Add to lightbox
function addToLightbox(id_images) {
	popWidth=275;
	popHeight=150;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
 	queryString = 'addtolightbox.php?id_images=' + id_images;
	window.open(queryString,'lightbox','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=no,top='+popTop+',left='+popLeft);
}
// Add to lightbox
function removeFromLightbox(id_images) {
	popWidth=275;
	popHeight=150;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
 	queryString = 'removelightbox.php?id_images=' + id_images;
	window.open(queryString,'lightbox','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=no,top='+popTop+',left='+popLeft);
}
// Error on Login
function loginError() {
	popWidth=400;
	popHeight=300;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
 	queryString = 'loginerror.php';
	window.open(queryString,'loginerror','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=no,top='+popTop+',left='+popLeft);
}
// Show samples
function showSamples() {
	popWidth=900;
	popHeight=680;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
	queryString = '/samples/index.html'
	window.open(queryString,'','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=no,top='+popTop+',left='+popLeft);
}

// Show samples
function addComment(photoID) {
	popWidth=450;
	popHeight=600;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
	queryString = 'comment.php?id_images=' + photoID;
	window.open(queryString,'','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=yes,scrolling=yes,top='+popTop+',left='+popLeft);
}

// Pop up mailer for image
function sendImage(photoID) {
	popWidth=480;
	popHeight=325;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
	queryString = 'mail_image.php?id_images=' + photoID;
	imageWin = window.open(queryString,'','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=no,top='+popTop+',left='+popLeft);
	imageWin.focus();
}

// Pop up mailer for lightbox
function sendLightbox(userID) {
	popWidth=480;
	popHeight=325;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
	queryString = 'mail_lightbox.php?id_users=' + userID;
	imageWin = window.open(queryString,'','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=no,top='+popTop+',left='+popLeft);
	imageWin.focus();
}

// Pop up mailer for image
function sendInquiry(photoID) {
	popWidth=480;
	popHeight=375;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
	queryString = 'mail_inquiry.php?id_images=' + photoID;
	imageWin = window.open(queryString,'','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=no,top='+popTop+',left='+popLeft);
	imageWin.focus();
}

// Pop up mailer for image purchase
function sendPurchase(photoID) {
	popWidth=480;
	popHeight=325;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
	queryString = 'mail_purchase.php?id_images=' + photoID;
	imageWin = window.open(queryString,'','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=no,top='+popTop+',left='+popLeft);
	imageWin.focus();
}
// User logout
function errorDownload() {
	popWidth=275;
	popHeight=150;
	screenWidth=screen.width;
	screenHeight=screen.height;
	popTop=Math.floor((screenHeight/2)-(popHeight/2));
	popLeft=Math.floor((screenWidth/2)-(popWidth/2));
	queryString = 'error.php';
	window.open(queryString,'logout','width='+popWidth+',height='+popHeight+',location=no,toolbars=no,resizable=no,top='+popTop+',left='+popLeft);
}

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

var ggsession = ggetCookie("gmpsess");
var ggusert = ggetCookie("usert");

