/*
 * Copyright 2009 ROSECOLOR Studio. All Rights Reserved.
 * =====================================================
 */

var fadeInLastTimeout = null;
var fadeOutLastTimeout = null;
var showNextLastTimeout = null;

var ieVer = -1; // Return value assumes failure.

if (navigator.appName == 'Microsoft Internet Explorer') {
	var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
	
	if (re.exec(navigator.userAgent) != null) ieVer = parseFloat( RegExp.$1 );
}

try {
	document.execCommand('BackgroundImageCache', false, true);
} 
catch (e) { 
	/* unless it's not IE6... */ 
}

var css_browser_selector = function() {
	var ua = navigator.userAgent.toLowerCase(),
		is = function(t) {
			return ua.indexOf(t) != -1;
		},
		h = document.getElementsByTagName('html')[0],
		b = (!(/opera|webtv/i.test(ua)) && /msie\s(\d)/.test(ua)) ? ('ie ie' + RegExp.$1):
			is('firefox/2')?'gecko ff2':
			is('firefox/3')?'gecko ff3':
			is('gecko/')?'gecko':
			is('opera/9')?'opera opera9':/opera\s(\d)/.test(ua)?'opera opera' + RegExp.$1:
			is('konqueror')?'konqueror':
			is('chrome')?'chrome webkit safari':
			is('applewebkit/')?'webkit safari':
			is('mozilla/')?'gecko':'',os = (is('x11') || is('linux'))?' linux':
			is('mac')?' mac':
			is('win')?' win':'';
			
	var c = b + os + ' js'; 
	
	h.className += h.className ? ' ' + c: c;
}
();

function addListener(element, type, expression, bubbling) {
	bubbling = bubbling || false;
  
  	if (window.addEventListener) { // Standard
    	element.addEventListener(type, expression, bubbling);
	
	    return true;
	} 
  	else if(window.attachEvent) { // IE
    	element.attachEvent('on' + type, expression);
	
	    return true;
  	} 
	else 
		return false;
}

var ImageLoader = function(url){
	this.url = url;
	this.image = null;
	this.loadEvent = null;
};

ImageLoader.prototype = {
	load:function() {
    	this.image = document.createElement('img');
    	var url = this.url;
    	var image = this.image;
    	var loadEvent = this.loadEvent;
    	
		addListener(this.image, 'load', function(e) { if (loadEvent != null) loadEvent(url, image); }, false);
		
	    this.image.src = this.url;
  	},
  	getImage:function() { return this.image; }
};

function fadeInImage(imgId, imgSrc, incr, pause) {
	var img = document.getElementById(imgId);
	
	setOpacity(img, 0);
	
	img.src = imgSrc;
	
	fadeIn2(imgId, 0, incr, pause);
}
function fadeInImage2(imgId, imgSrc) { fadeInImage(imgId, imgSrc, 2, 30) }

function setOpacity(obj, opacity) {
	opacity = (opacity == 100) ? 99.999 : opacity;
  
	// IE/Win
	obj.style.filter = "alpha(opacity:" + opacity + ")";
  
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity / 100;
  
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity / 100;
  
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity / 100;
}	

function fadeIn(objId, opacity) { fadeIn2(objId, opacity, 2, 30); }

function fadeIn2(objId, opacity, incr, pause) {
	obj = document.getElementById(objId);

	if (opacity <= 100) {
		setOpacity(obj, opacity);
		
		opacity += incr;
		
		fadeInLastTimeout = window.setTimeout("fadeIn2('" + objId + "'," + opacity + "," + incr + "," + pause +")", pause);
	}
}

function fadeOut(objId, opacity) {
	obj = document.getElementById(objId);

	if (opacity > 0) {
		setOpacity(obj, opacity);
		
		opacity -= 2;
		
		fadeOutLastTimeout = window.setTimeout("fadeOut('" + objId + "'," + opacity + ")", 30);
	}
}

function scheduleNext(func) { scheduleNext2(func, 5); }
	
function scheduleNext2(func, secs) { showNextLastTimeout = window.setTimeout(func, secs * 1000); }
		
function clearLastTimeouts() {
	if (fadeInLastTimeout != null) {
		window.clearTimeout(fadeInLastTimeout);
		
		fadeInLastTimeout = null;
	}
	
	if (showNextLastTimeout != null) {
		window.clearTimeout(showNextLastTimeout);
		
		showNextLastTimeout = null;
	}
}
		
function toggleDisplay(id) {
    var e = document.getElementById(id);

    if (e.style.display != 'none') {
        e.style.display = 'none';
        e.style.visibility = 'hidden';
    }
    else {
        e.style.display = 'block';
        e.style.visibility = 'visible';
    }
}

function isValidEmail(e) { return e.value.indexOf(".") > 0 && e.value.indexOf("@") > 0; }

function isNumeric(e) {
   var validChars = "0123456789";
   var isNumber=true;
   var ch;
 
   for (i = 0; i < e.value.length && isNumber == true; i++) { 
      ch = e.value.charAt(i); 
      
      if (validChars.indexOf(ch) == -1) isNumber = false;
   }
   
   return isNumber;   
}		

function isEmpty(e) { return e.value.length == 0 || e.value == null ? true : false;	}
 
function copyright() {
	document.write("copyright &copy; 2010 ");
	colorLogo();
	document.write(" ");
	secondLineLogo();
	document.write("<br/>All Rights Reserved");
}

var colorCss = ["l1", "l2", "l3", "l4", "l5", "l6"];

function colorText(txt) {
	var coloredTxt = "";
	
	var c = 0; 
	
	for (i = 0; i < txt.length; i++) {
		coloredTxt += "<span class='" + colorCss[c] + "'>" + txt.charAt(i) + "</span>";
		
		if (c == colorCss.length - 1) c = 0; else c++;
	}
	
	return coloredTxt;
}

function colorHomeNoLink() { document.write(colorText("HOME")); }
function colorPricesNoLink() { document.write(colorText("PRICES")); }
function colorBackNoLink() { document.write(colorText("< BACK")); }
function colorBlogNoLink() { document.write(colorText("BLOG")); }
function colorContactNoLink() { document.write(colorText("CONTACT")); }
function colorHiresNoLink() { document.write(colorText("HIGH RES")); }
function colorLogoNoLink() { document.write(colorText("ROSECOLOR")); }
function colorWeddingGalleryNoLink() { document.write(colorText("Latest Gallery")); }
function secondLineLogo() { document.write('studio'); }
function colorLogo() { document.write('<a title="Home page..." href="index.html">'); colorLogoNoLink();	document.write('</a>'); }

 