var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isDyn = (isDOM || isIE4 || isNS4);

function getRef(id)
{
 if (isDOM) return document.getElementById(id);
 if (isIE4) return document.all[id];
 if (isNS4) return document.layers[id];
}

// GLOBAL -------------------------------------------------------------------------------------------------


function writeGlobalHeader(){
	
	document.write('<div id="globalheader">');
	document.write('<ul id="globalnav">');
	document.write('	<li id="gn-anhminh"><a href="main.html">AnhMinh</a></li>');
	document.write('	<li id="gn-empty"><a href="#">&nbsp;</a></li>');
	document.write('	<li id="gn-profile"><a href="profile.html">Profile</a></li>');
	document.write('	<li id="gn-gallery"><a href="photoshoots.html">Photoshoots</a></li>');
	document.write('	<li id="gn-audio"><a href="audio.html">Audio</a></li>');
	document.write('	<li id="gn-video"><a href="video.html">Video</a></li>');
	document.write('	<li id="gn-contact"><a href="contact.html">Contact</a></li>');
	document.write('</ul>');
	document.write('</div>');
}

function writeGlobalFooter(){
	document.write('<div id="globalfooter">');
    document.write('	<p class="gf-buy">ANHMINH.NET</p>');
    document.write('	<p class="gf-links">');
	document.write('		<a href="main.html">Anh Minh</a>&nbsp;|&nbsp');
	document.write('		<a href="profile.html">Profile</a>&nbsp;|&nbsp');
	document.write('		<a href="photoshoots.html">Gallery</a>&nbsp;|&nbsp');
	document.write('		<a href="audio.html">Audio</a>&nbsp;|&nbsp');
	document.write('		<a href="video.html">Video</a>&nbsp;|&nbsp');
	document.write('		<a href="contact.html">Contact Me</a>');
    document.write('<p class="gf-sosumi">Copyright &copy; 2005 ANHMINH.NET. All rights reserved.</p>');
	document.write('</div>');
}


// STORE -------------------------------------------------------------------------------------------------

function writeShoppingHeader(){
	document.write('<div id="globalParameters">');
	document.write('	<input name="weight_unit" value="lb" type="hidden" />');
	document.write('	<input name="currency_code" value="USD" type="hidden" />');
	document.write('	<input name="shipping_method_price_per_shipment_amount" value="25.00" type="hidden" />');
	document.write('	<input name="merchant_id" value="AHVO1GVMD5B1E" type="hidden" />');
	document.write('</div>');
}

var cdXMASShop = new Array(7);
cdXMASShop[0] = 'Mua Dong Yeu Thuong CD';
cdXMASShop[1] = 'Mua Dong Yeu Thuong CD - Autographed';
cdXMASShop[2] = 'Anh Minh';
cdXMASShop[3] = '10.00'; //Price
cdXMASShop[4] = '0.00'; //Shipping
cdXMASShop[5] = '1'; //Weight
cdXMASShop[6] = 'Audio CD'; //Description
cdXMASShop[7] = 'In Stock.'; //Stock

var cdXMASPlusPosterShop = new Array(8);
cdXMASPlusPosterShop[0] = 'Mua Dong Yeu Thuong CD with Folded Poster';
cdXMASPlusPosterShop[1] = 'Mua Dong Yeu Thuong CD with Folded Poster - Autographed';
cdXMASPlusPosterShop[2] = 'Anh Minh';
cdXMASPlusPosterShop[3] = '14.00'; //Price
cdXMASPlusPosterShop[4] = '0.00'; //Shipping
cdXMASPlusPosterShop[5] = '2'; //Weight
cdXMASPlusPosterShop[6] = 'Audio CD plus 28\" x 20\" Folded Poster'; //Description
cdXMASPlusPosterShop[7] = 'In Stock.'; //Stock

var cdXMASPosterShop = new Array(8);
cdXMASPosterShop[0] = 'Mua Dong Yeu Thuong Folded Poster';
cdXMASPosterShop[1] = 'Mua Dong Yeu Thuong Folded Poster - Autographed';
cdXMASPosterShop[2] = 'Anh Minh';
cdXMASPosterShop[3] = '8.00'; //Price
cdXMASPosterShop[4] = '0.00'; //Shipping
cdXMASPosterShop[5] = '1'; //Weight
cdXMASPosterShop[6] = '28\" x 20\" Folded Poster'; //Description
cdXMASPosterShop[7] = 'In Stock.'; //Stock

var cdXMASdistShop = new Array(8);
cdXMASdistShop[0] = 'Mua Dong Yeu Thuong CD (Pack of 5)';
cdXMASdistShop[1] = 'Mua Dong Yeu Thuong CD (Pack of 5) - Autographed';
cdXMASdistShop[2] = 'Anh Minh';
cdXMASdistShop[3] = '30.00'; //Price
cdXMASdistShop[4] = '0.00'; //Shipping
cdXMASdistShop[5] = '5'; //Weight
cdXMASdistShop[6] = 'Audio CD; Pack of 5'; //Description
cdXMASdistShop[7] = 'In Stock.'; //Stock


var cdcs28Shop = new Array(8);
cdcs28Shop[0] = 'Take Control CD';
cdcs28Shop[1] = 'Take Control CD - Autographed';
cdcs28Shop[2] = 'Anh Minh';
cdcs28Shop[3] = '10.00';
cdcs28Shop[4] = '0.00';
cdcs28Shop[5] = '1'; //Weight
cdcs28Shop[6] = 'Audio CD'; //Description
cdcs28Shop[7] = 'In Stock.'; //Stock

var cdcs28PlusPosterShop = new Array(8);
cdcs28PlusPosterShop[0] = 'Take Control CD with Folded Poster';
cdcs28PlusPosterShop[1] = 'Take Control CD with Folded Poster - Autographed';
cdcs28PlusPosterShop[2] = 'Anh Minh';
cdcs28PlusPosterShop[3] = '14.00'; //Price
cdcs28PlusPosterShop[4] = '0.00'; //Shipping
cdcs28PlusPosterShop[5] = '2'; //Weight
cdcs28PlusPosterShop[6] = 'Audio CD plus 28\" x 20\" Folded Poster'; //Description
cdcs28PlusPosterShop[7] = 'In Stock.'; //Stock

var cdcs28PosterShop = new Array(8);
cdcs28PosterShop[0] = 'Take Control Folded Poster';
cdcs28PosterShop[1] = 'Take Control Folded Poster - Autographed';
cdcs28PosterShop[2] = 'Anh Minh';
cdcs28PosterShop[3] = '8.00'; //Price
cdcs28PosterShop[4] = '0.00'; //Shipping
cdcs28PosterShop[5] = '1'; //Weight
cdcs28PosterShop[6] = '28\" x 20\" Folded Poster'; //Description
cdcs28PosterShop[7] = 'In Stock.'; //Stock

var cdcs28distShop = new Array(8);
cdcs28distShop[0] = 'Take Control CD (Pack of 5)';
cdcs28distShop[1] = 'Take Control CD (Pack of 5) - Autographed';
cdcs28distShop[2] = 'Anh Minh';
cdcs28distShop[3] = '30.00';
cdcs28distShop[4] = '0.00';
cdcs28distShop[5] = '5'; //Weight
cdcs28distShop[6] = 'Audio CD; Pack of 5'; //Description
cdcs28distShop[7] = 'In Stock.'; //Stock


function writeShopping(cdNum){
	document.write('<div id="shopping-' + cdNum + '">');
	document.write('	<table class="item" width="980">');
	document.write('		<tr>');
	document.write('		<td valign="top" align="center" width="300"><img class="item_image_url" src="http://www.anhminh.net/images/store/' + cdNum + '.jpg"/></td>');
	
    document.write('		<td valign="top" width="580">');
	document.write('		<span class="item_title" id="' + cdNum + '-title">' + eval(cdNum + "Shop[0]") + '</span><br />');
	
    document.write('		<span class="item_artist">' + eval(cdNum + "Shop[2]") + '</span><br />');
    document.write('		<span class="item_description" display="true">' + eval(cdNum + "Shop[6]") + '</span><br /><br />');
    document.write('		Price:&nbsp; <span class="dollarSign">$</span><span class="item_price">' + eval(cdNum + "Shop[3]") + '</span>&nbsp;&amp; eligible for free shipping <br /><br />');
	document.write('		<span class="inStock">' + eval(cdNum + "Shop[7]") + '</span><br />');
    
	document.write('		Autographed:');
	document.write('			<select class="item_autograph" name="' + cdNum + '_autograph" onChange="changeAutograph(this, \'' + cdNum + '\');">');
	document.write('			<option value="No">No</option>');
	document.write('			<option value="Yes">Yes</option>');
	document.write('			</select>');
    
    document.write('		<input type="hidden" class="item_description" display="true" value="Anh Minh; Audio CD" />');
    document.write('		<input type="hidden" class="item_weight" value="' + eval(cdNum + "Shop[5]") + '" />');
    document.write('		<input type="hidden" class="item_sku" display="true" value="' + cdNum + '" />');
    document.write('		</td>');
    
	document.write('		<td valign="top" align="center" width="200">');
	document.write('		Quantity:');
	document.write('		<select class="item_quantity" name="item_quantity">');
	document.write('		<option value="1">1</option>');
	document.write('		<option value="2">2</option>');
	document.write('		<option value="3">3</option>');
	document.write('		</select><br />');
	
    document.write('		<input type="image" src="images/addtocart.gif" class="add_item" />');
    document.write('		</td>');
	document.write('		</tr>');
	document.write('	</table >'); 
	document.write('</div>');
	
}

function changeAutograph(x, cdNum){
	if (x.value == "Yes")
		getRef(cdNum + '-title').firstChild.nodeValue = eval(cdNum + "Shop[1]");
	else
		getRef(cdNum + '-title').firstChild.nodeValue = eval(cdNum + "Shop[0]");

}
// STORE -------------------------------------------------------------------------------------------------

// GALLERY -------------------------------------------------------------------------------------------------


function writeGalleryHeader(title){
	document.write('<div id="bxPhoto" onclick="hideBxPhoto();return false;"><img src="images/empty.jpg" name="photo" /></div>');
	
	document.write('<div id="galleryHeader">');
    document.write('<h1><span>' + title + '</span></h1>');
	document.write('	<ul id="galleryNav">');
	document.write('		<li id="gn-photoshoots"><a href="photoshoots.html">Photoshoots</a></li>');
	document.write('		<li id="gn-performances"><a href="liveshows.html">Live Shows</a></li>');
	document.write('		<li id="gn-performances"><a href="asiastage.html">Asia Stage</a></li>');
	document.write('		<li id="gn-backstage"><a href="backstage.html">Backstage</a></li>');
	document.write('		<li id="gn-fans"><a href="fans.html">Fans</a></li>');
	document.write('	</ul>');
	document.write('</div>');
}

function writeGallery(directory, end){
	for (i=end; i>1; i--){
    	document.write('<a href="#" onclick="switchPhoto(\'gallery/' + directory + i + '\');return false;"><img src="gallery/' + directory + '/t/' + i + '.jpg" alt="" /></a>');
	}
}

function hideBxPhoto(){
	getRef("bxPhoto").style.display="none";
	getRef("overlay").style.display="none";
	//fadeOut(id1, id2);
}

function switchPhoto(x){
	var theTop = getScrollY();
	var docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
	document.images["photo"].src = x + ".jpg";
	getRef("bxPhoto").style.top = theTop + "px";
	getRef("overlay").style.height=docHeight + "px";
	
	getRef("bxPhoto").style.display="block";
	getRef("overlay").style.display="block";
	//fadeIn();
	
}

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
	//Netscape compliant
	scrOfY = window.pageYOffset;
  } else if( document.body && document.body.scrollTop ) {
	//DOM compliant
	scrOfY = document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
	//IE6 standards compliant mode
	scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}
/*
function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth, myHeight];
}

return function getScrollX() {
  var scrOfX = 0;
  if( typeof( window.pageXOffset ) == 'number' ) {
	//Netscape compliant
	scrOfX = window.pageXOffset;
  } else if( document.body && document.body.scrollLeft ) {
	//DOM compliant
	scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && document.documentElement.scrollLeft ) {
	//IE6 standards compliant mode
	scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfX;
}*/

/*

var deltaFade=.2;
var fadeInVal=0;
var fadeOutVal=1;

var id1 = getRef("bxPhoto");
var id2 = getRef("overlay");

function fadeIn(){
  if(fadeInVal<1){
    fadeInVal+=deltaFade;
    getRef("bxPhoto").style.opacity= fadeInVal;
    getRef("overlay").style.opacity= fadeInVal;
    setTimeout("fadeIn()", 100);
  }
	  
}

function fadeOut(){
  if(fadeOutVal>0){
    fadeOutVal-=deltaFade;
    getRef("bxPhoto").style.opacity= fadeOutVal;
    getRef("overlay").style.opacity= fadeOutVal;
    setTimeout("fadeOut()", 100);
  }
  if(fadeOutVal<=0){
	getRef("bxPhoto").style.display="none";
	getRef("overlay").style.display="none";
  }
	  
}

*/


// GALLERY -------------------------------------------------------------------------------------------------


// VIDEO -------------------------------------------------------------------------------------------------
/*
function insertMov(movpath, movwidth, movheight){
	var theMov = QT_GenerateOBJECTText_XHTML(movpath, movwidth, movheight, '','scale','tofit');
	var masterPlayer = getRef('videoPlayer');
	masterPlayer.removeChild(masterPlayer.firstChild);
	masterPlayer.innerHTML=theMov;
}

function scrollUp(theTarget){
  var div = document.getElementById(theTarget);
  if (div.scrollTop>0){
     div.scrollTop-=5;
     tScroll = setTimeout("scrollUp('" + theTarget + "')", 10);
  }
  else clearTimeout(tScroll);
}

function scrollDn(theTarget, divHeight){
  var div = document.getElementById(theTarget);
  var scrollHeight = div.scrollHeight;
  if (div.scrollTop<(scrollHeight-divHeight)){
    div.scrollTop+=5;
    tScroll = setTimeout("scrollDn('" + theTarget + "', " + divHeight + ")", 10);
  }
  else clearTimeout(tScroll);
}
*/
// VIDEO -------------------------------------------------------------------------------------------------


// VIDEO -------------------------------------------------------------------------------------------------
var tscroll;
var movQuality = 0;

function changeMovInfo(x){
	getRef('videoTitle').firstChild.nodeValue=x.childNodes[3].firstChild.nodeValue;
	getRef('songTitle').firstChild.nodeValue=x.childNodes[5].firstChild.nodeValue;
}

/* REMOVE OPTION FOR non-HD VIDEOS
function changeMovSetting(){
	if(movQuality==0){ // Change HD setting from On to Off
		movQuality=1;
		getRef('movSetting').childNodes[1].firstChild.nodeValue='Off';
	}
	else{ // Change Quality from Low to High
		movQuality=0;
		getRef('movSetting').childNodes[1].firstChild.nodeValue='On';
	}
}
*/

function insertMov(x, movwidth, movheight){
	movpath = x.href
	var theMov = QT_GenerateOBJECTText_XHTML(movpath, movwidth, movheight, '','scale','tofit');
	var masterPlayer = document.getElementById('videoPlayer');
	masterPlayer.removeChild(masterPlayer.firstChild);
	masterPlayer.innerHTML=theMov;
	
	//changeMovInfo(x);
}

/* ORIGINAL
function insertMov(x, movwidth, movheight){
	movpath = x.href;
	
	var theMov = QT_GenerateOBJECTText_XHTML(movpath, movwidth, movheight, '','scale','tofit');
	var masterPlayer = getRef('videoPlayer');
	masterPlayer.removeChild(masterPlayer.firstChild);
	masterPlayer.innerHTML=theMov;
}
*/

function scrollUp(theTarget){
	var div = getRef(theTarget);
	var myInterval = window.setInterval(function (a,b) { div.scrollTop-=50; },50);
	window.setTimeout(function (a,b) { clearInterval(myInterval); },300);
}

function scrollDn(theTarget){
	var div = getRef(theTarget);
	var myInterval = window.setInterval(function (a,b) { div.scrollTop+=50; },50);
	window.setTimeout(function (a,b) { clearInterval(myInterval); },300);
}

// VIDEO -------------------------------------------------------------------------------------------------


// CONTACT -----------------------------------------------------------------------------------------------
function sendMail() {
  var winWidth=300;
  var winHeight=200;
  var maxX=screen.width;
  var maxY=screen.height;
  var screenLeft=(maxX-winWidth)/2;
  var screenTop=(maxY-winHeight)/2;
  var windowFeatures = "height=" + winHeight + ",width=" + winWidth + ",left=" + screenLeft + ",top=" + screenTop;
  var thankWindow= window.open("thank.html", "thank", windowFeatures);
  document.emailForm.method='POST';
  document.emailForm.submit();
}
function submitForm(){
  if (validateEmail() && validateMessage())
    sendMail();
  else
    openBox();
}
function clearForm(){
  var formElement = document.emailForm;
  formElement.txtEmail.value = " enter your email address";
  formElement.txtMessage.value = " enter your message";
}
function validateEmail(){
  var string = document.emailForm.txtEmail.value;
  if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
    return true;
  return false;
}
function validateMessage(){
  if ( (document.emailForm.txtMessage.value != "") && (document.emailForm.txtMessage.value != " ") && (document.emailForm.txtMessage.value != " enter your message") )
    return true;
  return false;
}
function openBox(){
  var boxDiv=document.getElementById("confirmForm").style;
  boxDiv.left="225px";
  boxDiv.top="150px";
  boxDiv.display="block";
}
function closeBox(){
  var boxDiv=document.getElementById("confirmForm").style;
  boxDiv.display="none";
}
// CONTACT -----------------------------------------------------------------------------------------------


// FRMAUDIO ----------------------------------------------------------------------------------------------
/*
function loadBGMusic(){
	var theSong = QT_GenerateOBJECTText_XHTML('audio/Anh Minh - Ngan Nam Cho Doi.mp3', 1, 1, '','','');
	var masterPlayer = getRef('bgPlayer');
	masterPlayer.removeChild(masterPlayer.firstChild);
	masterPlayer.innerHTML=theSong;
}
*/
function bgMusicPlay(){
	top.frmAudio.document.frmSongEmbed.Play();
}
function bgMusicPause(){
  top.frmAudio.document.frmSongEmbed.Stop();
}
function bgMusicStop(){
    top.frmAudio.document.frmSongEmbed.Stop();
    top.frmAudio.document.frmSongEmbed.Rewind();
}








