//////////////////////////////////////// GLOBAL FUNCTIONS
		
		// GET HEIGHT
		function GetWindowHeight() {
			var D = document;
			return Math.max(
				Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
				Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
				Math.max(D.body.clientHeight, D.documentElement.clientHeight)
			);
		}
			
		// OPACITY CHANGE
		function ChangeOpac(Opacity, ID, EndFunction) { 
			var DivObject = document.getElementById(ID).style; 
			DivObject.opacity = (Opacity / 100); 
			DivObject.MozOpacity = (Opacity / 100); 
			DivObject.KhtmlOpacity = (Opacity / 100); 
			DivObject.filter = "alpha(opacity=" + Opacity + ")"; 
			if (EndFunction != '') {
			var CallFunction = new Function (EndFunction);
			CallFunction();
			}
		} 
		
		// OPACITY FADE	PROGRESS
		function Opacity(ID, OpacStart, OpacEnd, Millisec, EndFunction) { 
			var Speed = Math.round(Millisec/100); 
			var Timer = 0; 
			if(OpacStart > OpacEnd) { 
				for(i = OpacStart; i >= OpacEnd; i--) { 
					if (i == OpacEnd) {
					setTimeout("ChangeOpac("+i+",'"+ID+"','"+EndFunction+"')",(Timer * Speed)); 
					} else {
					setTimeout("ChangeOpac("+i+",'"+ID+"','')",(Timer * Speed)); 
					}
					Timer++; 
				} 
			} else if(OpacStart < OpacEnd) { 
				for(i = OpacStart; i <= OpacEnd; i++) { 
					if (i == OpacEnd) {
					setTimeout("ChangeOpac("+i+",'"+ID+"','"+EndFunction+"')",(Timer * Speed)); 
					} else {
					setTimeout("ChangeOpac("+i+",'"+ID+"','')",(Timer * Speed)); 
					}
					Timer++; 
				} 
			} 
		} 
		
		// BACKGROUND
		function BackGroundCover (Type) {
			if (Type == 'Closed') {
				document.getElementById('bg-darken').style.display = "none";		
			} else if (Type == 'Close') {
				Opacity('bg-darken', 80, 0, 500,"BackGroundCover(\"Closed\")");			
			} else {
				var DivObject = document.getElementById('bg-darken').style; 
				DivObject.opacity = 0; 
				DivObject.MozOpacity = 0; 
				DivObject.KhtmlOpacity = 0; 
				DivObject.filter = "alpha(opacity=0)"; 
				document.getElementById('bg-darken').style.display = "block";
				Opacity('bg-darken', 0, 80, 500,"");
			}
		}
		
		// DETECT IE
     	function isIE() {
     		return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
    	}
		
		// NEWSLETTER VIEW/CLOSE
		function Newsletter(Type) {
			if (Type == 'Closed') {
				document.getElementById('newsletter').style.display = "none";					
			} else if (Type == 'Close') {
				if (!isIE()) {	
					Opacity('newsletter', 100, 0, 500,"Newsletter(\"Closed\")");
					BackGroundCover('Close');
				} else {
				BackGroundCover('Close');
				document.getElementById('newsletter').style.display = "none";	
				}
			} else {
				BackGroundCover('');				
				document.getElementById('newsletterform').style.display = "block";
				document.getElementById('thank-you').style.display = "none";	
				document.getElementById('firstname').value = ''
				document.getElementById('lastname').value = '';
				document.getElementById('email').value = '';
				document.getElementById('question').value = '';
				document.getElementById('firstname-error').style.visibility = "hidden";
				document.getElementById('lastname-error').style.visibility = "hidden";
				document.getElementById('email-error').style.visibility = "hidden";				
				document.getElementById('question-error').style.visibility = "hidden";
				if (!isIE()) {
					var DivObject = document.getElementById('newsletter').style; 
					DivObject.opacity = 0; 
					DivObject.MozOpacity = 0; 
					DivObject.KhtmlOpacity = 0; 
					DivObject.filter = "alpha(opacity=0)"; 
					document.getElementById('newsletter').style.display = "block";
					Opacity('newsletter', 0, 100, 500,"");		
				} else {
					setTimeout("document.getElementById('newsletter').style.display = \"block\"", 400);
				}
			}
		}		
		
		// NEWSLETTER POST
		function NewsLetterPost () {
			var Valid = true;
			var VerifyEmail = document.getElementById('email').value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
			if (document.getElementById('email').value == '' || !VerifyEmail) { Valid = false; document.getElementById('email-error').style.visibility = "visible"; } else { document.getElementById('email-error').style.visibility = "hidden"; }
			if (document.getElementById('firstname').value == '') { Valid = false; document.getElementById('firstname-error').style.visibility = "visible"; } else { document.getElementById('firstname-error').style.visibility = "hidden"; }		
			if (document.getElementById('lastname').value == '') { Valid = false; document.getElementById('lastname-error').style.visibility = "visible"; } else { document.getElementById('lastname-error').style.visibility = "hidden"; }		
			if (document.getElementById('question').value.toLowerCase() == 'sexy' || document.getElementById('question').value.toLowerCase() == 'hot') { document.getElementById('question-error').style.visibility = "hidden"; } else { document.getElementById('question-error').style.visibility = "visible"; Valid = false; }		
			if (Valid) {
				document.getElementById('btn-signup').style.display = "none";
				document.getElementById('in-progress').style.display = "block";
				var parameters = "firstname="+encodeURIComponent(document.getElementById('firstname').value)+"&lastname="+encodeURIComponent(document.getElementById('lastname').value)+"&email="+encodeURIComponent(document.getElementById('email').value);
				PostRequest('NewsletterPostVar','designedit_inc/newsletter.php',parameters,'NewsLetterPostComplete','NewsLetterPostError',false);	
			}
		}
		
		function NewsLetterPostComplete(Response) {	
			document.getElementById('newsletterform').style.display = "none";
			document.getElementById('thank-you').style.display = "block";
			document.getElementById('in-progress').style.display = "none";
			document.getElementById('btn-signup').style.display = "block";
			document.getElementById('firstname').value = ''
			document.getElementById('lastname').value = '';
			document.getElementById('email').value = '';
		}
		
		function NewsLetterPostError(Response) {
			document.getElementById('firstname').value = ''
			document.getElementById('lastname').value = '';
			document.getElementById('email').value = '';
			//document.getElementById('thank-you').style.display = "block";
		}

	// CALL VIEW/CLOSE
		function CallPopup(Type) {
			if (Type == 'Closed') {
				document.getElementById('callme').style.display = "none";	
			} else if (Type == 'Close') {
				if (!isIE()) {
					Opacity('callme', 100, 0, 500,"CallPopup(\"Closed\")");
					BackGroundCover('Close');
				} else {
				BackGroundCover('Close');
				document.getElementById('callme').style.display = "none";	
				}
			} else {
				BackGroundCover('');	
				if (!isIE()) {
					var DivObject = document.getElementById('callme').style; 
					DivObject.opacity = 0; 
					DivObject.MozOpacity = 0; 
					DivObject.KhtmlOpacity = 0; 
					DivObject.filter = "alpha(opacity=0)"; 
					document.getElementById('callme').style.display = "block";
					Opacity('callme', 0, 100, 500,"");		
				} else {
					setTimeout("document.getElementById('callme').style.display = \"block\"", 400);
				}
			}
		}

		// EMAIL VIEW/CLOSE
		function EmailPopup(Type) {
			if (Type == 'Closed') {
				document.getElementById('email-popup').style.display = "none";					
			} else if (Type == 'Close') {
				if (!isIE()) {	
					Opacity('email-popup', 100, 0, 500,"EmailPopup(\"Closed\")");
					BackGroundCover('Close');
				} else {
				BackGroundCover('Close');
				document.getElementById('email-popup').style.display = "none";	
				}
			} else {
				BackGroundCover('');				
				document.getElementById('emailform').style.display = "block";
				document.getElementById('mail-thank-you').style.display = "none";	
				document.getElementById('mail-name').value = '';
				document.getElementById('mail-email').value = '';
				document.getElementById('mail-subject').value = '';
				document.getElementById('mail-comments').value = '';
				document.getElementById('mail-question').value = '';
				document.getElementById('mail-name-error').style.visibility = "hidden";
				document.getElementById('mail-email-error').style.visibility = "hidden";
				document.getElementById('mail-subject-error').style.visibility = "hidden";
				document.getElementById('mail-comments-error').style.visibility = "hidden";
				document.getElementById('mail-question-error').style.visibility = "hidden";
				if (!isIE()) {
					var DivObject = document.getElementById('email-popup').style; 
					DivObject.opacity = 0; 
					DivObject.MozOpacity = 0; 
					DivObject.KhtmlOpacity = 0; 
					DivObject.filter = "alpha(opacity=0)"; 
					document.getElementById('email-popup').style.display = "block";
					Opacity('email-popup', 0, 100, 500,"");		
				} else {
					setTimeout("document.getElementById('email-popup').style.display = \"block\"", 400);
				}
			}
		}
		
		// EMAIL POST
		function EmailPost () {
			var Valid = true;
			var VerifyEmail = document.getElementById('mail-email').value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
			if (document.getElementById('mail-email').value == '' || !VerifyEmail) { Valid = false; document.getElementById('mail-email-error').style.visibility = "visible"; } else { document.getElementById('mail-email-error').style.visibility = "hidden"; }
			if (document.getElementById('mail-name').value == '') { Valid = false; document.getElementById('mail-name-error').style.visibility = "visible"; } else { document.getElementById('mail-name-error').style.visibility = "hidden"; }		
			if (document.getElementById('mail-subject').value == '') { Valid = false; document.getElementById('mail-subject-error').style.visibility = "visible"; } else { document.getElementById('mail-subject-error').style.visibility = "hidden"; }		
			if (document.getElementById('mail-comments').value == '') { Valid = false; document.getElementById('mail-comments-error').style.visibility = "visible"; } else { document.getElementById('mail-comments-error').style.visibility = "hidden"; }					
			if (document.getElementById('mail-question').value.toLowerCase() == 'sexy' || document.getElementById('mail-question').value.toLowerCase() == 'hot') { document.getElementById('mail-question-error').style.visibility = "hidden"; } else { document.getElementById('mail-question-error').style.visibility = "visible"; Valid = false; }		
		
			if (Valid) {
				document.getElementById('mail-btn-submit').style.display = "none";
				document.getElementById('mail-in-progress').style.display = "block";
				var parameters = "name="+encodeURIComponent(document.getElementById('mail-name').value)+"&email="+encodeURIComponent(document.getElementById('mail-email').value)+"&subject="+encodeURIComponent(document.getElementById('mail-subject').value)+"&comments="+encodeURIComponent(document.getElementById('mail-comments').value);
				PostRequest('EmailPostVar','designedit_inc/emailform.php',parameters,'EmailPostComplete','EmailPostError',false);	
			}
		}
		
		function EmailPostComplete(Response) {
			document.getElementById('emailform').style.display = "none";
			document.getElementById('mail-thank-you').style.display = "block";			
			document.getElementById('mail-btn-submit').style.display = "block";
			document.getElementById('mail-in-progress').style.display = "none";
			document.getElementById('mail-name').value = '';
			document.getElementById('mail-email').value = '';
			document.getElementById('mail-subject').value = '';
			document.getElementById('mail-comments').value = '';
		}
		
		function EmailPostError(Response) {
			document.getElementById('mail-name').value = '';
			document.getElementById('mail-email').value = '';
			document.getElementById('mail-subject').value = '';
			document.getElementById('mail-comments').value = '';
		}
		
		// VIEW HOME CLIP
		var CurrentHomeClip = 0;
		function ViewHomeClip (FileName,Thumbnail,ID) {
			
			// HIGHTLIGHT THUMBNAIL
			if (CurrentHomeClip != 0) {
			document.getElementById('ClipURL_'+CurrentHomeClip).className = "tn";
			}
			CurrentHomeClip = ID;
			document.getElementById('ClipURL_'+CurrentHomeClip).className = "tn selected";
			
			// CREATE FLASH HOLDER DIV
			if (!document.getElementById('flash_player_location')) {
				document.getElementById('main-vid-new').innerHTML = '';
				var NewDiv = document.createElement("DIV");
				NewDiv.setAttribute("id", 'flash_player_location');
				document.getElementById('main-vid-new').appendChild(NewDiv);			
			}
			
			// PLAY VIDEO
			var flashvars = {};
			var params = {};
				params.allowFullScreen = "true";
				params.allowScriptAccess = "always";
				params.bgcolor = "#000000";
				params.wmode = "transparent";
			var attributes = {};
			swfobject.embedSWF("http://vimeo.com/moogaloop.swf?clip_id="+FileName+"&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=388fb1&amp;fullscreen=1&amp;autoplay=1 ", "flash_player_location", "640", "360", "9.0.0", false, flashvars, params, attributes);
		}		
		
		
		// SHARE THIS VIDEO
		function ShareThisVideo() {
			if (document.getElementById('share-tab').style.visibility == 'visible') {
				if (!isIE()) {	
				Opacity('share-tab', 100, 0, 250,"document.getElementById(\"share-tab\").style.visibility = \"hidden\"");	
				} else {
				document.getElementById('share-tab').style.visibility = "hidden";		
				}
			} else {				
				document.getElementById('shareinput').value = location.href;					
				
				var EmbedCode = '<object width="400" height="225">';
				EmbedCode += '<param name="allowfullscreen" value="true" />';
				EmbedCode += '<param name="allowscriptaccess" value="always" />';
				EmbedCode += '<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+CurrentFileName+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=41c4da&amp;fullscreen=1" />';
				EmbedCode += '<embed src="http://vimeo.com/moogaloop.swf?clip_id='+CurrentFileName+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=41c4da&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225">';
				EmbedCode += '</embed></object>';
				
				document.getElementById('embedinput').value = EmbedCode;
				if (!isIE()) {	
				document.getElementById('share-tab').style.visibility = "visible";		
				var DivObject = document.getElementById('share-tab').style; 
				DivObject.opacity = 0; 
				DivObject.MozOpacity = 0; 
				DivObject.KhtmlOpacity = 0; 
				DivObject.filter = "alpha(opacity=0)"; 
				Opacity('share-tab', 0, 100, 250,"");
				} else {
				document.getElementById('share-tab').style.visibility = "visible";	
				}
			}		
		}
		
		
		// VIEW CLIP VIMEO
		var CurrentClip = 0;
		var	CurrentFileName = '';
		function ViewClip (FileName,Thumbnail,ID) {
			BackGroundCover('');
			// HIGHTLIGHT THUMBNAIL
			if (CurrentClip != 0) {
			document.getElementById('ClipURL_'+CurrentClip).className = "tn";
			}
			CurrentClip = ID;
			CurrentFileName = FileName;
			document.getElementById('ClipURL_'+CurrentClip).className = "tn selected";
			
			// CREATE FLASH HOLDER DIV
			if (!document.getElementById('flash_player_location')) {
				var NewDiv = document.createElement("DIV");
				NewDiv.setAttribute("id", 'flash_player_location');
				document.getElementById('video').appendChild(NewDiv);			
			}
			if (!isIE()) {	
			var DivObject = document.getElementById('archives-vid').style; 
				DivObject.opacity = 0; 
				DivObject.MozOpacity = 0; 
				DivObject.KhtmlOpacity = 0; 
				DivObject.filter = "alpha(opacity=0)"; 
				document.getElementById('archives-vid').style.display = "block";
				Opacity('archives-vid', 0, 100, 500,"ViewClipInsert(\""+FileName+"\",\""+Thumbnail+"\")");	
			} else {	
				setTimeout("document.getElementById('archives-vid').style.display = \"block\";ViewClipInsert(\""+FileName+"\",\""+Thumbnail+"\")", 400);
			}
		}
		
		// INSERT CLIP
		function ViewClipInsert(FileName,Thumbnail) {
			var flashvars = {};
			var params = {};
				params.allowFullScreen = "true";
				params.allowScriptAccess = "always";
				params.bgcolor = "#000000";
				params.wmode = "transparent";
			var attributes = {};
			swfobject.embedSWF("http://vimeo.com/moogaloop.swf?clip_id="+FileName+"&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=388fb1&amp;fullscreen=1&amp;autoplay=1", "flash_player_location", "640", "360", "9.0.0", false, flashvars, params, attributes);
		}
		
		// CLOSE CLIP
		function ViewClipClose(Type) {
			if (Type == 'Closed') {					
				document.getElementById('video').innerHTML = '';
				document.getElementById('archives-vid').style.display = "none";		
				document.getElementById('share-tab').style.visibility = "hidden";	
			} else {
				if (!isIE()) {	
				BackGroundCover('Close');				
				Opacity('archives-vid', 100, 0, 500,"ViewClipClose(\"Closed\")");
				} else {
				document.getElementById('video').innerHTML = '';
				document.getElementById('archives-vid').style.display = "none";		
				BackGroundCover('Close');	
				}
			}
		}
		
		// ON LOAD
		function CheckURL () {
			var ClipID = window.location.hash.substring(1);
			if (document.getElementById('ClipFileName_'+ClipID)) {
				if (document.getElementById('archives-vid')) {
				ViewClip (document.getElementById('ClipFileName_'+ClipID).value,document.getElementById('ClipThumbnail_'+ClipID).value,ClipID);
				}
			}
		}
		window.onload = CheckURL;
		
		
		// LOAD XML 
		function LoadXML(url,errorfunction) {
			var xmlDoc;	
			if (window.XMLHttpRequest) {
			  xmlDoc=new window.XMLHttpRequest();
			  xmlDoc.open("GET",url,false);	 
			  xmlDoc.send("");
			  return xmlDoc.responseXML;
			} else if (ActiveXObject("Microsoft.XMLDOM")) {
			  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			  xmlDoc.async=false;
			  xmlDoc.ignoreWhite=true;
			  xmlDoc.load(url);
			  return xmlDoc;
			} 
			if (errorfunction != '') {
			var ErrorFunction = new Function (''+errorfunction+'(\'1\')');
			ErrorFunction();
			} 
			return null;
		} 

	
		// STRING TO XML
		function StringToXML(xml) {
			if (window.ActiveXObject) {
			xmlDoc=new ActiveXObject("Microsoft.XMLDOM");

		xmlDoc.async=false;
			xmlDoc.loadXML(xml);
			return xmlDoc;
			} else if (window.XMLHttpRequest) {
			var parser=new DOMParser();
			xmlDoc=parser.parseFromString(xml,"text/xml");
			return xmlDoc;
			} 
		}
		
		// POST CALL
		function PostRequest(httpRequest,url,parameters,callfunction,errorfunction,parsexml) {

			window[httpRequest] = false;
			if (window.XMLHttpRequest) {
				 window[httpRequest] = new XMLHttpRequest();
				 if (window[httpRequest].overrideMimeType) {
					window[httpRequest].overrideMimeType('text/html');
				 }
			  } else if (window.ActiveXObject) {
				
				 try {
					window[httpRequest] = new ActiveXObject("Msxml2.XMLHTTP");
				 } catch (e) {
					try {
					   window[httpRequest] = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {}
				 }
			  }
			  if (!window[httpRequest]) {
				 if (errorfunction != '') {
				 var ErrorFunction = new Function (''+errorfunction+'(\'1\')');
				 ErrorFunction();
				 } 
				 return false;
			  }
			
			window[httpRequest].onreadystatechange = new Function ('PostRequestReturn("'+httpRequest+'","'+callfunction+'","'+errorfunction+'",'+parsexml+')');
			window[httpRequest].open('POST', url, true);
			window[httpRequest].setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			window[httpRequest].setRequestHeader("Content-length", parameters.length);
			window[httpRequest].setRequestHeader("Connection", "close");
			window[httpRequest].send(parameters);	
		} 
		
		// POST RESPONSE
		function PostRequestReturn(httpRequest,callfunction,errorfunction,parsexml) {
			if (window[httpRequest].readyState == 4) {
				 if (window[httpRequest].status == 200) {
					Result = window[httpRequest].responseText;
					if (parsexml) {
						var ResponseFunction = new Function (''+callfunction+'(StringToXML(Result))');   
					} else {
						var ResponseFunction = new Function (''+callfunction+'(Result)');   
					}
					ResponseFunction();
				 } else {
					if (errorfunction != '') {
					var ErrorFunction = new Function (''+errorfunction+'(\'2\')');
					ErrorFunction();
					}
				 }
			 }
		}