
window.name = "daddy";

function pic_window(category,id) {
	// Open the picutre window
	Pictures = window.open("description.php?picture_window=1&category="+category+"&product_id="+id+"&"+sid,"Pictures","TOOLBAR=0,RESIZABLE=1");
}

function ipix_window(id) {
	// Open the ipicture window
	iPicture = window.open('http://www.eyepicture.nl/system/huis.asp?id='+id,'iPicture','TOOLBAR=0,RESIZABLE=1');
}


function setwindow(thewindow,popup_width,popup_height) {
	// Set the size and stuff of the window
	locx = (screen.width - popup_width) / 2;
	locy = (screen.height - popup_height) / 2;
	thewindow.resizeTo(popup_width,popup_height);
	thewindow.moveTo(locx,locy);
	thewindow.focus();
}

function open_clipper(category,id,popup_width,popup_height) {
	// Open the clipper window and add an object or not
	if (category != null && id != null) {
	     clipboard=window.open("clipboard.php?mode=add&category="+category+"&product_id="+id+"&"+sid,"clipboard","TOOLBAR=0,RESIZABLE=1,SCROLLBARS=1");
	} else {
	     clipboard=window.open("clipboard.php?mode=overview&"+sid,"clipboard","TOOLBAR=0,RESIZABLE=1,SCROLLBARS=1");
	}
	setwindow(clipboard,popup_width,popup_height);
	clipboard.focus();
}

function tabit(keycode,theobject) {
	//Block the tab in a textarea and add chr(tab) to the field
	if (keycode == 9) {
		theobject.selection=document.selection.createRange();
		theobject.selection.text = String.fromCharCode(9);
		return false;
	} else {
		return true;
	}
}

function clipprint(category,totids) {
	// Open the clipper window in print mode
	clipboard_print=window.open("clipboard.php?mode=print&category="+category+"&totids="+totids+"&"+sid,"clipboard_print","TOOLBAR=0,RESIZABLE=1,SCROLLBARS=1");
	clipboard_print.focus();
}

function change_cat(theobject,newcat) {
	// This function replaces the category in the url of the specified window or adds it if no exist
	newurl = theobject.location.href;
	if (newurl.lastIndexOf('category=') > -1) {
		newurl = newurl.replace(/category=..../, 'category='+newcat);
	} else {
		if (newurl.lastIndexOf('?') > -1) {
			newurl = newurl + '&category=' + newcat;
		} else {
			newurl = newurl + '?category=' + newcat;
		}
	}
	theobject.location.href = newurl;
}

function change_off(theobject,newoff) {
	// This function replaces the office selected in the url of the specified window or adds it if no exist
	newurl = theobject.location.href;
	if (newurl.lastIndexOf('coffice=') > -1) {
		newurl = newurl.replace(/coffice=..../, 'coffice='+newoff);
	} else {
		if (newurl.lastIndexOf('?') > -1) {
			newurl = newurl + '&coffice=' + newoff;
		} else {
			newurl = newurl + '?coffice=' + newoff;
		}
	}
	theobject.location.href = newurl;
}
